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'''
221 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
222 resp
= ctx
.obj
.vnf
.list()
223 except ClientException
as inst
:
229 'operational status',
232 if 'mgmt-interface' not in vnfr
:
233 vnfr
['mgmt-interface'] = {}
234 vnfr
['mgmt-interface']['ip-address'] = None
238 vnfr
['operational-status'],
239 vnfr
['config-status']])
248 def nsd_show(ctx
, name
, literal
):
250 resp
= ctx
.obj
.nsd
.get(name
)
251 #resp = ctx.obj.nsd.get_individual(name)
252 except ClientException
as inst
:
257 print yaml
.safe_dump(resp
)
260 table
= PrettyTable(['field', 'value'])
261 for k
, v
in resp
.items():
262 table
.add_row([k
, json
.dumps(v
, indent
=2)])
267 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
268 @click.option('--literal', is_flag
=True,
269 help='print literally, no pretty table')
270 @click.argument('name')
272 def nsd_show1(ctx
, name
, literal
):
273 '''shows the content of a NSD
275 NAME: name or ID of the NSD/NSpkg
277 nsd_show(ctx
, name
, literal
)
280 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
281 @click.option('--literal', is_flag
=True,
282 help='print literally, no pretty table')
283 @click.argument('name')
285 def nsd_show2(ctx
, name
, literal
):
286 '''shows the content of a NSD
288 NAME: name or ID of the NSD/NSpkg
290 nsd_show(ctx
, name
, literal
)
293 def vnfd_show(ctx
, name
, literal
):
295 resp
= ctx
.obj
.vnfd
.get(name
)
296 #resp = ctx.obj.vnfd.get_individual(name)
297 except ClientException
as inst
:
302 print yaml
.safe_dump(resp
)
305 table
= PrettyTable(['field', 'value'])
306 for k
, v
in resp
.items():
307 table
.add_row([k
, json
.dumps(v
, indent
=2)])
312 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
313 @click.option('--literal', is_flag
=True,
314 help='print literally, no pretty table')
315 @click.argument('name')
317 def vnfd_show1(ctx
, name
, literal
):
318 '''shows the content of a VNFD
320 NAME: name or ID of the VNFD/VNFpkg
322 vnfd_show(ctx
, name
, literal
)
325 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
326 @click.option('--literal', is_flag
=True,
327 help='print literally, no pretty table')
328 @click.argument('name')
330 def vnfd_show2(ctx
, name
, literal
):
331 '''shows the content of a VNFD
333 NAME: name or ID of the VNFD/VNFpkg
335 vnfd_show(ctx
, name
, literal
)
338 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
339 @click.argument('name')
340 @click.option('--literal', is_flag
=True,
341 help='print literally, no pretty table')
342 @click.option('--filter', default
=None)
344 def ns_show(ctx
, name
, literal
, filter):
345 '''shows the info of a NS instance
347 NAME: name or ID of the NS instance
350 ns
= ctx
.obj
.ns
.get(name
)
351 except ClientException
as inst
:
356 print yaml
.safe_dump(resp
)
359 table
= PrettyTable(['field', 'value'])
361 for k
, v
in ns
.items():
362 if filter is None or filter in k
:
363 table
.add_row([k
, json
.dumps(v
, indent
=2)])
365 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
366 if fullclassname
!= 'osmclient.sol005.client.Client':
367 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
368 nsr_optdata
= nsopdata
['nsr:nsr']
369 for k
, v
in nsr_optdata
.items():
370 if filter is None or filter in k
:
371 table
.add_row([k
, json
.dumps(v
, indent
=2)])
376 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
377 @click.argument('name')
378 @click.option('--literal', is_flag
=True,
379 help='print literally, no pretty table')
380 @click.option('--filter', default
=None)
382 def vnf_show(ctx
, name
, literal
, filter):
383 '''shows the info of a VNF instance
385 NAME: name or ID of the VNF instance
388 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
389 resp
= ctx
.obj
.vnf
.get(name
)
390 except ClientException
as inst
:
395 print yaml
.safe_dump(resp
)
398 table
= PrettyTable(['field', 'value'])
399 for k
, v
in resp
.items():
400 if filter is None or filter in k
:
401 table
.add_row([k
, json
.dumps(v
, indent
=2)])
406 @cli.command(name
='vnf-monitoring-show')
407 @click.argument('vnf_name')
409 def vnf_monitoring_show(ctx
, vnf_name
):
411 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
412 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
413 except ClientException
as inst
:
417 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
423 monitor
['value-integer'],
429 @cli.command(name
='ns-monitoring-show')
430 @click.argument('ns_name')
432 def ns_monitoring_show(ctx
, ns_name
):
434 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
435 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
436 except ClientException
as inst
:
440 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
441 for key
, val
in resp
.items():
446 monitor
['value-integer'],
456 def nsd_create(ctx
, filename
, overwrite
):
458 check_client_version(ctx
.obj
, ctx
.command
.name
)
459 ctx
.obj
.nsd
.create(filename
, overwrite
)
460 except ClientException
as inst
:
465 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
466 @click.argument('filename')
467 @click.option('--overwrite', default
=None,
468 help='overwrites some fields in NSD')
470 def nsd_create1(ctx
, filename
, overwrite
):
471 '''creates a new NSD/NSpkg
473 FILENAME: NSD yaml file or NSpkg tar.gz file
475 nsd_create(ctx
, filename
, overwrite
)
478 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
479 @click.argument('filename')
480 @click.option('--overwrite', default
=None,
481 help='overwrites some fields in NSD')
483 def nsd_create2(ctx
, filename
, overwrite
):
484 '''creates a new NSD/NSpkg
486 FILENAME: NSD yaml file or NSpkg tar.gz file
488 nsd_create(ctx
, filename
, overwrite
)
491 def vnfd_create(ctx
, filename
, overwrite
):
493 check_client_version(ctx
.obj
, ctx
.command
.name
)
494 ctx
.obj
.vnfd
.create(filename
, overwrite
)
495 except ClientException
as inst
:
500 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
501 @click.argument('filename')
502 @click.option('--overwrite', default
=None,
503 help='overwrites some fields in VNFD')
505 def vnfd_create1(ctx
, filename
, overwrite
):
506 '''creates a new VNFD/VNFpkg
508 FILENAME: VNFD yaml file or VNFpkg tar.gz file
510 vnfd_create(ctx
, filename
, overwrite
)
513 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
514 @click.argument('filename')
515 @click.option('--overwrite', default
=None,
516 help='overwrites some fields in VNFD')
518 def vnfd_create2(ctx
, filename
, overwrite
):
519 '''creates a new VNFD/VNFpkg
521 FILENAME: VNFD yaml file or VNFpkg tar.gz file
523 vnfd_create(ctx
, filename
, overwrite
)
526 @cli.command(name
='ns-create')
527 @click.option('--ns_name',
529 @click.option('--nsd_name',
531 @click.option('--vim_account',
533 @click.option('--admin_status',
535 help='administration status')
536 @click.option('--ssh_keys',
538 help='comma separated list of keys to inject to vnfs')
539 @click.option('--config',
541 help='ns specific yaml configuration:\nvnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
542 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]')
551 '''creates a new NS instance'''
554 # check_client_version(ctx.obj, '--config', 'v1')
561 except ClientException
as inst
:
570 def nsd_update(ctx
, name
, content
):
572 check_client_version(ctx
.obj
, ctx
.command
.name
)
573 ctx
.obj
.nsd
.update(name
, content
)
574 except ClientException
as inst
:
578 @cli.command(name
='nsd-update', short_help
='updates a NSD/NSpkg')
579 @click.argument('name')
580 @click.option('--content', default
=None,
581 help='filename with the NSD/NSpkg replacing the current one')
583 def nsd_update1(ctx
, name
, content
):
584 '''updates a NSD/NSpkg
586 NAME: name or ID of the NSD/NSpkg
588 nsd_update(ctx
, name
, content
)
591 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
592 @click.argument('name')
593 @click.option('--content', default
=None,
594 help='filename with the NSD/NSpkg replacing the current one')
596 def nsd_update2(ctx
, name
, content
):
597 '''updates a NSD/NSpkg
599 NAME: name or ID of the NSD/NSpkg
601 nsd_update(ctx
, name
, content
)
604 def vnfd_update(ctx
, name
, content
):
606 check_client_version(ctx
.obj
, ctx
.command
.name
)
607 ctx
.obj
.vnfd
.update(name
, content
)
608 except ClientException
as inst
:
613 @cli.command(name
='vnfd-update', short_help
='updates a new VNFD/VNFpkg')
614 @click.argument('name')
615 @click.option('--content', default
=None,
616 help='filename with the VNFD/VNFpkg replacing the current one')
618 def vnfd_update1(ctx
, name
, content
):
619 '''updates a VNFD/VNFpkg
621 NAME: name or ID of the VNFD/VNFpkg
623 vnfd_update(ctx
, name
, content
)
626 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
627 @click.argument('name')
628 @click.option('--content', default
=None,
629 help='filename with the VNFD/VNFpkg replacing the current one')
631 def vnfd_update2(ctx
, name
, content
):
632 '''updates a VNFD/VNFpkg
634 NAME: VNFD yaml file or VNFpkg tar.gz file
636 vnfd_update(ctx
, name
, content
)
643 def nsd_delete(ctx
, name
):
645 ctx
.obj
.nsd
.delete(name
)
646 except ClientException
as inst
:
651 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
652 @click.argument('name')
654 def nsd_delete1(ctx
, name
):
655 '''deletes a NSD/NSpkg
657 NAME: name or ID of the NSD/NSpkg to be deleted
659 nsd_delete(ctx
, name
)
662 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
663 @click.argument('name')
665 def nsd_delete2(ctx
, name
):
666 '''deletes a NSD/NSpkg
668 NAME: name or ID of the NSD/NSpkg to be deleted
670 nsd_delete(ctx
, name
)
673 def vnfd_delete(ctx
, name
):
675 ctx
.obj
.vnfd
.delete(name
)
676 except ClientException
as inst
:
681 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
682 @click.argument('name')
684 def vnfd_delete1(ctx
, name
):
685 '''deletes a VNFD/VNFpkg
687 NAME: name or ID of the VNFD/VNFpkg to be deleted
689 vnfd_delete(ctx
, name
)
692 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
693 @click.argument('name')
695 def vnfd_delete2(ctx
, name
):
696 '''deletes a VNFD/VNFpkg
698 NAME: name or ID of the VNFD/VNFpkg to be deleted
700 vnfd_delete(ctx
, name
)
703 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
704 @click.argument('name')
706 def ns_delete(ctx
, name
):
707 '''deletes a NS instance
709 NAME: name or ID of the NS instance to be deleted
712 ctx
.obj
.ns
.delete(name
)
713 except ClientException
as inst
:
722 @cli.command(name
='vim-create')
723 @click.option('--name',
725 help='Name to create datacenter')
726 @click.option('--user',
729 @click.option('--password',
732 confirmation_prompt
=True,
734 @click.option('--auth_url',
737 @click.option('--tenant',
739 help='VIM tenant name')
740 @click.option('--config',
742 help='VIM specific config parameters')
743 @click.option('--account_type',
746 @click.option('--description',
747 default
='no description',
748 help='human readable description')
759 '''creates a new VIM account
762 vim
['vim-username'] = user
763 vim
['vim-password'] = password
764 vim
['vim-url'] = auth_url
765 vim
['vim-tenant-name'] = tenant
766 vim
['config'] = config
767 vim
['vim-type'] = account_type
768 vim
['description'] = description
770 ctx
.obj
.vim
.create(name
, vim
)
771 except ClientException
as inst
:
776 @cli.command(name
='vim-update', short_help
='updates a VIM account')
777 @click.argument('name')
778 @click.option('--newname', default
=None, help='New name for the VIM account')
779 @click.option('--user', default
=None, help='VIM username')
780 @click.option('--password', default
=None, help='VIM password')
781 @click.option('--auth_url', default
=None, help='VIM url')
782 @click.option('--tenant', default
=None, help='VIM tenant name')
783 @click.option('--config', default
=None, help='VIM specific config parameters')
784 @click.option('--account_type', default
=None, help='VIM type')
785 @click.option('--description', default
=None, help='human readable description')
797 '''updates a VIM account
799 NAME: name or ID of the VIM account
803 vim
['name'] = newname
804 vim
['vim_user'] = user
805 vim
['vim_password'] = password
806 vim
['vim_url'] = auth_url
807 vim
['vim-tenant-name'] = tenant
808 vim
['config'] = config
809 vim
['vim_type'] = account_type
810 vim
['description'] = description
812 check_client_version(ctx
.obj
, ctx
.command
.name
)
813 ctx
.obj
.vim
.update(name
, vim
)
814 except ClientException
as inst
:
819 @cli.command(name
='vim-delete')
820 @click.argument('name')
822 def vim_delete(ctx
, name
):
823 '''deletes a VIM account
825 NAME: name or ID of the VIM account to be deleted
828 ctx
.obj
.vim
.delete(name
)
829 except ClientException
as inst
:
834 @cli.command(name
='vim-list')
835 @click.option('--ro_update/--no_ro_update',
837 help='update list from RO')
838 @click.option('--filter', default
=None,
839 help='restricts the list to the VIM accounts matching the filter')
841 def vim_list(ctx
, ro_update
, filter):
842 '''list all VIM accounts'''
844 check_client_version(ctx
.obj
, '--filter')
846 check_client_version(ctx
.obj
, '--ro_update', 'v1')
847 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
848 if fullclassname
== 'osmclient.sol005.client.Client':
849 resp
= ctx
.obj
.vim
.list(filter)
851 resp
= ctx
.obj
.vim
.list(ro_update
)
852 table
= PrettyTable(['vim name', 'uuid'])
854 table
.add_row([vim
['name'], vim
['uuid']])
859 @cli.command(name
='vim-show')
860 @click.argument('name')
862 def vim_show(ctx
, name
):
863 '''shows the details of a VIM account
865 NAME: name or ID of the VIM account
868 resp
= ctx
.obj
.vim
.get(name
)
869 except ClientException
as inst
:
873 table
= PrettyTable(['key', 'attribute'])
874 for k
, v
in resp
.items():
875 table
.add_row([k
, json
.dumps(v
, indent
=2)])
884 @cli.command(name
='upload-package')
885 @click.argument('filename')
887 def upload_package(ctx
, filename
):
888 '''uploads a VNF package or NS package
890 FILENAME: VNF or NS package file (tar.gz)
893 ctx
.obj
.package
.upload(filename
)
894 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
895 if fullclassname
!= 'osmclient.sol005.client.Client':
896 ctx
.obj
.package
.wait_for_upload(filename
)
897 except ClientException
as inst
:
902 @cli.command(name
='ns-scaling-show')
903 @click.argument('ns_name')
905 def show_ns_scaling(ctx
, ns_name
):
906 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
907 resp
= ctx
.obj
.ns
.list()
912 'operational status',
917 if ns_name
== ns
['name']:
918 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
919 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
920 for record
in scaling_records
:
921 if 'instance' in record
:
922 instances
= record
['instance']
923 for inst
in instances
:
925 [record
['scaling-group-name-ref'],
928 time
.strftime('%Y-%m-%d %H:%M:%S',
930 inst
['create-time'])),
936 @cli.command(name
='ns-scale')
937 @click.argument('ns_name')
938 @click.option('--ns_scale_group', prompt
=True)
939 @click.option('--index', prompt
=True)
941 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
942 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
943 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
946 @cli.command(name
='config-agent-list')
948 def config_agent_list(ctx
):
949 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
950 table
= PrettyTable(['name', 'account-type', 'details'])
951 for account
in ctx
.obj
.vca
.list():
954 account
['account-type'],
960 @cli.command(name
='config-agent-delete')
961 @click.argument('name')
963 def config_agent_delete(ctx
, name
):
965 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
966 ctx
.obj
.vca
.delete(name
)
967 except ClientException
as inst
:
972 @cli.command(name
='config-agent-add')
973 @click.option('--name',
975 @click.option('--account_type',
977 @click.option('--server',
979 @click.option('--user',
981 @click.option('--secret',
984 confirmation_prompt
=True)
986 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
988 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
989 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
990 except ClientException
as inst
:
994 @cli.command(name
='ro-dump')
997 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
998 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
999 table
= PrettyTable(['key', 'attribute'])
1000 for k
, v
in resp
.items():
1001 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1006 @cli.command(name
='vcs-list')
1009 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1010 resp
= ctx
.obj
.utils
.get_vcs_info()
1011 table
= PrettyTable(['component name', 'state'])
1012 for component
in resp
:
1013 table
.add_row([component
['component_name'], component
['state']])
1018 if __name__
== '__main__':