Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
description = data['description']
nsd_id = data['nsd_id']
vim_id = data['vim_id']
param_val = data['param_values']
config_val = data['config_values']
ns_arg = {'ns': {'nsd_id': nsd_id, 'name': ns_name,
'description': description,
'vim_id': vim_id}}
ns_attr = ns_arg['ns'].setdefault('attributes', {})
if param_val:
ns_attr['param_values'] = param_val
if config_val:
ns_attr['config'] = config_val
api.tacker.create_ns(request, ns_arg)
messages.success(request,
_('NS %s create operation initiated.') %
ns_name)
return True
except Exception as e:
exceptions.handle(request,
_('Failed to create NS: %s') %
e.message)
try:
sahara = saharaclient.client(request)
extra = {}
bin_url = "%s://%s" % (context["job_binary_type"],
context["job_binary_url"])
if(context["job_binary_type"] == "internal-db"):
bin_url = self.handle_internal(request, context)
elif(context["job_binary_type"] == "swift"):
extra = self.handle_swift(request, context)
sahara.job_binaries.create(
context["job_binary_name"],
bin_url,
context["job_binary_description"],
extra)
messages.success(request, "Successfully created job binary")
return True
except api_base.APIException as e:
messages.error(request, str(e))
return False
except Exception as e:
messages.error(request, str(e))
return False
def handle(self, request, data):
group_id = self.initial['group_id']
name = self.initial['name']
delete_volumes = data['delete_volumes']
try:
cinder.group_delete(request, group_id,
delete_volumes=delete_volumes)
message = _('Deleting volume group "%s"') % name
messages.success(request, message)
return True
except Exception:
redirect = reverse(self.failure_url)
exceptions.handle(request, _('Errors occurred in deleting group.'),
redirect=redirect)
data['schedule_count'] = convert_empty_string_to_none(
data['schedule_count']
)
api.cron_trigger_create(
request,
data['name'],
data['workflow_id'],
data['input'],
data['params'],
data['schedule_pattern'],
data['first_time'],
data['schedule_count'],
)
msg = _('Successfully created Cron Trigger.')
messages.success(request, msg)
return True
def handle(self, request, data):
try:
response = api.adjutant.email_update(request, data['new_email'])
if response.status_code == 202:
msg = _("Confirmation email sent to %s.")
messages.success(request, msg % data['new_email'])
elif response.status_code == 400:
messages.warning(request, _(
'Unable to update email. May already be in use.'))
else:
messages.error(request, _('Failed to update email.'))
return True
except Exception as e:
messages.error(request, _('Failed to update email. %s' % str(e)))
return False
inf = data['param_file'].read()
param_data = yaml.load(inf)
lp_metadata = None
if data['lp_metadata']:
lp_metadata = json.dumps(json.load(data['lp_metadata']))
try:
solum.languagepacks.create(
name=data['name'], source_uri=data['source_uri'],
lp_metadata=lp_metadata, lp_params=param_data,
description=data['description'])
message = _(
'Languagepack %s was successfully created.') % data['name']
messages.success(request, message)
except Exception as e:
redirect = reverse('horizon:solum:languagepacks:index')
exceptions.handle(
self.request,
_('Unable to create languagepack: %s') % e,
redirect=redirect)
return True
def action(self, request, obj_id):
LOG.info("CEPH_LOG PRESENTPOOL: ACTION obj_id:%s"%obj_id)
#LOG.error(obj_id)
data = self.table.get_object_by_id(obj_id)
LOG.info("CEPH_LOG PRESENTPOOL: ACTION data:%s"%data)
#LOG.error(data)
#LOG.error("CEPH_LOG PRESENTPOOL: ACTION >")
vsmapi.present_pool(request, [obj_id,])
messages.success(request, "Present Pool %s Success" % data['name'])
def handle(self, request, data):
try:
snapshot = manila.share_group_snapshot_create(
request,
data['share_group_id'], data['name'], data['description'])
message = _('Creating share group snapshot "%s".') % data['name']
messages.success(request, message)
return snapshot
except Exception:
redirect = reverse("horizon:project:share_group_snapshots:index")
exceptions.handle(
request,
_('Unable to create share group snapshot.'),
redirect=redirect)
return False
def handle(self, request, data):
plan = api.tuskar.Plan.get_the_plan(self.request)
try:
plan.patch(request, plan.uuid, data)
except Exception as e:
horizon.exceptions.handle(
request,
_("Unable to update the service configuration."))
LOG.exception(e)
return False
else:
horizon.messages.success(
request,
_("Service configuration updated."))
return True
def single(self, data_table, request, object_id):
try:
manila.share_replica_delete(request, object_id)
messages.success(
request, _('Share replica %s has been deleted.') % object_id)
except Exception:
msg = _('Unable to delete replica "%s".') % object_id
messages.error(request, msg)