module.fail_json(msg='ovh-api python module is required to run this module ')
module.fail_json(msg='ovh-api python module\
isrequiredtorunthismodule')
# Get parameters
# Get parameters
name=module.params.get('name')
name=module.params.get('name')
state=module.params.get('state')
state=module.params.get('state')
backend=module.params.get('backend')
backend=module.params.get('backend')
weight=long(module.params.get('weight'))
weight=long(module.params.get('weight'))
probe=module.params.get('probe')
probe=module.params.get('probe')
timeout=module.params.get('timeout')
timeout=module.params.get('timeout')
# Connect to OVH API
# Connect to OVH API
client=getOvhClient(module)
client=getOvhClient(module)
# Check that the load balancing exists
# Check that the load balancing exists
try:
try:
loadBalancings=client.get('/ip/loadBalancing')
loadBalancings=client.get('/ip/loadBalancing')
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for getting the list of loadBalancing, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for getting the list of loadBalancing, \
module.fail_json(msg='IP LoadBalancing {} does not exist'.format(name))
module.fail_json(msg='IP LoadBalancing {} does not exist'.format(name))
# Check that no task is pending before going on
# Check that no task is pending before going on
try:
try:
ifnotwaitForNoTask(client,name,timeout):
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(msg='Timeout of {} seconds while waiting for no pending tasks before executing the module '.format(timeout))
module.fail_json(
msg='Timeout of {} seconds while waiting for no pending \
tasksbeforeexecutingthemodule'.format(timeout))
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for getting the list of pending tasks of the loadBalancing, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for getting the list of pending tasks \
module.fail_json(msg='Unable to call OVH api for getting the list of backends of the loadBalancing, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for getting the list of backends \
module.fail_json(msg='Timeout of {} seconds while waiting for completion of removing backend task'.format(timeout))
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion \
ofremovingbackendtask'.format(timeout))
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for deleting the backend, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for deleting the backend, \
module.fail_json(msg='Unable to call OVH api for getting the backend properties, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for getting the backend properties, \
module.fail_json(msg='Timeout of {} seconds while waiting for completion of setWeight to backend task'.format(timeout))
'.format(name, backend), weight=weight)
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion \
ofsetWeighttobackendtask'.format(timeout))
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for updating the weight of the backend, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for updating the weight of the \
module.fail_json(msg='Timeout of {} seconds while waiting for completion of setProbe to backend task'.format(timeout))
'.format(name, backend), probe=probe)
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion of \
setProbetobackendtask'.format(timeout))
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for updating the propbe of the backend, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for updating the propbe of \
module.fail_json(msg='Unable to call OVH api for creating the backend, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for creating the backend, check \
ifnotwaitForNoTask(client,name,timeout):
applicationkey,secret,consumerkeyandparameters. \
module.fail_json(msg='Timeout of {} seconds while waiting for completion of backend creation task'.format(timeout))
ErrorreturnedbyOVHapiwas:{}'.format(apiError))
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion of \
backendcreationtask'.format(timeout))
exceptAPIErrorasapiError:
exceptAPIErrorasapiError:
module.fail_json(msg='Unable to call OVH api for creating the backend, check application key, secret, consumerkey and parameters. Error returned by OVH api was : {}'.format(apiError))
module.fail_json(
msg='Unable to call OVH api for creating the backend, check \