本文整理汇总了Python中manila_ui.api.manila.share_get函数的典型用法代码示例。如果您正苦于以下问题:Python share_get函数的具体用法?Python share_get怎么用?Python share_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了share_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:openstack,项目名称:manila-ui,代码行数:8,代码来源:tables.py
示例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
开发者ID:ajarr,项目名称:manila-ui,代码行数:9,代码来源:views.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:9,代码来源:views.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:10,代码来源:views.py
示例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
开发者ID:jcsp,项目名称:manila-ui,代码行数:11,代码来源:views.py
示例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
开发者ID:vponomaryov,项目名称:manila-ui,代码行数:11,代码来源:views.py
示例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
开发者ID:bswartz,项目名称:manila-ui,代码行数:12,代码来源:views.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:13,代码来源:tables.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:14,代码来源:tables.py
示例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)
开发者ID:ajarr,项目名称:manila-ui,代码行数:14,代码来源:forms.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:16,代码来源:views.py
示例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
开发者ID:bswartz,项目名称:manila-ui,代码行数:18,代码来源:views.py
示例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)
开发者ID:ajarr,项目名称:manila-ui,代码行数:22,代码来源:forms.py
示例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
开发者ID:openstack,项目名称:manila-ui,代码行数:24,代码来源:views.py
示例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")
开发者ID:jcsp,项目名称:manila-ui,代码行数:3,代码来源:tables.py
示例16: __init__
def __init__(self, request, *args, **kwargs):
super(CreateForm, self).__init__(request, *args, **kwargs)
share_protos = ('NFS', 'CIFS', 'GlusterFS', 'HDFS', )
share_networks = manila.share_network_list(request)
share_types = manila.share_type_list(request)
self.fields['share_type'].choices = (
[("", "")] + [(st.name, st.name) for st in share_types])
self.fields['share_proto'].choices = [(sp, sp) for sp in share_protos]
if "snapshot_id" in request.GET:
try:
snapshot = self.get_snapshot(request,
request.GET["snapshot_id"])
self.fields['name'].initial = snapshot.name
self.fields['size'].initial = snapshot.size
self.fields['snapshot'].choices = ((snapshot.id, snapshot),)
try:
# Set the share type from the original share
orig_share = manila.share_get(request, snapshot.share_id)
self.fields['share_type'].initial = orig_share.share_type
except Exception:
pass
self.fields['size'].help_text = _(
'Share size must be equal to or greater than the snapshot '
'size (%sGB)') % snapshot.size
del self.fields['share_source_type']
except Exception:
exceptions.handle(request,
_('Unable to load the specified snapshot.'))
else:
source_type_choices = []
try:
snapshot_list = manila.share_snapshot_list(request)
snapshots = [s for s in snapshot_list
if s.status == 'available']
if snapshots:
source_type_choices.append(("snapshot",
_("Snapshot")))
choices = [('', _("Choose a snapshot"))] + \
[(s.id, s) for s in snapshots]
self.fields['snapshot'].choices = choices
else:
del self.fields['snapshot']
except Exception:
exceptions.handle(request, _("Unable to retrieve "
"share snapshots."))
if source_type_choices:
choices = ([('no_source_type',
_("No source, empty share"))] +
source_type_choices)
self.fields['share_source_type'].choices = choices
else:
del self.fields['share_source_type']
self.sn_field_name_prefix = 'share-network-choices-'
for st in share_types:
extra_specs = st.get_keys()
dhss = extra_specs.get('driver_handles_share_servers')
# NOTE(vponomaryov): Set and tie share-network field only for
# share types with enabled handling of share servers.
if (isinstance(dhss, six.string_types) and
dhss.lower() in ['true', '1']):
sn_choices = (
[('', '')] +
[(sn.id, sn.name or sn.id) for sn in share_networks])
sn_field_name = self.sn_field_name_prefix + st.name
sn_field = forms.ChoiceField(
label=_("Share Network"), required=True,
choices=sn_choices,
widget=forms.Select(attrs={
'class': 'switched',
'data-switch-on': 'sharetype',
'data-sharetype-%s' % st.name: _("Share Network"),
}))
self.fields.insert(5, sn_field_name, sn_field)
开发者ID:bswartz,项目名称:manila-ui,代码行数:76,代码来源:forms.py
示例17: __init__
def __init__(self, request, *args, **kwargs):
super(CreateForm, self).__init__(request, *args, **kwargs)
share_protos = ('NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS')
share_networks = manila.share_network_list(request)
share_types = manila.share_type_list(request)
self.fields['share_type'].choices = (
[("", "")] + [(st.name, st.name) for st in share_types])
availability_zones = nova.availability_zone_list(request)
self.fields['availability_zone'].choices = (
[("", "")] +
[(az.zoneName, az.zoneName) for az in availability_zones])
self.sn_field_name_prefix = 'share-network-choices-'
for st in share_types:
extra_specs = st.get_keys()
dhss = extra_specs.get('driver_handles_share_servers')
# NOTE(vponomaryov): Set and tie share-network field only for
# share types with enabled handling of share servers.
if (isinstance(dhss, six.string_types) and
dhss.lower() in ['true', '1']):
sn_choices = (
[('', '')] +
[(sn.id, sn.name or sn.id) for sn in share_networks])
sn_field_name = self.sn_field_name_prefix + st.name
sn_field = forms.ChoiceField(
label=_("Share Network"), required=True,
choices=sn_choices,
widget=forms.Select(attrs={
'class': 'switched',
'data-switch-on': 'sharetype',
'data-sharetype-%s' % st.name: _("Share Network"),
}))
self.fields[sn_field_name] = sn_field
self.fields['share_source_type'] = forms.ChoiceField(
label=_("Share Source"), required=False,
widget=forms.Select(
attrs={'class': 'switchable', 'data-slug': 'source'}))
self.fields['snapshot'] = forms.ChoiceField(
label=_("Use snapshot as a source"),
widget=forms.fields.SelectWidget(
attrs={'class': 'switched',
'data-switch-on': 'source',
'data-source-snapshot': _('Snapshot')},
data_attrs=('size', 'name'),
transform=lambda x: "%s (%sGiB)" % (x.name, x.size)),
required=False)
self.fields['metadata'] = forms.CharField(
label=_("Metadata"), required=False,
widget=forms.Textarea(attrs={'rows': 4}))
self.fields['is_public'] = forms.BooleanField(
label=_("Make visible for all"), required=False,
help_text=(
"If set then all tenants will be able to see this share."))
self.fields['share_proto'].choices = [(sp, sp) for sp in share_protos]
if "snapshot_id" in request.GET:
try:
snapshot = self.get_snapshot(request,
request.GET["snapshot_id"])
self.fields['name'].initial = snapshot.name
self.fields['size'].initial = snapshot.size
self.fields['snapshot'].choices = ((snapshot.id, snapshot),)
try:
# Set the share type from the original share
orig_share = manila.share_get(request, snapshot.share_id)
self.fields['share_type'].initial = orig_share.share_type
except Exception:
pass
self.fields['size'].help_text = _(
'Share size must be equal to or greater than the snapshot '
'size (%sGiB)') % snapshot.size
del self.fields['share_source_type']
except Exception:
exceptions.handle(request,
_('Unable to load the specified snapshot.'))
else:
source_type_choices = []
try:
snapshot_list = manila.share_snapshot_list(request)
snapshots = [s for s in snapshot_list
if s.status == 'available']
if snapshots:
source_type_choices.append(("snapshot",
_("Snapshot")))
choices = [('', _("Choose a snapshot"))] + \
[(s.id, s) for s in snapshots]
self.fields['snapshot'].choices = choices
else:
del self.fields['snapshot']
except Exception:
exceptions.handle(request, _("Unable to retrieve "
"share snapshots."))
if source_type_choices:
choices = ([('no_source_type',
_("No source, empty share"))] +
source_type_choices)
self.fields['share_source_type'].choices = choices
#.........这里部分代码省略.........
开发者ID:ajarr,项目名称:manila-ui,代码行数:101,代码来源:forms.py
示例18: allowed
def allowed(self, request, snapshot=None):
share = manila.share_get(request, snapshot.share_id)
return share.mount_snapshot_support
开发者ID:openstack,项目名称:manila-ui,代码行数:3,代码来源:tables.py
示例19: __init__
def __init__(self, request, *args, **kwargs):
super(CreateForm, self).__init__(request, *args, **kwargs)
# NOTE(vkmc): choose only those share protocols that are enabled
# FIXME(vkmc): this should be better implemented by having a
# capabilities endpoint on the control plane.
manila_features = getattr(settings, 'OPENSTACK_MANILA_FEATURES', {})
self.enabled_share_protocols = manila_features.get(
'enabled_share_protocols',
['NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS', 'MapRFS'])
self.enable_public_shares = manila_features.get(
'enable_public_shares', True)
share_networks = manila.share_network_list(request)
share_types = manila.share_type_list(request)
self.fields['share_type'].choices = (
[("", "")] + [(st.name, st.name) for st in share_types])
availability_zones = manila.availability_zone_list(request)
self.fields['availability_zone'].choices = (
[("", "")] + [(az.name, az.name) for az in availability_zones])
if features.is_share_groups_enabled():
share_groups = manila.share_group_list(request)
self.fields['sg'] = forms.ChoiceField(
label=_("Share Group"),
choices=[("", "")] + [(sg.id, sg.name or sg.id)
for sg in share_groups],
required=False)
self.sn_field_name_prefix = 'share-network-choices-'
for st in share_types:
extra_specs = st.get_keys()
dhss = extra_specs.get('driver_handles_share_servers')
# NOTE(vponomaryov): Set and tie share-network field only for
# share types with enabled handling of share servers.
if (isinstance(dhss, six.string_types) and
dhss.lower() in ['true', '1']):
sn_choices = (
[('', '')] +
[(sn.id, sn.name or sn.id) for sn in share_networks])
sn_field_name = self.sn_field_name_prefix + st.name
sn_field = forms.ChoiceField(
label=_("Share Network"), required=True,
choices=sn_choices,
widget=forms.Select(attrs={
'class': 'switched',
'data-switch-on': 'sharetype',
'data-sharetype-%s' % st.name: _("Share Network"),
}))
self.fields[sn_field_name] = sn_field
self.fields['share_source_type'] = forms.ChoiceField(
label=_("Share Source"), required=False,
widget=forms.Select(
attrs={'class': 'switchable', 'data-slug': 'source'}))
self.fields['snapshot'] = forms.ChoiceField(
label=_("Use snapshot as a source"),
widget=forms.fields.SelectWidget(
attrs={'class': 'switched',
'data-switch-on': 'source',
'data-source-snapshot': _('Snapshot')},
data_attrs=('size', 'name'),
transform=lambda x: "%s (%sGiB)" % (x.name, x.size)),
required=False)
self.fields['metadata'] = forms.CharField(
label=_("Metadata"), required=False,
widget=forms.Textarea(attrs={'rows': 4}))
if self.enable_public_shares:
self.fields['is_public'] = forms.BooleanField(
label=_("Make visible for all"), required=False,
help_text=(
"If set then all tenants will be able to see this share."))
self.fields['share_proto'].choices = [(sp, sp) for sp in
self.enabled_share_protocols]
if ("snapshot_id" in request.GET or
kwargs.get("data", {}).get("snapshot")):
try:
snapshot = self.get_snapshot(
request,
request.GET.get("snapshot_id",
kwargs.get("data", {}).get("snapshot")))
self.fields['name'].initial = snapshot.name
self.fields['size'].initial = snapshot.size
self.fields['snapshot'].choices = ((snapshot.id, snapshot),)
try:
# Set the share type from the original share
orig_share = manila.share_get(request, snapshot.share_id)
# NOTE(vponomaryov): we should use share type name, not ID,
# because we use names in our choices above.
self.fields['share_type'].initial = (
orig_share.share_type_name)
except Exception:
pass
self.fields['size'].help_text = _(
'Share size must be equal to or greater than the snapshot '
'size (%sGiB)') % snapshot.size
del self.fields['share_source_type']
except Exception:
exceptions.handle(request,
#.........这里部分代码省略.........
开发者ID:openstack,项目名称:manila-ui,代码行数:101,代码来源:forms.py
示例20: allowed
def allowed(self, request, datum=None):
share = manila.share_get(request, self.table.kwargs['share_id'])
return share.replication_type is not None
开发者ID:openstack,项目名称:manila-ui,代码行数:3,代码来源:tables.py
注:本文中的manila_ui.api.manila.share_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论