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
='vnf-list')
289 @click.option('--ns', default
=None, help='NS instance id or name to restrict the VNF list')
290 @click.option('--filter', default
=None,
291 help='restricts the list to the VNF instances matching the filter.')
293 def vnf_list(ctx
, ns
, filter):
294 '''list all VNF instances
298 --ns TEXT NS instance id or name to restrict the VNF list
299 --filter filterExpr Restricts the list to the VNF instances matching the filter
302 filterExpr consists of one or more strings formatted according to "simpleFilterExpr",
303 concatenated using the "&" character:
306 filterExpr := <simpleFilterExpr>["&"<simpleFilterExpr>]*
307 simpleFilterExpr := <attrName>["."<attrName>]*["."<op>]"="<value>[","<value>]*
308 op := "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "cont" | "ncont"
310 value := scalar value
314 * zero or more occurrences
315 ? zero or one occurrence
316 [] grouping of expressions to be used with ? and *
317 "" quotation marks for marking string constants
321 "AttrName" is the name of one attribute in the data type that defines the representation
322 of the resource. The dot (".") character in "simpleFilterExpr" allows concatenation of
323 <attrName> entries to filter by attributes deeper in the hierarchy of a structured document.
324 "Op" stands for the comparison operator. If the expression has concatenated <attrName>
325 entries, it means that the operator "op" is applied to the attribute addressed by the last
326 <attrName> entry included in the concatenation. All simple filter expressions are combined
327 by the "AND" logical operator. In a concatenation of <attrName> entries in a <simpleFilterExpr>,
328 the rightmost "attrName" entry in a "simpleFilterExpr" is called "leaf attribute". The
329 concatenation of all "attrName" entries except the leaf attribute is called the "attribute
330 prefix". If an attribute referenced in an expression is an array, an object that contains a
331 corresponding array shall be considered to match the expression if any of the elements in the
332 array matches all expressions that have the same attribute prefix.
336 --filter vim-account-id=<VIM_ACCOUNT_ID>
337 --filter vnfd-ref=<VNFD_NAME>
338 --filter vdur.ip-address=<IP_ADDRESS>
339 --filter vnfd-ref=<VNFD_NAME>,vdur.ip-address=<IP_ADDRESS>
344 check_client_version(ctx
.obj
, '--ns')
346 check_client_version(ctx
.obj
, '--filter')
347 resp
= ctx
.obj
.vnf
.list(ns
, filter)
349 resp
= ctx
.obj
.vnf
.list()
350 except ClientException
as inst
:
351 print((inst
.message
))
353 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
354 if fullclassname
== 'osmclient.sol005.client.Client':
364 name
= vnfr
['name'] if 'name' in vnfr
else '-'
369 vnfr
['member-vnf-index-ref'],
371 vnfr
['vim-account-id'],
377 'operational status',
380 if 'mgmt-interface' not in vnfr
:
381 vnfr
['mgmt-interface'] = {}
382 vnfr
['mgmt-interface']['ip-address'] = None
386 vnfr
['operational-status'],
387 vnfr
['config-status']])
391 @cli.command(name
='ns-op-list')
392 @click.argument('name')
394 def ns_op_list(ctx
, name
):
395 '''shows the history of operations over a NS instance
397 NAME: name or ID of the NS instance
400 check_client_version(ctx
.obj
, ctx
.command
.name
)
401 resp
= ctx
.obj
.ns
.list_op(name
)
402 except ClientException
as inst
:
403 print((inst
.message
))
406 table
= PrettyTable(['id', 'operation', 'status'])
408 table
.add_row([op
['id'], op
['lcmOperationType'],
409 op
['operationState']])
417 def nsd_show(ctx
, name
, literal
):
419 resp
= ctx
.obj
.nsd
.get(name
)
420 #resp = ctx.obj.nsd.get_individual(name)
421 except ClientException
as inst
:
422 print((inst
.message
))
426 print(yaml
.safe_dump(resp
))
429 table
= PrettyTable(['field', 'value'])
430 for k
, v
in list(resp
.items()):
431 table
.add_row([k
, json
.dumps(v
, indent
=2)])
436 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
437 @click.option('--literal', is_flag
=True,
438 help='print literally, no pretty table')
439 @click.argument('name')
441 def nsd_show1(ctx
, name
, literal
):
442 '''shows the content of a NSD
444 NAME: name or ID of the NSD/NSpkg
446 nsd_show(ctx
, name
, literal
)
449 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
450 @click.option('--literal', is_flag
=True,
451 help='print literally, no pretty table')
452 @click.argument('name')
454 def nsd_show2(ctx
, name
, literal
):
455 '''shows the content of a NSD
457 NAME: name or ID of the NSD/NSpkg
459 nsd_show(ctx
, name
, literal
)
462 def vnfd_show(ctx
, name
, literal
):
464 resp
= ctx
.obj
.vnfd
.get(name
)
465 #resp = ctx.obj.vnfd.get_individual(name)
466 except ClientException
as inst
:
467 print((inst
.message
))
471 print(yaml
.safe_dump(resp
))
474 table
= PrettyTable(['field', 'value'])
475 for k
, v
in list(resp
.items()):
476 table
.add_row([k
, json
.dumps(v
, indent
=2)])
481 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
482 @click.option('--literal', is_flag
=True,
483 help='print literally, no pretty table')
484 @click.argument('name')
486 def vnfd_show1(ctx
, name
, literal
):
487 '''shows the content of a VNFD
489 NAME: name or ID of the VNFD/VNFpkg
491 vnfd_show(ctx
, name
, literal
)
494 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
495 @click.option('--literal', is_flag
=True,
496 help='print literally, no pretty table')
497 @click.argument('name')
499 def vnfd_show2(ctx
, name
, literal
):
500 '''shows the content of a VNFD
502 NAME: name or ID of the VNFD/VNFpkg
504 vnfd_show(ctx
, name
, literal
)
507 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
508 @click.argument('name')
509 @click.option('--literal', is_flag
=True,
510 help='print literally, no pretty table')
511 @click.option('--filter', default
=None)
513 def ns_show(ctx
, name
, literal
, filter):
514 '''shows the info of a NS instance
516 NAME: name or ID of the NS instance
519 ns
= ctx
.obj
.ns
.get(name
)
520 except ClientException
as inst
:
521 print((inst
.message
))
525 print(yaml
.safe_dump(ns
))
528 table
= PrettyTable(['field', 'value'])
530 for k
, v
in list(ns
.items()):
531 if filter is None or filter in k
:
532 table
.add_row([k
, json
.dumps(v
, indent
=2)])
534 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
535 if fullclassname
!= 'osmclient.sol005.client.Client':
536 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
537 nsr_optdata
= nsopdata
['nsr:nsr']
538 for k
, v
in list(nsr_optdata
.items()):
539 if filter is None or filter in k
:
540 table
.add_row([k
, json
.dumps(v
, indent
=2)])
545 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
546 @click.argument('name')
547 @click.option('--literal', is_flag
=True,
548 help='print literally, no pretty table')
549 @click.option('--filter', default
=None)
551 def vnf_show(ctx
, name
, literal
, filter):
552 '''shows the info of a VNF instance
554 NAME: name or ID of the VNF instance
557 check_client_version(ctx
.obj
, ctx
.command
.name
)
558 resp
= ctx
.obj
.vnf
.get(name
)
559 except ClientException
as inst
:
560 print((inst
.message
))
564 print(yaml
.safe_dump(resp
))
567 table
= PrettyTable(['field', 'value'])
568 for k
, v
in list(resp
.items()):
569 if filter is None or filter in k
:
570 table
.add_row([k
, json
.dumps(v
, indent
=2)])
575 @cli.command(name
='vnf-monitoring-show')
576 @click.argument('vnf_name')
578 def vnf_monitoring_show(ctx
, vnf_name
):
580 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
581 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
582 except ClientException
as inst
:
583 print((inst
.message
))
586 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
592 monitor
['value-integer'],
598 @cli.command(name
='ns-monitoring-show')
599 @click.argument('ns_name')
601 def ns_monitoring_show(ctx
, ns_name
):
603 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
604 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
605 except ClientException
as inst
:
606 print((inst
.message
))
609 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
610 for key
, val
in list(resp
.items()):
615 monitor
['value-integer'],
620 @cli.command(name
='ns-op-show', short_help
='shows the info of an operation')
621 @click.argument('id')
622 @click.option('--filter', default
=None)
624 def ns_op_show(ctx
, id, filter):
625 '''shows the detailed info of an operation
627 ID: operation identifier
630 check_client_version(ctx
.obj
, ctx
.command
.name
)
631 op_info
= ctx
.obj
.ns
.get_op(id)
632 except ClientException
as inst
:
633 print((inst
.message
))
636 table
= PrettyTable(['field', 'value'])
637 for k
, v
in list(op_info
.items()):
638 if filter is None or filter in k
:
639 table
.add_row([k
, json
.dumps(v
, indent
=2)])
648 def nsd_create(ctx
, filename
, overwrite
):
650 check_client_version(ctx
.obj
, ctx
.command
.name
)
651 ctx
.obj
.nsd
.create(filename
, overwrite
)
652 except ClientException
as inst
:
653 print((inst
.message
))
657 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
658 @click.argument('filename')
659 @click.option('--overwrite', default
=None,
660 help='overwrites some fields in NSD')
662 def nsd_create1(ctx
, filename
, overwrite
):
663 '''creates a new NSD/NSpkg
665 FILENAME: NSD yaml file or NSpkg tar.gz file
667 nsd_create(ctx
, filename
, overwrite
)
670 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
671 @click.argument('filename')
672 @click.option('--overwrite', default
=None,
673 help='overwrites some fields in NSD')
675 def nsd_create2(ctx
, filename
, overwrite
):
676 '''creates a new NSD/NSpkg
678 FILENAME: NSD yaml file or NSpkg tar.gz file
680 nsd_create(ctx
, filename
, overwrite
)
683 def vnfd_create(ctx
, filename
, overwrite
):
685 check_client_version(ctx
.obj
, ctx
.command
.name
)
686 ctx
.obj
.vnfd
.create(filename
, overwrite
)
687 except ClientException
as inst
:
688 print((inst
.message
))
692 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
693 @click.argument('filename')
694 @click.option('--overwrite', default
=None,
695 help='overwrites some fields in VNFD')
697 def vnfd_create1(ctx
, filename
, overwrite
):
698 '''creates a new VNFD/VNFpkg
700 FILENAME: VNFD yaml file or VNFpkg tar.gz file
702 vnfd_create(ctx
, filename
, overwrite
)
705 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
706 @click.argument('filename')
707 @click.option('--overwrite', default
=None,
708 help='overwrites some fields in VNFD')
710 def vnfd_create2(ctx
, filename
, overwrite
):
711 '''creates a new VNFD/VNFpkg
713 FILENAME: VNFD yaml file or VNFpkg tar.gz file
715 vnfd_create(ctx
, filename
, overwrite
)
718 @cli.command(name
='ns-create')
719 @click.option('--ns_name',
721 @click.option('--nsd_name',
723 @click.option('--vim_account',
725 @click.option('--admin_status',
727 help='administration status')
728 @click.option('--ssh_keys',
730 help='comma separated list of public key files to inject to vnfs')
731 @click.option('--config',
733 help='ns specific yaml configuration')
734 @click.option('--config_file',
736 help='ns specific yaml configuration file')
746 '''creates a new NS instance'''
749 check_client_version(ctx
.obj
, '--config_file')
751 raise ClientException('"--config" option is incompatible with "--config_file" option')
752 with
open(config_file
, 'r') as cf
:
760 except ClientException
as inst
:
761 print((inst
.message
))
769 def nsd_update(ctx
, name
, content
):
771 check_client_version(ctx
.obj
, ctx
.command
.name
)
772 ctx
.obj
.nsd
.update(name
, content
)
773 except ClientException
as inst
:
774 print((inst
.message
))
777 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
778 @click.argument('name')
779 @click.option('--content', default
=None,
780 help='filename with the NSD/NSpkg replacing the current one')
782 def nsd_update1(ctx
, name
, content
):
783 '''updates a NSD/NSpkg
785 NAME: name or ID of the NSD/NSpkg
787 nsd_update(ctx
, name
, content
)
790 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
791 @click.argument('name')
792 @click.option('--content', default
=None,
793 help='filename with the NSD/NSpkg replacing the current one')
795 def nsd_update2(ctx
, name
, content
):
796 '''updates a NSD/NSpkg
798 NAME: name or ID of the NSD/NSpkg
800 nsd_update(ctx
, name
, content
)
803 def vnfd_update(ctx
, name
, content
):
805 check_client_version(ctx
.obj
, ctx
.command
.name
)
806 ctx
.obj
.vnfd
.update(name
, content
)
807 except ClientException
as inst
:
808 print((inst
.message
))
812 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
813 @click.argument('name')
814 @click.option('--content', default
=None,
815 help='filename with the VNFD/VNFpkg replacing the current one')
817 def vnfd_update1(ctx
, name
, content
):
818 '''updates a VNFD/VNFpkg
820 NAME: name or ID of the VNFD/VNFpkg
822 vnfd_update(ctx
, name
, content
)
825 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
826 @click.argument('name')
827 @click.option('--content', default
=None,
828 help='filename with the VNFD/VNFpkg replacing the current one')
830 def vnfd_update2(ctx
, name
, content
):
831 '''updates a VNFD/VNFpkg
833 NAME: VNFD yaml file or VNFpkg tar.gz file
835 vnfd_update(ctx
, name
, content
)
842 def nsd_delete(ctx
, name
, force
):
845 ctx
.obj
.nsd
.delete(name
)
847 check_client_version(ctx
.obj
, '--force')
848 ctx
.obj
.nsd
.delete(name
, force
)
849 except ClientException
as inst
:
850 print((inst
.message
))
854 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
855 @click.argument('name')
856 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
858 def nsd_delete1(ctx
, name
, force
):
859 '''deletes a NSD/NSpkg
861 NAME: name or ID of the NSD/NSpkg to be deleted
863 nsd_delete(ctx
, name
, force
)
866 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
867 @click.argument('name')
868 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
870 def nsd_delete2(ctx
, name
, force
):
871 '''deletes a NSD/NSpkg
873 NAME: name or ID of the NSD/NSpkg to be deleted
875 nsd_delete(ctx
, name
, force
)
878 def vnfd_delete(ctx
, name
, force
):
881 ctx
.obj
.vnfd
.delete(name
)
883 check_client_version(ctx
.obj
, '--force')
884 ctx
.obj
.vnfd
.delete(name
, force
)
885 except ClientException
as inst
:
886 print((inst
.message
))
890 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
891 @click.argument('name')
892 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
894 def vnfd_delete1(ctx
, name
, force
):
895 '''deletes a VNFD/VNFpkg
897 NAME: name or ID of the VNFD/VNFpkg to be deleted
899 vnfd_delete(ctx
, name
, force
)
902 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
903 @click.argument('name')
904 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
906 def vnfd_delete2(ctx
, name
, force
):
907 '''deletes a VNFD/VNFpkg
909 NAME: name or ID of the VNFD/VNFpkg to be deleted
911 vnfd_delete(ctx
, name
, force
)
914 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
915 @click.argument('name')
916 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
918 def ns_delete(ctx
, name
, force
):
919 '''deletes a NS instance
921 NAME: name or ID of the NS instance to be deleted
925 ctx
.obj
.ns
.delete(name
)
927 check_client_version(ctx
.obj
, '--force')
928 ctx
.obj
.ns
.delete(name
, force
)
929 except ClientException
as inst
:
930 print((inst
.message
))
938 @cli.command(name
='vim-create')
939 @click.option('--name',
941 help='Name to create datacenter')
942 @click.option('--user',
945 @click.option('--password',
948 confirmation_prompt
=True,
950 @click.option('--auth_url',
953 @click.option('--tenant',
955 help='VIM tenant name')
956 @click.option('--config',
958 help='VIM specific config parameters')
959 @click.option('--account_type',
962 @click.option('--description',
963 default
='no description',
964 help='human readable description')
965 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
966 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
979 '''creates a new VIM account
983 check_client_version(ctx
.obj
, '--sdn_controller')
985 check_client_version(ctx
.obj
, '--sdn_port_mapping')
987 vim
['vim-username'] = user
988 vim
['vim-password'] = password
989 vim
['vim-url'] = auth_url
990 vim
['vim-tenant-name'] = tenant
991 vim
['vim-type'] = account_type
992 vim
['description'] = description
993 vim
['config'] = config
994 if sdn_controller
or sdn_port_mapping
:
995 ctx
.obj
.vim
.create(name
, vim
, sdn_controller
, sdn_port_mapping
)
997 ctx
.obj
.vim
.create(name
, vim
)
998 except ClientException
as inst
:
999 print((inst
.message
))
1003 @cli.command(name
='vim-update', short_help
='updates a VIM account')
1004 @click.argument('name')
1005 @click.option('--newname', help='New name for the VIM account')
1006 @click.option('--user', help='VIM username')
1007 @click.option('--password', help='VIM password')
1008 @click.option('--auth_url', help='VIM url')
1009 @click.option('--tenant', help='VIM tenant name')
1010 @click.option('--config', help='VIM specific config parameters')
1011 @click.option('--account_type', help='VIM type')
1012 @click.option('--description', help='human readable description')
1013 @click.option('--sdn_controller', default
=None, help='Name or id of the SDN controller associated to this VIM account')
1014 @click.option('--sdn_port_mapping', default
=None, help="File describing the port mapping between compute nodes' ports and switch ports")
1028 '''updates a VIM account
1030 NAME: name or ID of the VIM account
1033 check_client_version(ctx
.obj
, ctx
.command
.name
)
1035 if newname
: vim
['name'] = newname
1036 if user
: vim
['vim_user'] = user
1037 if password
: vim
['vim_password'] = password
1038 if auth_url
: vim
['vim_url'] = auth_url
1039 if tenant
: vim
['vim-tenant-name'] = tenant
1040 if account_type
: vim
['vim_type'] = account_type
1041 if description
: vim
['description'] = description
1042 if config
: vim
['config'] = config
1043 ctx
.obj
.vim
.update(name
, vim
, sdn_controller
, sdn_port_mapping
)
1044 except ClientException
as inst
:
1045 print((inst
.message
))
1049 @cli.command(name
='vim-delete')
1050 @click.argument('name')
1051 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1053 def vim_delete(ctx
, name
, force
):
1054 '''deletes a VIM account
1056 NAME: name or ID of the VIM account to be deleted
1060 ctx
.obj
.vim
.delete(name
)
1062 check_client_version(ctx
.obj
, '--force')
1063 ctx
.obj
.vim
.delete(name
, force
)
1064 except ClientException
as inst
:
1065 print((inst
.message
))
1069 @cli.command(name
='vim-list')
1070 @click.option('--ro_update/--no_ro_update',
1072 help='update list from RO')
1073 @click.option('--filter', default
=None,
1074 help='restricts the list to the VIM accounts matching the filter')
1076 def vim_list(ctx
, ro_update
, filter):
1077 '''list all VIM accounts'''
1079 check_client_version(ctx
.obj
, '--filter')
1081 check_client_version(ctx
.obj
, '--ro_update', 'v1')
1082 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
1083 if fullclassname
== 'osmclient.sol005.client.Client':
1084 resp
= ctx
.obj
.vim
.list(filter)
1086 resp
= ctx
.obj
.vim
.list(ro_update
)
1087 table
= PrettyTable(['vim name', 'uuid'])
1089 table
.add_row([vim
['name'], vim
['uuid']])
1094 @cli.command(name
='vim-show')
1095 @click.argument('name')
1097 def vim_show(ctx
, name
):
1098 '''shows the details of a VIM account
1100 NAME: name or ID of the VIM account
1103 resp
= ctx
.obj
.vim
.get(name
)
1104 if 'vim_password' in resp
:
1105 resp
['vim_password']='********'
1106 except ClientException
as inst
:
1107 print((inst
.message
))
1110 table
= PrettyTable(['key', 'attribute'])
1111 for k
, v
in list(resp
.items()):
1112 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1117 ####################
1118 # SDN controller operations
1119 ####################
1121 @cli.command(name
='sdnc-create')
1122 @click.option('--name',
1124 help='Name to create sdn controller')
1125 @click.option('--type',
1127 help='SDN controller type')
1128 @click.option('--sdn_controller_version',
1129 help='SDN controller username')
1130 @click.option('--ip_address',
1132 help='SDN controller IP address')
1133 @click.option('--port',
1135 help='SDN controller port')
1136 @click.option('--switch_dpid',
1138 help='Switch DPID (Openflow Datapath ID)')
1139 @click.option('--user',
1140 help='SDN controller username')
1141 @click.option('--password',
1143 confirmation_prompt
=True,
1144 help='SDN controller password')
1145 #@click.option('--description',
1146 # default='no description',
1147 # help='human readable description')
1149 def sdnc_create(ctx
,
1152 sdn_controller_version
,
1158 '''creates a new SDN controller
1161 sdncontroller
['name'] = name
1162 sdncontroller
['type'] = type
1163 sdncontroller
['ip'] = ip_address
1164 sdncontroller
['port'] = int(port
)
1165 sdncontroller
['dpid'] = switch_dpid
1166 if sdn_controller_version
:
1167 sdncontroller
['version'] = sdn_controller_version
1169 sdncontroller
['user'] = user
1171 sdncontroller
['password'] = password
1172 # sdncontroller['description'] = description
1174 check_client_version(ctx
.obj
, ctx
.command
.name
)
1175 ctx
.obj
.sdnc
.create(name
, sdncontroller
)
1176 except ClientException
as inst
:
1177 print((inst
.message
))
1180 @cli.command(name
='sdnc-update', short_help
='updates an SDN controller')
1181 @click.argument('name')
1182 @click.option('--newname', help='New name for the SDN controller')
1183 @click.option('--type', help='SDN controller type')
1184 @click.option('--sdn_controller_version', help='SDN controller username')
1185 @click.option('--ip_address', help='SDN controller IP address')
1186 @click.option('--port', help='SDN controller port')
1187 @click.option('--switch_dpid', help='Switch DPID (Openflow Datapath ID)')
1188 @click.option('--user', help='SDN controller username')
1189 @click.option('--password', help='SDN controller password')
1190 #@click.option('--description', default=None, help='human readable description')
1192 def sdnc_update(ctx
,
1196 sdn_controller_version
,
1202 '''updates an SDN controller
1204 NAME: name or ID of the SDN controller
1207 if newname
: sdncontroller
['name'] = newname
1208 if type: sdncontroller
['type'] = type
1209 if ip_address
: sdncontroller
['ip'] = ip_address
1210 if port
: sdncontroller
['port'] = int(port
)
1211 if switch_dpid
: sdncontroller
['dpid'] = switch_dpid
1212 # sdncontroller['description'] = description
1213 if sdn_controller_version
is not None:
1214 if sdn_controller_version
=="":
1215 sdncontroller
['version'] = None
1217 sdncontroller
['version'] = sdn_controller_version
1218 if user
is not None:
1220 sdncontroller
['user'] = None
1222 sdncontroller
['user'] = user
1223 if password
is not None:
1225 sdncontroller
['password'] = None
1227 sdncontroller
['password'] = user
1229 check_client_version(ctx
.obj
, ctx
.command
.name
)
1230 ctx
.obj
.sdnc
.update(name
, sdncontroller
)
1231 except ClientException
as inst
:
1232 print((inst
.message
))
1236 @cli.command(name
='sdnc-delete')
1237 @click.argument('name')
1238 @click.option('--force', is_flag
=True, help='forces the deletion bypassing pre-conditions')
1240 def sdnc_delete(ctx
, name
, force
):
1241 '''deletes an SDN controller
1243 NAME: name or ID of the SDN controller to be deleted
1246 check_client_version(ctx
.obj
, ctx
.command
.name
)
1247 ctx
.obj
.sdnc
.delete(name
, force
)
1248 except ClientException
as inst
:
1249 print((inst
.message
))
1253 @cli.command(name
='sdnc-list')
1254 @click.option('--filter', default
=None,
1255 help='restricts the list to the SDN controllers matching the filter')
1257 def sdnc_list(ctx
, filter):
1258 '''list all SDN controllers'''
1260 check_client_version(ctx
.obj
, ctx
.command
.name
)
1261 resp
= ctx
.obj
.sdnc
.list(filter)
1262 except ClientException
as inst
:
1263 print((inst
.message
))
1265 table
= PrettyTable(['name', 'id'])
1267 table
.add_row([sdnc
['name'], sdnc
['_id']])
1272 @cli.command(name
='sdnc-show')
1273 @click.argument('name')
1275 def sdnc_show(ctx
, name
):
1276 '''shows the details of an SDN controller
1278 NAME: name or ID of the SDN controller
1281 check_client_version(ctx
.obj
, ctx
.command
.name
)
1282 resp
= ctx
.obj
.sdnc
.get(name
)
1283 except ClientException
as inst
:
1284 print((inst
.message
))
1287 table
= PrettyTable(['key', 'attribute'])
1288 for k
, v
in list(resp
.items()):
1289 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1294 ####################
1295 # Project mgmt operations
1296 ####################
1298 @cli.command(name
='project-create')
1299 @click.argument('name')
1300 #@click.option('--description',
1301 # default='no description',
1302 # help='human readable description')
1304 def project_create(ctx
, name
):
1305 '''Creates a new project
1307 NAME: name of the project
1310 project
['name'] = name
1312 check_client_version(ctx
.obj
, ctx
.command
.name
)
1313 ctx
.obj
.project
.create(name
, project
)
1314 except ClientException
as inst
:
1318 @cli.command(name
='project-delete')
1319 @click.argument('name')
1320 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
1322 def project_delete(ctx
, name
):
1323 '''deletes a project
1325 NAME: name or ID of the project to be deleted
1328 check_client_version(ctx
.obj
, ctx
.command
.name
)
1329 ctx
.obj
.project
.delete(name
)
1330 except ClientException
as inst
:
1335 @cli.command(name
='project-list')
1336 @click.option('--filter', default
=None,
1337 help='restricts the list to the projects matching the filter')
1339 def project_list(ctx
, filter):
1340 '''list all projects'''
1342 check_client_version(ctx
.obj
, ctx
.command
.name
)
1343 resp
= ctx
.obj
.project
.list(filter)
1344 except ClientException
as inst
:
1347 table
= PrettyTable(['name', 'id'])
1349 table
.add_row([proj
['name'], proj
['_id']])
1354 @cli.command(name
='project-show')
1355 @click.argument('name')
1357 def project_show(ctx
, name
):
1358 '''shows the details of a project
1360 NAME: name or ID of the project
1363 check_client_version(ctx
.obj
, ctx
.command
.name
)
1364 resp
= ctx
.obj
.project
.get(name
)
1365 except ClientException
as inst
:
1369 table
= PrettyTable(['key', 'attribute'])
1370 for k
, v
in resp
.items():
1371 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1376 ####################
1377 # User mgmt operations
1378 ####################
1380 @cli.command(name
='user-create')
1381 @click.argument('username')
1382 @click.option('--password',
1385 confirmation_prompt
=True,
1386 help='user password')
1387 @click.option('--projects',
1389 help='list of project ids that the user belongs to')
1390 #@click.option('--description',
1391 # default='no description',
1392 # help='human readable description')
1394 def user_create(ctx
, username
, password
, projects
):
1395 '''Creates a new user
1397 USERNAME: name of the user
1400 user
['username'] = username
1401 user
['password'] = password
1402 user
['projects'] = projects
1404 check_client_version(ctx
.obj
, ctx
.command
.name
)
1405 ctx
.obj
.user
.create(username
, user
)
1406 except ClientException
as inst
:
1410 @cli.command(name
='user-delete')
1411 @click.argument('name')
1412 #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions')
1414 def user_delete(ctx
, name
):
1417 NAME: name or ID of the user to be deleted
1420 check_client_version(ctx
.obj
, ctx
.command
.name
)
1421 ctx
.obj
.user
.delete(name
)
1422 except ClientException
as inst
:
1427 @cli.command(name
='user-list')
1428 @click.option('--filter', default
=None,
1429 help='restricts the list to the users matching the filter')
1431 def user_list(ctx
, filter):
1432 '''list all users'''
1434 check_client_version(ctx
.obj
, ctx
.command
.name
)
1435 resp
= ctx
.obj
.user
.list(filter)
1436 except ClientException
as inst
:
1439 table
= PrettyTable(['name', 'id'])
1441 table
.add_row([user
['name'], user
['_id']])
1446 @cli.command(name
='user-show')
1447 @click.argument('name')
1449 def user_show(ctx
, name
):
1450 '''shows the details of a user
1452 NAME: name or ID of the user
1455 check_client_version(ctx
.obj
, ctx
.command
.name
)
1456 resp
= ctx
.obj
.user
.get(name
)
1457 if 'password' in resp
:
1458 resp
['password']='********'
1459 except ClientException
as inst
:
1463 table
= PrettyTable(['key', 'attribute'])
1464 for k
, v
in resp
.items():
1465 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1470 ####################
1471 # Fault Management operations
1472 ####################
1474 @cli.command(name
='ns-alarm-create')
1475 @click.argument('name')
1476 @click.option('--ns', prompt
=True, help='NS instance id or name')
1477 @click.option('--vnf', prompt
=True,
1478 help='VNF name (VNF member index as declared in the NSD)')
1479 @click.option('--vdu', prompt
=True,
1480 help='VDU name (VDU name as declared in the VNFD)')
1481 @click.option('--metric', prompt
=True,
1482 help='Name of the metric (e.g. cpu_utilization)')
1483 @click.option('--severity', default
='WARNING',
1484 help='severity of the alarm (WARNING, MINOR, MAJOR, CRITICAL, INDETERMINATE)')
1485 @click.option('--threshold_value', prompt
=True,
1486 help='threshold value that, when crossed, an alarm is triggered')
1487 @click.option('--threshold_operator', prompt
=True,
1488 help='threshold operator describing the comparison (GE, LE, GT, LT, EQ)')
1489 @click.option('--statistic', default
='AVERAGE',
1490 help='statistic (AVERAGE, MINIMUM, MAXIMUM, COUNT, SUM)')
1492 def ns_alarm_create(ctx
, name
, ns
, vnf
, vdu
, metric
, severity
,
1493 threshold_value
, threshold_operator
, statistic
):
1494 '''creates a new alarm for a NS instance'''
1495 ns_instance
= ctx
.obj
.ns
.get(ns
)
1497 alarm
['alarm_name'] = name
1498 alarm
['ns_id'] = ns_instance
['_id']
1499 alarm
['correlation_id'] = ns_instance
['_id']
1500 alarm
['vnf_member_index'] = vnf
1501 alarm
['vdu_name'] = vdu
1502 alarm
['metric_name'] = metric
1503 alarm
['severity'] = severity
1504 alarm
['threshold_value'] = int(threshold_value
)
1505 alarm
['operation'] = threshold_operator
1506 alarm
['statistic'] = statistic
1508 check_client_version(ctx
.obj
, ctx
.command
.name
)
1509 ctx
.obj
.ns
.create_alarm(alarm
)
1510 except ClientException
as inst
:
1511 print((inst
.message
))
1515 #@cli.command(name='ns-alarm-delete')
1516 #@click.argument('name')
1517 #@click.pass_context
1518 #def ns_alarm_delete(ctx, name):
1519 # '''deletes an alarm
1521 # NAME: name of the alarm to be deleted
1524 # check_client_version(ctx.obj, ctx.command.name)
1525 # ctx.obj.ns.delete_alarm(name)
1526 # except ClientException as inst:
1527 # print(inst.message)
1531 ####################
1532 # Performance Management operations
1533 ####################
1535 @cli.command(name
='ns-metric-export')
1536 @click.option('--ns', prompt
=True, help='NS instance id or name')
1537 @click.option('--vnf', prompt
=True,
1538 help='VNF name (VNF member index as declared in the NSD)')
1539 @click.option('--vdu', prompt
=True,
1540 help='VDU name (VDU name as declared in the VNFD)')
1541 @click.option('--metric', prompt
=True,
1542 help='name of the metric (e.g. cpu_utilization)')
1543 #@click.option('--period', default='1w',
1544 # help='metric collection period (e.g. 20s, 30m, 2h, 3d, 1w)')
1545 @click.option('--interval', help='periodic interval (seconds) to export metrics continuously')
1547 def ns_metric_export(ctx
, ns
, vnf
, vdu
, metric
, interval
):
1548 '''exports a metric to the internal OSM bus, which can be read by other apps
1550 ns_instance
= ctx
.obj
.ns
.get(ns
)
1552 metric_data
['ns_id'] = ns_instance
['_id']
1553 metric_data
['correlation_id'] = ns_instance
['_id']
1554 metric_data
['vnf_member_index'] = vnf
1555 metric_data
['vdu_name'] = vdu
1556 metric_data
['metric_name'] = metric
1557 metric_data
['collection_unit'] = 'WEEK'
1558 metric_data
['collection_period'] = 1
1560 check_client_version(ctx
.obj
, ctx
.command
.name
)
1562 print('{}'.format(ctx
.obj
.ns
.export_metric(metric_data
)))
1566 print('{} {}'.format(ctx
.obj
.ns
.export_metric(metric_data
),i
))
1567 time
.sleep(int(interval
))
1569 except ClientException
as inst
:
1570 print((inst
.message
))
1574 ####################
1576 ####################
1578 @cli.command(name
='upload-package')
1579 @click.argument('filename')
1581 def upload_package(ctx
, filename
):
1582 '''uploads a VNF package or NS package
1584 FILENAME: VNF or NS package file (tar.gz)
1587 ctx
.obj
.package
.upload(filename
)
1588 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
1589 if fullclassname
!= 'osmclient.sol005.client.Client':
1590 ctx
.obj
.package
.wait_for_upload(filename
)
1591 except ClientException
as inst
:
1592 print((inst
.message
))
1596 @cli.command(name
='ns-scaling-show')
1597 @click.argument('ns_name')
1599 def show_ns_scaling(ctx
, ns_name
):
1600 '''shows the status of a NS scaling operation
1602 NS_NAME: name of the NS instance being scaled
1605 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1606 resp
= ctx
.obj
.ns
.list()
1607 except ClientException
as inst
:
1608 print((inst
.message
))
1611 table
= PrettyTable(
1614 'operational status',
1619 if ns_name
== ns
['name']:
1620 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
1621 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
1622 for record
in scaling_records
:
1623 if 'instance' in record
:
1624 instances
= record
['instance']
1625 for inst
in instances
:
1627 [record
['scaling-group-name-ref'],
1628 inst
['instance-id'],
1630 time
.strftime('%Y-%m-%d %H:%M:%S',
1632 inst
['create-time'])),
1638 @cli.command(name
='ns-scale')
1639 @click.argument('ns_name')
1640 @click.option('--ns_scale_group', prompt
=True)
1641 @click.option('--index', prompt
=True)
1643 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
1646 NS_NAME: name of the NS instance to be scaled
1649 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1650 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
1651 except ClientException
as inst
:
1652 print((inst
.message
))
1656 @cli.command(name
='config-agent-list')
1658 def config_agent_list(ctx
):
1659 '''list config agents'''
1661 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1662 except ClientException
as inst
:
1663 print((inst
.message
))
1665 table
= PrettyTable(['name', 'account-type', 'details'])
1666 for account
in ctx
.obj
.vca
.list():
1669 account
['account-type'],
1675 @cli.command(name
='config-agent-delete')
1676 @click.argument('name')
1678 def config_agent_delete(ctx
, name
):
1679 '''deletes a config agent
1681 NAME: name of the config agent to be deleted
1684 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1685 ctx
.obj
.vca
.delete(name
)
1686 except ClientException
as inst
:
1687 print((inst
.message
))
1691 @cli.command(name
='config-agent-add')
1692 @click.option('--name',
1694 @click.option('--account_type',
1696 @click.option('--server',
1698 @click.option('--user',
1700 @click.option('--secret',
1703 confirmation_prompt
=True)
1705 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
1706 '''adds a config agent'''
1708 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1709 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
1710 except ClientException
as inst
:
1711 print((inst
.message
))
1714 @cli.command(name
='ro-dump')
1717 '''shows RO agent information'''
1718 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1719 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
1720 table
= PrettyTable(['key', 'attribute'])
1721 for k
, v
in list(resp
.items()):
1722 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1727 @cli.command(name
='vcs-list')
1730 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1731 resp
= ctx
.obj
.utils
.get_vcs_info()
1732 table
= PrettyTable(['component name', 'state'])
1733 for component
in resp
:
1734 table
.add_row([component
['component_name'], component
['state']])
1739 @cli.command(name
='ns-action')
1740 @click.argument('ns_name')
1741 @click.option('--vnf_name', default
=None)
1742 @click.option('--action_name', prompt
=True)
1743 @click.option('--params', prompt
=True)
1750 '''executes an action/primitive over a NS instance
1752 NS_NAME: name or ID of the NS instance
1755 check_client_version(ctx
.obj
, ctx
.command
.name
)
1758 op_data
['vnf_member_index'] = vnf_name
1759 op_data
['primitive'] = action_name
1760 op_data
['primitive_params'] = yaml
.load(params
)
1761 ctx
.obj
.ns
.exec_op(ns_name
, op_name
='action', op_data
=op_data
)
1763 except ClientException
as inst
:
1764 print((inst
.message
))
1768 @cli.command(name
='vnf-scale')
1769 @click.argument('ns_name')
1770 @click.argument('vnf_name')
1771 @click.option('--scaling-group', prompt
=True, help="scaling-group-descriptor name to use")
1772 @click.option('--scale-in', default
=False, is_flag
=True, help="performs a scale in operation")
1773 @click.option('--scale-out', default
=False, is_flag
=True, help="performs a scale out operation (by default)")
1781 '''executes a VNF scale (adding/removing VDUs)
1784 NS_NAME: name or ID of the NS instance.
1785 VNF_NAME: member-vnf-index in the NS to be scaled.
1788 check_client_version(ctx
.obj
, ctx
.command
.name
)
1789 if not scale_in
and not scale_out
:
1791 ctx
.obj
.ns
.scale_vnf(ns_name
, vnf_name
, scaling_group
, scale_in
, scale_out
)
1792 except ClientException
as inst
:
1793 print((inst
.message
))
1797 if __name__
== '__main__':
1800 except pycurl
.error
as e
:
1802 print('Maybe "--hostname" option or OSM_HOSTNAME' +
1803 'environment variable needs to be specified')