Skip to content

Commit 12227cb

Browse files
added tests and route for server:power:rescue
1 parent 40b95f5 commit 12227cb

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

SoftLayer/CLI/hardware/power.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,20 @@ def power_cycle(env, identifier):
7777
raise exceptions.CLIAbort('Aborted.')
7878

7979
env.client['Hardware_Server'].powerCycle(id=hw_id)
80+
81+
82+
@click.command()
83+
@click.argument('identifier')
84+
@environment.pass_env
85+
def rescue(env, identifier):
86+
"""Reboot server into a rescue image."""
87+
88+
mgr = SoftLayer.HardwareManager(env.client)
89+
hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
90+
91+
if not (env.skip_confirmations or
92+
formatting.confirm("This action will reboot this server. Continue?")):
93+
94+
raise exceptions.CLIAbort('Aborted')
95+
96+
env.client['Hardware_Server'].bootToRescueLayer(id=hw_id)

SoftLayer/CLI/hardware/rescue.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
('hardware:reload', 'SoftLayer.CLI.hardware.reload:cli'),
211211
('hardware:credentials', 'SoftLayer.CLI.hardware.credentials:cli'),
212212
('hardware:update-firmware', 'SoftLayer.CLI.hardware.update_firmware:cli'),
213+
('hardware:rescue', 'SoftLayer.CLI.hardware.power:rescue'),
213214

214215
('securitygroup', 'SoftLayer.CLI.securitygroup'),
215216
('securitygroup:list', 'SoftLayer.CLI.securitygroup.list:cli'),

tests/CLI/modules/server_tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,12 @@ def test_edit(self):
445445
args=(100,),
446446
identifier=100,
447447
)
448+
449+
@mock.patch('SoftLayer.CLI.formatting.confirm')
450+
def test_rescue(self, confirm_mock):
451+
confirm_mock.return_value = True
452+
result = self.run_command(['server', 'rescue', '1000'])
453+
454+
self.assert_no_fail(result)
455+
self.assertEqual(result.output, "")
456+
self.assert_called_with('SoftLayer_Hardware_Server', 'bootToRescueLayer', identifier=1000)

0 commit comments

Comments
 (0)