mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vultr: fix for unreliable API behavior (#45712)
This commit is contained in:
parent
22986648dc
commit
1ed3bd9168
3 changed files with 9 additions and 9 deletions
|
@ -169,8 +169,7 @@ class Vultr:
|
||||||
timeout=self.api_config['api_timeout'],
|
timeout=self.api_config['api_timeout'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Did we hit the rate limit?
|
if info.get('status') == 200:
|
||||||
if info.get('status') and info.get('status') != 503:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# Vultr has a rate limiting requests per second, try to be polite
|
# Vultr has a rate limiting requests per second, try to be polite
|
||||||
|
|
|
@ -529,7 +529,6 @@ class AnsibleVultrServer(Vultr):
|
||||||
method="POST",
|
method="POST",
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
server = self._wait_for_state(key='server_state', state='ok')
|
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def _update_ipv6_setting(self, server, start_server):
|
def _update_ipv6_setting(self, server, start_server):
|
||||||
|
@ -554,7 +553,6 @@ class AnsibleVultrServer(Vultr):
|
||||||
method="POST",
|
method="POST",
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
server = self._wait_for_state(key='server_state', state='ok')
|
|
||||||
server = self._wait_for_state(key='v6_main_ip')
|
server = self._wait_for_state(key='v6_main_ip')
|
||||||
return server
|
return server
|
||||||
|
|
||||||
|
@ -579,7 +577,6 @@ class AnsibleVultrServer(Vultr):
|
||||||
method="POST",
|
method="POST",
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
server = self._wait_for_state(key='server_state', state='ok')
|
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def _update_plan_setting(self, server, start_server):
|
def _update_plan_setting(self, server, start_server):
|
||||||
|
@ -602,7 +599,6 @@ class AnsibleVultrServer(Vultr):
|
||||||
method="POST",
|
method="POST",
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
server = self._wait_for_state(key='server_state', state='ok')
|
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def _handle_power_status_for_update(self, server, start_server):
|
def _handle_power_status_for_update(self, server, start_server):
|
||||||
|
@ -702,7 +698,7 @@ class AnsibleVultrServer(Vultr):
|
||||||
if self.server_power_state in ['starting', 'running'] and start_server:
|
if self.server_power_state in ['starting', 'running'] and start_server:
|
||||||
server = self.start_server(skip_results=True)
|
server = self.start_server(skip_results=True)
|
||||||
|
|
||||||
server = self._wait_for_state(key='server_state', state='ok')
|
server = self._wait_for_state(key='status', state='active')
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def absent_server(self):
|
def absent_server(self):
|
||||||
|
@ -720,7 +716,7 @@ class AnsibleVultrServer(Vultr):
|
||||||
method="POST",
|
method="POST",
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
for s in range(0, 30):
|
for s in range(0, 60):
|
||||||
if server is not None:
|
if server is not None:
|
||||||
break
|
break
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -764,7 +760,7 @@ class AnsibleVultrServer(Vultr):
|
||||||
def _wait_for_state(self, key='power_status', state=None):
|
def _wait_for_state(self, key='power_status', state=None):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
server = self.get_server(refresh=True)
|
server = self.get_server(refresh=True)
|
||||||
for s in range(0, 30):
|
for s in range(0, 60):
|
||||||
# Check for Truely if wanted state is None
|
# Check for Truely if wanted state is None
|
||||||
if state is None and server.get(key):
|
if state is None and server.get(key):
|
||||||
break
|
break
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
that:
|
that:
|
||||||
- result is success
|
- result is success
|
||||||
|
|
||||||
|
# Servers can only be destroyed 5 min after creation
|
||||||
|
- name: wait for 5 min
|
||||||
|
local_action: wait_for
|
||||||
|
when: result is changed
|
||||||
|
|
||||||
- name: test fail if missing name
|
- name: test fail if missing name
|
||||||
vultr_server:
|
vultr_server:
|
||||||
register: result
|
register: result
|
||||||
|
|
Loading…
Reference in a new issue