本文整理汇总了Python中manila_ui.api.manila.share_get函数的典型用法代码示例。如果您正苦于以下问题:Python share_get函数的具体用法?Python share_get怎么用?Python share_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了share_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
def delete(self, request, obj_id):
share = manila.share_get(request, obj_id)
try:
manila.share_delete(
request, share.id, share_group_id=share.share_group_id)
except Exception:
msg = _('Unable to delete share "%s". ') % obj_id
messages.error(request, msg)
示例2: get_data
def get_data(self):
try:
share_id = self.kwargs['share_id']
share = manila.share_get(self.request, share_id)
except Exception:
exceptions.handle(
self.request, _('Unable to retrieve volume details.'),
redirect=self.success_url)
return share
示例3: get_context_data
def get_context_data(self, **kwargs):
context = super(ManageRulesView, self).get_context_data(**kwargs)
share = manila.share_get(self.request, self.kwargs['share_id'])
context['share_display_name'] = share.name or share.id
context["share"] = self.get_data()
context["page_title"] = _("Share Rules: "
"%(share_display_name)s") % {
'share_display_name': context['share_display_name']}
return context
示例4: get_object
def get_object(self):
if not hasattr(self, "_object"):
vol_id = self.kwargs['share_id']
try:
self._object = manila.share_get(self.request, vol_id)
except Exception:
msg = _('Unable to retrieve share.')
url = reverse('horizon:project:shares:index')
exceptions.handle(self.request, msg, redirect=url)
return self._object
示例5: get_data
def get_data(self):
try:
share_id = self.kwargs['share_id']
share = manila.share_get(self.request, share_id)
share.rules = manila.share_rules_list(self.request, share_id)
except Exception:
redirect = reverse('horizon:project:shares:index')
exceptions.handle(self.request,
_('Unable to retrieve share details.'),
redirect=redirect)
return share
示例6: get_data
def get_data(self):
try:
snapshot_id = self.kwargs['snapshot_id']
snapshot = manila.share_snapshot_get(self.request, snapshot_id)
share = manila.share_get(self.request, snapshot.share_id)
snapshot.share_name_or_id = share.name or share.id
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve snapshot details.'),
redirect=self.redirect_url)
return snapshot
示例7: get_data
def get_data(self):
try:
snapshot_id = self.kwargs['snapshot_id']
snapshot = manila.share_snapshot_get(self.request, snapshot_id)
share = manila.share_get(self.request, snapshot.share_id)
snapshot.share_name_or_id = share.name or share.id
except Exception:
redirect = reverse('horizon:project:shares:index')
exceptions.handle(self.request,
_('Unable to retrieve snapshot details.'),
redirect=redirect)
return snapshot
示例8: get_data
def get_data(self, request, share_id):
share = manila.share_get(request, share_id)
if not share.name:
share.name = share_id
if share.share_network_id:
share_net = manila.share_network_get(request,
share.share_network_id)
share.share_network = share_net.name or share_net.id
else:
share.share_network = None
share.metadata = utils.metadata_to_str(share.metadata)
return share
示例9: allowed
def allowed(self, request, replica=None):
if replica:
share = manila.share_get(request, replica.share_id)
replicas = manila.share_replica_list(request, replica.share_id)
if share.replication_type is None:
return False
elif (share.replication_type is 'writable' and
replica.status in DELETABLE_STATUSES and
len(replicas) > 1) or (
share.replication_type in ('dr', 'readable') and
replica.status in DELETABLE_STATUSES and
replica.replica_state != 'active'):
return True
return False
示例10: handle
def handle(self, request, data):
share_id = self.initial['share_id']
try:
share = manila.share_get(self.request, share_id)
manila.share_extend(
request, share.id, data['new_size'])
message = _('Extend share "%s"') % data['name']
messages.success(request, message)
return True
except Exception:
redirect = reverse("horizon:project:shares:index")
exceptions.handle(request,
_('Unable to extend share.'),
redirect=redirect)
示例11: get_context_data
def get_context_data(self, **kwargs):
context = super(ManageReplicasView, self).get_context_data(**kwargs)
try:
share = manila.share_get(self.request, self.kwargs["share_id"])
except Exception:
redirect = reverse(self._redirect_url)
exceptions.handle(
self.request,
_('Unable to retrieve share. %s') % self.kwargs["share_id"],
redirect=redirect)
context["share_display_name"] = share.name or share.id
context["share"] = self.get_data()
context["page_title"] = _(
"Share Replicas: %(share_display_name)s") % {
"share_display_name": context["share_display_name"]}
return context
示例12: get_context_data
def get_context_data(self, **kwargs):
context = super(CreateSnapshotView, self).get_context_data(**kwargs)
context['share_id'] = self.kwargs['share_id']
try:
share = manila.share_get(self.request, context['share_id'])
if (share.status == 'in-use'):
context['attached'] = True
context['form'].set_warning(_("This share is currently "
"attached to an instance. "
"In some cases, creating a "
"snapshot from an attached "
"share can result in a "
"corrupted snapshot."))
context['usages'] = quotas.tenant_limit_usages(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve share information.'))
return context
示例13: handle
def handle(self, request, data):
try:
share = manila.share_get(request, data['share_id'])
force = False
message = _('Creating share snapshot "%s".') % data['name']
if share.status == 'in-use':
force = True
message = _('Forcing to create snapshot "%s" '
'from attached share.') % data['name']
snapshot = manila.share_snapshot_create(request,
data['share_id'],
data['name'],
data['description'],
force=force)
messages.success(request, message)
return snapshot
except Exception:
redirect = reverse("horizon:project:shares:index")
exceptions.handle(request,
_('Unable to create share snapshot.'),
redirect=redirect)
示例14: get_data
def get_data(self):
try:
snapshot_id = self.kwargs['snapshot_id']
snapshot = manila.share_snapshot_get(self.request, snapshot_id)
share = manila.share_get(self.request, snapshot.share_id)
if share.mount_snapshot_support:
snapshot.rules = manila.share_snapshot_rules_list(
self.request, snapshot_id)
snapshot.export_locations = (
manila.share_snap_export_location_list(
self.request, snapshot))
export_locations = [
exp['path'] for exp in snapshot.export_locations
]
snapshot.el_size = ui_utils.calculate_longest_str_size(
export_locations)
snapshot.share_name_or_id = share.name or share.id
except Exception:
exceptions.handle(
self.request,
_('Unable to retrieve snapshot details.'),
redirect=self.redirect_url)
return snapshot
示例15: allowed
def allowed(self, request, share=None):
share = manila.share_get(request, self.table.kwargs['share_id'])
return share.status in ("available", "in-use")