Coverage for osmclient/cli_commands/netslice_ops.py: 51%
51 statements
« prev ^ index » next coverage.py v7.3.1, created at 2024-06-29 09:50 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2024-06-29 09:50 +0000
1# Copyright ETSI Contributors and Others.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16import click
17from osmclient.cli_commands import utils
18from prettytable import PrettyTable
19import json
20import logging
22logger = logging.getLogger("osmclient")
25def nsi_op_list(ctx, name):
26 logger.debug("")
27 utils.check_client_version(ctx.obj, ctx.command.name)
28 resp = ctx.obj.nsi.list_op(name)
29 table = PrettyTable(["id", "operation", "status"])
30 for op in resp:
31 table.add_row([op["id"], op["lcmOperationType"], op["operationState"]])
32 table.align = "l"
33 print(table)
36@click.command(
37 name="nsi-op-list",
38 short_help="shows the history of operations over a Network Slice Instance (NSI)",
39)
40@click.argument("name")
41@click.pass_context
42def nsi_op_list1(ctx, name):
43 """shows the history of operations over a Network Slice Instance (NSI)
45 NAME: name or ID of the Network Slice Instance
46 """
47 logger.debug("")
48 nsi_op_list(ctx, name)
51@click.command(
52 name="netslice-instance-op-list",
53 short_help="shows the history of operations over a Network Slice Instance (NSI)",
54)
55@click.argument("name")
56@click.pass_context
57def nsi_op_list2(ctx, name):
58 """shows the history of operations over a Network Slice Instance (NSI)
60 NAME: name or ID of the Network Slice Instance
61 """
62 logger.debug("")
63 nsi_op_list(ctx, name)
66def nsi_op_show(ctx, id, filter):
67 logger.debug("")
68 utils.check_client_version(ctx.obj, ctx.command.name)
69 op_info = ctx.obj.nsi.get_op(id)
71 table = PrettyTable(["field", "value"])
72 for k, v in list(op_info.items()):
73 if not filter or k in filter:
74 table.add_row([k, json.dumps(v, indent=2)])
75 table.align = "l"
76 print(table)
79@click.command(
80 name="nsi-op-show",
81 short_help="shows the info of an operation over a Network Slice Instance(NSI)",
82)
83@click.argument("id")
84@click.option(
85 "--filter",
86 multiple=True,
87 help="restricts the information to the fields in the filter",
88)
89@click.pass_context
90def nsi_op_show1(ctx, id, filter):
91 """shows the info of an operation over a Network Slice Instance(NSI)
93 ID: operation identifier
94 """
95 logger.debug("")
96 nsi_op_show(ctx, id, filter)
99@click.command(
100 name="netslice-instance-op-show",
101 short_help="shows the info of an operation over a Network Slice Instance(NSI)",
102)
103@click.argument("id")
104@click.option(
105 "--filter",
106 multiple=True,
107 help="restricts the information to the fields in the filter",
108)
109@click.pass_context
110def nsi_op_show2(ctx, id, filter):
111 """shows the info of an operation over a Network Slice Instance(NSI)
113 ID: operation identifier
114 """
115 logger.debug("")
116 nsi_op_show(ctx, id, filter)