本文整理匯總了Python中horizon.messages.success方法的典型用法代碼示例。如果您正苦於以下問題:Python messages.success方法的具體用法?Python messages.success怎麽用?Python messages.success使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizon.messages
的用法示例。
在下文中一共展示了messages.success方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
instance = data.get('instance_id')
try:
api.trove.user_update_attributes(
request,
instance,
data['user_name'],
host=data['user_host'],
new_name=data['new_name'],
new_password=data['new_password'],
new_host=data['new_host'])
messages.success(request,
_('Updated user "%s".') % data['user_name'])
except Exception as e:
redirect = reverse("horizon:project:databases:detail",
args=(instance,))
exceptions.handle(request, _('Unable to update user. %s') % e,
redirect=redirect)
return True
示例2: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
datastore = data['datastore'].split(',')[0]
datastore_version = data['datastore'].split(',')[1]
api.trove.configuration_create(request, data['name'], "{}",
description=data['description'],
datastore=datastore,
datastore_version=datastore_version)
messages.success(request, _('Created configuration group'))
except Exception as e:
redirect = reverse("horizon:project:database_configurations:index")
exceptions.handle(request, _('Unable to create configuration '
'group. %s') % e, redirect=redirect)
return True
示例3: collect
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def collect(request):
macro = {'collect_status': 'Collection failed'}
status = 0
BASE_DIR = settings.ROOT_PATH
# CUR_DIR = os.getcwd()
os.chdir(BASE_DIR + '/don/ovs')
cmd = 'sudo python collector.py'
for line in run_command(cmd):
if line.startswith('STATUS:') and line.find('Writing collected info') != -1:
status = 1
macro['collect_status'] = \
"Collecton successful. Click visualize to display"
# res = collector.main()
os.chdir(BASE_DIR)
if status:
messages.success(request, macro['collect_status'])
else:
messages.error(request, macro['collect_status'])
resp = HttpResponse(json.dumps(macro), content_type="application/json")
return resp
示例4: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
api.monitor.notification_create(
request,
name=data['name'],
type=data['type'],
address=data['address'],
period=int(data['period']))
messages.success(request,
_('Notification method has been created '
'successfully.'))
except Exception as e:
exceptions.handle(request,
_('Unable to create the notification '
'method: %s') % e)
return False
return True
示例5: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
alarm_actions = [notification.get('id')
for notification in data['notifications']]
api.monitor.alarm_create(
request,
name=data['name'],
expression=data['expression'],
description=data['description'],
severity=data['severity'],
alarm_actions=alarm_actions,
ok_actions=alarm_actions,
undetermined_actions=alarm_actions,
)
messages.success(request,
_('Alarm has been created successfully.'))
except Exception as e:
exceptions.handle(request, _('Unable to create the alarm: %s') % e.message)
return False
return True
示例6: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
alarm_def = api.monitor.alarmdef_get(request, self.initial['id'])
api.monitor.alarmdef_update(
request,
alarm_id=self.initial['id'],
severity=data['severity'],
name=data['name'],
expression=data['expression'],
description=data['description'],
match_by=alarm_def['match_by'],
actions_enabled=data['actions_enabled'],
alarm_actions=data['alarm_actions'],
ok_actions=data['ok_actions'],
undetermined_actions=data['undetermined_actions'],
)
messages.success(request,
_('Alarm definition has been updated.'))
except Exception as e:
exceptions.handle(request, _('%s') % e)
return False
return True
示例7: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
snapshot_id = self.initial['snapshot_id']
try:
manila.share_snapshot_allow(
request, snapshot_id,
access_to=data['access_to'],
access_type=data['access_type'])
message = _('Creating snapshot rule for "%s"') % data['access_to']
messages.success(request, message)
return True
except Exception:
redirect = reverse(
"horizon:project:share_snapshots:share_snapshot_manage_rules",
args=[self.initial['snapshot_id']])
exceptions.handle(
request, _('Unable to add snapshot rule.'), redirect=redirect)
示例8: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
share_id = self.initial['share_id']
is_public = data['is_public'] if self.enable_public_shares else False
try:
share = manila.share_get(self.request, share_id)
manila.share_update(
request, share, data['name'], data['description'],
is_public=is_public)
message = _('Updating share "%s"') % data['name']
messages.success(request, message)
return True
except Exception:
redirect = reverse("horizon:project:shares:index")
exceptions.handle(request,
_('Unable to update share.'),
redirect=redirect)
示例9: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
send_data = {'name': data['name']}
if data['description']:
send_data['description'] = data['description']
share_net_id = data.get('neutron_net_id', data.get('nova_net_id'))
share_net_id = share_net_id.strip()
if self.neutron_enabled and share_net_id:
send_data['neutron_net_id'] = share_net_id
subnet_key = 'subnet-choices-%s' % share_net_id
if subnet_key in data:
send_data['neutron_subnet_id'] = data[subnet_key]
elif not self.neutron_enabled and share_net_id:
send_data['nova_net_id'] = data['nova_net_id']
share_network = manila.share_network_create(request, **send_data)
messages.success(request, _('Successfully created share'
' network: %s') % send_data['name'])
return share_network
except Exception:
exceptions.handle(request, _('Unable to create share network.'))
return False
示例10: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
sec_service_id = self.initial['sec_service_id']
try:
manila.security_service_update(request, sec_service_id,
name=data['name'],
description=data['description'])
message = _('Successfully updated security service '
'"%s"') % data['name']
messages.success(request, message)
return True
except Exception:
redirect = reverse("horizon:project:security_services:index")
exceptions.handle(request,
_('Unable to update security service.'),
redirect=redirect)
示例11: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
share_name = _get_id_if_name_empty(data)
try:
result = manila.migration_get_progress(request,
self.initial['share_id'])
progress = result[1]
messages.success(
request,
_('Migration of share %(name)s is at %(progress)s percent.') %
{'name': share_name, 'progress': progress['total_progress']})
return True
except Exception:
exceptions.handle(request, _("Unable to obtain progress of "
"migration of share %s at this "
"moment.") % share_name)
return False
示例12: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
replica_id = self.initial['replica_id']
try:
replica = manila.share_replica_get(self.request, replica_id)
manila.share_replica_reset_status(
request, replica, data["replica_status"])
message = _("Reseting replica ('%(id)s') status from '%(from)s' "
"to '%(to)s'.") % {
"id": replica_id,
"from": replica.replica_state,
"to": data["replica_status"]}
messages.success(request, message)
return True
except Exception:
redirect = reverse("horizon:admin:shares:index")
exceptions.handle(
request,
_("Unable to reset status of replica '%s'.") % replica_id,
redirect=redirect)
示例13: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
s_id = self.initial['share_group_snapshot_id']
try:
manila.share_group_snapshot_reset_state(
request, s_id, data["status"])
message = _(
"Reseting share group snapshot ('%(id)s') status "
"from '%(from)s' to '%(to)s'.") % {
"id": self.initial['share_group_snapshot_name'] or s_id,
"from": self.initial['share_group_snapshot_status'],
"to": data["status"]}
messages.success(request, message)
return True
except Exception:
redirect = reverse("horizon:admin:share_group_snapshots:index")
exceptions.handle(
request,
_("Unable to reset status of share group snapshot "
"'%s'.") % s_id,
redirect=redirect)
return False
示例14: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
toscal = yaml.load(data['tosca'], Loader=yaml.SafeLoader)
vnfd_name = data['name']
vnfd_description = data['description']
tosca_arg = {'vnfd': {'name': vnfd_name,
'description': vnfd_description,
'attributes': {'vnfd': toscal}}}
vnfd_instance = api.tacker.create_vnfd(request, tosca_arg)
messages.success(request,
_('VNF Catalog entry %s has been created.') %
vnfd_instance['vnfd']['name'])
return toscal
except Exception as e:
msg = _('Unable to create TOSCA. %s')
msg %= e.message.split('Failed validating', 1)[0]
exceptions.handle(request, message=msg)
return False
示例15: handle
# 需要導入模塊: from horizon import messages [as 別名]
# 或者: from horizon.messages import success [as 別名]
def handle(self, request, data):
try:
toscal = data['tosca']
vnffgd_name = data['name']
vnffgd_description = data['description']
tosca_arg = {'vnffgd': {'name': vnffgd_name,
'description': vnffgd_description,
'template': {'vnffgd': toscal}}}
vnffgd_instance = api.tacker.create_vnffgd(request, tosca_arg)
messages.success(request,
_('VNFFG Catalog entry %s has been created.') %
vnffgd_instance['vnffgd']['name'])
return toscal
except Exception as e:
msg = _('Unable to create TOSCA. %s')
msg %= e.message.split('Failed validating', 1)[0]
exceptions.handle(request, message=msg)
return False