Revision 9b47150e kamaki/cli/commands/cyclades.py
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
48 | 48 |
server_cmds = CommandTree('server', 'Cyclades/Compute API server commands') |
49 | 49 |
flavor_cmds = CommandTree('flavor', 'Cyclades/Compute API flavor commands') |
50 | 50 |
network_cmds = CommandTree('network', 'Cyclades/Compute API network commands') |
51 |
floatingip_cmds = CommandTree( |
|
52 |
'floatingip', 'Cyclades/Compute API floating ip commands') |
|
51 | 53 |
_commands = [server_cmds, flavor_cmds, network_cmds] |
52 | 54 |
|
53 | 55 |
|
... | ... | |
719 | 721 |
super(self.__class__, self)._run() |
720 | 722 |
server_id = self._server_id_from_nic(nic_id=nic_id) |
721 | 723 |
self._run(nic_id=nic_id, server_id=server_id) |
724 |
|
|
725 |
|
|
726 |
@command(floatingip_cmds) |
|
727 |
class floatingip_pools(_init_cyclades, _optional_json): |
|
728 |
"""List all floating pools of floating ips""" |
|
729 |
|
|
730 |
@errors.generic.all |
|
731 |
@errors.cyclades.connection |
|
732 |
def _run(self): |
|
733 |
r = self.client.get_floating_ip_pools() |
|
734 |
self._print(r if self['json_output'] else r['floating_ip_pools']) |
|
735 |
|
|
736 |
def main(self): |
|
737 |
super(self.__class__, self)._run() |
|
738 |
self._run() |
|
739 |
|
|
740 |
|
|
741 |
@command(floatingip_cmds) |
|
742 |
class floatingip_list(_init_cyclades, _optional_json): |
|
743 |
"""List all floating ips""" |
|
744 |
|
|
745 |
@errors.generic.all |
|
746 |
@errors.cyclades.connection |
|
747 |
def _run(self): |
|
748 |
r = self.client.get_floating_ips() |
|
749 |
self._print(r if self['json_output'] else r['floating_ips']) |
|
750 |
|
|
751 |
def main(self): |
|
752 |
super(self.__class__, self)._run() |
|
753 |
self._run() |
|
754 |
|
|
755 |
|
|
756 |
@command(floatingip_cmds) |
|
757 |
class floatingip_info(_init_cyclades, _optional_json): |
|
758 |
"""A floating IPs' details""" |
|
759 |
|
|
760 |
@errors.generic.all |
|
761 |
@errors.cyclades.connection |
|
762 |
def _run(self, ip): |
|
763 |
self._print(self.client.get_floating_ip(ip), print_dict) |
|
764 |
|
|
765 |
def main(self, ip): |
|
766 |
super(self.__class__, self)._run() |
|
767 |
self._run(ip=ip) |
|
768 |
|
|
769 |
|
|
770 |
@command(floatingip_cmds) |
|
771 |
class floatingip_create(_init_cyclades, _optional_json): |
|
772 |
"""Create a new floating IP""" |
|
773 |
|
|
774 |
arguments = dict( |
|
775 |
pool=ValueArgument('Source IP pool', ('--pool'), None) |
|
776 |
) |
|
777 |
|
|
778 |
@errors.generic.all |
|
779 |
@errors.cyclades.connection |
|
780 |
def _run(self, ip=None): |
|
781 |
self._print( |
|
782 |
self.client.alloc_floating_ip(self['pool'], ip), print_dict) |
|
783 |
|
|
784 |
def main(self, requested_address=None): |
|
785 |
super(self.__class__, self)._run() |
|
786 |
self._run(ip=requested_address) |
|
787 |
|
|
788 |
|
|
789 |
@command(floatingip_cmds) |
|
790 |
class floatingip_delete(_init_cyclades, _optional_output_cmd): |
|
791 |
"""Delete a floating ip""" |
|
792 |
|
|
793 |
@errors.generic.all |
|
794 |
@errors.cyclades.connection |
|
795 |
def _run(self, ip): |
|
796 |
self._optional_output(self.client.delete_floating_ip(ip)) |
|
797 |
|
|
798 |
def main(self, ip): |
|
799 |
super(self.__class__, self)._run() |
|
800 |
self._run(ip=ip) |
|
801 |
|
|
802 |
|
|
803 |
@command(server_cmds) |
|
804 |
class server_ip_attach(_init_cyclades, _optional_output_cmd): |
|
805 |
"""Attach a floating ip to a server with server_id |
|
806 |
""" |
|
807 |
|
|
808 |
@errors.generic.all |
|
809 |
@errors.cyclades.connection |
|
810 |
@errors.cyclades.server_id |
|
811 |
def _run(self, server_id, ip): |
|
812 |
self._optional_output(self.client.attach_floating_ip(server_id, ip)) |
|
813 |
|
|
814 |
def main(self, server_id, ip): |
|
815 |
super(self.__class__, self)._run() |
|
816 |
self._run(server_id=server_id, ip=ip) |
|
817 |
|
|
818 |
|
|
819 |
@command(server_cmds) |
|
820 |
class server_ip_detach(_init_cyclades): |
|
821 |
"""detach_floating_ip_to_server |
|
822 |
""" |
|
823 |
|
|
824 |
@errors.generic.all |
|
825 |
@errors.cyclades.connection |
|
826 |
@errors.cyclades.server_id |
|
827 |
def _run(self, server_id, ip): |
|
828 |
self._optional_output(self.client.detach_floating_ip(server_id, ip)) |
|
829 |
|
|
830 |
def main(self, server_id, ip): |
|
831 |
super(self.__class__, self)._run() |
|
832 |
self._run(server_id=server_id, ip=ip) |
Also available in: Unified diff