|
12 | 12 |
|
13 | 13 | @click.command(cls=SoftLayer.CLI.command.SLCommand, )
|
14 | 14 | @click.argument('identifier')
|
| 15 | +@click.option('--force', default=False, is_flag=True, help="Force modify") |
15 | 16 | @environment.pass_env
|
16 |
| -def power_off(env, identifier): |
| 17 | +def power_off(env, identifier, force): |
17 | 18 | """Power off an active server."""
|
18 | 19 |
|
19 | 20 | mgr = SoftLayer.HardwareManager(env.client)
|
20 | 21 | hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
|
21 |
| - if not (env.skip_confirmations or |
22 |
| - formatting.confirm('This will power off the server with id %s ' |
23 |
| - 'Continue?' % hw_id)): |
24 |
| - raise exceptions.CLIAbort('Aborted.') |
| 22 | + if not force: |
| 23 | + if not (env.skip_confirmations or |
| 24 | + formatting.confirm('This will power off the server with id %s ' |
| 25 | + 'Continue?' % hw_id)): |
| 26 | + raise exceptions.CLIAbort('Aborted.') |
25 | 27 |
|
26 | 28 | env.client['Hardware_Server'].powerOff(id=hw_id)
|
27 | 29 |
|
@@ -53,12 +55,20 @@ def reboot(env, identifier, hard):
|
53 | 55 |
|
54 | 56 | @click.command(cls=SoftLayer.CLI.command.SLCommand, )
|
55 | 57 | @click.argument('identifier')
|
| 58 | +@click.option('--force', default=False, is_flag=True, help="Force modify") |
56 | 59 | @environment.pass_env
|
57 |
| -def power_on(env, identifier): |
| 60 | +def power_on(env, identifier, force): |
58 | 61 | """Power on a server."""
|
59 | 62 |
|
60 | 63 | mgr = SoftLayer.HardwareManager(env.client)
|
61 | 64 | hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
|
| 65 | + |
| 66 | + if not force: |
| 67 | + if not (env.skip_confirmations or |
| 68 | + formatting.confirm('This will power off the server with id %s. ' |
| 69 | + 'Continue?' % hw_id)): |
| 70 | + raise exceptions.CLIAbort('Aborted.') |
| 71 | + |
62 | 72 | env.client['Hardware_Server'].powerOn(id=hw_id)
|
63 | 73 |
|
64 | 74 |
|
|
0 commit comments