forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreload.py
More file actions
36 lines (30 loc) · 1.27 KB
/
reload.py
File metadata and controls
36 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Reload operating system on a server."""
# :license: MIT, see LICENSE for more details.
import click
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers
@click.command()
@click.argument('identifier')
@click.option('--postinstall', '-i',
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")
@environment.pass_env
def cli(env, identifier, postinstall, key):
"""Reload operating system on a server."""
hardware = SoftLayer.HardwareManager(env.client)
hardware_id = helpers.resolve_id(hardware.resolve_ids,
identifier,
'hardware')
key_list = []
if key:
for single_key in key:
resolver = SoftLayer.SshKeyManager(env.client).resolve_ids
key_id = helpers.resolve_id(resolver, single_key, 'SshKey')
key_list.append(key_id)
if not (env.skip_confirmations or formatting.no_going_back(hardware_id)):
raise exceptions.CLIAbort('Aborted')
hardware.reload(hardware_id, postinstall, key_list)