696 |
696 |
|
697 |
697 |
|
698 |
698 |
@command(network_cmds)
|
699 |
|
class network_create(_init_cyclades, _optional_json):
|
|
699 |
class network_create(_init_cyclades, _optional_json, _network_wait):
|
700 |
700 |
"""Create an (unconnected) network"""
|
701 |
701 |
|
702 |
702 |
arguments = dict(
|
... | ... | |
707 |
707 |
'Valid network types are '
|
708 |
708 |
'CUSTOM, IP_LESS_ROUTED, MAC_FILTERED (default), PHYSICAL_VLAN',
|
709 |
709 |
'--with-type',
|
710 |
|
default='MAC_FILTERED')
|
|
710 |
default='MAC_FILTERED'),
|
|
711 |
wait=FlagArgument('Wait network to build', ('-w', '--wait'))
|
711 |
712 |
)
|
712 |
713 |
|
713 |
714 |
@errors.generic.all
|
714 |
715 |
@errors.cyclades.connection
|
715 |
716 |
@errors.cyclades.network_max
|
716 |
717 |
def _run(self, name):
|
717 |
|
self._print(self.client.create_network(
|
|
718 |
r = self.client.create_network(
|
718 |
719 |
name,
|
719 |
720 |
cidr=self['cidr'],
|
720 |
721 |
gateway=self['gateway'],
|
721 |
722 |
dhcp=self['dhcp'],
|
722 |
|
type=self['type']), print_dict)
|
|
723 |
type=self['type'])
|
|
724 |
self._print(r, print_dict)
|
|
725 |
|
|
726 |
if self['wait']:
|
|
727 |
self._wait(r['id'], 'PENDING')
|
723 |
728 |
|
724 |
729 |
def main(self, name):
|
725 |
730 |
super(self.__class__, self)._run()
|
... | ... | |
743 |
748 |
|
744 |
749 |
|
745 |
750 |
@command(network_cmds)
|
746 |
|
class network_delete(_init_cyclades, _optional_output_cmd):
|
|
751 |
class network_delete(_init_cyclades, _optional_output_cmd, _network_wait):
|
747 |
752 |
"""Delete a network"""
|
748 |
753 |
|
|
754 |
arguments = dict(
|
|
755 |
wait=FlagArgument('Wait network to build', ('-w', '--wait'))
|
|
756 |
)
|
|
757 |
|
749 |
758 |
@errors.generic.all
|
750 |
759 |
@errors.cyclades.connection
|
751 |
760 |
@errors.cyclades.network_id
|
752 |
761 |
@errors.cyclades.network_in_use
|
753 |
762 |
def _run(self, network_id):
|
754 |
|
self._optional_output(self.client.delete_network(int(network_id)))
|
|
763 |
status = 'DELETED'
|
|
764 |
if self['wait']:
|
|
765 |
r = self.client.get_network_details(network_id)
|
|
766 |
status = r['status']
|
|
767 |
if status in ('DELETED', ):
|
|
768 |
return
|
|
769 |
|
|
770 |
r = self.client.delete_network(int(network_id))
|
|
771 |
self._optional_output(r)
|
|
772 |
|
|
773 |
if self['wait']:
|
|
774 |
self._wait(network_id, status)
|
755 |
775 |
|
756 |
776 |
def main(self, network_id):
|
757 |
777 |
super(self.__class__, self)._run()
|