Adds missing fields for iapp service (#26507)

The iApp service module worked fine previously, but this patch
adds enhancements to it to include more fields that can be
specified when creating iapp services.
This commit is contained in:
Tim Rupp 2017-07-09 23:27:49 -07:00 committed by John R Barker
commit 37ca55bf71
3 changed files with 46 additions and 1 deletions

View file

@ -159,7 +159,8 @@ from deepdiff import DeepDiff
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
returnables = [] returnables = []
api_attributes = [ api_attributes = [
'tables', 'variables', 'template', 'lists' 'tables', 'variables', 'template', 'lists', 'deviceGroup',
'inheritedDevicegroup', 'inheritedTrafficGroup', 'trafficGroup'
] ]
updatables = ['tables', 'variables', 'lists'] updatables = ['tables', 'variables', 'lists']
@ -282,6 +283,14 @@ class Parameters(AnsibleF5Parameters):
self.variables = value['variables'] self.variables = value['variables']
if 'lists' in value: if 'lists' in value:
self.lists = value['lists'] self.lists = value['lists']
if 'deviceGroup' in value:
self.deviceGroup = value['deviceGroup']
if 'inheritedDevicegroup' in value:
self.inheritedDevicegroup = value['inheritedDevicegroup']
if 'inheritedTrafficGroup' in value:
self.inheritedTrafficGroup = value['inheritedTrafficGroup']
if 'trafficGroup' in value:
self.trafficGroup = value['trafficGroup']
@property @property
def template(self): def template(self):

View file

@ -2,6 +2,10 @@
"name": "http_example", "name": "http_example",
"partition": "Common", "partition": "Common",
"template": "/Common/f5.http", "template": "/Common/f5.http",
"inheritedDevicegroup": "true",
"deviceGroup": "none",
"inheritedTrafficGroup": "true",
"trafficGroup": "/Common/traffic-group-local-only",
"lists": [ "lists": [
{ {
"name": "irules__irules", "name": "irules__irules",

View file

@ -83,6 +83,10 @@ class TestParameters(unittest.TestCase):
assert p.name == 'http_example' assert p.name == 'http_example'
assert p.partition == 'Common' assert p.partition == 'Common'
assert p.template == '/Common/f5.http' assert p.template == '/Common/f5.http'
assert p.deviceGroup == 'none'
assert p.inheritedTrafficGroup == 'true'
assert p.inheritedDevicegroup == 'true'
assert p.trafficGroup == '/Common/traffic-group-local-only'
def test_module_parameters_lists(self): def test_module_parameters_lists(self):
args = load_fixture('create_iapp_service_parameters_f5_http.json') args = load_fixture('create_iapp_service_parameters_f5_http.json')
@ -197,6 +201,34 @@ class TestParameters(unittest.TestCase):
assert p.tables[0]['rows'][0]['row'] == ['12.12.12.12', '80', '0'] assert p.tables[0]['rows'][0]['row'] == ['12.12.12.12', '80', '0']
assert p.tables[0]['rows'][1]['row'] == ['13.13.13.13', '443', '10'] assert p.tables[0]['rows'][1]['row'] == ['13.13.13.13', '443', '10']
def test_api_parameters_device_group(self):
args = dict(
deviceGroup='none'
)
p = Parameters(args)
assert p.deviceGroup == 'none'
def test_api_parameters_inherited_traffic_group(self):
args = dict(
inheritedTrafficGroup='true'
)
p = Parameters(args)
assert p.inheritedTrafficGroup == 'true'
def test_api_parameters_inherited_devicegroup(self):
args = dict(
inheritedDevicegroup='true'
)
p = Parameters(args)
assert p.inheritedDevicegroup == 'true'
def test_api_parameters_traffic_group(self):
args = dict(
trafficGroup='/Common/traffic-group-local-only'
)
p = Parameters(args)
assert p.trafficGroup == '/Common/traffic-group-local-only'
def test_module_template_same_partition(self): def test_module_template_same_partition(self):
args = dict( args = dict(
template='foo', template='foo',