diff --git a/lib/ansible/modules/extras/network/a10/a10_server.py b/lib/ansible/modules/extras/network/a10/a10_server.py index 6df65743d0b..38a3b1a3aa1 100644 --- a/lib/ansible/modules/extras/network/a10/a10_server.py +++ b/lib/ansible/modules/extras/network/a10/a10_server.py @@ -34,6 +34,12 @@ notes: - Requires A10 Networks aXAPI 2.1. extends_documentation_fragment: a10 options: + partition: + version_added: "2.3" + description: + - set active-partition + required: false + default: null server_name: description: - The SLB (Server Load Balancer) server name. @@ -87,6 +93,7 @@ EXAMPLES = ''' host: a10.mydomain.com username: myadmin password: mypassword + partition: mypartition server: test server_ip: 1.1.1.100 server_ports: @@ -97,6 +104,15 @@ EXAMPLES = ''' ''' +RETURN = ''' +content: + description: the full info regarding the slb_server + returned: success + type: string + sample: "mynewserver" +''' + + VALID_PORT_FIELDS = ['port_num', 'protocol', 'status'] def validate_ports(module, ports): @@ -142,6 +158,7 @@ def main(): server_ip=dict(type='str', aliases=['ip', 'address']), server_status=dict(type='str', default='enabled', aliases=['status'], choices=['enabled', 'disabled']), server_ports=dict(type='list', aliases=['port'], default=[]), + partition=dict(type='str', default=[]), ) ) @@ -151,6 +168,7 @@ def main(): ) host = module.params['host'] + partition = module.params['partition'] username = module.params['username'] password = module.params['password'] state = module.params['state'] @@ -185,6 +203,8 @@ def main(): if slb_server_status: json_post['server']['status'] = axapi_enabled_disabled(slb_server_status) + slb_server_partition = axapi_call(module, session_url + '&method=system.partition.active', json.dumps({'name': partition})) + slb_server_data = axapi_call(module, session_url + '&method=slb.server.search', json.dumps({'name': slb_server})) slb_server_exists = not axapi_failure(slb_server_data) diff --git a/lib/ansible/modules/extras/network/a10/a10_service_group.py b/lib/ansible/modules/extras/network/a10/a10_service_group.py index c99676b832e..39716fda49b 100644 --- a/lib/ansible/modules/extras/network/a10/a10_service_group.py +++ b/lib/ansible/modules/extras/network/a10/a10_service_group.py @@ -35,6 +35,12 @@ notes: - When a server doesn't exist and is added to the service-group the server will be created. extends_documentation_fragment: a10 options: + partition: + version_added: "2.3" + description: + - set active-partition + required: false + default: null service_group: description: - The SLB (Server Load Balancing) service-group name @@ -82,6 +88,7 @@ EXAMPLES = ''' host: a10.mydomain.com username: myadmin password: mypassword + partition: mypartition service_group: sg-80-tcp servers: - server: foo1.mydomain.com @@ -96,6 +103,14 @@ EXAMPLES = ''' ''' +RETURN = ''' +content: + description: the full info regarding the slb_service_group + returned: success + type: string + sample: "mynewservicegroup" +''' + VALID_SERVICE_GROUP_FIELDS = ['name', 'protocol', 'lb_method'] VALID_SERVER_FIELDS = ['server', 'port', 'status'] @@ -147,6 +162,7 @@ def main(): 'src-ip-only-hash', 'src-ip-hash']), servers=dict(type='list', aliases=['server', 'member'], default=[]), + partition=dict(type='str', default=[]), ) ) @@ -158,6 +174,7 @@ def main(): host = module.params['host'] username = module.params['username'] password = module.params['password'] + partition = module.params['partition'] state = module.params['state'] write_config = module.params['write_config'] slb_service_group = module.params['service_group'] @@ -199,7 +216,8 @@ def main(): # first we authenticate to get a session id session_url = axapi_authenticate(module, axapi_base_url, username, password) - + # then we select the active-partition + slb_server_partition = axapi_call(module, session_url + '&method=system.partition.active', json.dumps({'name': partition})) # then we check to see if the specified group exists slb_result = axapi_call(module, session_url + '&method=slb.service_group.search', json.dumps({'name': slb_service_group})) slb_service_group_exist = not axapi_failure(slb_result) diff --git a/lib/ansible/modules/extras/network/a10/a10_virtual_server.py b/lib/ansible/modules/extras/network/a10/a10_virtual_server.py index d631a0564f4..783cfa4baa4 100644 --- a/lib/ansible/modules/extras/network/a10/a10_virtual_server.py +++ b/lib/ansible/modules/extras/network/a10/a10_virtual_server.py @@ -34,6 +34,12 @@ notes: - Requires A10 Networks aXAPI 2.1. extends_documentation_fragment: a10 options: + partition: + version_added: "2.3" + description: + - set active-partition + required: false + default: null virtual_server: description: - The SLB (Server Load Balancing) virtual server name. @@ -80,6 +86,7 @@ EXAMPLES = ''' host: a10.mydomain.com username: myadmin password: mypassword + partition: mypartition virtual_server: vserver1 virtual_server_ip: 1.1.1.1 virtual_server_ports: @@ -95,6 +102,14 @@ EXAMPLES = ''' ''' +RETURN = ''' +content: + description: the full info regarding the slb_virtual + returned: success + type: string + sample: "mynewvirtualserver" +''' + VALID_PORT_FIELDS = ['port', 'protocol', 'service_group', 'status'] def validate_ports(module, ports): @@ -143,6 +158,7 @@ def main(): virtual_server_ip=dict(type='str', aliases=['ip', 'address'], required=True), virtual_server_status=dict(type='str', default='enabled', aliases=['status'], choices=['enabled', 'disabled']), virtual_server_ports=dict(type='list', required=True), + partition=dict(type='str', default=[]), ) ) @@ -154,6 +170,7 @@ def main(): host = module.params['host'] username = module.params['username'] password = module.params['password'] + partition = module.params['partition'] state = module.params['state'] write_config = module.params['write_config'] slb_virtual = module.params['virtual_server'] @@ -169,6 +186,7 @@ def main(): axapi_base_url = 'https://%s/services/rest/V2.1/?format=json' % host session_url = axapi_authenticate(module, axapi_base_url, username, password) + slb_server_partition = axapi_call(module, session_url + '&method=system.partition.active', json.dumps({'name': partition})) slb_virtual_data = axapi_call(module, session_url + '&method=slb.virtual_server.search', json.dumps({'name': slb_virtual})) slb_virtual_exists = not axapi_failure(slb_virtual_data)