diff --git a/SoftLayer/CLI/hardware/reload.py b/SoftLayer/CLI/hardware/reload.py index 11286d0d9..798e01968 100644 --- a/SoftLayer/CLI/hardware/reload.py +++ b/SoftLayer/CLI/hardware/reload.py @@ -13,17 +13,16 @@ @click.command() @click.argument('identifier') @click.option('--postinstall', '-i', - help=("Post-install script to download " - "(Only HTTPS executes, HTTP leaves file in /root")) + help=("Post-install script to download (Only HTTPS executes, HTTP leaves file in /root")) @helpers.multi_option('--key', '-k', help="SSH keys to add to the root user") +@click.option('--lvm', '-l', is_flag=True, default=False, show_default=True, + help="A flag indicating that the provision should use LVM for all logical drives.") @environment.pass_env -def cli(env, identifier, postinstall, key): +def cli(env, identifier, postinstall, key, lvm): """Reload operating system on a server.""" hardware = SoftLayer.HardwareManager(env.client) - hardware_id = helpers.resolve_id(hardware.resolve_ids, - identifier, - 'hardware') + hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier, 'hardware') key_list = [] if key: for single_key in key: @@ -33,4 +32,4 @@ def cli(env, identifier, postinstall, key): if not (env.skip_confirmations or formatting.no_going_back(hardware_id)): raise exceptions.CLIAbort('Aborted') - hardware.reload(hardware_id, postinstall, key_list) + hardware.reload(hardware_id, postinstall, key_list, lvm) diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py index 956d33e3a..2db54ed25 100644 --- a/SoftLayer/managers/hardware.py +++ b/SoftLayer/managers/hardware.py @@ -269,13 +269,14 @@ def get_hardware(self, hardware_id, **kwargs): return self.hardware.getObject(id=hardware_id, **kwargs) - def reload(self, hardware_id, post_uri=None, ssh_keys=None): + def reload(self, hardware_id, post_uri=None, ssh_keys=None, lvm=False): """Perform an OS reload of a server with its current configuration. + https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Hardware_Server_Configuration/ :param integer hardware_id: the instance ID to reload - :param string post_uri: The URI of the post-install script to run - after reload + :param string post_uri: The URI of the post-install script to run after reload :param list ssh_keys: The SSH keys to add to the root user + :param bool lvm: A flag indicating that the provision should use LVM for all logical drives. """ config = {} @@ -285,9 +286,10 @@ def reload(self, hardware_id, post_uri=None, ssh_keys=None): if ssh_keys: config['sshKeyIds'] = list(ssh_keys) + if lvm: + config['lvmFlag'] = lvm - return self.hardware.reloadOperatingSystem('FORCE', config, - id=hardware_id) + return self.hardware.reloadOperatingSystem('FORCE', config, id=hardware_id) def rescue(self, hardware_id): """Reboot a server into the a recsue kernel. diff --git a/tests/CLI/modules/server_tests.py b/tests/CLI/modules/server_tests.py index f11d9d0a6..1f539c84e 100644 --- a/tests/CLI/modules/server_tests.py +++ b/tests/CLI/modules/server_tests.py @@ -219,11 +219,15 @@ def test_server_reload(self, reload_mock, ngb_mock): ngb_mock.return_value = False # Check the positive case - result = self.run_command(['--really', 'server', 'reload', '12345', - '--key=4567']) + result = self.run_command(['--really', 'server', 'reload', '12345', '--key=4567']) self.assert_no_fail(result) - reload_mock.assert_called_with(12345, None, [4567]) + reload_mock.assert_called_with(12345, None, [4567], False) + + # LVM switch + result = self.run_command(['--really', 'server', 'reload', '12345', '--lvm']) + self.assert_no_fail(result) + reload_mock.assert_called_with(12345, None, [], True) # Now check to make sure we properly call CLIAbort in the negative case result = self.run_command(['server', 'reload', '12345']) diff --git a/tests/managers/hardware_tests.py b/tests/managers/hardware_tests.py index a61aeece0..d7516aec0 100644 --- a/tests/managers/hardware_tests.py +++ b/tests/managers/hardware_tests.py @@ -107,13 +107,15 @@ def test_reload(self): result = self.hardware.reload(1, post_uri=post_uri, ssh_keys=[1701]) self.assertEqual(result, 'OK') - self.assert_called_with('SoftLayer_Hardware_Server', - 'reloadOperatingSystem', - args=('FORCE', - {'customProvisionScriptUri': post_uri, - 'sshKeyIds': [1701]}), + self.assert_called_with('SoftLayer_Hardware_Server', 'reloadOperatingSystem', + args=('FORCE', {'customProvisionScriptUri': post_uri, 'sshKeyIds': [1701]}), identifier=1) + result = self.hardware.reload(100, lvm=True) + self.assertEqual(result, 'OK') + self.assert_called_with('SoftLayer_Hardware_Server', 'reloadOperatingSystem', + args=('FORCE', {'lvmFlag': True}), identifier=100) + def test_get_create_options(self): options = self.hardware.get_create_options()