new feature (#57320)
This commit is contained in:
parent
3fadf4a1cb
commit
57b3160f13
2 changed files with 10 additions and 6 deletions
|
@ -211,7 +211,7 @@ class NetAppONTAPPortset(object):
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
for port in ports:
|
for port in ports:
|
||||||
self.modify_port(port, 'portset-remove')
|
self.modify_port(port, 'portset-remove', 'removing')
|
||||||
|
|
||||||
def add_ports(self):
|
def add_ports(self):
|
||||||
"""
|
"""
|
||||||
|
@ -222,9 +222,9 @@ class NetAppONTAPPortset(object):
|
||||||
if self.parameters.get('ports') == [''] or self.parameters.get('ports') is None:
|
if self.parameters.get('ports') == [''] or self.parameters.get('ports') is None:
|
||||||
return
|
return
|
||||||
for port in self.parameters['ports']:
|
for port in self.parameters['ports']:
|
||||||
self.modify_port(port, 'portset-add')
|
self.modify_port(port, 'portset-add', 'adding')
|
||||||
|
|
||||||
def modify_port(self, port, zapi):
|
def modify_port(self, port, zapi, action):
|
||||||
"""
|
"""
|
||||||
Add or remove an port to/from a portset
|
Add or remove an port to/from a portset
|
||||||
"""
|
"""
|
||||||
|
@ -237,8 +237,8 @@ class NetAppONTAPPortset(object):
|
||||||
try:
|
try:
|
||||||
self.server.invoke_successfully(portset_modify, enable_tunneling=True)
|
self.server.invoke_successfully(portset_modify, enable_tunneling=True)
|
||||||
except netapp_utils.zapi.NaApiError as error:
|
except netapp_utils.zapi.NaApiError as error:
|
||||||
self.module.fail_json(msg='Error modifying port in portset %s: %s' % (self.parameters['name'],
|
self.module.fail_json(msg='Error %s port in portset %s: %s' % (action, self.parameters['name'],
|
||||||
to_native(error)),
|
to_native(error)),
|
||||||
exception=traceback.format_exc())
|
exception=traceback.format_exc())
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
|
@ -257,6 +257,7 @@ class NetAppONTAPPortset(object):
|
||||||
else:
|
else:
|
||||||
if cd_action == 'create':
|
if cd_action == 'create':
|
||||||
self.create_portset()
|
self.create_portset()
|
||||||
|
self.add_ports()
|
||||||
elif cd_action == 'delete':
|
elif cd_action == 'delete':
|
||||||
self.delete_portset()
|
self.delete_portset()
|
||||||
elif modify:
|
elif modify:
|
||||||
|
|
|
@ -102,6 +102,7 @@ class TestMyModule(unittest.TestCase):
|
||||||
name = 'test'
|
name = 'test'
|
||||||
type = 'mixed'
|
type = 'mixed'
|
||||||
vserver = 'ansible_test'
|
vserver = 'ansible_test'
|
||||||
|
ports = ['a1', 'a2']
|
||||||
else:
|
else:
|
||||||
hostname = 'hostname'
|
hostname = 'hostname'
|
||||||
username = 'username'
|
username = 'username'
|
||||||
|
@ -109,13 +110,15 @@ class TestMyModule(unittest.TestCase):
|
||||||
name = 'name'
|
name = 'name'
|
||||||
type = 'mixed'
|
type = 'mixed'
|
||||||
vserver = 'vserver'
|
vserver = 'vserver'
|
||||||
|
ports = ['a1', 'a2']
|
||||||
return dict({
|
return dict({
|
||||||
'hostname': hostname,
|
'hostname': hostname,
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password,
|
'password': password,
|
||||||
'name': name,
|
'name': name,
|
||||||
'type': type,
|
'type': type,
|
||||||
'vserver': vserver
|
'vserver': vserver,
|
||||||
|
'ports': ports
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_module_fail_when_required_args_missing(self):
|
def test_module_fail_when_required_args_missing(self):
|
||||||
|
|
Loading…
Reference in a new issue