Thanks to visit codestin.com
Credit goes to github.com

Skip to content

#875 added option to reload bare metal servers with LVM enabled #1307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions SoftLayer/CLI/hardware/reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
12 changes: 7 additions & 5 deletions SoftLayer/managers/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions tests/CLI/modules/server_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
12 changes: 7 additions & 5 deletions tests/managers/hardware_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down