16ac7d7bef86d1864d82e2440c7e7fa2dd088449
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')
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':
120 nsr_name
= nsr
['name']
123 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
124 nsr
= nsopdata
['nsr:nsr']
125 nsr_name
= nsr
['name-ref']
126 nsr_id
= nsr
['ns-instance-config-ref']
127 opstatus
= nsr
['operational-status'] if 'operational-status' in nsr
else 'Not found'
128 configstatus
= nsr
['config-status'] if 'config-status' in nsr
else 'Not found'
129 if configstatus
== "config_not_needed":
130 configstatus
= "configured (no charms)"
140 def nsd_list(ctx
, filter):
142 check_client_version(ctx
.obj
, '--filter')
143 resp
= ctx
.obj
.nsd
.list(filter)
145 resp
= ctx
.obj
.nsd
.list()
146 #print yaml.safe_dump(resp)
147 table
= PrettyTable(['nsd name', 'id'])
148 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
149 if fullclassname
== 'osmclient.sol005.client.Client':
151 name
= ns
['name'] if 'name' in ns
else '-'
152 table
.add_row([name
, ns
['_id']])
155 table
.add_row([ns
['name'], ns
['id']])
160 @cli.command(name
='nsd-list')
161 @click.option('--filter', default
=None,
162 help='restricts the list to the NSD/NSpkg matching the filter')
164 def nsd_list1(ctx
, filter):
165 '''list all NSD/NSpkg in the system'''
169 @cli.command(name
='nspkg-list')
170 @click.option('--filter', default
=None,
171 help='restricts the list to the NSD/NSpkg matching the filter')
173 def nsd_list2(ctx
, filter):
174 '''list all NSD/NSpkg in the system'''
178 def vnfd_list(ctx
, filter):
180 check_client_version(ctx
.obj
, '--filter')
181 resp
= ctx
.obj
.vnfd
.list(filter)
183 resp
= ctx
.obj
.vnfd
.list()
184 #print yaml.safe_dump(resp)
185 table
= PrettyTable(['vnfd name', 'id'])
186 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
187 if fullclassname
== 'osmclient.sol005.client.Client':
189 name
= vnfd
['name'] if 'name' in vnfd
else '-'
190 table
.add_row([name
, vnfd
['_id']])
193 table
.add_row([vnfd
['name'], vnfd
['id']])
198 @cli.command(name
='vnfd-list')
199 @click.option('--filter', default
=None,
200 help='restricts the list to the VNFD/VNFpkg matching the filter')
202 def vnfd_list1(ctx
, filter):
203 '''list all VNFD/VNFpkg in the system'''
204 vnfd_list(ctx
,filter)
207 @cli.command(name
='vnfpkg-list')
208 @click.option('--filter', default
=None,
209 help='restricts the list to the VNFD/VNFpkg matching the filter')
211 def vnfd_list2(ctx
, filter):
212 '''list all VNFD/VNFpkg in the system'''
213 vnfd_list(ctx
,filter)
216 @cli.command(name
='vnf-list')
219 ''' list all VNF instances'''
220 resp
= ctx
.obj
.vnf
.list()
224 'operational status',
227 if 'mgmt-interface' not in vnfr
:
228 vnfr
['mgmt-interface'] = {}
229 vnfr
['mgmt-interface']['ip-address'] = None
233 vnfr
['operational-status'],
234 vnfr
['config-status']])
243 def nsd_show(ctx
, name
, literal
):
245 resp
= ctx
.obj
.nsd
.get(name
)
246 #resp = ctx.obj.nsd.get_individual(name)
247 except ClientException
as inst
:
252 print yaml
.safe_dump(resp
)
255 table
= PrettyTable(['field', 'value'])
256 for k
, v
in resp
.items():
257 table
.add_row([k
, json
.dumps(v
, indent
=2)])
262 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
263 @click.option('--literal', is_flag
=True,
264 help='print literally, no pretty table')
265 @click.argument('name')
267 def nsd_show1(ctx
, name
, literal
):
268 '''shows the content of a NSD
270 NAME: name or ID of the NSD/NSpkg
272 nsd_show(ctx
, name
, literal
)
275 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
276 @click.option('--literal', is_flag
=True,
277 help='print literally, no pretty table')
278 @click.argument('name')
280 def nsd_show2(ctx
, name
, literal
):
281 '''shows the content of a NSD
283 NAME: name or ID of the NSD/NSpkg
285 nsd_show(ctx
, name
, literal
)
288 def vnfd_show(ctx
, name
, literal
):
290 resp
= ctx
.obj
.vnfd
.get(name
)
291 #resp = ctx.obj.vnfd.get_individual(name)
292 except ClientException
as inst
:
297 print yaml
.safe_dump(resp
)
300 table
= PrettyTable(['field', 'value'])
301 for k
, v
in resp
.items():
302 table
.add_row([k
, json
.dumps(v
, indent
=2)])
307 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
308 @click.option('--literal', is_flag
=True,
309 help='print literally, no pretty table')
310 @click.argument('name')
312 def vnfd_show1(ctx
, name
, literal
):
313 '''shows the content of a VNFD
315 NAME: name or ID of the VNFD/VNFpkg
317 vnfd_show(ctx
, name
, literal
)
320 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
321 @click.option('--literal', is_flag
=True,
322 help='print literally, no pretty table')
323 @click.argument('name')
325 def vnfd_show2(ctx
, name
, literal
):
326 '''shows the content of a VNFD
328 NAME: name or ID of the VNFD/VNFpkg
330 vnfd_show(ctx
, name
, literal
)
333 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
334 @click.argument('name')
335 @click.option('--literal', is_flag
=True,
336 help='print literally, no pretty table')
337 @click.option('--filter', default
=None)
339 def ns_show(ctx
, name
, literal
, filter):
340 '''shows the info of a NS instance
342 NAME: name or ID of the NS instance
345 ns
= ctx
.obj
.ns
.get(name
)
346 except ClientException
as inst
:
351 print yaml
.safe_dump(resp
)
354 table
= PrettyTable(['field', 'value'])
356 for k
, v
in ns
.items():
357 if filter is None or filter in k
:
358 table
.add_row([k
, json
.dumps(v
, indent
=2)])
360 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
361 if fullclassname
!= 'osmclient.sol005.client.Client':
362 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
363 nsr_optdata
= nsopdata
['nsr:nsr']
364 for k
, v
in nsr_optdata
.items():
365 if filter is None or filter in k
:
366 table
.add_row([k
, json
.dumps(v
, indent
=2)])
371 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
372 @click.argument('name')
373 @click.option('--literal', is_flag
=True,
374 help='print literally, no pretty table')
375 @click.option('--filter', default
=None)
377 def vnf_show(ctx
, name
, literal
, filter):
378 '''shows the info of a VNF instance
380 NAME: name or ID of the VNF instance
383 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
384 resp
= ctx
.obj
.vnf
.get(name
)
385 except ClientException
as inst
:
390 print yaml
.safe_dump(resp
)
393 table
= PrettyTable(['field', 'value'])
394 for k
, v
in resp
.items():
395 if filter is None or filter in k
:
396 table
.add_row([k
, json
.dumps(v
, indent
=2)])
401 @cli.command(name
='vnf-monitoring-show')
402 @click.argument('vnf_name')
404 def vnf_monitoring_show(ctx
, vnf_name
):
406 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
407 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
408 except ClientException
as inst
:
412 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
418 monitor
['value-integer'],
424 @cli.command(name
='ns-monitoring-show')
425 @click.argument('ns_name')
427 def ns_monitoring_show(ctx
, ns_name
):
429 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
430 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
431 except ClientException
as inst
:
435 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
436 for key
, val
in resp
.items():
441 monitor
['value-integer'],
451 def nsd_create(ctx
, filename
, overwrite
):
453 check_client_version(ctx
.obj
, ctx
.command
.name
)
454 ctx
.obj
.nsd
.create(filename
, overwrite
)
455 except ClientException
as inst
:
460 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
461 @click.argument('filename')
462 @click.option('--overwrite', default
=None,
463 help='overwrites some fields in NSD')
465 def nsd_create1(ctx
, filename
, overwrite
):
466 '''creates a new NSD/NSpkg
468 FILENAME: NSD yaml file or NSpkg tar.gz file
470 nsd_create(ctx
, filename
, overwrite
)
473 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
474 @click.argument('filename')
475 @click.option('--overwrite', default
=None,
476 help='overwrites some fields in NSD')
478 def nsd_create2(ctx
, filename
, overwrite
):
479 '''creates a new NSD/NSpkg
481 FILENAME: NSD yaml file or NSpkg tar.gz file
483 nsd_create(ctx
, filename
, overwrite
)
486 def vnfd_create(ctx
, filename
, overwrite
):
488 check_client_version(ctx
.obj
, ctx
.command
.name
)
489 ctx
.obj
.vnfd
.create(filename
, overwrite
)
490 except ClientException
as inst
:
495 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
496 @click.argument('filename')
497 @click.option('--overwrite', default
=None,
498 help='overwrites some fields in VNFD')
500 def vnfd_create1(ctx
, filename
, overwrite
):
501 '''creates a new VNFD/VNFpkg
503 FILENAME: VNFD yaml file or VNFpkg tar.gz file
505 vnfd_create(ctx
, filename
, overwrite
)
508 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
509 @click.argument('filename')
510 @click.option('--overwrite', default
=None,
511 help='overwrites some fields in VNFD')
513 def vnfd_create2(ctx
, filename
, overwrite
):
514 '''creates a new VNFD/VNFpkg
516 FILENAME: VNFD yaml file or VNFpkg tar.gz file
518 vnfd_create(ctx
, filename
, overwrite
)
521 @cli.command(name
='ns-create')
522 @click.option('--ns_name',
524 @click.option('--nsd_name',
526 @click.option('--vim_account',
528 @click.option('--admin_status',
530 help='administration status')
531 @click.option('--ssh_keys',
533 help='comma separated list of keys to inject to vnfs')
534 @click.option('--config',
536 help='ns specific yaml configuration:\nvnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
537 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]')
546 '''creates a new NS instance'''
549 # check_client_version(ctx.obj, '--config', 'v1')
556 except ClientException
as inst
:
565 def nsd_update(ctx
, name
, content
):
567 check_client_version(ctx
.obj
, ctx
.command
.name
)
568 ctx
.obj
.nsd
.update(name
, content
)
569 except ClientException
as inst
:
573 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
574 @click.argument('name')
575 @click.option('--content', default
=None,
576 help='filename with the NSD/NSpkg replacing the current one')
578 def nsd_update1(ctx
, name
, content
):
579 '''updates a NSD/NSpkg
581 NAME: name or ID of the NSD/NSpkg
583 nsd_update(ctx
, name
, content
)
586 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
587 @click.argument('name')
588 @click.option('--content', default
=None,
589 help='filename with the NSD/NSpkg replacing the current one')
591 def nsd_update2(ctx
, name
, content
):
592 '''updates a NSD/NSpkg
594 NAME: name or ID of the NSD/NSpkg
596 nsd_update(ctx
, name
, content
)
599 def vnfd_update(ctx
, name
, content
):
601 check_client_version(ctx
.obj
, ctx
.command
.name
)
602 ctx
.obj
.vnfd
.update(name
, content
)
603 except ClientException
as inst
:
608 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
609 @click.argument('name')
610 @click.option('--content', default
=None,
611 help='filename with the VNFD/VNFpkg replacing the current one')
613 def vnfd_update1(ctx
, name
, content
):
614 '''updates a VNFD/VNFpkg
616 NAME: name or ID of the VNFD/VNFpkg
618 vnfd_update(ctx
, name
, content
)
621 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
622 @click.argument('name')
623 @click.option('--content', default
=None,
624 help='filename with the VNFD/VNFpkg replacing the current one')
626 def vnfd_update2(ctx
, name
, content
):
627 '''updates a VNFD/VNFpkg
629 NAME: VNFD yaml file or VNFpkg tar.gz file
631 vnfd_update(ctx
, name
, content
)
638 def nsd_delete(ctx
, name
):
640 ctx
.obj
.nsd
.delete(name
)
641 except ClientException
as inst
:
646 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
647 @click.argument('name')
649 def nsd_delete1(ctx
, name
):
650 '''deletes a NSD/NSpkg
652 NAME: name or ID of the NSD/NSpkg to be deleted
654 nsd_delete(ctx
, name
)
657 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
658 @click.argument('name')
660 def nsd_delete2(ctx
, name
):
661 '''deletes a NSD/NSpkg
663 NAME: name or ID of the NSD/NSpkg to be deleted
665 nsd_delete(ctx
, name
)
668 def vnfd_delete(ctx
, name
):
670 ctx
.obj
.vnfd
.delete(name
)
671 except ClientException
as inst
:
676 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
677 @click.argument('name')
679 def vnfd_delete1(ctx
, name
):
680 '''deletes a VNFD/VNFpkg
682 NAME: name or ID of the VNFD/VNFpkg to be deleted
684 vnfd_delete(ctx
, name
)
687 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
688 @click.argument('name')
690 def vnfd_delete2(ctx
, name
):
691 '''deletes a VNFD/VNFpkg
693 NAME: name or ID of the VNFD/VNFpkg to be deleted
695 vnfd_delete(ctx
, name
)
698 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
699 @click.argument('name')
701 def ns_delete(ctx
, name
):
702 '''deletes a NS instance
704 NAME: name or ID of the NS instance to be deleted
707 ctx
.obj
.ns
.delete(name
)
708 except ClientException
as inst
:
717 @cli.command(name
='vim-create')
718 @click.option('--name',
720 help='Name to create datacenter')
721 @click.option('--user',
724 @click.option('--password',
727 confirmation_prompt
=True,
729 @click.option('--auth_url',
732 @click.option('--tenant',
734 help='VIM tenant name')
735 @click.option('--config',
737 help='VIM specific config parameters')
738 @click.option('--account_type',
741 @click.option('--description',
742 default
='no description',
743 help='human readable description')
754 '''creates a new VIM account
757 vim
['vim-username'] = user
758 vim
['vim-password'] = password
759 vim
['vim-url'] = auth_url
760 vim
['vim-tenant-name'] = tenant
761 vim
['config'] = config
762 vim
['vim-type'] = account_type
763 vim
['description'] = description
765 ctx
.obj
.vim
.create(name
, vim
)
766 except ClientException
as inst
:
771 @cli.command(name
='vim-update', short_help
='updates a VIM account')
772 @click.argument('name')
773 @click.option('--newname', default
=None, help='New name for the VIM account')
774 @click.option('--user', default
=None, help='VIM username')
775 @click.option('--password', default
=None, help='VIM password')
776 @click.option('--auth_url', default
=None, help='VIM url')
777 @click.option('--tenant', default
=None, help='VIM tenant name')
778 @click.option('--config', default
=None, help='VIM specific config parameters')
779 @click.option('--account_type', default
=None, help='VIM type')
780 @click.option('--description', default
=None, help='human readable description')
792 '''updates a VIM account
794 NAME: name or ID of the VIM account
798 vim
['name'] = newname
799 vim
['vim_user'] = user
800 vim
['vim_password'] = password
801 vim
['vim_url'] = auth_url
802 vim
['vim-tenant-name'] = tenant
803 vim
['config'] = config
804 vim
['vim_type'] = account_type
805 vim
['description'] = description
807 check_client_version(ctx
.obj
, ctx
.command
.name
)
808 ctx
.obj
.vim
.update(name
, vim
)
809 except ClientException
as inst
:
814 @cli.command(name
='vim-delete')
815 @click.argument('name')
817 def vim_delete(ctx
, name
):
818 '''deletes a VIM account
820 NAME: name or ID of the VIM account to be deleted
823 ctx
.obj
.vim
.delete(name
)
824 except ClientException
as inst
:
829 @cli.command(name
='vim-list')
830 @click.option('--ro_update/--no_ro_update',
832 help='update list from RO')
833 @click.option('--filter', default
=None,
834 help='restricts the list to the VIM accounts matching the filter')
836 def vim_list(ctx
, ro_update
, filter):
837 '''list all VIM accounts'''
839 check_client_version(ctx
.obj
, '--filter')
841 check_client_version(ctx
.obj
, '--ro_update', 'v1')
842 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
843 if fullclassname
== 'osmclient.sol005.client.Client':
844 resp
= ctx
.obj
.vim
.list(filter)
846 resp
= ctx
.obj
.vim
.list(ro_update
)
847 table
= PrettyTable(['vim name', 'uuid'])
849 table
.add_row([vim
['name'], vim
['uuid']])
854 @cli.command(name
='vim-show')
855 @click.argument('name')
857 def vim_show(ctx
, name
):
858 '''shows the details of a VIM account
860 NAME: name or ID of the VIM account
863 resp
= ctx
.obj
.vim
.get(name
)
864 except ClientException
as inst
:
868 table
= PrettyTable(['key', 'attribute'])
869 for k
, v
in resp
.items():
870 table
.add_row([k
, json
.dumps(v
, indent
=2)])
879 @cli.command(name
='upload-package')
880 @click.argument('filename')
882 def upload_package(ctx
, filename
):
883 '''uploads a VNF package or NS package
885 FILENAME: VNF or NS package file (tar.gz)
888 ctx
.obj
.package
.upload(filename
)
889 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
890 if fullclassname
!= 'osmclient.sol005.client.Client':
891 ctx
.obj
.package
.wait_for_upload(filename
)
892 except ClientException
as inst
:
897 @cli.command(name
='ns-scaling-show')
898 @click.argument('ns_name')
900 def show_ns_scaling(ctx
, ns_name
):
901 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
902 resp
= ctx
.obj
.ns
.list()
907 'operational status',
912 if ns_name
== ns
['name']:
913 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
914 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
915 for record
in scaling_records
:
916 if 'instance' in record
:
917 instances
= record
['instance']
918 for inst
in instances
:
920 [record
['scaling-group-name-ref'],
923 time
.strftime('%Y-%m-%d %H:%M:%S',
925 inst
['create-time'])),
931 @cli.command(name
='ns-scale')
932 @click.argument('ns_name')
933 @click.option('--ns_scale_group', prompt
=True)
934 @click.option('--index', prompt
=True)
936 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
937 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
938 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
941 @cli.command(name
='config-agent-list')
943 def config_agent_list(ctx
):
944 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
945 table
= PrettyTable(['name', 'account-type', 'details'])
946 for account
in ctx
.obj
.vca
.list():
949 account
['account-type'],
955 @cli.command(name
='config-agent-delete')
956 @click.argument('name')
958 def config_agent_delete(ctx
, name
):
960 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
961 ctx
.obj
.vca
.delete(name
)
962 except ClientException
as inst
:
967 @cli.command(name
='config-agent-add')
968 @click.option('--name',
970 @click.option('--account_type',
972 @click.option('--server',
974 @click.option('--user',
976 @click.option('--secret',
979 confirmation_prompt
=True)
981 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
983 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
984 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
985 except ClientException
as inst
:
989 @cli.command(name
='ro-dump')
992 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
993 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
994 table
= PrettyTable(['key', 'attribute'])
995 for k
, v
in resp
.items():
996 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1001 @cli.command(name
='vcs-list')
1004 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1005 resp
= ctx
.obj
.utils
.get_vcs_info()
1006 table
= PrettyTable(['component name', 'state'])
1007 for component
in resp
:
1008 table
.add_row([component
['component_name'], component
['state']])
1013 if __name__
== '__main__':