1
0
Fork 0
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:
René Moser 2018-09-19 00:01:53 +02:00 committed by GitHub
parent 22986648dc
commit 1ed3bd9168
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -169,8 +169,7 @@ class Vultr:
timeout=self.api_config['api_timeout'],
)
# Did we hit the rate limit?
if info.get('status') and info.get('status') != 503:
if info.get('status') == 200:
break
# Vultr has a rate limiting requests per second, try to be polite

View file

@ -529,7 +529,6 @@ class AnsibleVultrServer(Vultr):
method="POST",
data=data
)
server = self._wait_for_state(key='server_state', state='ok')
return server
def _update_ipv6_setting(self, server, start_server):
@ -554,7 +553,6 @@ class AnsibleVultrServer(Vultr):
method="POST",
data=data
)
server = self._wait_for_state(key='server_state', state='ok')
server = self._wait_for_state(key='v6_main_ip')
return server
@ -579,7 +577,6 @@ class AnsibleVultrServer(Vultr):
method="POST",
data=data
)
server = self._wait_for_state(key='server_state', state='ok')
return server
def _update_plan_setting(self, server, start_server):
@ -602,7 +599,6 @@ class AnsibleVultrServer(Vultr):
method="POST",
data=data
)
server = self._wait_for_state(key='server_state', state='ok')
return 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:
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
def absent_server(self):
@ -720,7 +716,7 @@ class AnsibleVultrServer(Vultr):
method="POST",
data=data
)
for s in range(0, 30):
for s in range(0, 60):
if server is not None:
break
time.sleep(2)
@ -764,7 +760,7 @@ class AnsibleVultrServer(Vultr):
def _wait_for_state(self, key='power_status', state=None):
time.sleep(1)
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
if state is None and server.get(key):
break

View file

@ -11,6 +11,11 @@
that:
- 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
vultr_server:
register: result