Skip to content

Commit 0ff9f33

Browse files
Merge pull request #1307 from allmightyspiff/875
#875 added option to reload bare metal servers with LVM enabled
2 parents 318151a + fb59874 commit 0ff9f33

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

SoftLayer/CLI/hardware/reload.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@
1313
@click.command()
1414
@click.argument('identifier')
1515
@click.option('--postinstall', '-i',
16-
help=("Post-install script to download "
17-
"(Only HTTPS executes, HTTP leaves file in /root"))
16+
help=("Post-install script to download (Only HTTPS executes, HTTP leaves file in /root"))
1817
@helpers.multi_option('--key', '-k', help="SSH keys to add to the root user")
18+
@click.option('--lvm', '-l', is_flag=True, default=False, show_default=True,
19+
help="A flag indicating that the provision should use LVM for all logical drives.")
1920
@environment.pass_env
20-
def cli(env, identifier, postinstall, key):
21+
def cli(env, identifier, postinstall, key, lvm):
2122
"""Reload operating system on a server."""
2223

2324
hardware = SoftLayer.HardwareManager(env.client)
24-
hardware_id = helpers.resolve_id(hardware.resolve_ids,
25-
identifier,
26-
'hardware')
25+
hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier, 'hardware')
2726
key_list = []
2827
if key:
2928
for single_key in key:
@@ -33,4 +32,4 @@ def cli(env, identifier, postinstall, key):
3332
if not (env.skip_confirmations or formatting.no_going_back(hardware_id)):
3433
raise exceptions.CLIAbort('Aborted')
3534

36-
hardware.reload(hardware_id, postinstall, key_list)
35+
hardware.reload(hardware_id, postinstall, key_list, lvm)

SoftLayer/managers/hardware.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,14 @@ def get_hardware(self, hardware_id, **kwargs):
269269

270270
return self.hardware.getObject(id=hardware_id, **kwargs)
271271

272-
def reload(self, hardware_id, post_uri=None, ssh_keys=None):
272+
def reload(self, hardware_id, post_uri=None, ssh_keys=None, lvm=False):
273273
"""Perform an OS reload of a server with its current configuration.
274274
275+
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Hardware_Server_Configuration/
275276
:param integer hardware_id: the instance ID to reload
276-
:param string post_uri: The URI of the post-install script to run
277-
after reload
277+
:param string post_uri: The URI of the post-install script to run after reload
278278
:param list ssh_keys: The SSH keys to add to the root user
279+
:param bool lvm: A flag indicating that the provision should use LVM for all logical drives.
279280
"""
280281

281282
config = {}
@@ -285,9 +286,10 @@ def reload(self, hardware_id, post_uri=None, ssh_keys=None):
285286

286287
if ssh_keys:
287288
config['sshKeyIds'] = list(ssh_keys)
289+
if lvm:
290+
config['lvmFlag'] = lvm
288291

289-
return self.hardware.reloadOperatingSystem('FORCE', config,
290-
id=hardware_id)
292+
return self.hardware.reloadOperatingSystem('FORCE', config, id=hardware_id)
291293

292294
def rescue(self, hardware_id):
293295
"""Reboot a server into the a recsue kernel.

tests/CLI/modules/server_tests.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,15 @@ def test_server_reload(self, reload_mock, ngb_mock):
219219
ngb_mock.return_value = False
220220

221221
# Check the positive case
222-
result = self.run_command(['--really', 'server', 'reload', '12345',
223-
'--key=4567'])
222+
result = self.run_command(['--really', 'server', 'reload', '12345', '--key=4567'])
224223

225224
self.assert_no_fail(result)
226-
reload_mock.assert_called_with(12345, None, [4567])
225+
reload_mock.assert_called_with(12345, None, [4567], False)
226+
227+
# LVM switch
228+
result = self.run_command(['--really', 'server', 'reload', '12345', '--lvm'])
229+
self.assert_no_fail(result)
230+
reload_mock.assert_called_with(12345, None, [], True)
227231

228232
# Now check to make sure we properly call CLIAbort in the negative case
229233
result = self.run_command(['server', 'reload', '12345'])

tests/managers/hardware_tests.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ def test_reload(self):
107107
result = self.hardware.reload(1, post_uri=post_uri, ssh_keys=[1701])
108108

109109
self.assertEqual(result, 'OK')
110-
self.assert_called_with('SoftLayer_Hardware_Server',
111-
'reloadOperatingSystem',
112-
args=('FORCE',
113-
{'customProvisionScriptUri': post_uri,
114-
'sshKeyIds': [1701]}),
110+
self.assert_called_with('SoftLayer_Hardware_Server', 'reloadOperatingSystem',
111+
args=('FORCE', {'customProvisionScriptUri': post_uri, 'sshKeyIds': [1701]}),
115112
identifier=1)
116113

114+
result = self.hardware.reload(100, lvm=True)
115+
self.assertEqual(result, 'OK')
116+
self.assert_called_with('SoftLayer_Hardware_Server', 'reloadOperatingSystem',
117+
args=('FORCE', {'lvmFlag': True}), identifier=100)
118+
117119
def test_get_create_options(self):
118120
options = self.hardware.get_create_options()
119121

0 commit comments

Comments
 (0)