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
29 def check_client_version(obj
, what
, version
='sol005'):
31 Checks the version of the client object and raises error if it not the expected.
33 :param obj: the client object
34 :what: the function or command under evaluation (used when an error is raised)
36 :raises ClientError: if the specified version does not match the client version
38 fullclassname
= obj
.__module
__ + "." + obj
.__class
__.__name
__
39 message
= 'the following commands or options are only supported with the option "--sol005": {}'.format(what
)
41 message
= 'the following commands or options are not supported when using option "--sol005": {}'.format(what
)
42 if fullclassname
!= 'osmclient.{}.client.Client'.format(version
):
43 raise ClientException(message
)
47 @click.option('--hostname',
49 envvar
='OSM_HOSTNAME',
50 help='hostname of server. ' +
51 'Also can set OSM_HOSTNAME in environment')
52 @click.option('--so-port',
55 help='hostname of server. ' +
56 'Also can set OSM_SO_PORT in environment')
57 @click.option('--so-project',
59 envvar
='OSM_SO_PROJECT',
60 help='Project Name in SO. ' +
61 'Also can set OSM_SO_PROJECT in environment')
62 @click.option('--ro-hostname',
64 envvar
='OSM_RO_HOSTNAME',
65 help='hostname of RO server. ' +
66 'Also can set OSM_RO_HOSTNAME in environment')
67 @click.option('--ro-port',
70 help='hostname of RO server. ' +
71 'Also can set OSM_RO_PORT in environment')
72 @click.option('--sol005',
75 help='Use ETSI NFV SOL005 API')
77 def cli(ctx
, hostname
, so_port
, so_project
, ro_hostname
, ro_port
, sol005
):
80 "either hostname option or OSM_HOSTNAME " +
81 "environment variable needs to be specified")
84 if so_port
is not None:
85 kwargs
['so_port']=so_port
86 if so_project
is not None:
87 kwargs
['so_project']=so_project
88 if ro_hostname
is not None:
89 kwargs
['ro_host']=ro_hostname
90 if ro_port
is not None:
91 kwargs
['ro_port']=ro_port
93 ctx
.obj
= client
.Client(host
=hostname
, sol005
=sol005
, **kwargs
)
100 @cli.command(name
='ns-list')
101 @click.option('--filter', default
=None,
102 help='restricts the list to the NS instances matching the filter')
104 def ns_list(ctx
, filter):
105 '''list all NS instances'''
107 check_client_version(ctx
.obj
, '--filter option')
108 resp
= ctx
.obj
.ns
.list(filter)
110 resp
= ctx
.obj
.ns
.list()
114 'operational status',
117 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
118 if fullclassname
== 'osmclient.sol005.client.Client':
121 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
122 nsr
= nsopdata
['nsr:nsr']
123 opstatus
= nsr
['operational-status'] if 'operational-status' in nsr
else 'Not found'
124 configstatus
= nsr
['config-status'] if 'config-status' in nsr
else 'Not found'
125 if configstatus
== "config_not_needed":
126 configstatus
= "configured (no charms)"
136 def nsd_list(ctx
, filter):
138 check_client_version(ctx
.obj
, '--filter')
139 resp
= ctx
.obj
.nsd
.list(filter)
141 resp
= ctx
.obj
.nsd
.list()
142 #print yaml.safe_dump(resp)
143 table
= PrettyTable(['nsd name', 'id'])
144 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
145 if fullclassname
== 'osmclient.sol005.client.Client':
147 name
= ns
['name'] if 'name' in ns
else '-'
148 table
.add_row([name
, ns
['_id']])
151 table
.add_row([ns
['name'], ns
['id']])
156 @cli.command(name
='nsd-list')
157 @click.option('--filter', default
=None,
158 help='restricts the list to the NSD/NSpkg matching the filter')
160 def nsd_list1(ctx
, filter):
161 '''list all NSD/NSpkg in the system'''
165 @cli.command(name
='nspkg-list')
166 @click.option('--filter', default
=None,
167 help='restricts the list to the NSD/NSpkg matching the filter')
169 def nsd_list2(ctx
, filter):
170 '''list all NSD/NSpkg in the system'''
174 def vnfd_list(ctx
, filter):
176 check_client_version(ctx
.obj
, '--filter')
177 resp
= ctx
.obj
.vnfd
.list(filter)
179 resp
= ctx
.obj
.vnfd
.list()
180 #print yaml.safe_dump(resp)
181 table
= PrettyTable(['vnfd name', 'id'])
182 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
183 if fullclassname
== 'osmclient.sol005.client.Client':
185 name
= vnfd
['name'] if 'name' in vnfd
else '-'
186 table
.add_row([name
, vnfd
['_id']])
189 table
.add_row([vnfd
['name'], vnfd
['id']])
194 @cli.command(name
='vnfd-list')
195 @click.option('--filter', default
=None,
196 help='restricts the list to the VNFD/VNFpkg matching the filter')
198 def vnfd_list1(ctx
, filter):
199 '''list all VNFD/VNFpkg in the system'''
200 vnfd_list(ctx
,filter)
203 @cli.command(name
='vnfpkg-list')
204 @click.option('--filter', default
=None,
205 help='restricts the list to the VNFD/VNFpkg matching the filter')
207 def vnfd_list2(ctx
, filter):
208 '''list all VNFD/VNFpkg in the system'''
209 vnfd_list(ctx
,filter)
212 @cli.command(name
='vnf-list')
215 ''' list all VNF instances'''
216 resp
= ctx
.obj
.vnf
.list()
220 'operational status',
223 if 'mgmt-interface' not in vnfr
:
224 vnfr
['mgmt-interface'] = {}
225 vnfr
['mgmt-interface']['ip-address'] = None
229 vnfr
['operational-status'],
230 vnfr
['config-status']])
239 def nsd_show(ctx
, name
, literal
):
241 resp
= ctx
.obj
.nsd
.get(name
)
242 #resp = ctx.obj.nsd.get_individual(name)
243 except ClientException
as inst
:
248 print yaml
.safe_dump(resp
)
251 table
= PrettyTable(['field', 'value'])
252 for k
, v
in resp
.items():
253 table
.add_row([k
, json
.dumps(v
, indent
=2)])
258 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
259 @click.option('--literal', is_flag
=True,
260 help='print literally, no pretty table')
261 @click.argument('name')
263 def nsd_show1(ctx
, name
, literal
):
264 '''shows the content of a NSD
266 NAME: name or ID of the NSD/NSpkg
268 nsd_show(ctx
, name
, literal
)
271 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
272 @click.option('--literal', is_flag
=True,
273 help='print literally, no pretty table')
274 @click.argument('name')
276 def nsd_show2(ctx
, name
, literal
):
277 '''shows the content of a NSD
279 NAME: name or ID of the NSD/NSpkg
281 nsd_show(ctx
, name
, literal
)
284 def vnfd_show(ctx
, name
, literal
):
286 resp
= ctx
.obj
.vnfd
.get(name
)
287 #resp = ctx.obj.vnfd.get_individual(name)
288 except ClientException
as inst
:
293 print yaml
.safe_dump(resp
)
296 table
= PrettyTable(['field', 'value'])
297 for k
, v
in resp
.items():
298 table
.add_row([k
, json
.dumps(v
, indent
=2)])
303 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
304 @click.option('--literal', is_flag
=True,
305 help='print literally, no pretty table')
306 @click.argument('name')
308 def vnfd_show1(ctx
, name
, literal
):
309 '''shows the content of a VNFD
311 NAME: name or ID of the VNFD/VNFpkg
313 vnfd_show(ctx
, name
, literal
)
316 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
317 @click.option('--literal', is_flag
=True,
318 help='print literally, no pretty table')
319 @click.argument('name')
321 def vnfd_show2(ctx
, name
, literal
):
322 '''shows the content of a VNFD
324 NAME: name or ID of the VNFD/VNFpkg
326 vnfd_show(ctx
, name
, literal
)
329 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
330 @click.argument('name')
331 @click.option('--literal', is_flag
=True,
332 help='print literally, no pretty table')
333 @click.option('--filter', default
=None)
335 def ns_show(ctx
, name
, literal
, filter):
336 '''shows the info of a NS instance
338 NAME: name or ID of the NS instance
341 ns
= ctx
.obj
.ns
.get(name
)
342 except ClientException
as inst
:
347 print yaml
.safe_dump(resp
)
350 table
= PrettyTable(['field', 'value'])
352 for k
, v
in ns
.items():
353 if filter is None or filter in k
:
354 table
.add_row([k
, json
.dumps(v
, indent
=2)])
356 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
357 if fullclassname
!= 'osmclient.sol005.client.Client':
358 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
359 nsr_optdata
= nsopdata
['nsr:nsr']
360 for k
, v
in nsr_optdata
.items():
361 if filter is None or filter in k
:
362 table
.add_row([k
, json
.dumps(v
, indent
=2)])
367 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
368 @click.argument('name')
369 @click.option('--literal', is_flag
=True,
370 help='print literally, no pretty table')
371 @click.option('--filter', default
=None)
373 def vnf_show(ctx
, name
, literal
, filter):
374 '''shows the info of a VNF instance
376 NAME: name or ID of the VNF instance
379 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
380 resp
= ctx
.obj
.vnf
.get(name
)
381 except ClientException
as inst
:
386 print yaml
.safe_dump(resp
)
389 table
= PrettyTable(['field', 'value'])
390 for k
, v
in resp
.items():
391 if filter is None or filter in k
:
392 table
.add_row([k
, json
.dumps(v
, indent
=2)])
397 @cli.command(name
='vnf-monitoring-show')
398 @click.argument('vnf_name')
400 def vnf_monitoring_show(ctx
, vnf_name
):
402 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
403 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
404 except ClientException
as inst
:
408 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
414 monitor
['value-integer'],
420 @cli.command(name
='ns-monitoring-show')
421 @click.argument('ns_name')
423 def ns_monitoring_show(ctx
, ns_name
):
425 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
426 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
427 except ClientException
as inst
:
431 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
432 for key
, val
in resp
.items():
437 monitor
['value-integer'],
447 def nsd_create(ctx
, filename
, overwrite
):
449 check_client_version(ctx
.obj
, ctx
.command
.name
)
450 ctx
.obj
.nsd
.create(filename
, overwrite
)
451 except ClientException
as inst
:
456 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
457 @click.argument('filename')
458 @click.option('--overwrite', default
=None,
459 help='overwrites some fields in NSD')
461 def nsd_create1(ctx
, filename
, overwrite
):
462 '''creates a new NSD/NSpkg
464 FILENAME: NSD yaml file or NSpkg tar.gz file
466 nsd_create(ctx
, filename
, overwrite
)
469 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
470 @click.argument('filename')
471 @click.option('--overwrite', default
=None,
472 help='overwrites some fields in NSD')
474 def nsd_create2(ctx
, filename
, overwrite
):
475 '''creates a new NSD/NSpkg
477 FILENAME: NSD yaml file or NSpkg tar.gz file
479 nsd_create(ctx
, filename
, overwrite
)
482 def vnfd_create(ctx
, filename
, overwrite
):
484 check_client_version(ctx
.obj
, ctx
.command
.name
)
485 ctx
.obj
.vnfd
.create(filename
, overwrite
)
486 except ClientException
as inst
:
491 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
492 @click.argument('filename')
493 @click.option('--overwrite', default
=None,
494 help='overwrites some fields in VNFD')
496 def vnfd_create1(ctx
, filename
, overwrite
):
497 '''creates a new VNFD/VNFpkg
499 FILENAME: VNFD yaml file or VNFpkg tar.gz file
501 vnfd_create(ctx
, filename
, overwrite
)
504 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
505 @click.argument('filename')
506 @click.option('--overwrite', default
=None,
507 help='overwrites some fields in VNFD')
509 def vnfd_create2(ctx
, filename
, overwrite
):
510 '''creates a new VNFD/VNFpkg
512 FILENAME: VNFD yaml file or VNFpkg tar.gz file
514 vnfd_create(ctx
, filename
, overwrite
)
517 @cli.command(name
='ns-create')
518 @click.option('--ns_name',
520 @click.option('--nsd_name',
522 @click.option('--vim_account',
524 @click.option('--admin_status',
526 help='administration status')
527 @click.option('--ssh_keys',
529 help='comma separated list of keys to inject to vnfs')
530 @click.option('--config',
532 help='ns specific yaml configuration')
541 '''creates a new NS instance'''
544 check_client_version(ctx
.obj
, '--config', 'v1')
551 except ClientException
as inst
:
560 def nsd_update(ctx
, name
, content
):
562 check_client_version(ctx
.obj
, ctx
.command
.name
)
563 ctx
.obj
.nsd
.update(name
, content
)
564 except ClientException
as inst
:
568 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
569 @click.argument('name')
570 @click.option('--content', default
=None,
571 help='filename with the NSD/NSpkg replacing the current one')
573 def nsd_update1(ctx
, name
, content
):
574 '''updates a NSD/NSpkg
576 NAME: name or ID of the NSD/NSpkg
578 nsd_update(ctx
, name
, content
)
581 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
582 @click.argument('name')
583 @click.option('--content', default
=None,
584 help='filename with the NSD/NSpkg replacing the current one')
586 def nsd_update2(ctx
, name
, content
):
587 '''updates a NSD/NSpkg
589 NAME: name or ID of the NSD/NSpkg
591 nsd_update(ctx
, name
, content
)
594 def vnfd_update(ctx
, name
, content
):
596 check_client_version(ctx
.obj
, ctx
.command
.name
)
597 ctx
.obj
.vnfd
.update(name
, content
)
598 except ClientException
as inst
:
603 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
604 @click.argument('name')
605 @click.option('--content', default
=None,
606 help='filename with the VNFD/VNFpkg replacing the current one')
608 def vnfd_update1(ctx
, name
, content
):
609 '''updates a VNFD/VNFpkg
611 NAME: name or ID of the VNFD/VNFpkg
613 vnfd_update(ctx
, name
, content
)
616 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
617 @click.argument('name')
618 @click.option('--content', default
=None,
619 help='filename with the VNFD/VNFpkg replacing the current one')
621 def vnfd_update2(ctx
, name
, content
):
622 '''updates a VNFD/VNFpkg
624 NAME: VNFD yaml file or VNFpkg tar.gz file
626 vnfd_update(ctx
, name
, content
)
633 def nsd_delete(ctx
, name
):
635 ctx
.obj
.nsd
.delete(name
)
636 except ClientException
as inst
:
641 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
642 @click.argument('name')
644 def nsd_delete1(ctx
, name
):
645 '''deletes a NSD/NSpkg
647 NAME: name or ID of the NSD/NSpkg to be deleted
649 nsd_delete(ctx
, name
)
652 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
653 @click.argument('name')
655 def nsd_delete2(ctx
, name
):
656 '''deletes a NSD/NSpkg
658 NAME: name or ID of the NSD/NSpkg to be deleted
660 nsd_delete(ctx
, name
)
663 def vnfd_delete(ctx
, name
):
665 ctx
.obj
.vnfd
.delete(name
)
666 except ClientException
as inst
:
671 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
672 @click.argument('name')
674 def vnfd_delete1(ctx
, name
):
675 '''deletes a VNFD/VNFpkg
677 NAME: name or ID of the VNFD/VNFpkg to be deleted
679 vnfd_delete(ctx
, name
)
682 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
683 @click.argument('name')
685 def vnfd_delete2(ctx
, name
):
686 '''deletes a VNFD/VNFpkg
688 NAME: name or ID of the VNFD/VNFpkg to be deleted
690 vnfd_delete(ctx
, name
)
693 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
694 @click.argument('name')
696 def ns_delete(ctx
, name
):
697 '''deletes a NS instance
699 NAME: name or ID of the NS instance to be deleted
702 ctx
.obj
.ns
.delete(name
)
703 except ClientException
as inst
:
712 @cli.command(name
='vim-create')
713 @click.option('--name',
715 help='Name to create datacenter')
716 @click.option('--user',
719 @click.option('--password',
722 confirmation_prompt
=True,
724 @click.option('--auth_url',
727 @click.option('--tenant',
729 help='VIM tenant name')
730 @click.option('--config',
732 help='VIM specific config parameters')
733 @click.option('--account_type',
736 @click.option('--description',
737 default
='no description',
738 help='human readable description')
749 '''creates a new VIM account
752 vim
['vim-username'] = user
753 vim
['vim-password'] = password
754 vim
['vim-url'] = auth_url
755 vim
['vim-tenant-name'] = tenant
756 vim
['config'] = config
757 vim
['vim-type'] = account_type
758 vim
['description'] = description
760 ctx
.obj
.vim
.create(name
, vim
)
761 except ClientException
as inst
:
766 @cli.command(name
='vim-update', short_help
='updates a VIM account')
767 @click.argument('name')
768 @click.option('--newname', default
=None, help='New name for the VIM account')
769 @click.option('--user', default
=None, help='VIM username')
770 @click.option('--password', default
=None, help='VIM password')
771 @click.option('--auth_url', default
=None, help='VIM url')
772 @click.option('--tenant', default
=None, help='VIM tenant name')
773 @click.option('--config', default
=None, help='VIM specific config parameters')
774 @click.option('--account_type', default
=None, help='VIM type')
775 @click.option('--description', default
=None, help='human readable description')
787 '''updates a VIM account
789 NAME: name or ID of the VIM account
793 vim
['name'] = newname
794 vim
['vim_user'] = user
795 vim
['vim_password'] = password
796 vim
['vim_url'] = auth_url
797 vim
['vim-tenant-name'] = tenant
798 vim
['config'] = config
799 vim
['vim_type'] = account_type
800 vim
['description'] = description
802 check_client_version(ctx
.obj
, ctx
.command
.name
)
803 ctx
.obj
.vim
.update(name
, vim
)
804 except ClientException
as inst
:
809 @cli.command(name
='vim-delete')
810 @click.argument('name')
812 def vim_delete(ctx
, name
):
813 '''deletes a VIM account
815 NAME: name or ID of the VIM account to be deleted
818 ctx
.obj
.vim
.delete(name
)
819 except ClientException
as inst
:
824 @cli.command(name
='vim-list')
825 @click.option('--ro_update/--no_ro_update',
827 help='update list from RO')
828 @click.option('--filter', default
=None,
829 help='restricts the list to the VIM accounts matching the filter')
831 def vim_list(ctx
, ro_update
, filter):
832 '''list all VIM accounts'''
834 check_client_version(ctx
.obj
, '--filter')
836 check_client_version(ctx
.obj
, '--ro_update', 'v1')
837 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
838 if fullclassname
== 'osmclient.sol005.client.Client':
839 resp
= ctx
.obj
.vim
.list(filter)
841 resp
= ctx
.obj
.vim
.list(ro_update
)
842 table
= PrettyTable(['vim name', 'uuid'])
844 table
.add_row([vim
['name'], vim
['uuid']])
849 @cli.command(name
='vim-show')
850 @click.argument('name')
852 def vim_show(ctx
, name
):
853 '''shows the details of a VIM account
855 NAME: name or ID of the VIM account
858 resp
= ctx
.obj
.vim
.get(name
)
859 except ClientException
as inst
:
863 table
= PrettyTable(['key', 'attribute'])
864 for k
, v
in resp
.items():
865 table
.add_row([k
, json
.dumps(v
, indent
=2)])
874 @cli.command(name
='upload-package')
875 @click.argument('filename')
877 def upload_package(ctx
, filename
):
878 '''uploads a VNF package or NS package
880 FILENAME: VNF or NS package file (tar.gz)
883 ctx
.obj
.package
.upload(filename
)
884 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
885 if fullclassname
!= 'osmclient.sol005.client.Client':
886 ctx
.obj
.package
.wait_for_upload(filename
)
887 except ClientException
as inst
:
892 @cli.command(name
='ns-scaling-show')
893 @click.argument('ns_name')
895 def show_ns_scaling(ctx
, ns_name
):
896 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
897 resp
= ctx
.obj
.ns
.list()
902 'operational status',
907 if ns_name
== ns
['name']:
908 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
909 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
910 for record
in scaling_records
:
911 if 'instance' in record
:
912 instances
= record
['instance']
913 for inst
in instances
:
915 [record
['scaling-group-name-ref'],
918 time
.strftime('%Y-%m-%d %H:%M:%S',
920 inst
['create-time'])),
926 @cli.command(name
='ns-scale')
927 @click.argument('ns_name')
928 @click.option('--ns_scale_group', prompt
=True)
929 @click.option('--index', prompt
=True)
931 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
932 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
933 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
936 @cli.command(name
='config-agent-list')
938 def config_agent_list(ctx
):
939 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
940 table
= PrettyTable(['name', 'account-type', 'details'])
941 for account
in ctx
.obj
.vca
.list():
944 account
['account-type'],
950 @cli.command(name
='config-agent-delete')
951 @click.argument('name')
953 def config_agent_delete(ctx
, name
):
955 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
956 ctx
.obj
.vca
.delete(name
)
957 except ClientException
as inst
:
962 @cli.command(name
='config-agent-add')
963 @click.option('--name',
965 @click.option('--account_type',
967 @click.option('--server',
969 @click.option('--user',
971 @click.option('--secret',
974 confirmation_prompt
=True)
976 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
978 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
979 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
980 except ClientException
as inst
:
984 @cli.command(name
='ro-dump')
987 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
988 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
989 table
= PrettyTable(['key', 'attribute'])
990 for k
, v
in resp
.items():
991 table
.add_row([k
, json
.dumps(v
, indent
=2)])
996 @cli.command(name
='vcs-list')
999 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1000 resp
= ctx
.obj
.utils
.get_vcs_info()
1001 table
= PrettyTable(['component name', 'state'])
1002 for component
in resp
:
1003 table
.add_row([component
['component_name'], component
['state']])
1008 if __name__
== '__main__':