print((inst.message))
exit(1)
-
####################
# UPDATE operations
####################
exit(1)
-####################
+#################
# VIM operations
-####################
+#################
@cli.command(name='vim-create')
@click.option('--name',
ctx.obj.sdnc.create(name, sdncontroller, wait=wait)
except ClientException as inst:
print((inst.message))
-
+ exit(1)
@cli.command(name='sdnc-update', short_help='updates an SDN controller')
@click.argument('name')
except ClientException as inst:
print((inst.message))
exit(1)
- table = PrettyTable(['name', 'id'])
+ table = PrettyTable(['sdnc name', 'id'])
for sdnc in resp:
table.add_row([sdnc['name'], sdnc['_id']])
table.align = 'l'
ctx.obj.project.create(name, project)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='project-delete')
ctx.obj.user.create(username, user)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='user-update')
ctx.obj.user.update(username, user)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='user-delete')
def ns_alarm_create(ctx, name, ns, vnf, vdu, metric, severity,
threshold_value, threshold_operator, statistic):
"""creates a new alarm for a NS instance"""
- ns_instance = ctx.obj.ns.get(ns)
- alarm = {}
- alarm['alarm_name'] = name
- alarm['ns_id'] = ns_instance['_id']
- alarm['correlation_id'] = ns_instance['_id']
- alarm['vnf_member_index'] = vnf
- alarm['vdu_name'] = vdu
- alarm['metric_name'] = metric
- alarm['severity'] = severity
- alarm['threshold_value'] = int(threshold_value)
- alarm['operation'] = threshold_operator
- alarm['statistic'] = statistic
- try:
+ # TODO: Check how to validate threshold_value.
+ # Should it be an integer (1-100), percentage, or decimal (0.01-1.00)?
+ try:
+ ns_instance = ctx.obj.ns.get(ns)
+ alarm = {}
+ alarm['alarm_name'] = name
+ alarm['ns_id'] = ns_instance['_id']
+ alarm['correlation_id'] = ns_instance['_id']
+ alarm['vnf_member_index'] = vnf
+ alarm['vdu_name'] = vdu
+ alarm['metric_name'] = metric
+ alarm['severity'] = severity
+ alarm['threshold_value'] = int(threshold_value)
+ alarm['operation'] = threshold_operator
+ alarm['statistic'] = statistic
check_client_version(ctx.obj, ctx.command.name)
ctx.obj.ns.create_alarm(alarm)
except ClientException as inst:
@click.pass_context
def ns_metric_export(ctx, ns, vnf, vdu, metric, interval):
"""exports a metric to the internal OSM bus, which can be read by other apps"""
- ns_instance = ctx.obj.ns.get(ns)
- metric_data = {}
- metric_data['ns_id'] = ns_instance['_id']
- metric_data['correlation_id'] = ns_instance['_id']
- metric_data['vnf_member_index'] = vnf
- metric_data['vdu_name'] = vdu
- metric_data['metric_name'] = metric
- metric_data['collection_unit'] = 'WEEK'
- metric_data['collection_period'] = 1
- try:
+ # TODO: Check how to validate interval.
+ # Should it be an integer (seconds), or should a suffix (s,m,h,d,w) also be permitted?
+ try:
+ ns_instance = ctx.obj.ns.get(ns)
+ metric_data = {}
+ metric_data['ns_id'] = ns_instance['_id']
+ metric_data['correlation_id'] = ns_instance['_id']
+ metric_data['vnf_member_index'] = vnf
+ metric_data['vdu_name'] = vdu
+ metric_data['metric_name'] = metric
+ metric_data['collection_unit'] = 'WEEK'
+ metric_data['collection_period'] = 1
check_client_version(ctx.obj, ctx.command.name)
if not interval:
print('{}'.format(ctx.obj.ns.export_metric(metric_data)))
@cli.command(name='role-create', short_help='creates a role')
@click.argument('name')
-@click.option('--definition',
+@click.option('--permissions',
default=None,
- help='role definition using a dictionary')
+ help='role permissions using a dictionary')
@click.pass_context
-def role_create(ctx, name, definition):
+def role_create(ctx, name, permissions):
"""
Creates a new role.
"""
try:
check_client_version(ctx.obj, ctx.command.name)
- ctx.obj.role.create(name, definition)
+ ctx.obj.role.create(name, permissions)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='role-update', short_help='updates a role')
@click.argument('name')
-@click.option('--definition',
+@click.option('--set-name',
default=None,
- help='add a new definition to the role')
+ help='change name of rle')
+# @click.option('--permissions',
+# default=None,
+# help='provide a yaml format dictionary with incremental changes. Values can be bool or None to delete')
@click.option('--add',
default=None,
- help='add a resource access grant/denial')
+ help='yaml format dictionary with permission: True/False to access grant/denial')
@click.option('--remove',
default=None,
- help='remove a resource access grant/denial')
+ help='yaml format list to remove a permission')
@click.pass_context
-def role_update(ctx, name, definition, add, remove):
+def role_update(ctx, name, set_name, add, remove):
"""
Updates a role.
"""
try:
check_client_version(ctx.obj, ctx.command.name)
- ctx.obj.role.update(name, definition, add, remove)
+ ctx.obj.role.update(name, set_name, None, add, remove)
except ClientException as inst:
print(inst.message)
exit(1)