mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
New module: manage 1&1 monitoring policy (cloud/oneandone/oneandone_monitoring_policy) (#35068)
* Added server_type parameter - defaults to K8S * Changed server_type default value to cloud. * Added server_type entry to documentation and updated server_type choice K8S to k8s_node * Added support for overriding the default ONEANDONE_API_URL, and custom wait_timeout period for wait_for methods. * Added firewall_policy, load_balancer, and monitoring_policy cloud modules for oneandone provider. * Updated OneAndOneResources class and argument specs for monitoring policy and load balancer. * Addressed ansible-test sanity pep8 and validate-modules errors. * Removed extra modules to adhere to one module per PR. * Fixed a typo
This commit is contained in:
parent
f46f6c8dec
commit
238760045e
3 changed files with 1093 additions and 20 deletions
|
@ -27,7 +27,15 @@ import time
|
|||
|
||||
|
||||
class OneAndOneResources:
|
||||
firewall_policy, load_balancer, monitoring_policy, private_network, public_ip, role, server, user, vpn = range(9)
|
||||
firewall_policy = 'firewall_policy'
|
||||
load_balancer = 'load_balancer'
|
||||
monitoring_policy = 'monitoring_policy'
|
||||
private_network = 'private_network'
|
||||
public_ip = 'public_ip'
|
||||
role = 'role'
|
||||
server = 'server'
|
||||
user = 'user'
|
||||
vpn = 'vpn'
|
||||
|
||||
|
||||
def get_resource(oneandone_conn, resource_type, resource_id):
|
||||
|
@ -43,7 +51,7 @@ def get_resource(oneandone_conn, resource_type, resource_id):
|
|||
'vpn': oneandone_conn.get_vpn,
|
||||
}
|
||||
|
||||
return switcher.get(resource_type.name, None)(resource_id)
|
||||
return switcher.get(resource_type, None)(resource_id)
|
||||
|
||||
|
||||
def get_datacenter(oneandone_conn, datacenter, full_object=False):
|
||||
|
@ -187,13 +195,14 @@ def get_vpn(oneandone_conn, vpn, full_object=False):
|
|||
def wait_for_resource_creation_completion(oneandone_conn,
|
||||
resource_type,
|
||||
resource_id,
|
||||
wait_timeout):
|
||||
wait_timeout,
|
||||
wait_interval):
|
||||
"""
|
||||
Waits for the resource create operation to complete based on the timeout period.
|
||||
"""
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
time.sleep(wait_interval)
|
||||
|
||||
# Refresh the resource info
|
||||
resource = get_resource(oneandone_conn, resource_type, resource_id)
|
||||
|
@ -215,22 +224,23 @@ def wait_for_resource_creation_completion(oneandone_conn,
|
|||
continue
|
||||
else:
|
||||
raise Exception(
|
||||
'Unknown %s state %s' % (resource_type.name, resource_state))
|
||||
'Unknown %s state %s' % (resource_type, resource_state))
|
||||
|
||||
raise Exception(
|
||||
'Timed out waiting for %s completion for %s' % (resource_type.name, resource_id))
|
||||
'Timed out waiting for %s completion for %s' % (resource_type, resource_id))
|
||||
|
||||
|
||||
def wait_for_resource_deletion_completion(oneandone_conn,
|
||||
resource_type,
|
||||
resource_id,
|
||||
wait_timeout):
|
||||
wait_timeout,
|
||||
wait_interval):
|
||||
"""
|
||||
Waits for the resource delete operation to complete based on the timeout period.
|
||||
"""
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
while wait_timeout > time.time():
|
||||
time.sleep(5)
|
||||
time.sleep(wait_interval)
|
||||
|
||||
# Refresh the operation info
|
||||
logs = oneandone_conn.list_logs(q='DELETE',
|
||||
|
@ -243,7 +253,7 @@ def wait_for_resource_deletion_completion(oneandone_conn,
|
|||
_type = 'PRIVATENETWORK'
|
||||
else:
|
||||
raise Exception(
|
||||
'Unsupported wait_for delete operation for %s resource' % resource_type.name)
|
||||
'Unsupported wait_for delete operation for %s resource' % resource_type)
|
||||
|
||||
for log in logs:
|
||||
if (log['resource']['id'] == resource_id and
|
||||
|
@ -252,4 +262,4 @@ def wait_for_resource_deletion_completion(oneandone_conn,
|
|||
log['status']['state'] == 'OK'):
|
||||
return
|
||||
raise Exception(
|
||||
'Timed out waiting for %s deletion for %s' % (resource_type.name, resource_id))
|
||||
'Timed out waiting for %s deletion for %s' % (resource_type, resource_id))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue