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')
print(table)
+@cli.command(name='project-update')
+@click.argument('project')
+@click.option('--name',
+ prompt=True,
+ help='new name for the project')
+
+@click.pass_context
+def project_update(ctx, project, name):
+ """
+ Update a project name
+
+ :param ctx:
+ :param project: id or name of the project to modify
+ :param name: new name for the project
+ :return:
+ """
+
+ project_changes = {}
+ project_changes['name'] = name
+
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.project.update(project, project_changes)
+ except ClientException as inst:
+ print(inst.message)
+
+
####################
# User mgmt operations
####################
ctx.obj.user.create(username, user)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='user-update')
# hide_input=True,
# confirmation_prompt=True,
help='user password')
+@click.option('--set-username', 'set_username',
+ default=None,
+ help='change username')
@click.option('--set-project', 'set_project',
default=None, multiple=True,
help='create/replace the project,role(s) mapping for this project: \'project,role1,role2,...\'')
default=None, multiple=True,
help='removes project,role(s) mapping: \'project,role1,role2,...\'')
@click.pass_context
-def user_update(ctx, username, password, set_project, remove_project,
+def user_update(ctx, username, password, set_username, set_project, remove_project,
add_project_role, remove_project_role):
"""Update a user information
\b
USERNAME: name of the user
PASSWORD: new password
+ SET_USERNAME: new username
SET_PROJECT: creating mappings for project/role(s)
REMOVE_PROJECT: deleting mappings for project/role(s)
ADD_PROJECT_ROLE: adding mappings for project/role(s)
REMOVE_PROJECT_ROLE: removing mappings for project/role(s)
"""
user = {}
- user['username'] = username
user['password'] = password
+ user['username'] = set_username
user['set-project'] = set_project
user['remove-project'] = remove_project
user['add-project-role'] = add_project_role
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)))
ctx.obj.role.create(name, definition)
except ClientException as inst:
print(inst.message)
+ exit(1)
@cli.command(name='role-update', short_help='updates a role')