\n* to set authentication token: /config set cloud.<cloud>.token <token>'
-class _network_wait(_service_wait):
-
- def _wait(self, net_id, current_status, timeout=60):
- super(_network_wait, self)._wait(
- 'Network', net_id, self.client.wait_network, current_status,
- timeout=timeout)
-
-
class _port_wait(_service_wait):
def _wait(self, port_id, current_status, timeout=60):
timeout=timeout)
-class _port_wait(_service_wait):
-
- def _wait(self, net_id, current_status, timeout=60):
- super(_network_wait, self)._wait(
- 'Network', net_id, self.client.wait_network, current_status,
- timeout=timeout)
-
-
class _init_network(_command_init):
@errors.generic.all
@addLogSettings
@command(network_cmds)
-class network_create(_init_network, _optional_json, _network_wait):
+class network_create(_init_network, _optional_json):
"""Create a new network"""
arguments = dict(
'Make network shared (special privileges required)', '--shared'),
network_type=NetworkTypeArgument(
'Valid network types: %s' % (', '.join(NetworkTypeArgument.types)),
- '--type'),
- wait=FlagArgument('Wait network to build', ('-w', '--wait')),
+ '--type')
)
required = ('network_type', )
def _run(self, network_type):
net = self.client.create_network(
network_type, name=self['name'], shared=self['shared'])
- if self['wait']:
- self._wait(net['id'], net['status'])
self._print(net, self.print_dict)
def main(self):
self._run(network_id=network_id)
-@command(network_cmds)
-class network_wait(_init_network, _network_wait):
- """Wait for network to finish [PENDING, ACTIVE, DELETED]"""
-
- arguments = dict(
- timeout=IntArgument(
- 'Wait limit in seconds (default: 60)', '--timeout', default=60)
- )
-
- @errors.generic.all
- @errors.cyclades.connection
- @errors.cyclades.network_id
- def _run(self, network_id, current_status):
- net = self.client.get_network_details(network_id)
- if net['status'].lower() == current_status.lower():
- self._wait(network_id, current_status, timeout=self['timeout'])
- else:
- self.error(
- 'Network %s: Cannot wait for status %s, '
- 'status is already %s' % (
- network_id, current_status, net['status']))
-
- def main(self, network_id, current_status='PENDING'):
- super(self.__class__, self)._run()
- self._run(network_id=network_id, current_status=current_status)
-
-
@command(subnet_cmds)
class subnet_list(_init_network, _optional_json, _name_filter, _id_filter):
"""List subnets
@command(port_cmds)
class port_wait(_init_network, _port_wait):
- """Wait for port to finish [PENDING, ACTIVE, DELETED]"""
+ """Wait for port to finish [ACTIVE, DOWN, BUILD, ERROR]"""
arguments = dict(
timeout=IntArgument(
'status is already %s' % (
port_id, current_status, port['status']))
- def main(self, port_id, current_status='PENDING'):
+ def main(self, port_id, current_status='BUILD'):
super(self.__class__, self)._run()
self._run(port_id=port_id, current_status=current_status)
# Wait methods
- def wait_network(
- self, net_id,
- current_status='PENDING', delay=1, max_wait=100, wait_cb=None):
-
- def get_status(self, net_id):
- r = self.get_network_details(net_id)
- return r['status'], None
-
- return self._wait(
- net_id, current_status, get_status, delay, max_wait, wait_cb)
-
- def wait_subnet(
- self, subnet_id,
- current_status='PENDING', delay=1, max_wait=100, wait_cb=None):
-
- def get_status(self, subnet_id):
- r = self.get_subnet_details(subnet_id)
- return r['status'], None
-
- return self._wait(
- subnet_id, current_status, get_status, delay, max_wait, wait_cb)
-
def wait_port(
self, port_id,
- current_status='PENDING', delay=1, max_wait=100, wait_cb=None):
+ current_status='BUILD', delay=1, max_wait=100, wait_cb=None):
def get_status(self, net_id):
r = self.get_port_details(port_id)
return self._wait(
port_id, current_status, get_status, delay, max_wait, wait_cb)
-
- def wait_floatingip(
- self, floatingip_id,
- current_status='PENDING', delay=1, max_wait=100, wait_cb=None):
-
- def get_status(self, floatingip_id):
- r = self.get_network_details(floatingip_id)
- return r['status'], None
-
- return self._wait(
- floatingip_id,
- current_status, get_status, delay, max_wait, wait_cb)