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
name=module.params.get('name')
state=module.params.get('state')
backend=module.params.get('backend')
weight=long(module.params.get('weight'))
probe=module.params.get('probe')
name=module.params.get('name')
state=module.params.get('state')
backend=module.params.get('backend')
weight=long(module.params.get('weight'))
probe=module.params.get('probe')
timeout=module.params.get('timeout')
# Connect to OVH API
client=getOvhClient(module)
# Check that the load balancing exists
try:
try:
loadBalancings=client.get('/ip/loadBalancing')
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))
ifnotnameinloadBalancings:
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))
# Check that no task is pending before going on
try:
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(msg='Timeout of {} seconds while waiting for no pending tasks before executing the module '.format(timeout))
try:
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for no pending \
tasksbeforeexecutingthemodule'.format(timeout))
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 \
msg='Timeout of {} seconds while waiting for completion \
ofremovingbackendtask'.format(timeout))
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))
try:
client.post(
'/ip/loadBalancing/{}/backend/{}/setWeight\
'.format(name, backend), weight=weight)
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion \
ofsetWeighttobackendtask'.format(timeout))
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))
try:
client.put(
'/ip/loadBalancing/{}/backend/{}\
'.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:
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))
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(msg='Timeout of {} seconds while waiting for completion of backend creation task'.format(timeout))
module.fail_json(
msg='Unable to call OVH api for creating the backend, check \
applicationkey,secret,consumerkeyandparameters. \
ErrorreturnedbyOVHapiwas:{}'.format(apiError))
ifnotwaitForNoTask(client,name,timeout):
module.fail_json(
msg='Timeout of {} seconds while waiting for completion of \
backendcreationtask'.format(timeout))
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 \