Revision e9c73313 kamaki/cli/commands/cyclades.py
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
75 | 75 |
'do not show progress bar', ('-N', '--no-progress-bar'), False) |
76 | 76 |
) |
77 | 77 |
|
78 |
def _wait(self, service, service_id, status_method, currect_status): |
|
78 |
def _wait( |
|
79 |
self, service, service_id, status_method, current_status, |
|
80 |
timeout=True): |
|
79 | 81 |
(progress_bar, wait_cb) = self._safe_progress_bar( |
80 |
'%s %s: periodically check if status is %s' % ( |
|
81 |
service, service_id, currect_status)) |
|
82 |
'%s %s: status is still %s' % ( |
|
83 |
service, service_id, current_status), |
|
84 |
timeout=timeout) |
|
82 | 85 |
|
83 | 86 |
try: |
84 | 87 |
new_mode = status_method( |
85 |
service_id, currect_status, wait_cb=wait_cb)
|
|
88 |
service_id, current_status, wait_cb=wait_cb)
|
|
86 | 89 |
if new_mode: |
87 |
self.error('\n%s %s: status is %s' % (
|
|
90 |
self.error('%s %s: status is now %s' % (
|
|
88 | 91 |
service, service_id, new_mode)) |
89 | 92 |
else: |
90 |
self.error('\nTime out: %s %s still in %s' % (
|
|
91 |
service, service_id, currect_status))
|
|
93 |
self.error('%s %s: (timeout) status is still %s' % (
|
|
94 |
service, service_id, current_status))
|
|
92 | 95 |
except KeyboardInterrupt: |
93 | 96 |
self.error('\n- canceled') |
94 | 97 |
finally: |
... | ... | |
97 | 100 |
|
98 | 101 |
class _server_wait(_service_wait): |
99 | 102 |
|
100 |
def _wait(self, server_id, currect_status):
|
|
103 |
def _wait(self, server_id, current_status):
|
|
101 | 104 |
super(_server_wait, self)._wait( |
102 |
'Server', server_id, self.client.wait_server, currect_status) |
|
105 |
'Server', server_id, self.client.wait_server, current_status, |
|
106 |
timeout=(current_status not in ('BUILD', ))) |
|
103 | 107 |
|
104 | 108 |
|
105 | 109 |
class _network_wait(_service_wait): |
106 | 110 |
|
107 |
def _wait(self, net_id, currect_status):
|
|
111 |
def _wait(self, net_id, current_status):
|
|
108 | 112 |
super(_network_wait, self)._wait( |
109 |
'Network', net_id, self.client.wait_network, currect_status)
|
|
113 |
'Network', net_id, self.client.wait_network, current_status)
|
|
110 | 114 |
|
111 | 115 |
|
112 | 116 |
class _init_cyclades(_command_init): |
... | ... | |
699 | 703 |
@errors.generic.all |
700 | 704 |
@errors.cyclades.connection |
701 | 705 |
@errors.cyclades.server_id |
702 |
def _run(self, server_id, currect_status): |
|
703 |
self._wait(server_id, currect_status) |
|
706 |
def _run(self, server_id, current_status): |
|
707 |
r = self.client.get_server_details(server_id) |
|
708 |
if r['status'].lower() == current_status.lower(): |
|
709 |
self._wait(server_id, current_status) |
|
710 |
else: |
|
711 |
self.error( |
|
712 |
'Server %s: Cannot wait for status %s, ' |
|
713 |
'status is already %s' % ( |
|
714 |
server_id, current_status, r['status'])) |
|
704 | 715 |
|
705 |
def main(self, server_id, currect_status='BUILD'):
|
|
716 |
def main(self, server_id, current_status='BUILD'):
|
|
706 | 717 |
super(self.__class__, self)._run() |
707 |
self._run(server_id=server_id, currect_status=currect_status)
|
|
718 |
self._run(server_id=server_id, current_status=current_status)
|
|
708 | 719 |
|
709 | 720 |
|
710 | 721 |
@command(flavor_cmds) |
... | ... | |
946 | 957 |
type=self['type']) |
947 | 958 |
_add_name(self, r) |
948 | 959 |
self._print(r, self.print_dict) |
949 |
if self['wait']: |
|
960 |
if self['wait'] and r['status'] in ('PENDING', ):
|
|
950 | 961 |
self._wait(r['id'], 'PENDING') |
951 | 962 |
|
952 | 963 |
def main(self, name): |
... | ... | |
1055 | 1066 |
@errors.generic.all |
1056 | 1067 |
@errors.cyclades.connection |
1057 | 1068 |
@errors.cyclades.network_id |
1058 |
def _run(self, network_id, currect_status): |
|
1059 |
self._wait(network_id, currect_status) |
|
1069 |
def _run(self, network_id, current_status): |
|
1070 |
net = self.client.get_network_details(network_id) |
|
1071 |
if net['status'].lower() == current_status.lower(): |
|
1072 |
self._wait(network_id, current_status) |
|
1073 |
else: |
|
1074 |
self.error( |
|
1075 |
'Network %s: Cannot wait for status %s, ' |
|
1076 |
'status is already %s' % ( |
|
1077 |
network_id, current_status, net['status'])) |
|
1060 | 1078 |
|
1061 |
def main(self, network_id, currect_status='PENDING'):
|
|
1079 |
def main(self, network_id, current_status='PENDING'):
|
|
1062 | 1080 |
super(self.__class__, self)._run() |
1063 |
self._run(network_id=network_id, currect_status=currect_status)
|
|
1081 |
self._run(network_id=network_id, current_status=current_status)
|
|
1064 | 1082 |
|
1065 | 1083 |
|
1066 | 1084 |
@command(server_cmds) |
Also available in: Unified diff