forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathready.py
More file actions
27 lines (22 loc) · 814 Bytes
/
ready.py
File metadata and controls
27 lines (22 loc) · 814 Bytes
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
"""Check if a server is ready."""
# :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 helpers
@click.command()
@click.argument('identifier')
@click.option('--wait', default=0, show_default=True, type=click.INT,
help="Seconds to wait")
@environment.pass_env
def cli(env, identifier, wait):
"""Check if a server is ready."""
compute = SoftLayer.HardwareManager(env.client)
compute_id = helpers.resolve_id(compute.resolve_ids, identifier,
'hardware')
ready = compute.wait_for_ready(compute_id, wait)
if ready:
env.fout("READY")
else:
raise exceptions.CLIAbort("Server %s not ready" % compute_id)