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',
118 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
119 if fullclassname
== 'osmclient.sol005.client.Client':
121 nsr_name
= nsr
['name']
124 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
125 nsr
= nsopdata
['nsr:nsr']
126 nsr_name
= nsr
['name-ref']
127 nsr_id
= nsr
['ns-instance-config-ref']
128 opstatus
= nsr
['operational-status'] if 'operational-status' in nsr
else 'Not found'
129 configstatus
= nsr
['config-status'] if 'config-status' in nsr
else 'Not found'
130 detailed_status
= nsr
['detailed-status'] if 'detailed-status' in nsr
else 'Not found'
131 if configstatus
== "config_not_needed":
132 configstatus
= "configured (no charms)"
143 def nsd_list(ctx
, filter):
145 check_client_version(ctx
.obj
, '--filter')
146 resp
= ctx
.obj
.nsd
.list(filter)
148 resp
= ctx
.obj
.nsd
.list()
149 #print yaml.safe_dump(resp)
150 table
= PrettyTable(['nsd name', 'id'])
151 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
152 if fullclassname
== 'osmclient.sol005.client.Client':
154 name
= ns
['name'] if 'name' in ns
else '-'
155 table
.add_row([name
, ns
['_id']])
158 table
.add_row([ns
['name'], ns
['id']])
163 @cli.command(name
='nsd-list')
164 @click.option('--filter', default
=None,
165 help='restricts the list to the NSD/NSpkg matching the filter')
167 def nsd_list1(ctx
, filter):
168 '''list all NSD/NSpkg in the system'''
172 @cli.command(name
='nspkg-list')
173 @click.option('--filter', default
=None,
174 help='restricts the list to the NSD/NSpkg matching the filter')
176 def nsd_list2(ctx
, filter):
177 '''list all NSD/NSpkg in the system'''
181 def vnfd_list(ctx
, filter):
183 check_client_version(ctx
.obj
, '--filter')
184 resp
= ctx
.obj
.vnfd
.list(filter)
186 resp
= ctx
.obj
.vnfd
.list()
187 #print yaml.safe_dump(resp)
188 table
= PrettyTable(['vnfd name', 'id'])
189 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
190 if fullclassname
== 'osmclient.sol005.client.Client':
192 name
= vnfd
['name'] if 'name' in vnfd
else '-'
193 table
.add_row([name
, vnfd
['_id']])
196 table
.add_row([vnfd
['name'], vnfd
['id']])
201 @cli.command(name
='vnfd-list')
202 @click.option('--filter', default
=None,
203 help='restricts the list to the VNFD/VNFpkg matching the filter')
205 def vnfd_list1(ctx
, filter):
206 '''list all VNFD/VNFpkg in the system'''
207 vnfd_list(ctx
,filter)
210 @cli.command(name
='vnfpkg-list')
211 @click.option('--filter', default
=None,
212 help='restricts the list to the VNFD/VNFpkg matching the filter')
214 def vnfd_list2(ctx
, filter):
215 '''list all VNFD/VNFpkg in the system'''
216 vnfd_list(ctx
,filter)
219 @cli.command(name
='vnf-list')
222 ''' list all VNF instances'''
224 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
225 resp
= ctx
.obj
.vnf
.list()
226 except ClientException
as inst
:
232 'operational status',
235 if 'mgmt-interface' not in vnfr
:
236 vnfr
['mgmt-interface'] = {}
237 vnfr
['mgmt-interface']['ip-address'] = None
241 vnfr
['operational-status'],
242 vnfr
['config-status']])
251 def nsd_show(ctx
, name
, literal
):
253 resp
= ctx
.obj
.nsd
.get(name
)
254 #resp = ctx.obj.nsd.get_individual(name)
255 except ClientException
as inst
:
260 print yaml
.safe_dump(resp
)
263 table
= PrettyTable(['field', 'value'])
264 for k
, v
in resp
.items():
265 table
.add_row([k
, json
.dumps(v
, indent
=2)])
270 @cli.command(name
='nsd-show', short_help
='shows the content of a NSD')
271 @click.option('--literal', is_flag
=True,
272 help='print literally, no pretty table')
273 @click.argument('name')
275 def nsd_show1(ctx
, name
, literal
):
276 '''shows the content of a NSD
278 NAME: name or ID of the NSD/NSpkg
280 nsd_show(ctx
, name
, literal
)
283 @cli.command(name
='nspkg-show', short_help
='shows the content of a NSD')
284 @click.option('--literal', is_flag
=True,
285 help='print literally, no pretty table')
286 @click.argument('name')
288 def nsd_show2(ctx
, name
, literal
):
289 '''shows the content of a NSD
291 NAME: name or ID of the NSD/NSpkg
293 nsd_show(ctx
, name
, literal
)
296 def vnfd_show(ctx
, name
, literal
):
298 resp
= ctx
.obj
.vnfd
.get(name
)
299 #resp = ctx.obj.vnfd.get_individual(name)
300 except ClientException
as inst
:
305 print yaml
.safe_dump(resp
)
308 table
= PrettyTable(['field', 'value'])
309 for k
, v
in resp
.items():
310 table
.add_row([k
, json
.dumps(v
, indent
=2)])
315 @cli.command(name
='vnfd-show', short_help
='shows the content of a VNFD')
316 @click.option('--literal', is_flag
=True,
317 help='print literally, no pretty table')
318 @click.argument('name')
320 def vnfd_show1(ctx
, name
, literal
):
321 '''shows the content of a VNFD
323 NAME: name or ID of the VNFD/VNFpkg
325 vnfd_show(ctx
, name
, literal
)
328 @cli.command(name
='vnfpkg-show', short_help
='shows the content of a VNFD')
329 @click.option('--literal', is_flag
=True,
330 help='print literally, no pretty table')
331 @click.argument('name')
333 def vnfd_show2(ctx
, name
, literal
):
334 '''shows the content of a VNFD
336 NAME: name or ID of the VNFD/VNFpkg
338 vnfd_show(ctx
, name
, literal
)
341 @cli.command(name
='ns-show', short_help
='shows the info of a NS instance')
342 @click.argument('name')
343 @click.option('--literal', is_flag
=True,
344 help='print literally, no pretty table')
345 @click.option('--filter', default
=None)
347 def ns_show(ctx
, name
, literal
, filter):
348 '''shows the info of a NS instance
350 NAME: name or ID of the NS instance
353 ns
= ctx
.obj
.ns
.get(name
)
354 except ClientException
as inst
:
359 print yaml
.safe_dump(resp
)
362 table
= PrettyTable(['field', 'value'])
364 for k
, v
in ns
.items():
365 if filter is None or filter in k
:
366 table
.add_row([k
, json
.dumps(v
, indent
=2)])
368 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
369 if fullclassname
!= 'osmclient.sol005.client.Client':
370 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
371 nsr_optdata
= nsopdata
['nsr:nsr']
372 for k
, v
in nsr_optdata
.items():
373 if filter is None or filter in k
:
374 table
.add_row([k
, json
.dumps(v
, indent
=2)])
379 @cli.command(name
='vnf-show', short_help
='shows the info of a VNF instance')
380 @click.argument('name')
381 @click.option('--literal', is_flag
=True,
382 help='print literally, no pretty table')
383 @click.option('--filter', default
=None)
385 def vnf_show(ctx
, name
, literal
, filter):
386 '''shows the info of a VNF instance
388 NAME: name or ID of the VNF instance
391 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
392 resp
= ctx
.obj
.vnf
.get(name
)
393 except ClientException
as inst
:
398 print yaml
.safe_dump(resp
)
401 table
= PrettyTable(['field', 'value'])
402 for k
, v
in resp
.items():
403 if filter is None or filter in k
:
404 table
.add_row([k
, json
.dumps(v
, indent
=2)])
409 @cli.command(name
='vnf-monitoring-show')
410 @click.argument('vnf_name')
412 def vnf_monitoring_show(ctx
, vnf_name
):
414 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
415 resp
= ctx
.obj
.vnf
.get_monitoring(vnf_name
)
416 except ClientException
as inst
:
420 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
426 monitor
['value-integer'],
432 @cli.command(name
='ns-monitoring-show')
433 @click.argument('ns_name')
435 def ns_monitoring_show(ctx
, ns_name
):
437 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
438 resp
= ctx
.obj
.ns
.get_monitoring(ns_name
)
439 except ClientException
as inst
:
443 table
= PrettyTable(['vnf name', 'monitoring name', 'value', 'units'])
444 for key
, val
in resp
.items():
449 monitor
['value-integer'],
459 def nsd_create(ctx
, filename
, overwrite
):
461 check_client_version(ctx
.obj
, ctx
.command
.name
)
462 ctx
.obj
.nsd
.create(filename
, overwrite
)
463 except ClientException
as inst
:
468 @cli.command(name
='nsd-create', short_help
='creates a new NSD/NSpkg')
469 @click.argument('filename')
470 @click.option('--overwrite', default
=None,
471 help='overwrites some fields in NSD')
473 def nsd_create1(ctx
, filename
, overwrite
):
474 '''creates a new NSD/NSpkg
476 FILENAME: NSD yaml file or NSpkg tar.gz file
478 nsd_create(ctx
, filename
, overwrite
)
481 @cli.command(name
='nspkg-create', short_help
='creates a new NSD/NSpkg')
482 @click.argument('filename')
483 @click.option('--overwrite', default
=None,
484 help='overwrites some fields in NSD')
486 def nsd_create2(ctx
, filename
, overwrite
):
487 '''creates a new NSD/NSpkg
489 FILENAME: NSD yaml file or NSpkg tar.gz file
491 nsd_create(ctx
, filename
, overwrite
)
494 def vnfd_create(ctx
, filename
, overwrite
):
496 check_client_version(ctx
.obj
, ctx
.command
.name
)
497 ctx
.obj
.vnfd
.create(filename
, overwrite
)
498 except ClientException
as inst
:
503 @cli.command(name
='vnfd-create', short_help
='creates a new VNFD/VNFpkg')
504 @click.argument('filename')
505 @click.option('--overwrite', default
=None,
506 help='overwrites some fields in VNFD')
508 def vnfd_create1(ctx
, filename
, overwrite
):
509 '''creates a new VNFD/VNFpkg
511 FILENAME: VNFD yaml file or VNFpkg tar.gz file
513 vnfd_create(ctx
, filename
, overwrite
)
516 @cli.command(name
='vnfpkg-create', short_help
='creates a new VNFD/VNFpkg')
517 @click.argument('filename')
518 @click.option('--overwrite', default
=None,
519 help='overwrites some fields in VNFD')
521 def vnfd_create2(ctx
, filename
, overwrite
):
522 '''creates a new VNFD/VNFpkg
524 FILENAME: VNFD yaml file or VNFpkg tar.gz file
526 vnfd_create(ctx
, filename
, overwrite
)
529 @cli.command(name
='ns-create')
530 @click.option('--ns_name',
532 @click.option('--nsd_name',
534 @click.option('--vim_account',
536 @click.option('--admin_status',
538 help='administration status')
539 @click.option('--ssh_keys',
541 help='comma separated list of keys to inject to vnfs')
542 @click.option('--config',
544 help='ns specific yaml configuration:\nvnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
545 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]')
554 '''creates a new NS instance'''
557 # check_client_version(ctx.obj, '--config', 'v1')
564 except ClientException
as inst
:
573 def nsd_update(ctx
, name
, content
):
575 check_client_version(ctx
.obj
, ctx
.command
.name
)
576 ctx
.obj
.nsd
.update(name
, content
)
577 except ClientException
as inst
:
581 @cli.command(name
='nsd-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_update1(ctx
, name
, content
):
587 '''updates a NSD/NSpkg
589 NAME: name or ID of the NSD/NSpkg
591 nsd_update(ctx
, name
, content
)
594 @cli.command(name
='nspkg-update', short_help
='updates a NSD/NSpkg')
595 @click.argument('name')
596 @click.option('--content', default
=None,
597 help='filename with the NSD/NSpkg replacing the current one')
599 def nsd_update2(ctx
, name
, content
):
600 '''updates a NSD/NSpkg
602 NAME: name or ID of the NSD/NSpkg
604 nsd_update(ctx
, name
, content
)
607 def vnfd_update(ctx
, name
, content
):
609 check_client_version(ctx
.obj
, ctx
.command
.name
)
610 ctx
.obj
.vnfd
.update(name
, content
)
611 except ClientException
as inst
:
616 @cli.command(name
='vnfd-update', short_help
='updates a new 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_update1(ctx
, name
, content
):
622 '''updates a VNFD/VNFpkg
624 NAME: name or ID of the VNFD/VNFpkg
626 vnfd_update(ctx
, name
, content
)
629 @cli.command(name
='vnfpkg-update', short_help
='updates a VNFD/VNFpkg')
630 @click.argument('name')
631 @click.option('--content', default
=None,
632 help='filename with the VNFD/VNFpkg replacing the current one')
634 def vnfd_update2(ctx
, name
, content
):
635 '''updates a VNFD/VNFpkg
637 NAME: VNFD yaml file or VNFpkg tar.gz file
639 vnfd_update(ctx
, name
, content
)
646 def nsd_delete(ctx
, name
):
648 ctx
.obj
.nsd
.delete(name
)
649 except ClientException
as inst
:
654 @cli.command(name
='nsd-delete', short_help
='deletes a NSD/NSpkg')
655 @click.argument('name')
657 def nsd_delete1(ctx
, name
):
658 '''deletes a NSD/NSpkg
660 NAME: name or ID of the NSD/NSpkg to be deleted
662 nsd_delete(ctx
, name
)
665 @cli.command(name
='nspkg-delete', short_help
='deletes a NSD/NSpkg')
666 @click.argument('name')
668 def nsd_delete2(ctx
, name
):
669 '''deletes a NSD/NSpkg
671 NAME: name or ID of the NSD/NSpkg to be deleted
673 nsd_delete(ctx
, name
)
676 def vnfd_delete(ctx
, name
):
678 ctx
.obj
.vnfd
.delete(name
)
679 except ClientException
as inst
:
684 @cli.command(name
='vnfd-delete', short_help
='deletes a VNFD/VNFpkg')
685 @click.argument('name')
687 def vnfd_delete1(ctx
, name
):
688 '''deletes a VNFD/VNFpkg
690 NAME: name or ID of the VNFD/VNFpkg to be deleted
692 vnfd_delete(ctx
, name
)
695 @cli.command(name
='vnfpkg-delete', short_help
='deletes a VNFD/VNFpkg')
696 @click.argument('name')
698 def vnfd_delete2(ctx
, name
):
699 '''deletes a VNFD/VNFpkg
701 NAME: name or ID of the VNFD/VNFpkg to be deleted
703 vnfd_delete(ctx
, name
)
706 @cli.command(name
='ns-delete', short_help
='deletes a NS instance')
707 @click.argument('name')
709 def ns_delete(ctx
, name
):
710 '''deletes a NS instance
712 NAME: name or ID of the NS instance to be deleted
715 ctx
.obj
.ns
.delete(name
)
716 except ClientException
as inst
:
725 @cli.command(name
='vim-create')
726 @click.option('--name',
728 help='Name to create datacenter')
729 @click.option('--user',
732 @click.option('--password',
735 confirmation_prompt
=True,
737 @click.option('--auth_url',
740 @click.option('--tenant',
742 help='VIM tenant name')
743 @click.option('--config',
745 help='VIM specific config parameters')
746 @click.option('--account_type',
749 @click.option('--description',
750 default
='no description',
751 help='human readable description')
762 '''creates a new VIM account
765 vim
['vim-username'] = user
766 vim
['vim-password'] = password
767 vim
['vim-url'] = auth_url
768 vim
['vim-tenant-name'] = tenant
769 vim
['config'] = config
770 vim
['vim-type'] = account_type
771 vim
['description'] = description
773 ctx
.obj
.vim
.create(name
, vim
)
774 except ClientException
as inst
:
779 @cli.command(name
='vim-update', short_help
='updates a VIM account')
780 @click.argument('name')
781 @click.option('--newname', default
=None, help='New name for the VIM account')
782 @click.option('--user', default
=None, help='VIM username')
783 @click.option('--password', default
=None, help='VIM password')
784 @click.option('--auth_url', default
=None, help='VIM url')
785 @click.option('--tenant', default
=None, help='VIM tenant name')
786 @click.option('--config', default
=None, help='VIM specific config parameters')
787 @click.option('--account_type', default
=None, help='VIM type')
788 @click.option('--description', default
=None, help='human readable description')
800 '''updates a VIM account
802 NAME: name or ID of the VIM account
806 vim
['name'] = newname
807 vim
['vim_user'] = user
808 vim
['vim_password'] = password
809 vim
['vim_url'] = auth_url
810 vim
['vim-tenant-name'] = tenant
811 vim
['config'] = config
812 vim
['vim_type'] = account_type
813 vim
['description'] = description
815 check_client_version(ctx
.obj
, ctx
.command
.name
)
816 ctx
.obj
.vim
.update(name
, vim
)
817 except ClientException
as inst
:
822 @cli.command(name
='vim-delete')
823 @click.argument('name')
825 def vim_delete(ctx
, name
):
826 '''deletes a VIM account
828 NAME: name or ID of the VIM account to be deleted
831 ctx
.obj
.vim
.delete(name
)
832 except ClientException
as inst
:
837 @cli.command(name
='vim-list')
838 @click.option('--ro_update/--no_ro_update',
840 help='update list from RO')
841 @click.option('--filter', default
=None,
842 help='restricts the list to the VIM accounts matching the filter')
844 def vim_list(ctx
, ro_update
, filter):
845 '''list all VIM accounts'''
847 check_client_version(ctx
.obj
, '--filter')
849 check_client_version(ctx
.obj
, '--ro_update', 'v1')
850 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
851 if fullclassname
== 'osmclient.sol005.client.Client':
852 resp
= ctx
.obj
.vim
.list(filter)
854 resp
= ctx
.obj
.vim
.list(ro_update
)
855 table
= PrettyTable(['vim name', 'uuid'])
857 table
.add_row([vim
['name'], vim
['uuid']])
862 @cli.command(name
='vim-show')
863 @click.argument('name')
865 def vim_show(ctx
, name
):
866 '''shows the details of a VIM account
868 NAME: name or ID of the VIM account
871 resp
= ctx
.obj
.vim
.get(name
)
872 if 'vim_password' in resp
:
873 resp
['vim_password']='********'
874 except ClientException
as inst
:
878 table
= PrettyTable(['key', 'attribute'])
879 for k
, v
in resp
.items():
880 table
.add_row([k
, json
.dumps(v
, indent
=2)])
889 @cli.command(name
='upload-package')
890 @click.argument('filename')
892 def upload_package(ctx
, filename
):
893 '''uploads a VNF package or NS package
895 FILENAME: VNF or NS package file (tar.gz)
898 ctx
.obj
.package
.upload(filename
)
899 fullclassname
= ctx
.obj
.__module
__ + "." + ctx
.obj
.__class
__.__name
__
900 if fullclassname
!= 'osmclient.sol005.client.Client':
901 ctx
.obj
.package
.wait_for_upload(filename
)
902 except ClientException
as inst
:
907 @cli.command(name
='ns-scaling-show')
908 @click.argument('ns_name')
910 def show_ns_scaling(ctx
, ns_name
):
911 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
912 resp
= ctx
.obj
.ns
.list()
917 'operational status',
922 if ns_name
== ns
['name']:
923 nsopdata
= ctx
.obj
.ns
.get_opdata(ns
['id'])
924 scaling_records
= nsopdata
['nsr:nsr']['scaling-group-record']
925 for record
in scaling_records
:
926 if 'instance' in record
:
927 instances
= record
['instance']
928 for inst
in instances
:
930 [record
['scaling-group-name-ref'],
933 time
.strftime('%Y-%m-%d %H:%M:%S',
935 inst
['create-time'])),
941 @cli.command(name
='ns-scale')
942 @click.argument('ns_name')
943 @click.option('--ns_scale_group', prompt
=True)
944 @click.option('--index', prompt
=True)
946 def ns_scale(ctx
, ns_name
, ns_scale_group
, index
):
947 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
948 ctx
.obj
.ns
.scale(ns_name
, ns_scale_group
, index
)
951 @cli.command(name
='config-agent-list')
953 def config_agent_list(ctx
):
954 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
955 table
= PrettyTable(['name', 'account-type', 'details'])
956 for account
in ctx
.obj
.vca
.list():
959 account
['account-type'],
965 @cli.command(name
='config-agent-delete')
966 @click.argument('name')
968 def config_agent_delete(ctx
, name
):
970 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
971 ctx
.obj
.vca
.delete(name
)
972 except ClientException
as inst
:
977 @cli.command(name
='config-agent-add')
978 @click.option('--name',
980 @click.option('--account_type',
982 @click.option('--server',
984 @click.option('--user',
986 @click.option('--secret',
989 confirmation_prompt
=True)
991 def config_agent_add(ctx
, name
, account_type
, server
, user
, secret
):
993 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
994 ctx
.obj
.vca
.create(name
, account_type
, server
, user
, secret
)
995 except ClientException
as inst
:
999 @cli.command(name
='ro-dump')
1002 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1003 resp
= ctx
.obj
.vim
.get_resource_orchestrator()
1004 table
= PrettyTable(['key', 'attribute'])
1005 for k
, v
in resp
.items():
1006 table
.add_row([k
, json
.dumps(v
, indent
=2)])
1011 @cli.command(name
='vcs-list')
1014 check_client_version(ctx
.obj
, ctx
.command
.name
, 'v1')
1015 resp
= ctx
.obj
.utils
.get_vcs_info()
1016 table
= PrettyTable(['component name', 'state'])
1017 for component
in resp
:
1018 table
.add_row([component
['component_name'], component
['state']])
1023 if __name__
== '__main__':