a12cfb20e04f8dd288ee02453ad655f2c0cd4d75
1 # Copyright 2017-2018 Sandvine
2 # Copyright 2018 Telefonica
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
22 from osmclient
import client
23 from osmclient
.common
.exceptions
import ClientException
24 from prettytable
import PrettyTable
30 def check_client_version(obj
, what
, version
='sol005'):
32 Checks the version of the client object and raises error if it not the expected.
34 :param obj: the client object
35 :what: the function or command under evaluation (used when an error is raised)
37 :raises ClientError: if the specified version does not match the client version
39 fullclassname
= obj
.__module
__ + "." + obj
.__class
__.__name
__
40 message
= 'The following commands or options are only supported with the option "--sol005": {}'.format(what
)
42 message
= 'The following commands or options are not supported when using option "--sol005": {}'.format(what
)
43 if fullclassname
!= 'osmclient.{}.client.Client'.format(version
):
44 raise ClientException(message
)
48 @click.option('--hostname',
50 envvar
='OSM_HOSTNAME',
51 help='hostname of server. ' +
52 'Also can set OSM_HOSTNAME in environment')
53 @click.option('--sol005/--no-sol005',
56 help='Use ETSI NFV SOL005 API (default) or the previous SO API. ' +
57 'Also can set OSM_SOL005 in environment')
58 @click.option('--user',
61 help='user (only from Release FOUR, defaults to admin). ' +
62 'Also can set OSM_USER in environment')
63 @click.option('--password',
65 envvar
='OSM_PASSWORD',
66 help='password (only from Release FOUR, defaults to admin). ' +
67 'Also can set OSM_PASSWORD in environment')
68 @click.option('--project',
71 help='project (only from Release FOUR, defaults to admin). ' +
72 'Also can set OSM_PROJECT in environment')
73 @click.option('--so-port',
76 help='hostname of server. ' +
77 'Also can set OSM_SO_PORT in environment')
78 @click.option('--so-project',
80 envvar
='OSM_SO_PROJECT',
81 help='Project Name in SO. ' +
82 'Also can set OSM_SO_PROJECT in environment')
83 @click.option('--ro-hostname',
85 envvar
='OSM_RO_HOSTNAME',
86 help='hostname of RO server. ' +
87 'Also can set OSM_RO_HOSTNAME in environment')
88 @click.option('--ro-port',
91 help='hostname of RO server. ' +
92 'Also can set OSM_RO_PORT in environment')
94 def cli(ctx
, hostname
, sol005
, user
, password
, project
, so_port
, so_project
, ro_hostname
, ro_port
):
97 "either hostname option or OSM_HOSTNAME " +
98 "environment variable needs to be specified"))
101 if so_port
is not None:
102 kwargs
['so_port']=so_port
103 if so_project
is not None:
104 kwargs
['so_project']=so_project
105 if ro_hostname
is not None:
106 kwargs
['ro_host']=ro_hostname
107 if ro_port
is not None:
108 kwargs
['ro_port']=ro_port
111 if password
is not None:
112 kwargs
['password']=password
113 if project
is not None:
114 kwargs
['project']=project
116 ctx
.obj
= client
.Client(host
=hostname
, sol005
=sol005
, **kwargs
)
123 @cli.command(name
='ns-list')
124 @click.option('--filter', default
=None,
125 help='restricts the list to the NS instances matching the filter.')
127 def ns_list(ctx
, filter):
128 '''list all NS instances
132 --filter filterExpr Restricts the list to the NS instances matching the filter
135 filterExpr consists of one or more strings formatted according to "simpleFilterExpr",
136 concatenated using the "&" character:
139 filterExpr := <simpleFilterExpr>["&"<simpleFilterExpr>]*
140 simpleFilterExpr := <attrName>["."<attrName>]*["."<op>]"="<value>[","<value>]*
141 op := "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "cont" | "ncont"
143 value := scalar value
147 * zero or more occurrences
148 ? zero or one occurrence
149 [] grouping of expressions to be used with ? and *
150 "" quotation marks for marking string constants
154 "AttrName" is the name of one attribute in the data type that defines the representation
155 of the resource. The dot (".") character in "simpleFilterExpr" allows concatenation of
156 <attrName> entries to filter by attributes deeper in the hierarchy of a structured document.
157 "Op" stands for the comparison operator. If the expression has concatenated <attrName>
158 entries, it means that the operator "op" is applied to the attribute addressed by the last
159 <attrName> entry included in the concatenation. All simple filter expressions are combined
160 by the "AND" logical operator. In a concatenation of <attrName> entries in a <simpleFilterExpr>,
161 the rightmost "attrName" entry in a "simpleFilterExpr" is called "leaf attribute". The
162 concatenation of all "attrName" entries except the leaf attribute is called the "attribute
163 prefix". If an attribute referenced in an expression is an array, an object that contains a
164 corresponding array shall be considered to match the expression if any of the elements in the
165 array matches all expressions that have the same attribute prefix.
169 --filter admin-status=ENABLED
170 --filter nsd-ref=<NSD_NAME>
171 --filter nsd.vendor=<VENDOR>
172 --filter nsd.vendor=<VENDOR>&nsd-ref=<NSD_NAME>
173 --filter nsd.constituent-vnfd.vnfd-id-ref=<VNFD_NAME>
176 check_client_version(ctx
.obj
, '--filter')
177 resp
= ctx
.obj
.ns
.list(filter)
179 resp
= ctx
.obj
.ns
.list()
183 'operational status',
187 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
188 if fullclassname
== 'osmclient.sol005.client.Client':
190 nsr_name
= nsr
['name']
193 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
194 nsr
= nsopdata
['nsr:nsr']
195 nsr_name
= nsr
['name-ref']
196 nsr_id
= nsr
['ns-instance-config-ref']
197 opstatus
= nsr
['operational-status'] if 'operational-status' in nsr
else 'Not found'
198 configstatus
= nsr
['config-status'] if 'config-status' in nsr
else 'Not found'
199 detailed_status
= nsr
['detailed-status'] if 'detailed-status' in nsr
else 'Not found'
200 if configstatus
== "config_not_needed":
201 configstatus
= "configured (no charms)"
212 def nsd_list(ctx
, filter):
214 check_client_version(ctx
.obj
, '--filter')
215 resp
= ctx
.obj
.nsd
.list(filter)
217 resp
= ctx
.obj
.nsd
.list()
218 #print yaml.safe_dump(resp)
219 table
= PrettyTable(['nsd name', 'id'])
220 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
221 if fullclassname
== 'osmclient.sol005.client.Client':
223 name
= ns
['name'] if 'name' in ns
else '-'
224 table
.add_row([name
, ns
['_id']])
227 table
.add_row([ns
['name'], ns
['id']])
232 @cli.command(name
='nsd-list')
233 @click.option('--filter', default
=None,
234 help='restricts the list to the NSD/NSpkg matching the filter')
236 def nsd_list1(ctx
, filter):
237 '''list all NSD/NSpkg in the system'''
241 @cli.command(name
='nspkg-list')
242 @click.option('--filter', default
=None,
243 help='restricts the list to the NSD/NSpkg matching the filter')
245 def nsd_list2(ctx
, filter):
246 '''list all NSD/NSpkg in the system'''
250 def vnfd_list(ctx
, filter):
252 check_client_version(ctx
.obj
, '--filter')
253 resp
= ctx
.obj
.vnfd
.list(filter)
255 resp
= ctx
.obj
.vnfd
.list()
256 #print yaml.safe_dump(resp)
257 table
= PrettyTable(['vnfd name', 'id'])
258 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
259 if fullclassname
== 'osmclient.sol005.client.Client':
261 name
= vnfd
['name'] if 'name' in vnfd
else '-'
262 table
.add_row([name
, vnfd
['_id']])
265 table
.add_row([vnfd
['name'], vnfd
['id']])
270 @cli.command(name
='vnfd-list')
271 @click.option('--filter', default
=None,
272 help='restricts the list to the VNFD/VNFpkg matching the filter')
274 def vnfd_list1(ctx
, filter):
275 '''list all VNFD/VNFpkg in the system'''
276 vnfd_list(ctx
,filter)
279 @cli.command(name
='vnfpkg-list')
280 @click.option('--filter', default
=None,
281 help='restricts the list to the VNFD/VNFpkg matching the filter')
283 def vnfd_list2(ctx
, filter):
284 '''list all VNFD/VNFpkg in the system'''
285 vnfd_list(ctx
,filter)
288 @cli.command(name
='nfpkg-list')
289 @click.option('--nf_type', help='type of NFPKG (vnf, pnf, hnf)')
290 @click.option('--filter', default
=None,
291 help='restricts the list to the xNFpkg matching the filter')
293 def nfpkg_list(ctx
, nf_type
, filter):
294 '''list all NFpkg (VNFpkg, PNFpkg, HNFpkg) in the system'''
296 check_client_version(ctx
.obj
, ctx
.command
.name
)
299 nf_filter
= "_admin.type=vnfd"
300 elif nf_type
== "pnf":
301 nf_filter
= "_admin.type=pnfd"
302 elif nf_type
== "hnf":
303 nf_filter
= "_admin.type=hnfd"
305 raise ClientException('wrong value for "--nf_type" option, allowed values: vnf, pnf, hnf')
307 filter = '{}&{}'.format(nf_filter
, filter)
308 vnfd_list(ctx
,filter)
309 except ClientException
as inst
:
310 print((inst
.message
))
314 @cli.command(name
='vnf-list')
315 @click.option('--ns', default
=None, help='NS instance id or name to restrict the VNF list')
316 @click.option('--filter', default
=None,
317 help='restricts the list to the VNF instances matching the filter.')
319 def vnf_list(ctx
, ns
, filter):
320 '''list all VNF instances
324 --ns TEXT NS instance id or name to restrict the VNF list
325 --filter filterExpr Restricts the list to the VNF instances matching the filter
328 filterExpr consists of one or more strings formatted according to "simpleFilterExpr",
329 concatenated using the "&" character:
332 filterExpr := <simpleFilterExpr>["&"<simpleFilterExpr>]*
333 simpleFilterExpr := <attrName>["."<attrName>]*["."<op>]"="<value>[","<value>]*
334 op := "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "cont" | "ncont"
336 value := scalar value
340 * zero or more occurrences
341 ? zero or one occurrence
342 [] grouping of expressions to be used with ? and *
343 "" quotation marks for marking string constants
347 "AttrName" is the name of one attribute in the data type that defines the representation
348 of the resource. The dot (".") character in "simpleFilterExpr" allows concatenation of
349 <attrName> entries to filter by attributes deeper in the hierarchy of a structured document.
350 "Op" stands for the comparison operator. If the expression has concatenated <attrName>
351 entries, it means that the operator "op" is applied to the attribute addressed by the last
352 <attrName> entry included in the concatenation. All simple filter expressions are combined
353 by the "AND" logical operator. In a concatenation of <attrName> entries in a <simpleFilterExpr>,
354 the rightmost "attrName" entry in a "simpleFilterExpr" is called "leaf attribute". The
355 concatenation of all "attrName" entries except the leaf attribute is called the "attribute
356 prefix". If an attribute referenced in an expression is an array, an object that contains a
357 corresponding array shall be considered to match the expression if any of the elements in the
358 array matches all expressions that have the same attribute prefix.
362 --filter vim-account-id=<VIM_ACCOUNT_ID>
363 --filter vnfd-ref=<VNFD_NAME>
364 --filter vdur.ip-address=<IP_ADDRESS>
365 --filter vnfd-ref=<VNFD_NAME>,vdur.ip-address=<IP_ADDRESS>
370 check_client_version(ctx
.obj
, '--ns')
372 check_client_version(ctx
.obj
, '--filter')
373 resp
= ctx
.obj
.vnf
.list(ns
, filter)
375 resp
= ctx
.obj
.vnf
.list()
376 except ClientException
as inst
:
377 print((inst
.message
))
379 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
380 if fullclassname
== 'osmclient.sol005.client.Client':
390 name
= vnfr
['name'] if 'name' in vnfr
else '-'
395 vnfr
['member-vnf-index-ref'],
397 vnfr
['vim-account-id'],
403 'operational status',
406 if 'mgmt-interface' not in vnfr
:
407 vnfr
['mgmt-interface'] = {}
408 vnfr
['mgmt-interface']['ip-address'] = None
412 vnfr
['operational-status'],
413 vnfr
['config-status']])
417 @cli.command(name
='ns-op-list')
418 @click.argument('name')
420 def ns_op_list(ctx
, name
):
421 '''shows the history of operations over a NS instance
423 NAME: name or ID of the NS instance
426 check_client_version(ctx
.obj
, ctx
.command
.name
)
427 resp
= ctx
.obj
.ns
.list_op(name
)
428 except ClientException
as inst
:
429 print((inst
.message
))
432 table
= PrettyTable(['id', 'operation', 'status'])
434 table
.add_row([op
['id'], op
['lcmOperationType'],
435 op
['operationState']])
440 def nsi_list(ctx
, filter):
441 '''list all Network Slice Instances'''
443 check_client_version(ctx
.obj
, ctx
.command
.name
)
444 resp
= ctx
.obj
.nsi
.list(filter)
445 except ClientException
as inst
:
446 print((inst
.message
))
449 ['netslice instance name',
451 'operational status',
455 nsi_name
= nsi
['name']
457 opstatus
= nsi
['operational-status'] if 'operational-status' in nsi
else 'Not found'
458 configstatus
= nsi
['config-status'] if 'config-status' in nsi
else 'Not found'
459 detailed_status
= nsi
['detailed-status'] if 'detailed-status' in nsi
else 'Not found'
460 if configstatus
== "config_not_needed":
461 configstatus
= "configured (no charms)"
472 @cli.command(name
='nsi-list')
473 @click.option('--filter', default
=None,
474 help='restricts the list to the Network Slice Instances matching the filter')
476 def nsi_list1(ctx
, filter):
477 '''list all Network Slice Instances (NSI)'''
481 @cli.command(name
='netslice-instance-list')
482 @click.option('--filter', default
=None,
483 help='restricts the list to the Network Slice Instances matching the filter')
485 def nsi_list2(ctx
, filter):
486 '''list all Network Slice Instances (NSI)'''
490 def nst_list(ctx
, filter):
492 check_client_version(ctx
.obj
, ctx
.command
.name
)
493 resp
= ctx
.obj
.nst
.list(filter)
494 except ClientException
as inst
:
495 print((inst
.message
))
497 #print yaml.safe_dump(resp)
498 table
= PrettyTable(['nst name', 'id'])
500 name
= nst
['name'] if 'name' in nst
else '-'
501 table
.add_row([name
, nst
['_id']])
506 @cli.command(name
='nst-list')
507 @click.option('--filter', default
=None,
508 help='restricts the list to the NST matching the filter')
510 def nst_list1(ctx
, filter):
511 '''list all Network Slice Templates (NST) in the system'''
515 @cli.command(name
='netslice-template-list')
516 @click.option('--filter', default
=None,
517 help='restricts the list to the NST matching the filter')
519 def nst_list2(ctx
, filter):
520 '''list all Network Slice Templates (NST) in the system'''
524 def nsi_op_list(ctx
, name
):
526 check_client_version(ctx
.obj
, ctx
.command
.name
)
527 resp
= ctx
.obj
.nsi
.list_op(name
)
528 except ClientException
as inst
:
529 print((inst
.message
))
531 table
= PrettyTable(['id', 'operation', 'status'])
533 table
.add_row([op
['id'], op
['lcmOperationType'],
534 op
['operationState']])
539 @cli.command(name
='nsi-op-list')
540 @click.argument('name')
542 def nsi_op_list1(ctx
, name
):
543 '''shows the history of operations over a Network Slice Instance (NSI)
545 NAME: name or ID of the Network Slice Instance
547 nsi_op_list(ctx
,name
)
550 @cli.command(name
='netslice-instance-op-list')
551 @click.argument('name')
553 def nsi_op_list2(ctx
, name
):
554 '''shows the history of operations over a Network Slice Instance (NSI)
556 NAME: name or ID of the Network Slice Instance
558 nsi_op_list(ctx
,name
)
561 @cli.command(name
='pdu-list')
562 @click.option('--filter', default
=None,
563 help='restricts the list to the Physical Deployment Units matching the filter')
565 def pdu_list(ctx
, filter):
566 '''list all Physical Deployment Units (PDU)'''
568 check_client_version(ctx
.obj
, ctx
.command
.name
)
569 resp
= ctx
.obj
.pdu
.list(filter)
570 except ClientException
as inst
:
571 print((inst
.message
))
579 pdu_name
= pdu
['name']
581 pdu_type
= pdu
['type']
582 pdu_ipaddress
= "None"
583 for iface
in pdu
['interfaces']:
585 pdu_ipaddress
= iface
['ip-address']
600 def nsd_show(ctx
, name
, literal
):
602 resp
= ctx
.obj
.nsd
.get(name
)
603 #resp = ctx.obj.nsd.get_individual(name)
604 except ClientException
as inst
:
605 print((inst
.message
))
609 print(yaml
.safe_dump(resp
))
612 table
= PrettyTable(['field', 'value'])
613 for k
, v
in list(resp
.items()):
614 table
.add_row([k
, json
.dumps(v
, indent
=2)])
619 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
620 @click.option('--literal', is_flag
=True,
621 help='print literally, no pretty table')
622 @click.argument('name')
624 def nsd_show1(ctx
, name
, literal
):
625 '''shows the content of a NSD
627 NAME: name or ID of the NSD/NSpkg
629 nsd_show(ctx
, name
, literal
)
632 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
633 @click.option('--literal', is_flag
=True,
634 help='print literally, no pretty table')
635 @click.argument('name')
637 def nsd_show2(ctx
, name
, literal
):
638 '''shows the content of a NSD
640 NAME: name or ID of the NSD/NSpkg
642 nsd_show(ctx
, name
, literal
)
645 def vnfd_show(ctx
, name
, literal
):
647 resp
= ctx
.obj
.vnfd
.get(name
)
648 #resp = ctx.obj.vnfd.get_individual(name)
649 except ClientException
as inst
:
650 print((inst
.message
))
654 print(yaml
.safe_dump(resp
))
657 table
= PrettyTable(['field', 'value'])
658 for k
, v
in list(resp
.items()):
659 table
.add_row([k
, json
.dumps(v
, indent
=2)])
664 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
665 @click.option('--literal', is_flag
=True,
666 help='print literally, no pretty table')
667 @click.argument('name')
669 def vnfd_show1(ctx
, name
, literal
):
670 '''shows the content of a VNFD
672 NAME: name or ID of the VNFD/VNFpkg
674 vnfd_show(ctx
, name
, literal
)
677 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
678 @click.option('--literal', is_flag
=True,
679 help='print literally, no pretty table')
680 @click.argument('name')
682 def vnfd_show2(ctx
, name
, literal
):
683 '''shows the content of a VNFD
685 NAME: name or ID of the VNFD/VNFpkg
687 vnfd_show(ctx
, name
, literal
)
690 @cli.command(name
='nfpkg-show', short_help
='shows the content of a NF Descriptor')
691 @click.option('--literal', is_flag
=True,
692 help='print literally, no pretty table')
693 @click.argument('name')
695 def nfpkg_show(ctx
, name
, literal
):
696 '''shows the content of a NF Descriptor
698 NAME: name or ID of the NFpkg
700 vnfd_show(ctx
, name
, literal
)
703 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
704 @click.argument('name')
705 @click.option('--literal', is_flag
=True,
706 help='print literally, no pretty table')
707 @click.option('--filter', default
=None)
709 def ns_show(ctx
, name
, literal
, filter):
710 '''shows the info of a NS instance
712 NAME: name or ID of the NS instance
715 ns
= ctx
.obj
.ns
.get(name
)
716 except ClientException
as inst
:
717 print((inst
.message
))
721 print(yaml
.safe_dump(ns
))
724 table
= PrettyTable(['field', 'value'])
726 for k
, v
in list(ns
.items()):
727 if filter is None or filter in k
:
728 table
.add_row([k
, json
.dumps(v
, indent
=2)])
730 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
731 if fullclassname
!= 'osmclient.sol005.client.Client':
732 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
733 nsr_optdata
= nsopdata
['nsr:nsr']
734 for k
, v
in list(nsr_optdata
.items()):
735 if filter is None or filter in k
:
736 table
.add_row([k
, json
.dumps(v
, indent
=2)])
741 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
742 @click.argument('name')
743 @click.option('--literal', is_flag
=True,
744 help='print literally, no pretty table')
745 @click.option('--filter', default
=None)
747 def vnf_show(ctx
, name
, literal
, filter):
748 '''shows the info of a VNF instance
750 NAME: name or ID of the VNF instance
753 check_client_version(ctx
.obj
, ctx
.command
.name
)
754 resp
= ctx
.obj
.vnf
.get(name
)
755 except ClientException
as inst
:
756 print((inst
.message
))
760 print(yaml
.safe_dump(resp
))
763 table
= PrettyTable(['field', 'value'])
764 for k
, v
in list(resp
.items()):
765 if filter is None or filter in k
:
766 table
.add_row([k
, json
.dumps(v
, indent
=2)])
771 @cli.command(name
='vnf-monitoring-show')
772 @click.argument('vnf_name')
774 def vnf_monitoring_show(ctx
, vnf_name
):
776 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
777 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
778 except ClientException
as inst
:
779 print((inst
.message
))
782 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
788 monitor
['value-integer'],
794 @cli.command(name
='ns-monitoring-show')
795 @click.argument('ns_name')
797 def ns_monitoring_show(ctx
, ns_name
):
799 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
800 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
801 except ClientException
as inst
:
802 print((inst
.message
))
805 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
806 for key
, val
in list(resp
.items()):
811 monitor
['value-integer'],
817 @cli.command(name
='ns-op-show', short_help
='shows the info of an operation')
818 @click.argument('id')
819 @click.option('--filter', default
=None)
821 def ns_op_show(ctx
, id, filter):
822 '''shows the detailed info of an operation
824 ID: operation identifier
827 check_client_version(ctx
.obj
, ctx
.command
.name
)
828 op_info
= ctx
.obj
.ns
.get_op(id)
829 except ClientException
as inst
:
830 print((inst
.message
))
833 table
= PrettyTable(['field', 'value'])
834 for k
, v
in list(op_info
.items()):
835 if filter is None or filter in k
:
836 table
.add_row([k
, json
.dumps(v
, indent
=2)])
841 def nst_show(ctx
, name
, literal
):
843 check_client_version(ctx
.obj
, ctx
.command
.name
)
844 resp
= ctx
.obj
.nst
.get(name
)
845 #resp = ctx.obj.nst.get_individual(name)
846 except ClientException
as inst
:
847 print((inst
.message
))
851 print(yaml
.safe_dump(resp
))
854 table
= PrettyTable(['field', 'value'])
855 for k
, v
in list(resp
.items()):
856 table
.add_row([k
, json
.dumps(v
, indent
=2)])
861 @cli.command(name
='nst-show', short_help
='shows the content of a Network Slice Template (NST)')
862 @click.option('--literal', is_flag
=True,
863 help='print literally, no pretty table')
864 @click.argument('name')
866 def nst_show1(ctx
, name
, literal
):
867 '''shows the content of a Network Slice Template (NST)
869 NAME: name or ID of the NST
871 nst_show(ctx
, name
, literal
)
874 @cli.command(name
='netslice-template-show', short_help
='shows the content of a Network Slice Template (NST)')
875 @click.option('--literal', is_flag
=True,
876 help='print literally, no pretty table')
877 @click.argument('name')
879 def nst_show2(ctx
, name
, literal
):
880 '''shows the content of a Network Slice Template (NST)
882 NAME: name or ID of the NST
884 nst_show(ctx
, name
, literal
)
887 def nsi_show(ctx
, name
, literal
, filter):
889 check_client_version(ctx
.obj
, ctx
.command
.name
)
890 nsi
= ctx
.obj
.nsi
.get(name
)
891 except ClientException
as inst
:
892 print((inst
.message
))
896 print(yaml
.safe_dump(nsi
))
899 table
= PrettyTable(['field', 'value'])
901 for k
, v
in list(nsi
.items()):
902 if filter is None or filter in k
:
903 table
.add_row([k
, json
.dumps(v
, indent
=2)])
909 @cli.command(name
='nsi-show', short_help
='shows the content of a Network Slice Instance (NSI)')
910 @click.argument('name')
911 @click.option('--literal', is_flag
=True,
912 help='print literally, no pretty table')
913 @click.option('--filter', default
=None)
915 def nsi_show1(ctx
, name
, literal
, filter):
916 '''shows the content of a Network Slice Instance (NSI)
918 NAME: name or ID of the Network Slice Instance
920 nsi_show(ctx
, name
, literal
, filter)
923 @cli.command(name
='netslice-instance-show', short_help
='shows the content of a Network Slice Instance (NSI)')
924 @click.argument('name')
925 @click.option('--literal', is_flag
=True,
926 help='print literally, no pretty table')
927 @click.option('--filter', default
=None)
929 def nsi_show2(ctx
, name
, literal
, filter):
930 '''shows the content of a Network Slice Instance (NSI)
932 NAME: name or ID of the Network Slice Instance
934 nsi_show(ctx
, name
, literal
, filter)
937 def nsi_op_show(ctx
, id, filter):
939 check_client_version(ctx
.obj
, ctx
.command
.name
)
940 op_info
= ctx
.obj
.nsi
.get_op(id)
941 except ClientException
as inst
:
942 print((inst
.message
))
945 table
= PrettyTable(['field', 'value'])
946 for k
, v
in list(op_info
.items()):
947 if filter is None or filter in k
:
948 table
.add_row([k
, json
.dumps(v
, indent
=2)])
953 @cli.command(name
='nsi-op-show', short_help
='shows the info of an operation over a Network Slice Instance(NSI)')
954 @click.argument('id')
955 @click.option('--filter', default
=None)
957 def nsi_op_show1(ctx
, id, filter):
958 '''shows the info of an operation over a Network Slice Instance(NSI)
960 ID: operation identifier
962 nsi_op_show(ctx
, id, filter)
965 @cli.command(name
='netslice-instance-op-show', short_help
='shows the info of an operation over a Network Slice Instance(NSI)')
966 @click.argument('id')
967 @click.option('--filter', default
=None)
969 def nsi_op_show2(ctx
, id, filter):
970 '''shows the info of an operation over a Network Slice Instance(NSI)
972 ID: operation identifier
974 nsi_op_show(ctx
, id, filter)
977 @cli.command(name
='pdu-show', short_help
='shows the content of a Physical Deployment Unit (PDU)')
978 @click.argument('name')
979 @click.option('--literal', is_flag
=True,
980 help='print literally, no pretty table')
981 @click.option('--filter', default
=None)
983 def pdu_show(ctx
, name
, literal
, filter):
984 '''shows the content of a Physical Deployment Unit (PDU)
986 NAME: name or ID of the PDU
989 check_client_version(ctx
.obj
, ctx
.command
.name
)
990 pdu
= ctx
.obj
.pdu
.get(name
)
991 except ClientException
as inst
:
992 print((inst
.message
))
996 print(yaml
.safe_dump(pdu
))
999 table
= PrettyTable(['field', 'value'])
1001 for k
, v
in list(pdu
.items()):
1002 if filter is None or filter in k
:
1003 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1009 ####################
1011 ####################
1013 def nsd_create(ctx
, filename
, overwrite
):
1015 check_client_version(ctx
.obj
, ctx
.command
.name
)
1016 ctx
.obj
.nsd
.create(filename
, overwrite
)
1017 except ClientException
as inst
:
1018 print((inst
.message
))
1022 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
1023 @click.argument('filename')
1024 @click.option('--overwrite', default
=None,
1025 help='overwrites some fields in NSD')
1027 def nsd_create1(ctx
, filename
, overwrite
):
1028 '''creates a new NSD/NSpkg
1030 FILENAME: NSD yaml file or NSpkg tar.gz file
1032 nsd_create(ctx
, filename
, overwrite
)
1035 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
1036 @click.argument('filename')
1037 @click.option('--overwrite', default
=None,
1038 help='overwrites some fields in NSD')
1040 def nsd_create2(ctx
, filename
, overwrite
):
1041 '''creates a new NSD/NSpkg
1043 FILENAME: NSD yaml file or NSpkg tar.gz file
1045 nsd_create(ctx
, filename
, overwrite
)
1048 def vnfd_create(ctx
, filename
, overwrite
):
1050 check_client_version(ctx
.obj
, ctx
.command
.name
)
1051 ctx
.obj
.vnfd
.create(filename
, overwrite
)
1052 except ClientException
as inst
:
1053 print((inst
.message
))
1057 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
1058 @click.argument('filename')
1059 @click.option('--overwrite', default
=None,
1060 help='overwrites some fields in VNFD')
1062 def vnfd_create1(ctx
, filename
, overwrite
):
1063 '''creates a new VNFD/VNFpkg
1065 FILENAME: VNFD yaml file or VNFpkg tar.gz file
1067 vnfd_create(ctx
, filename
, overwrite
)
1070 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
1071 @click.argument('filename')
1072 @click.option('--overwrite', default
=None,
1073 help='overwrites some fields in VNFD')
1075 def vnfd_create2(ctx
, filename
, overwrite
):
1076 '''creates a new VNFD/VNFpkg
1078 FILENAME: VNFD yaml file or VNFpkg tar.gz file
1080 vnfd_create(ctx
, filename
, overwrite
)
1083 @cli.command(name
='nfpkg-create', short_help
='creates a new NFpkg')
1084 @click.argument('filename')
1085 @click.option('--overwrite', default
=None,
1086 help='overwrites some fields in NFD')
1088 def nfpkg_create(ctx
, filename
, overwrite
):
1089 '''creates a new NFpkg
1091 FILENAME: NF Descriptor yaml file or NFpkg tar.gz file
1093 vnfd_create(ctx
, filename
, overwrite
)
1096 @cli.command(name
='ns-create', short_help
='creates a new Network Service instance')
1097 @click.option('--ns_name',
1098 prompt
=True, help='name of the NS instance')
1099 @click.option('--nsd_name',
1100 prompt
=True, help='name of the NS descriptor')
1101 @click.option('--vim_account',
1102 prompt
=True, help='default VIM account id or name for the deployment')
1103 @click.option('--admin_status',
1105 help='administration status')
1106 @click.option('--ssh_keys',
1108 help='comma separated list of public key files to inject to vnfs')
1109 @click.option('--config',
1111 help='ns specific yaml configuration')
1112 @click.option('--config_file',
1114 help='ns specific yaml configuration file')
1124 '''creates a new NS instance'''
1127 check_client_version(ctx
.obj
, '--config_file')
1129 raise ClientException('"--config" option is incompatible with "--config_file" option')
1130 with
open(config_file
, 'r') as cf
:
1137 account
=vim_account
)
1138 except ClientException
as inst
:
1139 print((inst
.message
))
1143 def nst_create(ctx
, filename
, overwrite
):
1145 check_client_version(ctx
.obj
, ctx
.command
.name
)
1146 ctx
.obj
.nst
.create(filename
, overwrite
)
1147 except ClientException
as inst
:
1148 print((inst
.message
))
1152 @cli.command(name
='nst-create', short_help
='creates a new Network Slice Template (NST)')
1153 @click.argument('filename')
1154 @click.option('--overwrite', default
=None,
1155 help='overwrites some fields in NST')
1157 def nst_create1(ctx
, filename
, overwrite
):
1158 '''creates a new Network Slice Template (NST)
1160 FILENAME: NST yaml file or NSTpkg tar.gz file
1162 nst_create(ctx
, filename
, overwrite
)
1165 @cli.command(name
='netslice-template-create', short_help
='creates a new Network Slice Template (NST)')
1166 @click.argument('filename')
1167 @click.option('--overwrite', default
=None,
1168 help='overwrites some fields in NST')
1170 def nst_create2(ctx
, filename
, overwrite
):
1171 '''creates a new Network Slice Template (NST)
1173 FILENAME: NST yaml file or NSTpkg tar.gz file
1175 nst_create(ctx
, filename
, overwrite
)
1178 def nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1179 '''creates a new Network Slice Instance (NSI)'''
1181 check_client_version(ctx
.obj
, ctx
.command
.name
)
1184 raise ClientException('"--config" option is incompatible with "--config_file" option')
1185 with
open(config_file
, 'r') as cf
:
1187 ctx
.obj
.nsi
.create(nst_name
, nsi_name
, config
=config
, ssh_keys
=ssh_keys
,
1188 account
=vim_account
)
1189 except ClientException
as inst
:
1190 print((inst
.message
))
1194 @cli.command(name
='nsi-create', short_help
='creates a new Network Slice Instance')
1195 @click.option('--nsi_name', prompt
=True, help='name of the Network Slice Instance')
1196 @click.option('--nst_name', prompt
=True, help='name of the Network Slice Template')
1197 @click.option('--vim_account', prompt
=True, help='default VIM account id or name for the deployment')
1198 @click.option('--ssh_keys', default
=None,
1199 help='comma separated list of keys to inject to vnfs')
1200 @click.option('--config', default
=None,
1201 help='Netslice specific yaml configuration:\n'
1202 'netslice_subnet: [\n'
1203 'id: TEXT, vim_account: TEXT,\n'
1204 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
1205 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1207 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1209 @click.option('--config_file',
1211 help='nsi specific yaml configuration file')
1213 def nsi_create1(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1214 '''creates a new Network Slice Instance (NSI)'''
1215 nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
)
1218 @cli.command(name
='netslice-instance-create', short_help
='creates a new Network Slice Instance')
1219 @click.option('--nsi_name', prompt
=True, help='name of the Network Slice Instance')
1220 @click.option('--nst_name', prompt
=True, help='name of the Network Slice Template')
1221 @click.option('--vim_account', prompt
=True, help='default VIM account id or name for the deployment')
1222 @click.option('--ssh_keys', default
=None,
1223 help='comma separated list of keys to inject to vnfs')
1224 @click.option('--config', default
=None,
1225 help='Netslice specific yaml configuration:\n'
1226 'netslice_subnet: [\n'
1227 'id: TEXT, vim_account: TEXT,\n'
1228 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
1229 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1231 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1233 @click.option('--config_file',
1235 help='nsi specific yaml configuration file')
1237 def nsi_create2(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1238 '''creates a new Network Slice Instance (NSI)'''
1239 nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
)
1242 @cli.command(name
='pdu-create', short_help
='adds a new Physical Deployment Unit to the catalog')
1243 @click.option('--name', help='name of the Physical Deployment Unit')
1244 @click.option('--pdu_type', help='type of PDU (e.g. router, firewall, FW001)')
1245 @click.option('--interface',
1246 help='interface(s) of the PDU: name=<NAME>,mgmt=<true|false>,ip-address=<IP_ADDRESS>'+
1247 '[,type=<overlay|underlay>][,mac-address=<MAC_ADDRESS>][,vim-network-name=<VIM_NET_NAME>]',
1249 @click.option('--description', help='human readable description')
1250 @click.option('--vim_account', help='list of VIM accounts (in the same VIM) that can reach this PDU', multiple
=True)
1251 @click.option('--descriptor_file', default
=None, help='PDU descriptor file (as an alternative to using the other arguments')
1253 def pdu_create(ctx
, name
, pdu_type
, interface
, description
, vim_account
, descriptor_file
):
1254 '''creates a new Physical Deployment Unit (PDU)'''
1256 check_client_version(ctx
.obj
, ctx
.command
.name
)
1258 if not descriptor_file
:
1260 raise ClientException('in absence of descriptor file, option "--name" is mandatory')
1262 raise ClientException('in absence of descriptor file, option "--pdu_type" is mandatory')
1264 raise ClientException('in absence of descriptor file, option "--interface" is mandatory (at least once)')
1266 raise ClientException('in absence of descriptor file, option "--vim_account" is mandatory (at least once)')
1268 with
open(descriptor_file
, 'r') as df
:
1269 pdu
= yaml
.load(df
.read())
1270 if name
: pdu
["name"] = name
1271 if pdu_type
: pdu
["type"] = pdu_type
1272 if description
: pdu
["description"] = description
1273 if vim_account
: pdu
["vim_accounts"] = vim_account
1276 for iface
in interface
:
1277 new_iface
={k
:v
for k
,v
in [i
.split('=') for i
in iface
.split(',')]}
1278 new_iface
["mgmt"] = (new_iface
.get("mgmt","false").lower() == "true")
1279 ifaces_list
.append(new_iface
)
1280 pdu
["interfaces"] = ifaces_list
1281 ctx
.obj
.pdu
.create(pdu
)
1282 except ClientException
as inst
:
1283 print((inst
.message
))
1287 ####################
1289 ####################
1291 def nsd_update(ctx
, name
, content
):
1293 check_client_version(ctx
.obj
, ctx
.command
.name
)
1294 ctx
.obj
.nsd
.update(name
, content
)
1295 except ClientException
as inst
:
1296 print((inst
.message
))
1300 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
1301 @click.argument('name')
1302 @click.option('--content', default
=None,
1303 help='filename with the NSD/NSpkg replacing the current one')
1305 def nsd_update1(ctx
, name
, content
):
1306 '''updates a NSD/NSpkg
1308 NAME: name or ID of the NSD/NSpkg
1310 nsd_update(ctx
, name
, content
)
1313 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
1314 @click.argument('name')
1315 @click.option('--content', default
=None,
1316 help='filename with the NSD/NSpkg replacing the current one')
1318 def nsd_update2(ctx
, name
, content
):
1319 '''updates a NSD/NSpkg
1321 NAME: name or ID of the NSD/NSpkg
1323 nsd_update(ctx
, name
, content
)
1326 def vnfd_update(ctx
, name
, content
):
1328 check_client_version(ctx
.obj
, ctx
.command
.name
)
1329 ctx
.obj
.vnfd
.update(name
, content
)
1330 except ClientException
as inst
:
1331 print((inst
.message
))
1335 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
1336 @click.argument('name')
1337 @click.option('--content', default
=None,
1338 help='filename with the VNFD/VNFpkg replacing the current one')
1340 def vnfd_update1(ctx
, name
, content
):
1341 '''updates a VNFD/VNFpkg
1343 NAME: name or ID of the VNFD/VNFpkg
1345 vnfd_update(ctx
, name
, content
)
1348 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
1349 @click.argument('name')
1350 @click.option('--content', default
=None,
1351 help='filename with the VNFD/VNFpkg replacing the current one')
1353 def vnfd_update2(ctx
, name
, content
):
1354 '''updates a VNFD/VNFpkg
1356 NAME: VNFD yaml file or VNFpkg tar.gz file
1358 vnfd_update(ctx
, name
, content
)
1361 @cli.command(name
='nfpkg-update', short_help
='updates a NFpkg')
1362 @click.argument('name')
1363 @click.option('--content', default
=None,
1364 help='filename with the NFpkg replacing the current one')
1366 def nfpkg_update(ctx
, name
, content
):
1369 NAME: NF Descriptor yaml file or NFpkg tar.gz file
1371 vnfd_update(ctx
, name
, content
)
1374 def nst_update(ctx
, name
, content
):
1376 check_client_version(ctx
.obj
, ctx
.command
.name
)
1377 ctx
.obj
.nst
.update(name
, content
)
1378 except ClientException
as inst
:
1379 print((inst
.message
))
1383 @cli.command(name
='nst-update', short_help
='updates a Network Slice Template (NST)')
1384 @click.argument('name')
1385 @click.option('--content', default
=None,
1386 help='filename with the NST/NSTpkg replacing the current one')
1388 def nst_update1(ctx
, name
, content
):
1389 '''updates a Network Slice Template (NST)
1391 NAME: name or ID of the NSD/NSpkg
1393 nst_update(ctx
, name
, content
)
1396 @cli.command(name
='netslice-template-update', short_help
='updates a Network Slice Template (NST)')
1397 @click.argument('name')
1398 @click.option('--content', default
=None,
1399 help='filename with the NST/NSTpkg replacing the current one')
1401 def nst_update2(ctx
, name
, content
):
1402 '''updates a Network Slice Template (NST)
1404 NAME: name or ID of the NSD/NSpkg
1406 nst_update(ctx
, name
, content
)
1409 ####################
1411 ####################
1413 def nsd_delete(ctx
, name
, force
):
1416 ctx
.obj
.nsd
.delete(name
)
1418 check_client_version(ctx
.obj
, '--force')
1419 ctx
.obj
.nsd
.delete(name
, force
)
1420 except ClientException
as inst
:
1421 print((inst
.message
))
1425 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
1426 @click.argument('name')
1427 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1429 def nsd_delete1(ctx
, name
, force
):
1430 '''deletes a NSD/NSpkg
1432 NAME: name or ID of the NSD/NSpkg to be deleted
1434 nsd_delete(ctx
, name
, force
)
1437 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
1438 @click.argument('name')
1439 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1441 def nsd_delete2(ctx
, name
, force
):
1442 '''deletes a NSD/NSpkg
1444 NAME: name or ID of the NSD/NSpkg to be deleted
1446 nsd_delete(ctx
, name
, force
)
1449 def vnfd_delete(ctx
, name
, force
):
1452 ctx
.obj
.vnfd
.delete(name
)
1454 check_client_version(ctx
.obj
, '--force')
1455 ctx
.obj
.vnfd
.delete(name
, force
)
1456 except ClientException
as inst
:
1457 print((inst
.message
))
1461 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
1462 @click.argument('name')
1463 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1465 def vnfd_delete1(ctx
, name
, force
):
1466 '''deletes a VNFD/VNFpkg
1468 NAME: name or ID of the VNFD/VNFpkg to be deleted
1470 vnfd_delete(ctx
, name
, force
)
1473 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
1474 @click.argument('name')
1475 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1477 def vnfd_delete2(ctx
, name
, force
):
1478 '''deletes a VNFD/VNFpkg
1480 NAME: name or ID of the VNFD/VNFpkg to be deleted
1482 vnfd_delete(ctx
, name
, force
)
1485 @cli.command(name
='nfpkg-delete', short_help
='deletes a NFpkg')
1486 @click.argument('name')
1487 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1489 def nfpkg_delete(ctx
, name
, force
):
1492 NAME: name or ID of the NFpkg to be deleted
1494 vnfd_delete(ctx
, name
, force
)
1497 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
1498 @click.argument('name')
1499 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1501 def ns_delete(ctx
, name
, force
):
1502 '''deletes a NS instance
1504 NAME: name or ID of the NS instance to be deleted
1508 ctx
.obj
.ns
.delete(name
)
1510 check_client_version(ctx
.obj
, '--force')
1511 ctx
.obj
.ns
.delete(name
, force
)
1512 except ClientException
as inst
:
1513 print((inst
.message
))
1517 def nst_delete(ctx
, name
, force
):
1519 check_client_version(ctx
.obj
, ctx
.command
.name
)
1520 ctx
.obj
.nst
.delete(name
, force
)
1521 except ClientException
as inst
:
1522 print((inst
.message
))
1526 @cli.command(name
='nst-delete', short_help
='deletes a Network Slice Template (NST)')
1527 @click.argument('name')
1528 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1530 def nst_delete1(ctx
, name
, force
):
1531 '''deletes a Network Slice Template (NST)
1533 NAME: name or ID of the NST/NSTpkg to be deleted
1535 nst_delete(ctx
, name
, force
)
1538 @cli.command(name
='netslice-template-delete', short_help
='deletes a Network Slice Template (NST)')
1539 @click.argument('name')
1540 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1542 def nst_delete2(ctx
, name
, force
):
1543 '''deletes a Network Slice Template (NST)
1545 NAME: name or ID of the NST/NSTpkg to be deleted
1547 nst_delete(ctx
, name
, force
)
1550 def nsi_delete(ctx
, name
, force
):
1552 check_client_version(ctx
.obj
, ctx
.command
.name
)
1553 ctx
.obj
.nsi
.delete(name
, force
)
1554 except ClientException
as inst
:
1555 print((inst
.message
))
1559 @cli.command(name
='nsi-delete', short_help
='deletes a Network Slice Instance (NSI)')
1560 @click.argument('name')
1561 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1563 def nsi_delete1(ctx
, name
, force
):
1564 '''deletes a Network Slice Instance (NSI)
1566 NAME: name or ID of the Network Slice instance to be deleted
1568 nsi_delete(ctx
, name
, force
)
1571 @cli.command(name
='netslice-instance-delete', short_help
='deletes a Network Slice Instance (NSI)')
1572 @click.argument('name')
1573 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1575 def nsi_delete2(ctx
, name
, force
):
1576 '''deletes a Network Slice Instance (NSI)
1578 NAME: name or ID of the Network Slice instance to be deleted
1580 nsi_delete(ctx
, name
, force
)
1583 @cli.command(name
='pdu-delete', short_help
='deletes a Physical Deployment Unit (PDU)')
1584 @click.argument('name')
1585 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1587 def pdu_delete(ctx
, name
, force
):
1588 '''deletes a Physical Deployment Unit (PDU)
1590 NAME: name or ID of the PDU to be deleted
1593 check_client_version(ctx
.obj
, ctx
.command
.name
)
1594 ctx
.obj
.pdu
.delete(name
, force
)
1595 except ClientException
as inst
:
1596 print((inst
.message
))
1600 ####################
1602 ####################
1604 @cli.command(name
='vim-create')
1605 @click.option('--name',
1607 help='Name to create datacenter')
1608 @click.option('--user',
1610 help='VIM username')
1611 @click.option('--password',
1614 confirmation_prompt
=True,
1615 help='VIM password')
1616 @click.option('--auth_url',
1619 @click.option('--tenant',
1621 help='VIM tenant name')
1622 @click.option('--config',
1624 help='VIM specific config parameters')
1625 @click.option('--account_type',
1626 default
='openstack',
1628 @click.option('--description',
1629 default
='no description',
1630 help='human readable description')
1631 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
1632 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
1645 '''creates a new VIM account
1649 check_client_version(ctx
.obj
, '--sdn_controller')
1650 if sdn_port_mapping
:
1651 check_client_version(ctx
.obj
, '--sdn_port_mapping')
1653 vim
['vim-username'] = user
1654 vim
['vim-password'] = password
1655 vim
['vim-url'] = auth_url
1656 vim
['vim-tenant-name'] = tenant
1657 vim
['vim-type'] = account_type
1658 vim
['description'] = description
1659 vim
['config'] = config
1660 if sdn_controller
or sdn_port_mapping
:
1661 ctx
.obj
.vim
.create(name
, vim
, sdn_controller
, sdn_port_mapping
)
1663 ctx
.obj
.vim
.create(name
, vim
)
1664 except ClientException
as inst
:
1665 print((inst
.message
))
1669 @cli.command(name
='vim-update', short_help
='updates a VIM account')
1670 @click.argument('name')
1671 @click.option('--newname', help='New name for the VIM account')
1672 @click.option('--user', help='VIM username')
1673 @click.option('--password', help='VIM password')
1674 @click.option('--auth_url', help='VIM url')
1675 @click.option('--tenant', help='VIM tenant name')
1676 @click.option('--config', help='VIM specific config parameters')
1677 @click.option('--account_type', help='VIM type')
1678 @click.option('--description', help='human readable description')
1679 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
1680 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
1694 '''updates a VIM account
1696 NAME: name or ID of the VIM account
1699 check_client_version(ctx
.obj
, ctx
.command
.name
)
1701 if newname
: vim
['name'] = newname
1702 if user
: vim
['vim_user'] = user
1703 if password
: vim
['vim_password'] = password
1704 if auth_url
: vim
['vim_url'] = auth_url
1705 if tenant
: vim
['vim-tenant-name'] = tenant
1706 if account_type
: vim
['vim_type'] = account_type
1707 if description
: vim
['description'] = description
1708 if config
: vim
['config'] = config
1709 ctx
.obj
.vim
.update(name
, vim
, sdn_controller
, sdn_port_mapping
)
1710 except ClientException
as inst
:
1711 print((inst
.message
))
1715 @cli.command(name
='vim-delete')
1716 @click.argument('name')
1717 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1719 def vim_delete(ctx
, name
, force
):
1720 '''deletes a VIM account
1722 NAME: name or ID of the VIM account to be deleted
1726 ctx
.obj
.vim
.delete(name
)
1728 check_client_version(ctx
.obj
, '--force')
1729 ctx
.obj
.vim
.delete(name
, force
)
1730 except ClientException
as inst
:
1731 print((inst
.message
))
1735 @cli.command(name
='vim-list')
1736 @click.option('--ro_update/--no_ro_update',
1738 help='update list from RO')
1739 @click.option('--filter', default
=None,
1740 help='restricts the list to the VIM accounts matching the filter')
1742 def vim_list(ctx
, ro_update
, filter):
1743 '''list all VIM accounts'''
1745 check_client_version(ctx
.obj
, '--filter')
1747 check_client_version(ctx
.obj
, '--ro_update', 'v1')
1748 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
1749 if fullclassname
== 'osmclient.sol005.client.Client':
1750 resp
= ctx
.obj
.vim
.list(filter)
1752 resp
= ctx
.obj
.vim
.list(ro_update
)
1753 table
= PrettyTable(['vim name', 'uuid'])
1755 table
.add_row([vim
['name'], vim
['uuid']])
1760 @cli.command(name
='vim-show')
1761 @click.argument('name')
1763 def vim_show(ctx
, name
):
1764 '''shows the details of a VIM account
1766 NAME: name or ID of the VIM account
1769 resp
= ctx
.obj
.vim
.get(name
)
1770 if 'vim_password' in resp
:
1771 resp
['vim_password']='********'
1772 except ClientException
as inst
:
1773 print((inst
.message
))
1776 table
= PrettyTable(['key', 'attribute'])
1777 for k
, v
in list(resp
.items()):
1778 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1783 ####################
1784 # SDN controller operations
1785 ####################
1787 @cli.command(name
='sdnc-create')
1788 @click.option('--name',
1790 help='Name to create sdn controller')
1791 @click.option('--type',
1793 help='SDN controller type')
1794 @click.option('--sdn_controller_version',
1795 help='SDN controller username')
1796 @click.option('--ip_address',
1798 help='SDN controller IP address')
1799 @click.option('--port',
1801 help='SDN controller port')
1802 @click.option('--switch_dpid',
1804 help='Switch DPID (Openflow Datapath ID)')
1805 @click.option('--user',
1806 help='SDN controller username')
1807 @click.option('--password',
1809 confirmation_prompt
=True,
1810 help='SDN controller password')
1811 #@click.option('--description',
1812 # default='no description',
1813 # help='human readable description')
1815 def sdnc_create(ctx
,
1818 sdn_controller_version
,
1824 '''creates a new SDN controller
1827 sdncontroller
['name'] = name
1828 sdncontroller
['type'] = type
1829 sdncontroller
['ip'] = ip_address
1830 sdncontroller
['port'] = int(port
)
1831 sdncontroller
['dpid'] = switch_dpid
1832 if sdn_controller_version
:
1833 sdncontroller
['version'] = sdn_controller_version
1835 sdncontroller
['user'] = user
1837 sdncontroller
['password'] = password
1838 # sdncontroller['description'] = description
1840 check_client_version(ctx
.obj
, ctx
.command
.name
)
1841 ctx
.obj
.sdnc
.create(name
, sdncontroller
)
1842 except ClientException
as inst
:
1843 print((inst
.message
))
1846 @cli.command(name
='sdnc-update', short_help
='updates an SDN controller')
1847 @click.argument('name')
1848 @click.option('--newname', help='New name for the SDN controller')
1849 @click.option('--type', help='SDN controller type')
1850 @click.option('--sdn_controller_version', help='SDN controller username')
1851 @click.option('--ip_address', help='SDN controller IP address')
1852 @click.option('--port', help='SDN controller port')
1853 @click.option('--switch_dpid', help='Switch DPID (Openflow Datapath ID)')
1854 @click.option('--user', help='SDN controller username')
1855 @click.option('--password', help='SDN controller password')
1856 #@click.option('--description', default=None, help='human readable description')
1858 def sdnc_update(ctx
,
1862 sdn_controller_version
,
1868 '''updates an SDN controller
1870 NAME: name or ID of the SDN controller
1873 if newname
: sdncontroller
['name'] = newname
1874 if type: sdncontroller
['type'] = type
1875 if ip_address
: sdncontroller
['ip'] = ip_address
1876 if port
: sdncontroller
['port'] = int(port
)
1877 if switch_dpid
: sdncontroller
['dpid'] = switch_dpid
1878 # sdncontroller['description'] = description
1879 if sdn_controller_version
is not None:
1880 if sdn_controller_version
=="":
1881 sdncontroller
['version'] = None
1883 sdncontroller
['version'] = sdn_controller_version
1884 if user
is not None:
1886 sdncontroller
['user'] = None
1888 sdncontroller
['user'] = user
1889 if password
is not None:
1891 sdncontroller
['password'] = None
1893 sdncontroller
['password'] = user
1895 check_client_version(ctx
.obj
, ctx
.command
.name
)
1896 ctx
.obj
.sdnc
.update(name
, sdncontroller
)
1897 except ClientException
as inst
:
1898 print((inst
.message
))
1902 @cli.command(name
='sdnc-delete')
1903 @click.argument('name')
1904 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1906 def sdnc_delete(ctx
, name
, force
):
1907 '''deletes an SDN controller
1909 NAME: name or ID of the SDN controller to be deleted
1912 check_client_version(ctx
.obj
, ctx
.command
.name
)
1913 ctx
.obj
.sdnc
.delete(name
, force
)
1914 except ClientException
as inst
:
1915 print((inst
.message
))
1919 @cli.command(name
='sdnc-list')
1920 @click.option('--filter', default
=None,
1921 help='restricts the list to the SDN controllers matching the filter')
1923 def sdnc_list(ctx
, filter):
1924 '''list all SDN controllers'''
1926 check_client_version(ctx
.obj
, ctx
.command
.name
)
1927 resp
= ctx
.obj
.sdnc
.list(filter)
1928 except ClientException
as inst
:
1929 print((inst
.message
))
1931 table
= PrettyTable(['name', 'id'])
1933 table
.add_row([sdnc
['name'], sdnc
['_id']])
1938 @cli.command(name
='sdnc-show')
1939 @click.argument('name')
1941 def sdnc_show(ctx
, name
):
1942 '''shows the details of an SDN controller
1944 NAME: name or ID of the SDN controller
1947 check_client_version(ctx
.obj
, ctx
.command
.name
)
1948 resp
= ctx
.obj
.sdnc
.get(name
)
1949 except ClientException
as inst
:
1950 print((inst
.message
))
1953 table
= PrettyTable(['key', 'attribute'])
1954 for k
, v
in list(resp
.items()):
1955 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1960 ####################
1961 # Project mgmt operations
1962 ####################
1964 @cli.command(name
='project-create')
1965 @click.argument('name')
1966 #@click.option('--description',
1967 # default='no description',
1968 # help='human readable description')
1970 def project_create(ctx
, name
):
1971 '''Creates a new project
1973 NAME: name of the project
1976 project
['name'] = name
1978 check_client_version(ctx
.obj
, ctx
.command
.name
)
1979 ctx
.obj
.project
.create(name
, project
)
1980 except ClientException
as inst
:
1984 @cli.command(name
='project-delete')
1985 @click.argument('name')
1986 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
1988 def project_delete(ctx
, name
):
1989 '''deletes a project
1991 NAME: name or ID of the project to be deleted
1994 check_client_version(ctx
.obj
, ctx
.command
.name
)
1995 ctx
.obj
.project
.delete(name
)
1996 except ClientException
as inst
:
2001 @cli.command(name
='project-list')
2002 @click.option('--filter', default
=None,
2003 help='restricts the list to the projects matching the filter')
2005 def project_list(ctx
, filter):
2006 '''list all projects'''
2008 check_client_version(ctx
.obj
, ctx
.command
.name
)
2009 resp
= ctx
.obj
.project
.list(filter)
2010 except ClientException
as inst
:
2013 table
= PrettyTable(['name', 'id'])
2015 table
.add_row([proj
['name'], proj
['_id']])
2020 @cli.command(name
='project-show')
2021 @click.argument('name')
2023 def project_show(ctx
, name
):
2024 '''shows the details of a project
2026 NAME: name or ID of the project
2029 check_client_version(ctx
.obj
, ctx
.command
.name
)
2030 resp
= ctx
.obj
.project
.get(name
)
2031 except ClientException
as inst
:
2035 table
= PrettyTable(['key', 'attribute'])
2036 for k
, v
in resp
.items():
2037 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2042 ####################
2043 # User mgmt operations
2044 ####################
2046 @cli.command(name
='user-create')
2047 @click.argument('username')
2048 @click.option('--password',
2051 confirmation_prompt
=True,
2052 help='user password')
2053 @click.option('--projects',
2055 help='list of project ids that the user belongs to')
2056 #@click.option('--description',
2057 # default='no description',
2058 # help='human readable description')
2060 def user_create(ctx
, username
, password
, projects
):
2061 '''Creates a new user
2063 USERNAME: name of the user
2066 user
['username'] = username
2067 user
['password'] = password
2068 user
['projects'] = projects
2070 check_client_version(ctx
.obj
, ctx
.command
.name
)
2071 ctx
.obj
.user
.create(username
, user
)
2072 except ClientException
as inst
:
2076 @cli.command(name
='user-delete')
2077 @click.argument('name')
2078 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
2080 def user_delete(ctx
, name
):
2083 NAME: name or ID of the user to be deleted
2086 check_client_version(ctx
.obj
, ctx
.command
.name
)
2087 ctx
.obj
.user
.delete(name
)
2088 except ClientException
as inst
:
2093 @cli.command(name
='user-list')
2094 @click.option('--filter', default
=None,
2095 help='restricts the list to the users matching the filter')
2097 def user_list(ctx
, filter):
2098 '''list all users'''
2100 check_client_version(ctx
.obj
, ctx
.command
.name
)
2101 resp
= ctx
.obj
.user
.list(filter)
2102 except ClientException
as inst
:
2105 table
= PrettyTable(['name', 'id'])
2107 table
.add_row([user
['name'], user
['_id']])
2112 @cli.command(name
='user-show')
2113 @click.argument('name')
2115 def user_show(ctx
, name
):
2116 '''shows the details of a user
2118 NAME: name or ID of the user
2121 check_client_version(ctx
.obj
, ctx
.command
.name
)
2122 resp
= ctx
.obj
.user
.get(name
)
2123 if 'password' in resp
:
2124 resp
['password']='********'
2125 except ClientException
as inst
:
2129 table
= PrettyTable(['key', 'attribute'])
2130 for k
, v
in resp
.items():
2131 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2136 ####################
2137 # Fault Management operations
2138 ####################
2140 @cli.command(name
='ns-alarm-create')
2141 @click.argument('name')
2142 @click.option('--ns', prompt
=True, help='NS instance id or name')
2143 @click.option('--vnf', prompt
=True,
2144 help='VNF name (VNF member index as declared in the NSD)')
2145 @click.option('--vdu', prompt
=True,
2146 help='VDU name (VDU name as declared in the VNFD)')
2147 @click.option('--metric', prompt
=True,
2148 help='Name of the metric (e.g. cpu_utilization)')
2149 @click.option('--severity', default
='WARNING',
2150 help='severity of the alarm (WARNING, MINOR, MAJOR, CRITICAL, INDETERMINATE)')
2151 @click.option('--threshold_value', prompt
=True,
2152 help='threshold value that, when crossed, an alarm is triggered')
2153 @click.option('--threshold_operator', prompt
=True,
2154 help='threshold operator describing the comparison (GE, LE, GT, LT, EQ)')
2155 @click.option('--statistic', default
='AVERAGE',
2156 help='statistic (AVERAGE, MINIMUM, MAXIMUM, COUNT, SUM)')
2158 def ns_alarm_create(ctx
, name
, ns
, vnf
, vdu
, metric
, severity
,
2159 threshold_value
, threshold_operator
, statistic
):
2160 '''creates a new alarm for a NS instance'''
2161 ns_instance
= ctx
.obj
.ns
.get(ns
)
2163 alarm
['alarm_name'] = name
2164 alarm
['ns_id'] = ns_instance
['_id']
2165 alarm
['correlation_id'] = ns_instance
['_id']
2166 alarm
['vnf_member_index'] = vnf
2167 alarm
['vdu_name'] = vdu
2168 alarm
['metric_name'] = metric
2169 alarm
['severity'] = severity
2170 alarm
['threshold_value'] = int(threshold_value
)
2171 alarm
['operation'] = threshold_operator
2172 alarm
['statistic'] = statistic
2174 check_client_version(ctx
.obj
, ctx
.command
.name
)
2175 ctx
.obj
.ns
.create_alarm(alarm
)
2176 except ClientException
as inst
:
2177 print((inst
.message
))
2181 #@cli.command(name='ns-alarm-delete')
2182 #@click.argument('name')
2183 #@click.pass_context
2184 #def ns_alarm_delete(ctx, name):
2185 # '''deletes an alarm
2187 # NAME: name of the alarm to be deleted
2190 # check_client_version(ctx.obj, ctx.command.name)
2191 # ctx.obj.ns.delete_alarm(name)
2192 # except ClientException as inst:
2193 # print(inst.message)
2197 ####################
2198 # Performance Management operations
2199 ####################
2201 @cli.command(name
='ns-metric-export')
2202 @click.option('--ns', prompt
=True, help='NS instance id or name')
2203 @click.option('--vnf', prompt
=True,
2204 help='VNF name (VNF member index as declared in the NSD)')
2205 @click.option('--vdu', prompt
=True,
2206 help='VDU name (VDU name as declared in the VNFD)')
2207 @click.option('--metric', prompt
=True,
2208 help='name of the metric (e.g. cpu_utilization)')
2209 #@click.option('--period', default='1w',
2210 # help='metric collection period (e.g. 20s, 30m, 2h, 3d, 1w)')
2211 @click.option('--interval', help='periodic interval (seconds) to export metrics continuously')
2213 def ns_metric_export(ctx
, ns
, vnf
, vdu
, metric
, interval
):
2214 '''exports a metric to the internal OSM bus, which can be read by other apps
2216 ns_instance
= ctx
.obj
.ns
.get(ns
)
2218 metric_data
['ns_id'] = ns_instance
['_id']
2219 metric_data
['correlation_id'] = ns_instance
['_id']
2220 metric_data
['vnf_member_index'] = vnf
2221 metric_data
['vdu_name'] = vdu
2222 metric_data
['metric_name'] = metric
2223 metric_data
['collection_unit'] = 'WEEK'
2224 metric_data
['collection_period'] = 1
2226 check_client_version(ctx
.obj
, ctx
.command
.name
)
2228 print('{}'.format(ctx
.obj
.ns
.export_metric(metric_data
)))
2232 print('{} {}'.format(ctx
.obj
.ns
.export_metric(metric_data
),i
))
2233 time
.sleep(int(interval
))
2235 except ClientException
as inst
:
2236 print((inst
.message
))
2240 ####################
2242 ####################
2244 @cli.command(name
='upload-package')
2245 @click.argument('filename')
2247 def upload_package(ctx
, filename
):
2248 '''uploads a VNF package or NS package
2250 FILENAME: VNF or NS package file (tar.gz)
2253 ctx
.obj
.package
.upload(filename
)
2254 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
2255 if fullclassname
!= 'osmclient.sol005.client.Client':
2256 ctx
.obj
.package
.wait_for_upload(filename
)
2257 except ClientException
as inst
:
2258 print((inst
.message
))
2262 @cli.command(name
='ns-scaling-show')
2263 @click.argument('ns_name')
2265 def show_ns_scaling(ctx
, ns_name
):
2266 '''shows the status of a NS scaling operation
2268 NS_NAME: name of the NS instance being scaled
2271 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2272 resp
= ctx
.obj
.ns
.list()
2273 except ClientException
as inst
:
2274 print((inst
.message
))
2277 table
= PrettyTable(
2280 'operational status',
2285 if ns_name
== ns
['name']:
2286 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
2287 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
2288 for record
in scaling_records
:
2289 if 'instance' in record
:
2290 instances
= record
['instance']
2291 for inst
in instances
:
2293 [record
['scaling-group-name-ref'],
2294 inst
['instance-id'],
2296 time
.strftime('%Y-%m-%d %H:%M:%S',
2298 inst
['create-time'])),
2304 @cli.command(name
='ns-scale')
2305 @click.argument('ns_name')
2306 @click.option('--ns_scale_group', prompt
=True)
2307 @click.option('--index', prompt
=True)
2309 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
2312 NS_NAME: name of the NS instance to be scaled
2315 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2316 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
2317 except ClientException
as inst
:
2318 print((inst
.message
))
2322 @cli.command(name
='config-agent-list')
2324 def config_agent_list(ctx
):
2325 '''list config agents'''
2327 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2328 except ClientException
as inst
:
2329 print((inst
.message
))
2331 table
= PrettyTable(['name', 'account-type', 'details'])
2332 for account
in ctx
.obj
.vca
.list():
2335 account
['account-type'],
2341 @cli.command(name
='config-agent-delete')
2342 @click.argument('name')
2344 def config_agent_delete(ctx
, name
):
2345 '''deletes a config agent
2347 NAME: name of the config agent to be deleted
2350 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2351 ctx
.obj
.vca
.delete(name
)
2352 except ClientException
as inst
:
2353 print((inst
.message
))
2357 @cli.command(name
='config-agent-add')
2358 @click.option('--name',
2360 @click.option('--account_type',
2362 @click.option('--server',
2364 @click.option('--user',
2366 @click.option('--secret',
2369 confirmation_prompt
=True)
2371 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
2372 '''adds a config agent'''
2374 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2375 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
2376 except ClientException
as inst
:
2377 print((inst
.message
))
2380 @cli.command(name
='ro-dump')
2383 '''shows RO agent information'''
2384 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2385 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
2386 table
= PrettyTable(['key', 'attribute'])
2387 for k
, v
in list(resp
.items()):
2388 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2393 @cli.command(name
='vcs-list')
2396 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2397 resp
= ctx
.obj
.utils
.get_vcs_info()
2398 table
= PrettyTable(['component name', 'state'])
2399 for component
in resp
:
2400 table
.add_row([component
['component_name'], component
['state']])
2405 @cli.command(name
='ns-action')
2406 @click.argument('ns_name')
2407 @click.option('--vnf_name', default
=None)
2408 @click.option('--action_name', prompt
=True)
2409 @click.option('--params', prompt
=True)
2416 '''executes an action/primitive over a NS instance
2418 NS_NAME: name or ID of the NS instance
2421 check_client_version(ctx
.obj
, ctx
.command
.name
)
2424 op_data
['vnf_member_index'] = vnf_name
2425 op_data
['primitive'] = action_name
2426 op_data
['primitive_params'] = yaml
.load(params
)
2427 ctx
.obj
.ns
.exec_op(ns_name
, op_name
='action', op_data
=op_data
)
2429 except ClientException
as inst
:
2430 print((inst
.message
))
2434 @cli.command(name
='vnf-scale')
2435 @click.argument('ns_name')
2436 @click.argument('vnf_name')
2437 @click.option('--scaling-group', prompt
=True, help="scaling-group-descriptor name to use")
2438 @click.option('--scale-in', default
=False, is_flag
=True, help="performs a scale in operation")
2439 @click.option('--scale-out', default
=False, is_flag
=True, help="performs a scale out operation (by default)")
2447 '''executes a VNF scale (adding/removing VDUs)
2450 NS_NAME: name or ID of the NS instance.
2451 VNF_NAME: member-vnf-index in the NS to be scaled.
2454 check_client_version(ctx
.obj
, ctx
.command
.name
)
2455 if not scale_in
and not scale_out
:
2457 ctx
.obj
.ns
.scale_vnf(ns_name
, vnf_name
, scaling_group
, scale_in
, scale_out
)
2458 except ClientException
as inst
:
2459 print((inst
.message
))
2463 if __name__
== '__main__':
2466 except pycurl
.error
as e
:
2468 print('Maybe "--hostname" option or OSM_HOSTNAME' +
2469 'environment variable needs to be specified')