diff --git a/system_tests/vm_tests.py b/system_tests/vm_tests.py index 31423bea..044606ce 100644 --- a/system_tests/vm_tests.py +++ b/system_tests/vm_tests.py @@ -67,6 +67,7 @@ class VmTest(BaseTestCase): _computer_name_update = 'mycom' _boot_delay_update = 60 _enter_bios_setup_update = True + _new_ovf_info = 'new info' def test_0000_setup(self): """Load configuration and create a click runner to invoke CLI.""" @@ -542,6 +543,21 @@ def _power_off_and_undeploy(self, vapp): task = vapp.undeploy() VmTest._client.get_task_monitor().wait_for_success(task) + def test_0340_list_os_section(self): + # list os section properties + result = VmTest._runner.invoke( + vm, args=['list-os-section', + VAppConstants.name, VAppConstants.vm1_name]) + self.assertEqual(0, result.exit_code) + + def test_0340_update_os_section(self): + # update os section properties + result = VmTest._runner.invoke( + vm, args=['update-os-section', + VAppConstants.name, VAppConstants.vm1_name, + '--ovf-info', VmTest._new_ovf_info]) + self.assertEqual(0, result.exit_code) + def test_9998_tearDown(self): """Delete the vApp created during setup. diff --git a/vcd_cli/vm.py b/vcd_cli/vm.py index 35b5ab0c..24bef1b7 100644 --- a/vcd_cli/vm.py +++ b/vcd_cli/vm.py @@ -245,6 +245,15 @@ def vm(ctx): --datastore-id 0d8c7358-3e8d-4862-9364-68155069d252 Relocate VM to given datastore. +\b + vcd vm list-os-section vapp1 vm1 + List OS section properties of VM. + +\b + vcd vm update-os-section vapp1 vm1 + --ovf-info newInfo + --description newDescription + Update OS section properties of VM. """ pass @@ -1198,3 +1207,46 @@ def relocate(ctx, vapp_name, vm_name, datastore_id): stdout(task, ctx) except Exception as e: stderr(e, ctx) + +@vm.command('list-os-section', short_help='list operating system section ' + 'properties of VM') +@click.pass_context +@click.argument('vapp-name', metavar='', required=True) +@click.argument('vm-name', metavar='', required=True) +def list_os_section(ctx, vapp_name, vm_name): + try: + restore_session(ctx, vdc_required=True) + vm = _get_vm(ctx, vapp_name, vm_name) + result = vm.list_os_section() + stdout(result, ctx) + except Exception as e: + stderr(e, ctx) + +@vm.command( + 'update-os-section', short_help='update os section properties of VM') +@click.pass_context +@click.argument('vapp-name', metavar='', required=True) +@click.argument('vm-name', metavar='', required=True) +@click.option( + 'ovf_info', + '--ovf-info', + required=False, + default=None, + metavar='', + help='ovf info') +@click.option( + 'description', + '--d', + required=False, + default=None, + metavar='', + help='description') +def update_os_section(ctx, vapp_name, vm_name, ovf_info, description): + try: + restore_session(ctx, vdc_required=True) + vm = _get_vm(ctx, vapp_name, vm_name) + task = vm.update_operating_system_section(ovf_info=ovf_info, + description=description) + stdout(task, ctx) + except Exception as e: + stderr(e, ctx)