Commit fac340da authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Add --status to port wait

parent 9930045a
......@@ -748,7 +748,7 @@ class server_stats(_init_cyclades, _optional_json):
@command(server_cmds)
class server_wait(_init_cyclades, _server_wait):
"""Wait for server to finish [BUILD, STOPPED, REBOOT, ACTIVE]"""
"""Wait for server to finish (BUILD, STOPPED, REBOOT, ACTIVE)"""
arguments = dict(
timeout=IntArgument(
......
......@@ -478,6 +478,25 @@ class port_modify(_init_network, _optional_json):
self._run(port_id=port_id)
class PortStatusArgument(ValueArgument):
valid = ('BUILD', 'ACTIVE', 'DOWN', 'ERROR')
@property
def value(self):
return getattr(self, '_value', None)
@value.setter
def value(self, new_status):
if new_status:
new_status = new_status.upper()
if new_status in self.valid:
raise CLIInvalidArgument(
'Invalid argument %s' % new_status, details=[
'Status valid values: %s'] % ', '.join(self.valid))
self._value = new_status
class _port_create(_init_network, _optional_json, _port_wait):
def connect(self, network_id, device_id):
......@@ -535,6 +554,8 @@ class port_wait(_init_network, _port_wait):
"""Wait for port to finish [ACTIVE, DOWN, BUILD, ERROR]"""
arguments = dict(
current_status=PortStatusArgument(
'Wait while in this status', '--status'),
timeout=IntArgument(
'Wait limit in seconds (default: 60)', '--timeout', default=60)
)
......@@ -551,8 +572,10 @@ class port_wait(_init_network, _port_wait):
'status is already %s' % (
port_id, current_status, port['status']))
def main(self, port_id, current_status='BUILD'):
def main(self, port_id):
super(self.__class__, self)._run()
current_status = self['current_status'] or self.arguments[
'current_status'].valid[0]
self._run(port_id=port_id, current_status=current_status)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment