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
, nf_type
, filter):
252 check_client_version(ctx
.obj
, '--nf_type')
254 check_client_version(ctx
.obj
, '--filter')
257 nf_filter
= "_admin.type=vnfd"
258 elif nf_type
== "pnf":
259 nf_filter
= "_admin.type=pnfd"
260 elif nf_type
== "hnf":
261 nf_filter
= "_admin.type=hnfd"
263 raise ClientException('wrong value for "--nf_type" option, allowed values: vnf, pnf, hnf')
265 filter = '{}&{}'.format(nf_filter
, filter)
269 resp
= ctx
.obj
.vnfd
.list(filter)
271 resp
= ctx
.obj
.vnfd
.list()
272 #print yaml.safe_dump(resp)
273 table
= PrettyTable(['vnfd name', 'id'])
274 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
275 if fullclassname
== 'osmclient.sol005.client.Client':
277 name
= vnfd
['name'] if 'name' in vnfd
else '-'
278 table
.add_row([name
, vnfd
['_id']])
281 table
.add_row([vnfd
['name'], vnfd
['id']])
286 @cli.command(name
='vnfd-list')
287 @click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
288 @click.option('--filter', default
=None,
289 help='restricts the list to the NFpkg matching the filter')
291 def vnfd_list1(ctx
, nf_type
, filter):
292 '''list all VNFD/VNFpkg in the system'''
293 vnfd_list(ctx
,nf_type
,filter)
296 @cli.command(name
='vnfpkg-list')
297 @click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
298 @click.option('--filter', default
=None,
299 help='restricts the list to the NFpkg matching the filter')
301 def vnfd_list2(ctx
, nf_type
, filter):
302 '''list all VNFD/VNFpkg in the system'''
303 vnfd_list(ctx
,nf_type
,filter)
306 @cli.command(name
='nfpkg-list')
307 @click.option('--nf_type', help='type of NF (vnf, pnf, hnf)')
308 @click.option('--filter', default
=None,
309 help='restricts the list to the NFpkg matching the filter')
311 def nfpkg_list(ctx
, nf_type
, filter):
312 '''list all NFpkg (VNFpkg, PNFpkg, HNFpkg) in the system'''
314 check_client_version(ctx
.obj
, ctx
.command
.name
)
315 vnfd_list(ctx
,nf_type
,filter)
316 except ClientException
as inst
:
317 print((inst
.message
))
321 @cli.command(name
='vnf-list')
322 @click.option('--ns', default
=None, help='NS instance id or name to restrict the VNF list')
323 @click.option('--filter', default
=None,
324 help='restricts the list to the VNF instances matching the filter.')
326 def vnf_list(ctx
, ns
, filter):
327 '''list all VNF instances
331 --ns TEXT NS instance id or name to restrict the VNF list
332 --filter filterExpr Restricts the list to the VNF instances matching the filter
335 filterExpr consists of one or more strings formatted according to "simpleFilterExpr",
336 concatenated using the "&" character:
339 filterExpr := <simpleFilterExpr>["&"<simpleFilterExpr>]*
340 simpleFilterExpr := <attrName>["."<attrName>]*["."<op>]"="<value>[","<value>]*
341 op := "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "cont" | "ncont"
343 value := scalar value
347 * zero or more occurrences
348 ? zero or one occurrence
349 [] grouping of expressions to be used with ? and *
350 "" quotation marks for marking string constants
354 "AttrName" is the name of one attribute in the data type that defines the representation
355 of the resource. The dot (".") character in "simpleFilterExpr" allows concatenation of
356 <attrName> entries to filter by attributes deeper in the hierarchy of a structured document.
357 "Op" stands for the comparison operator. If the expression has concatenated <attrName>
358 entries, it means that the operator "op" is applied to the attribute addressed by the last
359 <attrName> entry included in the concatenation. All simple filter expressions are combined
360 by the "AND" logical operator. In a concatenation of <attrName> entries in a <simpleFilterExpr>,
361 the rightmost "attrName" entry in a "simpleFilterExpr" is called "leaf attribute". The
362 concatenation of all "attrName" entries except the leaf attribute is called the "attribute
363 prefix". If an attribute referenced in an expression is an array, an object that contains a
364 corresponding array shall be considered to match the expression if any of the elements in the
365 array matches all expressions that have the same attribute prefix.
369 --filter vim-account-id=<VIM_ACCOUNT_ID>
370 --filter vnfd-ref=<VNFD_NAME>
371 --filter vdur.ip-address=<IP_ADDRESS>
372 --filter vnfd-ref=<VNFD_NAME>,vdur.ip-address=<IP_ADDRESS>
377 check_client_version(ctx
.obj
, '--ns')
379 check_client_version(ctx
.obj
, '--filter')
380 resp
= ctx
.obj
.vnf
.list(ns
, filter)
382 resp
= ctx
.obj
.vnf
.list()
383 except ClientException
as inst
:
384 print((inst
.message
))
386 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
387 if fullclassname
== 'osmclient.sol005.client.Client':
397 name
= vnfr
['name'] if 'name' in vnfr
else '-'
402 vnfr
['member-vnf-index-ref'],
404 vnfr
['vim-account-id'],
410 'operational status',
413 if 'mgmt-interface' not in vnfr
:
414 vnfr
['mgmt-interface'] = {}
415 vnfr
['mgmt-interface']['ip-address'] = None
419 vnfr
['operational-status'],
420 vnfr
['config-status']])
424 @cli.command(name
='ns-op-list')
425 @click.argument('name')
427 def ns_op_list(ctx
, name
):
428 '''shows the history of operations over a NS instance
430 NAME: name or ID of the NS instance
433 check_client_version(ctx
.obj
, ctx
.command
.name
)
434 resp
= ctx
.obj
.ns
.list_op(name
)
435 except ClientException
as inst
:
436 print((inst
.message
))
439 table
= PrettyTable(['id', 'operation', 'status'])
441 table
.add_row([op
['id'], op
['lcmOperationType'],
442 op
['operationState']])
447 def nsi_list(ctx
, filter):
448 '''list all Network Slice Instances'''
450 check_client_version(ctx
.obj
, ctx
.command
.name
)
451 resp
= ctx
.obj
.nsi
.list(filter)
452 except ClientException
as inst
:
453 print((inst
.message
))
456 ['netslice instance name',
458 'operational status',
462 nsi_name
= nsi
['name']
464 opstatus
= nsi
['operational-status'] if 'operational-status' in nsi
else 'Not found'
465 configstatus
= nsi
['config-status'] if 'config-status' in nsi
else 'Not found'
466 detailed_status
= nsi
['detailed-status'] if 'detailed-status' in nsi
else 'Not found'
467 if configstatus
== "config_not_needed":
468 configstatus
= "configured (no charms)"
479 @cli.command(name
='nsi-list')
480 @click.option('--filter', default
=None,
481 help='restricts the list to the Network Slice Instances matching the filter')
483 def nsi_list1(ctx
, filter):
484 '''list all Network Slice Instances (NSI)'''
488 @cli.command(name
='netslice-instance-list')
489 @click.option('--filter', default
=None,
490 help='restricts the list to the Network Slice Instances matching the filter')
492 def nsi_list2(ctx
, filter):
493 '''list all Network Slice Instances (NSI)'''
497 def nst_list(ctx
, filter):
499 check_client_version(ctx
.obj
, ctx
.command
.name
)
500 resp
= ctx
.obj
.nst
.list(filter)
501 except ClientException
as inst
:
502 print((inst
.message
))
504 #print yaml.safe_dump(resp)
505 table
= PrettyTable(['nst name', 'id'])
507 name
= nst
['name'] if 'name' in nst
else '-'
508 table
.add_row([name
, nst
['_id']])
513 @cli.command(name
='nst-list')
514 @click.option('--filter', default
=None,
515 help='restricts the list to the NST matching the filter')
517 def nst_list1(ctx
, filter):
518 '''list all Network Slice Templates (NST) in the system'''
522 @cli.command(name
='netslice-template-list')
523 @click.option('--filter', default
=None,
524 help='restricts the list to the NST matching the filter')
526 def nst_list2(ctx
, filter):
527 '''list all Network Slice Templates (NST) in the system'''
531 def nsi_op_list(ctx
, name
):
533 check_client_version(ctx
.obj
, ctx
.command
.name
)
534 resp
= ctx
.obj
.nsi
.list_op(name
)
535 except ClientException
as inst
:
536 print((inst
.message
))
538 table
= PrettyTable(['id', 'operation', 'status'])
540 table
.add_row([op
['id'], op
['lcmOperationType'],
541 op
['operationState']])
546 @cli.command(name
='nsi-op-list')
547 @click.argument('name')
549 def nsi_op_list1(ctx
, name
):
550 '''shows the history of operations over a Network Slice Instance (NSI)
552 NAME: name or ID of the Network Slice Instance
554 nsi_op_list(ctx
,name
)
557 @cli.command(name
='netslice-instance-op-list')
558 @click.argument('name')
560 def nsi_op_list2(ctx
, name
):
561 '''shows the history of operations over a Network Slice Instance (NSI)
563 NAME: name or ID of the Network Slice Instance
565 nsi_op_list(ctx
,name
)
568 @cli.command(name
='pdu-list')
569 @click.option('--filter', default
=None,
570 help='restricts the list to the Physical Deployment Units matching the filter')
572 def pdu_list(ctx
, filter):
573 '''list all Physical Deployment Units (PDU)'''
575 check_client_version(ctx
.obj
, ctx
.command
.name
)
576 resp
= ctx
.obj
.pdu
.list(filter)
577 except ClientException
as inst
:
578 print((inst
.message
))
586 pdu_name
= pdu
['name']
588 pdu_type
= pdu
['type']
589 pdu_ipaddress
= "None"
590 for iface
in pdu
['interfaces']:
592 pdu_ipaddress
= iface
['ip-address']
607 def nsd_show(ctx
, name
, literal
):
609 resp
= ctx
.obj
.nsd
.get(name
)
610 #resp = ctx.obj.nsd.get_individual(name)
611 except ClientException
as inst
:
612 print((inst
.message
))
616 print(yaml
.safe_dump(resp
))
619 table
= PrettyTable(['field', 'value'])
620 for k
, v
in list(resp
.items()):
621 table
.add_row([k
, json
.dumps(v
, indent
=2)])
626 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
627 @click.option('--literal', is_flag
=True,
628 help='print literally, no pretty table')
629 @click.argument('name')
631 def nsd_show1(ctx
, name
, literal
):
632 '''shows the content of a NSD
634 NAME: name or ID of the NSD/NSpkg
636 nsd_show(ctx
, name
, literal
)
639 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
640 @click.option('--literal', is_flag
=True,
641 help='print literally, no pretty table')
642 @click.argument('name')
644 def nsd_show2(ctx
, name
, literal
):
645 '''shows the content of a NSD
647 NAME: name or ID of the NSD/NSpkg
649 nsd_show(ctx
, name
, literal
)
652 def vnfd_show(ctx
, name
, literal
):
654 resp
= ctx
.obj
.vnfd
.get(name
)
655 #resp = ctx.obj.vnfd.get_individual(name)
656 except ClientException
as inst
:
657 print((inst
.message
))
661 print(yaml
.safe_dump(resp
))
664 table
= PrettyTable(['field', 'value'])
665 for k
, v
in list(resp
.items()):
666 table
.add_row([k
, json
.dumps(v
, indent
=2)])
671 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
672 @click.option('--literal', is_flag
=True,
673 help='print literally, no pretty table')
674 @click.argument('name')
676 def vnfd_show1(ctx
, name
, literal
):
677 '''shows the content of a VNFD
679 NAME: name or ID of the VNFD/VNFpkg
681 vnfd_show(ctx
, name
, literal
)
684 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
685 @click.option('--literal', is_flag
=True,
686 help='print literally, no pretty table')
687 @click.argument('name')
689 def vnfd_show2(ctx
, name
, literal
):
690 '''shows the content of a VNFD
692 NAME: name or ID of the VNFD/VNFpkg
694 vnfd_show(ctx
, name
, literal
)
697 @cli.command(name
='nfpkg-show', short_help
='shows the content of a NF Descriptor')
698 @click.option('--literal', is_flag
=True,
699 help='print literally, no pretty table')
700 @click.argument('name')
702 def nfpkg_show(ctx
, name
, literal
):
703 '''shows the content of a NF Descriptor
705 NAME: name or ID of the NFpkg
707 vnfd_show(ctx
, name
, literal
)
710 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
711 @click.argument('name')
712 @click.option('--literal', is_flag
=True,
713 help='print literally, no pretty table')
714 @click.option('--filter', default
=None)
716 def ns_show(ctx
, name
, literal
, filter):
717 '''shows the info of a NS instance
719 NAME: name or ID of the NS instance
722 ns
= ctx
.obj
.ns
.get(name
)
723 except ClientException
as inst
:
724 print((inst
.message
))
728 print(yaml
.safe_dump(ns
))
731 table
= PrettyTable(['field', 'value'])
733 for k
, v
in list(ns
.items()):
734 if filter is None or filter in k
:
735 table
.add_row([k
, json
.dumps(v
, indent
=2)])
737 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
738 if fullclassname
!= 'osmclient.sol005.client.Client':
739 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
740 nsr_optdata
= nsopdata
['nsr:nsr']
741 for k
, v
in list(nsr_optdata
.items()):
742 if filter is None or filter in k
:
743 table
.add_row([k
, json
.dumps(v
, indent
=2)])
748 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
749 @click.argument('name')
750 @click.option('--literal', is_flag
=True,
751 help='print literally, no pretty table')
752 @click.option('--filter', default
=None)
754 def vnf_show(ctx
, name
, literal
, filter):
755 '''shows the info of a VNF instance
757 NAME: name or ID of the VNF instance
760 check_client_version(ctx
.obj
, ctx
.command
.name
)
761 resp
= ctx
.obj
.vnf
.get(name
)
762 except ClientException
as inst
:
763 print((inst
.message
))
767 print(yaml
.safe_dump(resp
))
770 table
= PrettyTable(['field', 'value'])
771 for k
, v
in list(resp
.items()):
772 if filter is None or filter in k
:
773 table
.add_row([k
, json
.dumps(v
, indent
=2)])
778 @cli.command(name
='vnf-monitoring-show')
779 @click.argument('vnf_name')
781 def vnf_monitoring_show(ctx
, vnf_name
):
783 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
784 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
785 except ClientException
as inst
:
786 print((inst
.message
))
789 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
795 monitor
['value-integer'],
801 @cli.command(name
='ns-monitoring-show')
802 @click.argument('ns_name')
804 def ns_monitoring_show(ctx
, ns_name
):
806 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
807 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
808 except ClientException
as inst
:
809 print((inst
.message
))
812 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
813 for key
, val
in list(resp
.items()):
818 monitor
['value-integer'],
824 @cli.command(name
='ns-op-show', short_help
='shows the info of an operation')
825 @click.argument('id')
826 @click.option('--filter', default
=None)
828 def ns_op_show(ctx
, id, filter):
829 '''shows the detailed info of an operation
831 ID: operation identifier
834 check_client_version(ctx
.obj
, ctx
.command
.name
)
835 op_info
= ctx
.obj
.ns
.get_op(id)
836 except ClientException
as inst
:
837 print((inst
.message
))
840 table
= PrettyTable(['field', 'value'])
841 for k
, v
in list(op_info
.items()):
842 if filter is None or filter in k
:
843 table
.add_row([k
, json
.dumps(v
, indent
=2)])
848 def nst_show(ctx
, name
, literal
):
850 check_client_version(ctx
.obj
, ctx
.command
.name
)
851 resp
= ctx
.obj
.nst
.get(name
)
852 #resp = ctx.obj.nst.get_individual(name)
853 except ClientException
as inst
:
854 print((inst
.message
))
858 print(yaml
.safe_dump(resp
))
861 table
= PrettyTable(['field', 'value'])
862 for k
, v
in list(resp
.items()):
863 table
.add_row([k
, json
.dumps(v
, indent
=2)])
868 @cli.command(name
='nst-show', short_help
='shows the content of a Network Slice Template (NST)')
869 @click.option('--literal', is_flag
=True,
870 help='print literally, no pretty table')
871 @click.argument('name')
873 def nst_show1(ctx
, name
, literal
):
874 '''shows the content of a Network Slice Template (NST)
876 NAME: name or ID of the NST
878 nst_show(ctx
, name
, literal
)
881 @cli.command(name
='netslice-template-show', short_help
='shows the content of a Network Slice Template (NST)')
882 @click.option('--literal', is_flag
=True,
883 help='print literally, no pretty table')
884 @click.argument('name')
886 def nst_show2(ctx
, name
, literal
):
887 '''shows the content of a Network Slice Template (NST)
889 NAME: name or ID of the NST
891 nst_show(ctx
, name
, literal
)
894 def nsi_show(ctx
, name
, literal
, filter):
896 check_client_version(ctx
.obj
, ctx
.command
.name
)
897 nsi
= ctx
.obj
.nsi
.get(name
)
898 except ClientException
as inst
:
899 print((inst
.message
))
903 print(yaml
.safe_dump(nsi
))
906 table
= PrettyTable(['field', 'value'])
908 for k
, v
in list(nsi
.items()):
909 if filter is None or filter in k
:
910 table
.add_row([k
, json
.dumps(v
, indent
=2)])
916 @cli.command(name
='nsi-show', short_help
='shows the content of a Network Slice Instance (NSI)')
917 @click.argument('name')
918 @click.option('--literal', is_flag
=True,
919 help='print literally, no pretty table')
920 @click.option('--filter', default
=None)
922 def nsi_show1(ctx
, name
, literal
, filter):
923 '''shows the content of a Network Slice Instance (NSI)
925 NAME: name or ID of the Network Slice Instance
927 nsi_show(ctx
, name
, literal
, filter)
930 @cli.command(name
='netslice-instance-show', short_help
='shows the content of a Network Slice Instance (NSI)')
931 @click.argument('name')
932 @click.option('--literal', is_flag
=True,
933 help='print literally, no pretty table')
934 @click.option('--filter', default
=None)
936 def nsi_show2(ctx
, name
, literal
, filter):
937 '''shows the content of a Network Slice Instance (NSI)
939 NAME: name or ID of the Network Slice Instance
941 nsi_show(ctx
, name
, literal
, filter)
944 def nsi_op_show(ctx
, id, filter):
946 check_client_version(ctx
.obj
, ctx
.command
.name
)
947 op_info
= ctx
.obj
.nsi
.get_op(id)
948 except ClientException
as inst
:
949 print((inst
.message
))
952 table
= PrettyTable(['field', 'value'])
953 for k
, v
in list(op_info
.items()):
954 if filter is None or filter in k
:
955 table
.add_row([k
, json
.dumps(v
, indent
=2)])
960 @cli.command(name
='nsi-op-show', short_help
='shows the info of an operation over a Network Slice Instance(NSI)')
961 @click.argument('id')
962 @click.option('--filter', default
=None)
964 def nsi_op_show1(ctx
, id, filter):
965 '''shows the info of an operation over a Network Slice Instance(NSI)
967 ID: operation identifier
969 nsi_op_show(ctx
, id, filter)
972 @cli.command(name
='netslice-instance-op-show', short_help
='shows the info of an operation over a Network Slice Instance(NSI)')
973 @click.argument('id')
974 @click.option('--filter', default
=None)
976 def nsi_op_show2(ctx
, id, filter):
977 '''shows the info of an operation over a Network Slice Instance(NSI)
979 ID: operation identifier
981 nsi_op_show(ctx
, id, filter)
984 @cli.command(name
='pdu-show', short_help
='shows the content of a Physical Deployment Unit (PDU)')
985 @click.argument('name')
986 @click.option('--literal', is_flag
=True,
987 help='print literally, no pretty table')
988 @click.option('--filter', default
=None)
990 def pdu_show(ctx
, name
, literal
, filter):
991 '''shows the content of a Physical Deployment Unit (PDU)
993 NAME: name or ID of the PDU
996 check_client_version(ctx
.obj
, ctx
.command
.name
)
997 pdu
= ctx
.obj
.pdu
.get(name
)
998 except ClientException
as inst
:
999 print((inst
.message
))
1003 print(yaml
.safe_dump(pdu
))
1006 table
= PrettyTable(['field', 'value'])
1008 for k
, v
in list(pdu
.items()):
1009 if filter is None or filter in k
:
1010 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1016 ####################
1018 ####################
1020 def nsd_create(ctx
, filename
, overwrite
):
1022 check_client_version(ctx
.obj
, ctx
.command
.name
)
1023 ctx
.obj
.nsd
.create(filename
, overwrite
)
1024 except ClientException
as inst
:
1025 print((inst
.message
))
1029 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
1030 @click.argument('filename')
1031 @click.option('--overwrite', default
=None,
1032 help='overwrites some fields in NSD')
1034 def nsd_create1(ctx
, filename
, overwrite
):
1035 '''creates a new NSD/NSpkg
1037 FILENAME: NSD yaml file or NSpkg tar.gz file
1039 nsd_create(ctx
, filename
, overwrite
)
1042 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
1043 @click.argument('filename')
1044 @click.option('--overwrite', default
=None,
1045 help='overwrites some fields in NSD')
1047 def nsd_create2(ctx
, filename
, overwrite
):
1048 '''creates a new NSD/NSpkg
1050 FILENAME: NSD yaml file or NSpkg tar.gz file
1052 nsd_create(ctx
, filename
, overwrite
)
1055 def vnfd_create(ctx
, filename
, overwrite
):
1057 check_client_version(ctx
.obj
, ctx
.command
.name
)
1058 ctx
.obj
.vnfd
.create(filename
, overwrite
)
1059 except ClientException
as inst
:
1060 print((inst
.message
))
1064 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
1065 @click.argument('filename')
1066 @click.option('--overwrite', default
=None,
1067 help='overwrites some fields in VNFD')
1069 def vnfd_create1(ctx
, filename
, overwrite
):
1070 '''creates a new VNFD/VNFpkg
1072 FILENAME: VNFD yaml file or VNFpkg tar.gz file
1074 vnfd_create(ctx
, filename
, overwrite
)
1077 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
1078 @click.argument('filename')
1079 @click.option('--overwrite', default
=None,
1080 help='overwrites some fields in VNFD')
1082 def vnfd_create2(ctx
, filename
, overwrite
):
1083 '''creates a new VNFD/VNFpkg
1085 FILENAME: VNFD yaml file or VNFpkg tar.gz file
1087 vnfd_create(ctx
, filename
, overwrite
)
1090 @cli.command(name
='nfpkg-create', short_help
='creates a new NFpkg')
1091 @click.argument('filename')
1092 @click.option('--overwrite', default
=None,
1093 help='overwrites some fields in NFD')
1095 def nfpkg_create(ctx
, filename
, overwrite
):
1096 '''creates a new NFpkg
1098 FILENAME: NF Descriptor yaml file or NFpkg tar.gz file
1100 vnfd_create(ctx
, filename
, overwrite
)
1103 @cli.command(name
='ns-create', short_help
='creates a new Network Service instance')
1104 @click.option('--ns_name',
1105 prompt
=True, help='name of the NS instance')
1106 @click.option('--nsd_name',
1107 prompt
=True, help='name of the NS descriptor')
1108 @click.option('--vim_account',
1109 prompt
=True, help='default VIM account id or name for the deployment')
1110 @click.option('--admin_status',
1112 help='administration status')
1113 @click.option('--ssh_keys',
1115 help='comma separated list of public key files to inject to vnfs')
1116 @click.option('--config',
1118 help='ns specific yaml configuration')
1119 @click.option('--config_file',
1121 help='ns specific yaml configuration file')
1131 '''creates a new NS instance'''
1134 check_client_version(ctx
.obj
, '--config_file')
1136 raise ClientException('"--config" option is incompatible with "--config_file" option')
1137 with
open(config_file
, 'r') as cf
:
1144 account
=vim_account
)
1145 except ClientException
as inst
:
1146 print((inst
.message
))
1150 def nst_create(ctx
, filename
, overwrite
):
1152 check_client_version(ctx
.obj
, ctx
.command
.name
)
1153 ctx
.obj
.nst
.create(filename
, overwrite
)
1154 except ClientException
as inst
:
1155 print((inst
.message
))
1159 @cli.command(name
='nst-create', short_help
='creates a new Network Slice Template (NST)')
1160 @click.argument('filename')
1161 @click.option('--overwrite', default
=None,
1162 help='overwrites some fields in NST')
1164 def nst_create1(ctx
, filename
, overwrite
):
1165 '''creates a new Network Slice Template (NST)
1167 FILENAME: NST yaml file or NSTpkg tar.gz file
1169 nst_create(ctx
, filename
, overwrite
)
1172 @cli.command(name
='netslice-template-create', short_help
='creates a new Network Slice Template (NST)')
1173 @click.argument('filename')
1174 @click.option('--overwrite', default
=None,
1175 help='overwrites some fields in NST')
1177 def nst_create2(ctx
, filename
, overwrite
):
1178 '''creates a new Network Slice Template (NST)
1180 FILENAME: NST yaml file or NSTpkg tar.gz file
1182 nst_create(ctx
, filename
, overwrite
)
1185 def nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1186 '''creates a new Network Slice Instance (NSI)'''
1188 check_client_version(ctx
.obj
, ctx
.command
.name
)
1191 raise ClientException('"--config" option is incompatible with "--config_file" option')
1192 with
open(config_file
, 'r') as cf
:
1194 ctx
.obj
.nsi
.create(nst_name
, nsi_name
, config
=config
, ssh_keys
=ssh_keys
,
1195 account
=vim_account
)
1196 except ClientException
as inst
:
1197 print((inst
.message
))
1201 @cli.command(name
='nsi-create', short_help
='creates a new Network Slice Instance')
1202 @click.option('--nsi_name', prompt
=True, help='name of the Network Slice Instance')
1203 @click.option('--nst_name', prompt
=True, help='name of the Network Slice Template')
1204 @click.option('--vim_account', prompt
=True, help='default VIM account id or name for the deployment')
1205 @click.option('--ssh_keys', default
=None,
1206 help='comma separated list of keys to inject to vnfs')
1207 @click.option('--config', default
=None,
1208 help='Netslice specific yaml configuration:\n'
1209 'netslice_subnet: [\n'
1210 'id: TEXT, vim_account: TEXT,\n'
1211 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
1212 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1214 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1216 @click.option('--config_file',
1218 help='nsi specific yaml configuration file')
1220 def nsi_create1(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1221 '''creates a new Network Slice Instance (NSI)'''
1222 nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
)
1225 @cli.command(name
='netslice-instance-create', short_help
='creates a new Network Slice Instance')
1226 @click.option('--nsi_name', prompt
=True, help='name of the Network Slice Instance')
1227 @click.option('--nst_name', prompt
=True, help='name of the Network Slice Template')
1228 @click.option('--vim_account', prompt
=True, help='default VIM account id or name for the deployment')
1229 @click.option('--ssh_keys', default
=None,
1230 help='comma separated list of keys to inject to vnfs')
1231 @click.option('--config', default
=None,
1232 help='Netslice specific yaml configuration:\n'
1233 'netslice_subnet: [\n'
1234 'id: TEXT, vim_account: TEXT,\n'
1235 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
1236 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1238 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
1240 @click.option('--config_file',
1242 help='nsi specific yaml configuration file')
1244 def nsi_create2(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
):
1245 '''creates a new Network Slice Instance (NSI)'''
1246 nsi_create(ctx
, nst_name
, nsi_name
, vim_account
, ssh_keys
, config
, config_file
)
1249 @cli.command(name
='pdu-create', short_help
='adds a new Physical Deployment Unit to the catalog')
1250 @click.option('--name', help='name of the Physical Deployment Unit')
1251 @click.option('--pdu_type', help='type of PDU (e.g. router, firewall, FW001)')
1252 @click.option('--interface',
1253 help='interface(s) of the PDU: name=<NAME>,mgmt=<true|false>,ip-address=<IP_ADDRESS>'+
1254 '[,type=<overlay|underlay>][,mac-address=<MAC_ADDRESS>][,vim-network-name=<VIM_NET_NAME>]',
1256 @click.option('--description', help='human readable description')
1257 @click.option('--vim_account', help='list of VIM accounts (in the same VIM) that can reach this PDU', multiple
=True)
1258 @click.option('--descriptor_file', default
=None, help='PDU descriptor file (as an alternative to using the other arguments')
1260 def pdu_create(ctx
, name
, pdu_type
, interface
, description
, vim_account
, descriptor_file
):
1261 '''creates a new Physical Deployment Unit (PDU)'''
1263 check_client_version(ctx
.obj
, ctx
.command
.name
)
1265 if not descriptor_file
:
1267 raise ClientException('in absence of descriptor file, option "--name" is mandatory')
1269 raise ClientException('in absence of descriptor file, option "--pdu_type" is mandatory')
1271 raise ClientException('in absence of descriptor file, option "--interface" is mandatory (at least once)')
1273 raise ClientException('in absence of descriptor file, option "--vim_account" is mandatory (at least once)')
1275 with
open(descriptor_file
, 'r') as df
:
1276 pdu
= yaml
.load(df
.read())
1277 if name
: pdu
["name"] = name
1278 if pdu_type
: pdu
["type"] = pdu_type
1279 if description
: pdu
["description"] = description
1280 if vim_account
: pdu
["vim_accounts"] = vim_account
1283 for iface
in interface
:
1284 new_iface
={k
:v
for k
,v
in [i
.split('=') for i
in iface
.split(',')]}
1285 new_iface
["mgmt"] = (new_iface
.get("mgmt","false").lower() == "true")
1286 ifaces_list
.append(new_iface
)
1287 pdu
["interfaces"] = ifaces_list
1288 ctx
.obj
.pdu
.create(pdu
)
1289 except ClientException
as inst
:
1290 print((inst
.message
))
1294 ####################
1296 ####################
1298 def nsd_update(ctx
, name
, content
):
1300 check_client_version(ctx
.obj
, ctx
.command
.name
)
1301 ctx
.obj
.nsd
.update(name
, content
)
1302 except ClientException
as inst
:
1303 print((inst
.message
))
1307 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
1308 @click.argument('name')
1309 @click.option('--content', default
=None,
1310 help='filename with the NSD/NSpkg replacing the current one')
1312 def nsd_update1(ctx
, name
, content
):
1313 '''updates a NSD/NSpkg
1315 NAME: name or ID of the NSD/NSpkg
1317 nsd_update(ctx
, name
, content
)
1320 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
1321 @click.argument('name')
1322 @click.option('--content', default
=None,
1323 help='filename with the NSD/NSpkg replacing the current one')
1325 def nsd_update2(ctx
, name
, content
):
1326 '''updates a NSD/NSpkg
1328 NAME: name or ID of the NSD/NSpkg
1330 nsd_update(ctx
, name
, content
)
1333 def vnfd_update(ctx
, name
, content
):
1335 check_client_version(ctx
.obj
, ctx
.command
.name
)
1336 ctx
.obj
.vnfd
.update(name
, content
)
1337 except ClientException
as inst
:
1338 print((inst
.message
))
1342 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
1343 @click.argument('name')
1344 @click.option('--content', default
=None,
1345 help='filename with the VNFD/VNFpkg replacing the current one')
1347 def vnfd_update1(ctx
, name
, content
):
1348 '''updates a VNFD/VNFpkg
1350 NAME: name or ID of the VNFD/VNFpkg
1352 vnfd_update(ctx
, name
, content
)
1355 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
1356 @click.argument('name')
1357 @click.option('--content', default
=None,
1358 help='filename with the VNFD/VNFpkg replacing the current one')
1360 def vnfd_update2(ctx
, name
, content
):
1361 '''updates a VNFD/VNFpkg
1363 NAME: VNFD yaml file or VNFpkg tar.gz file
1365 vnfd_update(ctx
, name
, content
)
1368 @cli.command(name
='nfpkg-update', short_help
='updates a NFpkg')
1369 @click.argument('name')
1370 @click.option('--content', default
=None,
1371 help='filename with the NFpkg replacing the current one')
1373 def nfpkg_update(ctx
, name
, content
):
1376 NAME: NF Descriptor yaml file or NFpkg tar.gz file
1378 vnfd_update(ctx
, name
, content
)
1381 def nst_update(ctx
, name
, content
):
1383 check_client_version(ctx
.obj
, ctx
.command
.name
)
1384 ctx
.obj
.nst
.update(name
, content
)
1385 except ClientException
as inst
:
1386 print((inst
.message
))
1390 @cli.command(name
='nst-update', short_help
='updates a Network Slice Template (NST)')
1391 @click.argument('name')
1392 @click.option('--content', default
=None,
1393 help='filename with the NST/NSTpkg replacing the current one')
1395 def nst_update1(ctx
, name
, content
):
1396 '''updates a Network Slice Template (NST)
1398 NAME: name or ID of the NSD/NSpkg
1400 nst_update(ctx
, name
, content
)
1403 @cli.command(name
='netslice-template-update', short_help
='updates a Network Slice Template (NST)')
1404 @click.argument('name')
1405 @click.option('--content', default
=None,
1406 help='filename with the NST/NSTpkg replacing the current one')
1408 def nst_update2(ctx
, name
, content
):
1409 '''updates a Network Slice Template (NST)
1411 NAME: name or ID of the NSD/NSpkg
1413 nst_update(ctx
, name
, content
)
1416 ####################
1418 ####################
1420 def nsd_delete(ctx
, name
, force
):
1423 ctx
.obj
.nsd
.delete(name
)
1425 check_client_version(ctx
.obj
, '--force')
1426 ctx
.obj
.nsd
.delete(name
, force
)
1427 except ClientException
as inst
:
1428 print((inst
.message
))
1432 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
1433 @click.argument('name')
1434 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1436 def nsd_delete1(ctx
, name
, force
):
1437 '''deletes a NSD/NSpkg
1439 NAME: name or ID of the NSD/NSpkg to be deleted
1441 nsd_delete(ctx
, name
, force
)
1444 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
1445 @click.argument('name')
1446 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1448 def nsd_delete2(ctx
, name
, force
):
1449 '''deletes a NSD/NSpkg
1451 NAME: name or ID of the NSD/NSpkg to be deleted
1453 nsd_delete(ctx
, name
, force
)
1456 def vnfd_delete(ctx
, name
, force
):
1459 ctx
.obj
.vnfd
.delete(name
)
1461 check_client_version(ctx
.obj
, '--force')
1462 ctx
.obj
.vnfd
.delete(name
, force
)
1463 except ClientException
as inst
:
1464 print((inst
.message
))
1468 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
1469 @click.argument('name')
1470 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1472 def vnfd_delete1(ctx
, name
, force
):
1473 '''deletes a VNFD/VNFpkg
1475 NAME: name or ID of the VNFD/VNFpkg to be deleted
1477 vnfd_delete(ctx
, name
, force
)
1480 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
1481 @click.argument('name')
1482 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1484 def vnfd_delete2(ctx
, name
, force
):
1485 '''deletes a VNFD/VNFpkg
1487 NAME: name or ID of the VNFD/VNFpkg to be deleted
1489 vnfd_delete(ctx
, name
, force
)
1492 @cli.command(name
='nfpkg-delete', short_help
='deletes a NFpkg')
1493 @click.argument('name')
1494 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1496 def nfpkg_delete(ctx
, name
, force
):
1499 NAME: name or ID of the NFpkg to be deleted
1501 vnfd_delete(ctx
, name
, force
)
1504 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
1505 @click.argument('name')
1506 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1508 def ns_delete(ctx
, name
, force
):
1509 '''deletes a NS instance
1511 NAME: name or ID of the NS instance to be deleted
1515 ctx
.obj
.ns
.delete(name
)
1517 check_client_version(ctx
.obj
, '--force')
1518 ctx
.obj
.ns
.delete(name
, force
)
1519 except ClientException
as inst
:
1520 print((inst
.message
))
1524 def nst_delete(ctx
, name
, force
):
1526 check_client_version(ctx
.obj
, ctx
.command
.name
)
1527 ctx
.obj
.nst
.delete(name
, force
)
1528 except ClientException
as inst
:
1529 print((inst
.message
))
1533 @cli.command(name
='nst-delete', short_help
='deletes a Network Slice Template (NST)')
1534 @click.argument('name')
1535 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1537 def nst_delete1(ctx
, name
, force
):
1538 '''deletes a Network Slice Template (NST)
1540 NAME: name or ID of the NST/NSTpkg to be deleted
1542 nst_delete(ctx
, name
, force
)
1545 @cli.command(name
='netslice-template-delete', short_help
='deletes a Network Slice Template (NST)')
1546 @click.argument('name')
1547 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1549 def nst_delete2(ctx
, name
, force
):
1550 '''deletes a Network Slice Template (NST)
1552 NAME: name or ID of the NST/NSTpkg to be deleted
1554 nst_delete(ctx
, name
, force
)
1557 def nsi_delete(ctx
, name
, force
):
1559 check_client_version(ctx
.obj
, ctx
.command
.name
)
1560 ctx
.obj
.nsi
.delete(name
, force
)
1561 except ClientException
as inst
:
1562 print((inst
.message
))
1566 @cli.command(name
='nsi-delete', short_help
='deletes a Network Slice Instance (NSI)')
1567 @click.argument('name')
1568 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1570 def nsi_delete1(ctx
, name
, force
):
1571 '''deletes a Network Slice Instance (NSI)
1573 NAME: name or ID of the Network Slice instance to be deleted
1575 nsi_delete(ctx
, name
, force
)
1578 @cli.command(name
='netslice-instance-delete', short_help
='deletes a Network Slice Instance (NSI)')
1579 @click.argument('name')
1580 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1582 def nsi_delete2(ctx
, name
, force
):
1583 '''deletes a Network Slice Instance (NSI)
1585 NAME: name or ID of the Network Slice instance to be deleted
1587 nsi_delete(ctx
, name
, force
)
1590 @cli.command(name
='pdu-delete', short_help
='deletes a Physical Deployment Unit (PDU)')
1591 @click.argument('name')
1592 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1594 def pdu_delete(ctx
, name
, force
):
1595 '''deletes a Physical Deployment Unit (PDU)
1597 NAME: name or ID of the PDU to be deleted
1600 check_client_version(ctx
.obj
, ctx
.command
.name
)
1601 ctx
.obj
.pdu
.delete(name
, force
)
1602 except ClientException
as inst
:
1603 print((inst
.message
))
1607 ####################
1609 ####################
1611 @cli.command(name
='vim-create')
1612 @click.option('--name',
1614 help='Name to create datacenter')
1615 @click.option('--user',
1617 help='VIM username')
1618 @click.option('--password',
1621 confirmation_prompt
=True,
1622 help='VIM password')
1623 @click.option('--auth_url',
1626 @click.option('--tenant',
1628 help='VIM tenant name')
1629 @click.option('--config',
1631 help='VIM specific config parameters')
1632 @click.option('--account_type',
1633 default
='openstack',
1635 @click.option('--description',
1636 default
='no description',
1637 help='human readable description')
1638 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
1639 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
1652 '''creates a new VIM account
1656 check_client_version(ctx
.obj
, '--sdn_controller')
1657 if sdn_port_mapping
:
1658 check_client_version(ctx
.obj
, '--sdn_port_mapping')
1660 vim
['vim-username'] = user
1661 vim
['vim-password'] = password
1662 vim
['vim-url'] = auth_url
1663 vim
['vim-tenant-name'] = tenant
1664 vim
['vim-type'] = account_type
1665 vim
['description'] = description
1666 vim
['config'] = config
1667 if sdn_controller
or sdn_port_mapping
:
1668 ctx
.obj
.vim
.create(name
, vim
, sdn_controller
, sdn_port_mapping
)
1670 ctx
.obj
.vim
.create(name
, vim
)
1671 except ClientException
as inst
:
1672 print((inst
.message
))
1676 @cli.command(name
='vim-update', short_help
='updates a VIM account')
1677 @click.argument('name')
1678 @click.option('--newname', help='New name for the VIM account')
1679 @click.option('--user', help='VIM username')
1680 @click.option('--password', help='VIM password')
1681 @click.option('--auth_url', help='VIM url')
1682 @click.option('--tenant', help='VIM tenant name')
1683 @click.option('--config', help='VIM specific config parameters')
1684 @click.option('--account_type', help='VIM type')
1685 @click.option('--description', help='human readable description')
1686 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
1687 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
1701 '''updates a VIM account
1703 NAME: name or ID of the VIM account
1706 check_client_version(ctx
.obj
, ctx
.command
.name
)
1708 if newname
: vim
['name'] = newname
1709 if user
: vim
['vim_user'] = user
1710 if password
: vim
['vim_password'] = password
1711 if auth_url
: vim
['vim_url'] = auth_url
1712 if tenant
: vim
['vim-tenant-name'] = tenant
1713 if account_type
: vim
['vim_type'] = account_type
1714 if description
: vim
['description'] = description
1715 if config
: vim
['config'] = config
1716 ctx
.obj
.vim
.update(name
, vim
, sdn_controller
, sdn_port_mapping
)
1717 except ClientException
as inst
:
1718 print((inst
.message
))
1722 @cli.command(name
='vim-delete')
1723 @click.argument('name')
1724 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1726 def vim_delete(ctx
, name
, force
):
1727 '''deletes a VIM account
1729 NAME: name or ID of the VIM account to be deleted
1733 ctx
.obj
.vim
.delete(name
)
1735 check_client_version(ctx
.obj
, '--force')
1736 ctx
.obj
.vim
.delete(name
, force
)
1737 except ClientException
as inst
:
1738 print((inst
.message
))
1742 @cli.command(name
='vim-list')
1743 @click.option('--ro_update/--no_ro_update',
1745 help='update list from RO')
1746 @click.option('--filter', default
=None,
1747 help='restricts the list to the VIM accounts matching the filter')
1749 def vim_list(ctx
, ro_update
, filter):
1750 '''list all VIM accounts'''
1752 check_client_version(ctx
.obj
, '--filter')
1754 check_client_version(ctx
.obj
, '--ro_update', 'v1')
1755 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
1756 if fullclassname
== 'osmclient.sol005.client.Client':
1757 resp
= ctx
.obj
.vim
.list(filter)
1759 resp
= ctx
.obj
.vim
.list(ro_update
)
1760 table
= PrettyTable(['vim name', 'uuid'])
1762 table
.add_row([vim
['name'], vim
['uuid']])
1767 @cli.command(name
='vim-show')
1768 @click.argument('name')
1770 def vim_show(ctx
, name
):
1771 '''shows the details of a VIM account
1773 NAME: name or ID of the VIM account
1776 resp
= ctx
.obj
.vim
.get(name
)
1777 if 'vim_password' in resp
:
1778 resp
['vim_password']='********'
1779 except ClientException
as inst
:
1780 print((inst
.message
))
1783 table
= PrettyTable(['key', 'attribute'])
1784 for k
, v
in list(resp
.items()):
1785 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1790 ####################
1791 # SDN controller operations
1792 ####################
1794 @cli.command(name
='sdnc-create')
1795 @click.option('--name',
1797 help='Name to create sdn controller')
1798 @click.option('--type',
1800 help='SDN controller type')
1801 @click.option('--sdn_controller_version',
1802 help='SDN controller username')
1803 @click.option('--ip_address',
1805 help='SDN controller IP address')
1806 @click.option('--port',
1808 help='SDN controller port')
1809 @click.option('--switch_dpid',
1811 help='Switch DPID (Openflow Datapath ID)')
1812 @click.option('--user',
1813 help='SDN controller username')
1814 @click.option('--password',
1816 confirmation_prompt
=True,
1817 help='SDN controller password')
1818 #@click.option('--description',
1819 # default='no description',
1820 # help='human readable description')
1822 def sdnc_create(ctx
,
1825 sdn_controller_version
,
1831 '''creates a new SDN controller
1834 sdncontroller
['name'] = name
1835 sdncontroller
['type'] = type
1836 sdncontroller
['ip'] = ip_address
1837 sdncontroller
['port'] = int(port
)
1838 sdncontroller
['dpid'] = switch_dpid
1839 if sdn_controller_version
:
1840 sdncontroller
['version'] = sdn_controller_version
1842 sdncontroller
['user'] = user
1844 sdncontroller
['password'] = password
1845 # sdncontroller['description'] = description
1847 check_client_version(ctx
.obj
, ctx
.command
.name
)
1848 ctx
.obj
.sdnc
.create(name
, sdncontroller
)
1849 except ClientException
as inst
:
1850 print((inst
.message
))
1853 @cli.command(name
='sdnc-update', short_help
='updates an SDN controller')
1854 @click.argument('name')
1855 @click.option('--newname', help='New name for the SDN controller')
1856 @click.option('--type', help='SDN controller type')
1857 @click.option('--sdn_controller_version', help='SDN controller username')
1858 @click.option('--ip_address', help='SDN controller IP address')
1859 @click.option('--port', help='SDN controller port')
1860 @click.option('--switch_dpid', help='Switch DPID (Openflow Datapath ID)')
1861 @click.option('--user', help='SDN controller username')
1862 @click.option('--password', help='SDN controller password')
1863 #@click.option('--description', default=None, help='human readable description')
1865 def sdnc_update(ctx
,
1869 sdn_controller_version
,
1875 '''updates an SDN controller
1877 NAME: name or ID of the SDN controller
1880 if newname
: sdncontroller
['name'] = newname
1881 if type: sdncontroller
['type'] = type
1882 if ip_address
: sdncontroller
['ip'] = ip_address
1883 if port
: sdncontroller
['port'] = int(port
)
1884 if switch_dpid
: sdncontroller
['dpid'] = switch_dpid
1885 # sdncontroller['description'] = description
1886 if sdn_controller_version
is not None:
1887 if sdn_controller_version
=="":
1888 sdncontroller
['version'] = None
1890 sdncontroller
['version'] = sdn_controller_version
1891 if user
is not None:
1893 sdncontroller
['user'] = None
1895 sdncontroller
['user'] = user
1896 if password
is not None:
1898 sdncontroller
['password'] = None
1900 sdncontroller
['password'] = user
1902 check_client_version(ctx
.obj
, ctx
.command
.name
)
1903 ctx
.obj
.sdnc
.update(name
, sdncontroller
)
1904 except ClientException
as inst
:
1905 print((inst
.message
))
1909 @cli.command(name
='sdnc-delete')
1910 @click.argument('name')
1911 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1913 def sdnc_delete(ctx
, name
, force
):
1914 '''deletes an SDN controller
1916 NAME: name or ID of the SDN controller to be deleted
1919 check_client_version(ctx
.obj
, ctx
.command
.name
)
1920 ctx
.obj
.sdnc
.delete(name
, force
)
1921 except ClientException
as inst
:
1922 print((inst
.message
))
1926 @cli.command(name
='sdnc-list')
1927 @click.option('--filter', default
=None,
1928 help='restricts the list to the SDN controllers matching the filter')
1930 def sdnc_list(ctx
, filter):
1931 '''list all SDN controllers'''
1933 check_client_version(ctx
.obj
, ctx
.command
.name
)
1934 resp
= ctx
.obj
.sdnc
.list(filter)
1935 except ClientException
as inst
:
1936 print((inst
.message
))
1938 table
= PrettyTable(['name', 'id'])
1940 table
.add_row([sdnc
['name'], sdnc
['_id']])
1945 @cli.command(name
='sdnc-show')
1946 @click.argument('name')
1948 def sdnc_show(ctx
, name
):
1949 '''shows the details of an SDN controller
1951 NAME: name or ID of the SDN controller
1954 check_client_version(ctx
.obj
, ctx
.command
.name
)
1955 resp
= ctx
.obj
.sdnc
.get(name
)
1956 except ClientException
as inst
:
1957 print((inst
.message
))
1960 table
= PrettyTable(['key', 'attribute'])
1961 for k
, v
in list(resp
.items()):
1962 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1967 ####################
1968 # Project mgmt operations
1969 ####################
1971 @cli.command(name
='project-create')
1972 @click.argument('name')
1973 #@click.option('--description',
1974 # default='no description',
1975 # help='human readable description')
1977 def project_create(ctx
, name
):
1978 '''Creates a new project
1980 NAME: name of the project
1983 project
['name'] = name
1985 check_client_version(ctx
.obj
, ctx
.command
.name
)
1986 ctx
.obj
.project
.create(name
, project
)
1987 except ClientException
as inst
:
1991 @cli.command(name
='project-delete')
1992 @click.argument('name')
1993 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
1995 def project_delete(ctx
, name
):
1996 '''deletes a project
1998 NAME: name or ID of the project to be deleted
2001 check_client_version(ctx
.obj
, ctx
.command
.name
)
2002 ctx
.obj
.project
.delete(name
)
2003 except ClientException
as inst
:
2008 @cli.command(name
='project-list')
2009 @click.option('--filter', default
=None,
2010 help='restricts the list to the projects matching the filter')
2012 def project_list(ctx
, filter):
2013 '''list all projects'''
2015 check_client_version(ctx
.obj
, ctx
.command
.name
)
2016 resp
= ctx
.obj
.project
.list(filter)
2017 except ClientException
as inst
:
2020 table
= PrettyTable(['name', 'id'])
2022 table
.add_row([proj
['name'], proj
['_id']])
2027 @cli.command(name
='project-show')
2028 @click.argument('name')
2030 def project_show(ctx
, name
):
2031 '''shows the details of a project
2033 NAME: name or ID of the project
2036 check_client_version(ctx
.obj
, ctx
.command
.name
)
2037 resp
= ctx
.obj
.project
.get(name
)
2038 except ClientException
as inst
:
2042 table
= PrettyTable(['key', 'attribute'])
2043 for k
, v
in resp
.items():
2044 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2049 ####################
2050 # User mgmt operations
2051 ####################
2053 @cli.command(name
='user-create')
2054 @click.argument('username')
2055 @click.option('--password',
2058 confirmation_prompt
=True,
2059 help='user password')
2060 @click.option('--projects',
2062 help='list of project ids that the user belongs to')
2063 #@click.option('--description',
2064 # default='no description',
2065 # help='human readable description')
2067 def user_create(ctx
, username
, password
, projects
):
2068 '''Creates a new user
2070 USERNAME: name of the user
2073 user
['username'] = username
2074 user
['password'] = password
2075 user
['projects'] = projects
2077 check_client_version(ctx
.obj
, ctx
.command
.name
)
2078 ctx
.obj
.user
.create(username
, user
)
2079 except ClientException
as inst
:
2083 @cli.command(name
='user-delete')
2084 @click.argument('name')
2085 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
2087 def user_delete(ctx
, name
):
2090 NAME: name or ID of the user to be deleted
2093 check_client_version(ctx
.obj
, ctx
.command
.name
)
2094 ctx
.obj
.user
.delete(name
)
2095 except ClientException
as inst
:
2100 @cli.command(name
='user-list')
2101 @click.option('--filter', default
=None,
2102 help='restricts the list to the users matching the filter')
2104 def user_list(ctx
, filter):
2105 '''list all users'''
2107 check_client_version(ctx
.obj
, ctx
.command
.name
)
2108 resp
= ctx
.obj
.user
.list(filter)
2109 except ClientException
as inst
:
2112 table
= PrettyTable(['name', 'id'])
2114 table
.add_row([user
['name'], user
['_id']])
2119 @cli.command(name
='user-show')
2120 @click.argument('name')
2122 def user_show(ctx
, name
):
2123 '''shows the details of a user
2125 NAME: name or ID of the user
2128 check_client_version(ctx
.obj
, ctx
.command
.name
)
2129 resp
= ctx
.obj
.user
.get(name
)
2130 if 'password' in resp
:
2131 resp
['password']='********'
2132 except ClientException
as inst
:
2136 table
= PrettyTable(['key', 'attribute'])
2137 for k
, v
in resp
.items():
2138 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2143 ####################
2144 # Fault Management operations
2145 ####################
2147 @cli.command(name
='ns-alarm-create')
2148 @click.argument('name')
2149 @click.option('--ns', prompt
=True, help='NS instance id or name')
2150 @click.option('--vnf', prompt
=True,
2151 help='VNF name (VNF member index as declared in the NSD)')
2152 @click.option('--vdu', prompt
=True,
2153 help='VDU name (VDU name as declared in the VNFD)')
2154 @click.option('--metric', prompt
=True,
2155 help='Name of the metric (e.g. cpu_utilization)')
2156 @click.option('--severity', default
='WARNING',
2157 help='severity of the alarm (WARNING, MINOR, MAJOR, CRITICAL, INDETERMINATE)')
2158 @click.option('--threshold_value', prompt
=True,
2159 help='threshold value that, when crossed, an alarm is triggered')
2160 @click.option('--threshold_operator', prompt
=True,
2161 help='threshold operator describing the comparison (GE, LE, GT, LT, EQ)')
2162 @click.option('--statistic', default
='AVERAGE',
2163 help='statistic (AVERAGE, MINIMUM, MAXIMUM, COUNT, SUM)')
2165 def ns_alarm_create(ctx
, name
, ns
, vnf
, vdu
, metric
, severity
,
2166 threshold_value
, threshold_operator
, statistic
):
2167 '''creates a new alarm for a NS instance'''
2168 ns_instance
= ctx
.obj
.ns
.get(ns
)
2170 alarm
['alarm_name'] = name
2171 alarm
['ns_id'] = ns_instance
['_id']
2172 alarm
['correlation_id'] = ns_instance
['_id']
2173 alarm
['vnf_member_index'] = vnf
2174 alarm
['vdu_name'] = vdu
2175 alarm
['metric_name'] = metric
2176 alarm
['severity'] = severity
2177 alarm
['threshold_value'] = int(threshold_value
)
2178 alarm
['operation'] = threshold_operator
2179 alarm
['statistic'] = statistic
2181 check_client_version(ctx
.obj
, ctx
.command
.name
)
2182 ctx
.obj
.ns
.create_alarm(alarm
)
2183 except ClientException
as inst
:
2184 print((inst
.message
))
2188 #@cli.command(name='ns-alarm-delete')
2189 #@click.argument('name')
2190 #@click.pass_context
2191 #def ns_alarm_delete(ctx, name):
2192 # '''deletes an alarm
2194 # NAME: name of the alarm to be deleted
2197 # check_client_version(ctx.obj, ctx.command.name)
2198 # ctx.obj.ns.delete_alarm(name)
2199 # except ClientException as inst:
2200 # print(inst.message)
2204 ####################
2205 # Performance Management operations
2206 ####################
2208 @cli.command(name
='ns-metric-export')
2209 @click.option('--ns', prompt
=True, help='NS instance id or name')
2210 @click.option('--vnf', prompt
=True,
2211 help='VNF name (VNF member index as declared in the NSD)')
2212 @click.option('--vdu', prompt
=True,
2213 help='VDU name (VDU name as declared in the VNFD)')
2214 @click.option('--metric', prompt
=True,
2215 help='name of the metric (e.g. cpu_utilization)')
2216 #@click.option('--period', default='1w',
2217 # help='metric collection period (e.g. 20s, 30m, 2h, 3d, 1w)')
2218 @click.option('--interval', help='periodic interval (seconds) to export metrics continuously')
2220 def ns_metric_export(ctx
, ns
, vnf
, vdu
, metric
, interval
):
2221 '''exports a metric to the internal OSM bus, which can be read by other apps
2223 ns_instance
= ctx
.obj
.ns
.get(ns
)
2225 metric_data
['ns_id'] = ns_instance
['_id']
2226 metric_data
['correlation_id'] = ns_instance
['_id']
2227 metric_data
['vnf_member_index'] = vnf
2228 metric_data
['vdu_name'] = vdu
2229 metric_data
['metric_name'] = metric
2230 metric_data
['collection_unit'] = 'WEEK'
2231 metric_data
['collection_period'] = 1
2233 check_client_version(ctx
.obj
, ctx
.command
.name
)
2235 print('{}'.format(ctx
.obj
.ns
.export_metric(metric_data
)))
2239 print('{} {}'.format(ctx
.obj
.ns
.export_metric(metric_data
),i
))
2240 time
.sleep(int(interval
))
2242 except ClientException
as inst
:
2243 print((inst
.message
))
2247 ####################
2249 ####################
2251 @cli.command(name
='upload-package')
2252 @click.argument('filename')
2254 def upload_package(ctx
, filename
):
2255 '''uploads a VNF package or NS package
2257 FILENAME: VNF or NS package file (tar.gz)
2260 ctx
.obj
.package
.upload(filename
)
2261 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
2262 if fullclassname
!= 'osmclient.sol005.client.Client':
2263 ctx
.obj
.package
.wait_for_upload(filename
)
2264 except ClientException
as inst
:
2265 print((inst
.message
))
2269 @cli.command(name
='ns-scaling-show')
2270 @click.argument('ns_name')
2272 def show_ns_scaling(ctx
, ns_name
):
2273 '''shows the status of a NS scaling operation
2275 NS_NAME: name of the NS instance being scaled
2278 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2279 resp
= ctx
.obj
.ns
.list()
2280 except ClientException
as inst
:
2281 print((inst
.message
))
2284 table
= PrettyTable(
2287 'operational status',
2292 if ns_name
== ns
['name']:
2293 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
2294 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
2295 for record
in scaling_records
:
2296 if 'instance' in record
:
2297 instances
= record
['instance']
2298 for inst
in instances
:
2300 [record
['scaling-group-name-ref'],
2301 inst
['instance-id'],
2303 time
.strftime('%Y-%m-%d %H:%M:%S',
2305 inst
['create-time'])),
2311 @cli.command(name
='ns-scale')
2312 @click.argument('ns_name')
2313 @click.option('--ns_scale_group', prompt
=True)
2314 @click.option('--index', prompt
=True)
2316 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
2319 NS_NAME: name of the NS instance to be scaled
2322 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2323 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
2324 except ClientException
as inst
:
2325 print((inst
.message
))
2329 @cli.command(name
='config-agent-list')
2331 def config_agent_list(ctx
):
2332 '''list config agents'''
2334 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2335 except ClientException
as inst
:
2336 print((inst
.message
))
2338 table
= PrettyTable(['name', 'account-type', 'details'])
2339 for account
in ctx
.obj
.vca
.list():
2342 account
['account-type'],
2348 @cli.command(name
='config-agent-delete')
2349 @click.argument('name')
2351 def config_agent_delete(ctx
, name
):
2352 '''deletes a config agent
2354 NAME: name of the config agent to be deleted
2357 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2358 ctx
.obj
.vca
.delete(name
)
2359 except ClientException
as inst
:
2360 print((inst
.message
))
2364 @cli.command(name
='config-agent-add')
2365 @click.option('--name',
2367 @click.option('--account_type',
2369 @click.option('--server',
2371 @click.option('--user',
2373 @click.option('--secret',
2376 confirmation_prompt
=True)
2378 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
2379 '''adds a config agent'''
2381 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2382 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
2383 except ClientException
as inst
:
2384 print((inst
.message
))
2387 @cli.command(name
='ro-dump')
2390 '''shows RO agent information'''
2391 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2392 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
2393 table
= PrettyTable(['key', 'attribute'])
2394 for k
, v
in list(resp
.items()):
2395 table
.add_row([k
, json
.dumps(v
, indent
=2)])
2400 @cli.command(name
='vcs-list')
2403 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
2404 resp
= ctx
.obj
.utils
.get_vcs_info()
2405 table
= PrettyTable(['component name', 'state'])
2406 for component
in resp
:
2407 table
.add_row([component
['component_name'], component
['state']])
2412 @cli.command(name
='ns-action')
2413 @click.argument('ns_name')
2414 @click.option('--vnf_name', default
=None)
2415 @click.option('--action_name', prompt
=True)
2416 @click.option('--params', prompt
=True)
2423 '''executes an action/primitive over a NS instance
2425 NS_NAME: name or ID of the NS instance
2428 check_client_version(ctx
.obj
, ctx
.command
.name
)
2431 op_data
['vnf_member_index'] = vnf_name
2432 op_data
['primitive'] = action_name
2433 op_data
['primitive_params'] = yaml
.load(params
)
2434 ctx
.obj
.ns
.exec_op(ns_name
, op_name
='action', op_data
=op_data
)
2436 except ClientException
as inst
:
2437 print((inst
.message
))
2441 @cli.command(name
='vnf-scale')
2442 @click.argument('ns_name')
2443 @click.argument('vnf_name')
2444 @click.option('--scaling-group', prompt
=True, help="scaling-group-descriptor name to use")
2445 @click.option('--scale-in', default
=False, is_flag
=True, help="performs a scale in operation")
2446 @click.option('--scale-out', default
=False, is_flag
=True, help="performs a scale out operation (by default)")
2454 '''executes a VNF scale (adding/removing VDUs)
2457 NS_NAME: name or ID of the NS instance.
2458 VNF_NAME: member-vnf-index in the NS to be scaled.
2461 check_client_version(ctx
.obj
, ctx
.command
.name
)
2462 if not scale_in
and not scale_out
:
2464 ctx
.obj
.ns
.scale_vnf(ns_name
, vnf_name
, scaling_group
, scale_in
, scale_out
)
2465 except ClientException
as inst
:
2466 print((inst
.message
))
2470 if __name__
== '__main__':
2473 except pycurl
.error
as e
:
2475 print('Maybe "--hostname" option or OSM_HOSTNAME' +
2476 'environment variable needs to be specified')