Revision 58f4caba kamaki/cli/commands/network.py
b/kamaki/cli/commands/network.py | ||
---|---|---|
670 | 670 |
@errors.generic.all |
671 | 671 |
@errors.cyclades.connection |
672 | 672 |
@errors.cyclades.server_id |
673 |
def _run(self, ip_address, server_id):
|
|
673 |
def _run(self, ip_or_ip_id, server_id):
|
|
674 | 674 |
netid = None |
675 | 675 |
for ip in self.client.list_floatingips(): |
676 |
if ip['floating_ip_address'] == ip_address:
|
|
676 |
if ip_or_ip_id in (ip['floating_ip_address'], ip['id']):
|
|
677 | 677 |
netid = ip['floating_network_id'] |
678 | 678 |
iparg = ValueArgument(parsed_name='--ip') |
679 |
iparg.value = ip_address
|
|
679 |
iparg.value = ip['floating_ip_address']
|
|
680 | 680 |
self.arguments['ip_address'] = iparg |
681 | 681 |
break |
682 | 682 |
if netid: |
683 | 683 |
self.error('Creating a port to attach IP %s to server %s' % ( |
684 |
ip_address, server_id))
|
|
684 |
ip_or_ip_id, server_id))
|
|
685 | 685 |
self.connect(netid, server_id) |
686 | 686 |
else: |
687 | 687 |
raiseCLIError( |
688 |
'IP address %s does not match any reserved IPs' % ip_address,
|
|
688 |
'%s does not match any reserved IPs or IP ids' % ip_or_ip_id,
|
|
689 | 689 |
details=[ |
690 | 690 |
'To reserve an IP:', ' [kamaki] ip create', |
691 | 691 |
'To see all reserved IPs:', ' [kamaki] ip list']) |
692 | 692 |
|
693 |
def main(self, ip_address):
|
|
693 |
def main(self, ip_or_ip_id):
|
|
694 | 694 |
super(self.__class__, self)._run() |
695 |
self._run(ip_address=ip_address, server_id=self['server_id'])
|
|
695 |
self._run(ip_or_ip_id=ip_or_ip_id, server_id=self['server_id'])
|
|
696 | 696 |
|
697 | 697 |
|
698 | 698 |
@command(ip_cmds) |
... | ... | |
705 | 705 |
|
706 | 706 |
@errors.generic.all |
707 | 707 |
@errors.cyclades.connection |
708 |
def _run(self, ip_address):
|
|
708 |
def _run(self, ip_or_ip_id):
|
|
709 | 709 |
for ip in self.client.list_floatingips(): |
710 |
if ip['floating_ip_address'] == ip_address:
|
|
710 |
if ip_or_ip_id in (ip['floating_ip_address'], ip['id']):
|
|
711 | 711 |
if not ip['port_id']: |
712 |
raiseCLIError('IP %s is not attached' % ip_address)
|
|
712 |
raiseCLIError('IP %s is not attached' % ip_or_ip_id)
|
|
713 | 713 |
self.error('Deleting port %s:' % ip['port_id']) |
714 | 714 |
self.client.delete_port(ip['port_id']) |
715 | 715 |
if self['wait']: |
... | ... | |
722 | 722 |
raise |
723 | 723 |
self.error('Port %s is deleted' % ip['port_id']) |
724 | 724 |
return |
725 |
raiseCLIError('IP %s not found' % ip_address)
|
|
725 |
raiseCLIError('IP or IP id %s not found' % ip_or_ip_id)
|
|
726 | 726 |
|
727 |
def main(self, ip_address):
|
|
727 |
def main(self, ip_or_ip_id):
|
|
728 | 728 |
super(self.__class__, self)._run() |
729 |
self._run(ip_address)
|
|
729 |
self._run(ip_or_ip_id)
|
|
730 | 730 |
|
731 | 731 |
|
732 | 732 |
# Warn users for some importand changes |
Also available in: Unified diff