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. |
15 |
|
|
16 |
1 |
import click |
17 |
1 |
from osmclient.cli_commands import utils |
18 |
1 |
from prettytable import PrettyTable |
19 |
1 |
import json |
20 |
1 |
import logging |
21 |
|
|
22 |
1 |
logger = logging.getLogger("osmclient") |
23 |
|
|
24 |
|
|
25 |
1 |
def nsi_op_list(ctx, name): |
26 |
0 |
logger.debug("") |
27 |
0 |
utils.check_client_version(ctx.obj, ctx.command.name) |
28 |
0 |
resp = ctx.obj.nsi.list_op(name) |
29 |
0 |
table = PrettyTable(["id", "operation", "status"]) |
30 |
0 |
for op in resp: |
31 |
0 |
table.add_row([op["id"], op["lcmOperationType"], op["operationState"]]) |
32 |
0 |
table.align = "l" |
33 |
0 |
print(table) |
34 |
|
|
35 |
|
|
36 |
1 |
@click.command( |
37 |
|
name="nsi-op-list", |
38 |
|
short_help="shows the history of operations over a Network Slice Instance (NSI)", |
39 |
|
) |
40 |
1 |
@click.argument("name") |
41 |
1 |
@click.pass_context |
42 |
1 |
def nsi_op_list1(ctx, name): |
43 |
|
"""shows the history of operations over a Network Slice Instance (NSI) |
44 |
|
|
45 |
|
NAME: name or ID of the Network Slice Instance |
46 |
|
""" |
47 |
0 |
logger.debug("") |
48 |
0 |
nsi_op_list(ctx, name) |
49 |
|
|
50 |
|
|
51 |
1 |
@click.command( |
52 |
|
name="netslice-instance-op-list", |
53 |
|
short_help="shows the history of operations over a Network Slice Instance (NSI)", |
54 |
|
) |
55 |
1 |
@click.argument("name") |
56 |
1 |
@click.pass_context |
57 |
1 |
def nsi_op_list2(ctx, name): |
58 |
|
"""shows the history of operations over a Network Slice Instance (NSI) |
59 |
|
|
60 |
|
NAME: name or ID of the Network Slice Instance |
61 |
|
""" |
62 |
0 |
logger.debug("") |
63 |
0 |
nsi_op_list(ctx, name) |
64 |
|
|
65 |
|
|
66 |
1 |
def nsi_op_show(ctx, id, filter): |
67 |
0 |
logger.debug("") |
68 |
0 |
utils.check_client_version(ctx.obj, ctx.command.name) |
69 |
0 |
op_info = ctx.obj.nsi.get_op(id) |
70 |
|
|
71 |
0 |
table = PrettyTable(["field", "value"]) |
72 |
0 |
for k, v in list(op_info.items()): |
73 |
0 |
if not filter or k in filter: |
74 |
0 |
table.add_row([k, json.dumps(v, indent=2)]) |
75 |
0 |
table.align = "l" |
76 |
0 |
print(table) |
77 |
|
|
78 |
|
|
79 |
1 |
@click.command( |
80 |
|
name="nsi-op-show", |
81 |
|
short_help="shows the info of an operation over a Network Slice Instance(NSI)", |
82 |
|
) |
83 |
1 |
@click.argument("id") |
84 |
1 |
@click.option( |
85 |
|
"--filter", |
86 |
|
multiple=True, |
87 |
|
help="restricts the information to the fields in the filter", |
88 |
|
) |
89 |
1 |
@click.pass_context |
90 |
1 |
def nsi_op_show1(ctx, id, filter): |
91 |
|
"""shows the info of an operation over a Network Slice Instance(NSI) |
92 |
|
|
93 |
|
ID: operation identifier |
94 |
|
""" |
95 |
0 |
logger.debug("") |
96 |
0 |
nsi_op_show(ctx, id, filter) |
97 |
|
|
98 |
|
|
99 |
1 |
@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 |
1 |
@click.argument("id") |
104 |
1 |
@click.option( |
105 |
|
"--filter", |
106 |
|
multiple=True, |
107 |
|
help="restricts the information to the fields in the filter", |
108 |
|
) |
109 |
1 |
@click.pass_context |
110 |
1 |
def nsi_op_show2(ctx, id, filter): |
111 |
|
"""shows the info of an operation over a Network Slice Instance(NSI) |
112 |
|
|
113 |
|
ID: operation identifier |
114 |
|
""" |
115 |
0 |
logger.debug("") |
116 |
0 |
nsi_op_show(ctx, id, filter) |