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):
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(
......@@ -478,6 +478,25 @@ class port_modify(_init_network, _optional_json):
class PortStatusArgument(ValueArgument):
valid = ('BUILD', 'ACTIVE', 'DOWN', 'ERROR')
def value(self):
return getattr(self, '_value', None)
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(
'Wait while in this status', '--status'),
'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[
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