Revision 6489c38b kamaki/cli/commands/cyclades.py
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
51 | 51 |
server_cmds = CommandTree('server', 'Cyclades/Compute API server commands') |
52 | 52 |
flavor_cmds = CommandTree('flavor', 'Cyclades/Compute API flavor commands') |
53 | 53 |
network_cmds = CommandTree('network', 'Cyclades/Compute API network commands') |
54 |
_commands = [server_cmds, flavor_cmds, network_cmds] |
|
54 |
ip_cmds = CommandTree('ip', 'Cyclades/Compute API floating ip commands') |
|
55 |
_commands = [server_cmds, flavor_cmds, network_cmds, ip_cmds] |
|
55 | 56 |
|
56 | 57 |
|
57 | 58 |
about_authentication = '\nUser Authentication:\ |
... | ... | |
1093 | 1094 |
self._run(network_id=network_id, current_status=current_status) |
1094 | 1095 |
|
1095 | 1096 |
|
1096 |
@command(server_cmds) |
|
1097 |
class server_ip(_init_cyclades): |
|
1098 |
"""Manage floating IPs for the servers""" |
|
1099 |
|
|
1100 |
|
|
1101 |
@command(server_cmds) |
|
1102 |
class server_ip_pools(_init_cyclades, _optional_json): |
|
1103 |
"""List all floating pools of floating ips""" |
|
1097 |
@command(ip_cmds) |
|
1098 |
class ip_pools(_init_cyclades, _optional_json): |
|
1099 |
"""List pools of floating IPs""" |
|
1104 | 1100 |
|
1105 | 1101 |
@errors.generic.all |
1106 | 1102 |
@errors.cyclades.connection |
... | ... | |
1113 | 1109 |
self._run() |
1114 | 1110 |
|
1115 | 1111 |
|
1116 |
@command(server_cmds)
|
|
1117 |
class server_ip_list(_init_cyclades, _optional_json):
|
|
1118 |
"""List all floating ips"""
|
|
1112 |
@command(ip_cmds)
|
|
1113 |
class ip_list(_init_cyclades, _optional_json): |
|
1114 |
"""List reserved floating IPs"""
|
|
1119 | 1115 |
|
1120 | 1116 |
@errors.generic.all |
1121 | 1117 |
@errors.cyclades.connection |
... | ... | |
1128 | 1124 |
self._run() |
1129 | 1125 |
|
1130 | 1126 |
|
1131 |
@command(server_cmds)
|
|
1132 |
class server_ip_info(_init_cyclades, _optional_json):
|
|
1133 |
"""A floating IPs' details"""
|
|
1127 |
@command(ip_cmds)
|
|
1128 |
class ip_info(_init_cyclades, _optional_json): |
|
1129 |
"""Details for an IP"""
|
|
1134 | 1130 |
|
1135 | 1131 |
@errors.generic.all |
1136 | 1132 |
@errors.cyclades.connection |
1137 | 1133 |
def _run(self, ip): |
1138 | 1134 |
self._print(self.client.get_floating_ip(ip), self.print_dict) |
1139 | 1135 |
|
1140 |
def main(self, ip):
|
|
1136 |
def main(self, IP):
|
|
1141 | 1137 |
super(self.__class__, self)._run() |
1142 |
self._run(ip=ip)
|
|
1138 |
self._run(ip=IP)
|
|
1143 | 1139 |
|
1144 | 1140 |
|
1145 |
@command(server_cmds) |
|
1146 |
class server_ip_create(_init_cyclades, _optional_json): |
|
1147 |
"""Create a new floating IP""" |
|
1141 |
@command(ip_cmds) |
|
1142 |
class ip_reserve(_init_cyclades, _optional_json): |
|
1143 |
"""Reserve a floating IP |
|
1144 |
An IP is reserved from an IP pool. The default IP pool is chosen |
|
1145 |
automatically, but there is the option if specifying an explicit IP pool. |
|
1146 |
""" |
|
1148 | 1147 |
|
1149 | 1148 |
arguments = dict(pool=ValueArgument('Source IP pool', ('--pool'), None)) |
1150 | 1149 |
|
... | ... | |
1153 | 1152 |
def _run(self, ip=None): |
1154 | 1153 |
self._print([self.client.alloc_floating_ip(self['pool'], ip)]) |
1155 | 1154 |
|
1156 |
def main(self, requested_address=None):
|
|
1155 |
def main(self, requested_IP=None):
|
|
1157 | 1156 |
super(self.__class__, self)._run() |
1158 |
self._run(ip=requested_address)
|
|
1157 |
self._run(ip=requested_IP)
|
|
1159 | 1158 |
|
1160 | 1159 |
|
1161 |
@command(server_cmds) |
|
1162 |
class server_ip_delete(_init_cyclades, _optional_output_cmd): |
|
1163 |
"""Delete a floating ip""" |
|
1160 |
@command(ip_cmds) |
|
1161 |
class ip_release(_init_cyclades, _optional_output_cmd): |
|
1162 |
"""Release a floating IP |
|
1163 |
The release IP is "returned" to the IP pool it came from. |
|
1164 |
""" |
|
1164 | 1165 |
|
1165 | 1166 |
@errors.generic.all |
1166 | 1167 |
@errors.cyclades.connection |
1167 | 1168 |
def _run(self, ip): |
1168 | 1169 |
self._optional_output(self.client.delete_floating_ip(ip)) |
1169 | 1170 |
|
1170 |
def main(self, ip):
|
|
1171 |
def main(self, IP):
|
|
1171 | 1172 |
super(self.__class__, self)._run() |
1172 |
self._run(ip=ip)
|
|
1173 |
self._run(ip=IP)
|
|
1173 | 1174 |
|
1174 | 1175 |
|
1175 |
@command(server_cmds)
|
|
1176 |
class server_ip_attach(_init_cyclades, _optional_output_cmd):
|
|
1177 |
"""Attach a floating ip to a server with server_id
|
|
1176 |
@command(ip_cmds)
|
|
1177 |
class ip_attach(_init_cyclades, _optional_output_cmd): |
|
1178 |
"""Attach a floating IP to a server
|
|
1178 | 1179 |
""" |
1179 | 1180 |
|
1180 | 1181 |
@errors.generic.all |
... | ... | |
1183 | 1184 |
def _run(self, server_id, ip): |
1184 | 1185 |
self._optional_output(self.client.attach_floating_ip(server_id, ip)) |
1185 | 1186 |
|
1186 |
def main(self, server_id, ip):
|
|
1187 |
def main(self, server_id, IP):
|
|
1187 | 1188 |
super(self.__class__, self)._run() |
1188 |
self._run(server_id=server_id, ip=ip)
|
|
1189 |
self._run(server_id=server_id, ip=IP)
|
|
1189 | 1190 |
|
1190 | 1191 |
|
1191 |
@command(server_cmds)
|
|
1192 |
class server_ip_detach(_init_cyclades, _optional_output_cmd):
|
|
1193 |
"""Detach floating IP from server
|
|
1192 |
@command(ip_cmds)
|
|
1193 |
class ip_detach(_init_cyclades, _optional_output_cmd): |
|
1194 |
"""Detach a floating IP from a server
|
|
1194 | 1195 |
""" |
1195 | 1196 |
|
1196 | 1197 |
@errors.generic.all |
... | ... | |
1199 | 1200 |
def _run(self, server_id, ip): |
1200 | 1201 |
self._optional_output(self.client.detach_floating_ip(server_id, ip)) |
1201 | 1202 |
|
1202 |
def main(self, server_id, ip):
|
|
1203 |
def main(self, server_id, IP):
|
|
1203 | 1204 |
super(self.__class__, self)._run() |
1204 |
self._run(server_id=server_id, ip=ip) |
|
1205 |
self._run(server_id=server_id, ip=IP) |
Also available in: Unified diff