parent
e80d6f18ce
commit
98da0e6c99
1 changed files with 20 additions and 10 deletions
|
@ -128,6 +128,7 @@ EXAMPLES = '''
|
||||||
is_auto_revert: true
|
is_auto_revert: true
|
||||||
address: 10.10.10.10
|
address: 10.10.10.10
|
||||||
netmask: 255.255.255.0
|
netmask: 255.255.255.0
|
||||||
|
force_subnet_association: false
|
||||||
vserver: svm1
|
vserver: svm1
|
||||||
hostname: "{{ netapp_hostname }}"
|
hostname: "{{ netapp_hostname }}"
|
||||||
username: "{{ netapp_username }}"
|
username: "{{ netapp_username }}"
|
||||||
|
@ -183,6 +184,11 @@ class NetAppOntapInterface(object):
|
||||||
|
|
||||||
self.module = AnsibleModule(
|
self.module = AnsibleModule(
|
||||||
argument_spec=self.argument_spec,
|
argument_spec=self.argument_spec,
|
||||||
|
mutually_exclusive=[
|
||||||
|
['subnet_name', 'address'],
|
||||||
|
['subnet_name', 'netmask']
|
||||||
|
],
|
||||||
|
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
self.na_helper = NetAppModule()
|
self.na_helper = NetAppModule()
|
||||||
|
@ -194,7 +200,7 @@ class NetAppOntapInterface(object):
|
||||||
else:
|
else:
|
||||||
self.server = netapp_utils.setup_na_ontap_zapi(module=self.module)
|
self.server = netapp_utils.setup_na_ontap_zapi(module=self.module)
|
||||||
|
|
||||||
def get_interface(self, interface_name=None):
|
def get_interface(self):
|
||||||
"""
|
"""
|
||||||
Return details about the interface
|
Return details about the interface
|
||||||
:param:
|
:param:
|
||||||
|
@ -203,11 +209,10 @@ class NetAppOntapInterface(object):
|
||||||
:return: Details about the interface. None if not found.
|
:return: Details about the interface. None if not found.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
if interface_name is None:
|
|
||||||
interface_name = self.parameters['interface_name']
|
|
||||||
interface_info = netapp_utils.zapi.NaElement('net-interface-get-iter')
|
interface_info = netapp_utils.zapi.NaElement('net-interface-get-iter')
|
||||||
interface_attributes = netapp_utils.zapi.NaElement('net-interface-info')
|
interface_attributes = netapp_utils.zapi.NaElement('net-interface-info')
|
||||||
interface_attributes.add_new_child('interface-name', interface_name)
|
interface_attributes.add_new_child('interface-name', self.parameters['interface_name'])
|
||||||
|
interface_attributes.add_new_child('vserver', self.parameters['vserver'])
|
||||||
query = netapp_utils.zapi.NaElement('query')
|
query = netapp_utils.zapi.NaElement('query')
|
||||||
query.add_child_elem(interface_attributes)
|
query.add_child_elem(interface_attributes)
|
||||||
interface_info.add_child_elem(query)
|
interface_info.add_child_elem(query)
|
||||||
|
@ -234,7 +239,8 @@ class NetAppOntapInterface(object):
|
||||||
return_value['firewall_policy'] = interface_attributes['firewall-policy']
|
return_value['firewall_policy'] = interface_attributes['firewall-policy']
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
def set_options(self, options, parameters):
|
@staticmethod
|
||||||
|
def set_options(options, parameters):
|
||||||
""" set attributes for create or modify """
|
""" set attributes for create or modify """
|
||||||
if parameters.get('home_port') is not None:
|
if parameters.get('home_port') is not None:
|
||||||
options['home-port'] = parameters['home_port']
|
options['home-port'] = parameters['home_port']
|
||||||
|
@ -303,7 +309,7 @@ class NetAppOntapInterface(object):
|
||||||
if node is not None:
|
if node is not None:
|
||||||
self.parameters['home_node'] = node
|
self.parameters['home_node'] = node
|
||||||
# validate if mandatory parameters are present for create
|
# validate if mandatory parameters are present for create
|
||||||
if not keys.issubset(set(self.parameters.keys())):
|
if not keys.issubset(set(self.parameters.keys())) and self.parameters.get('subnet_name') is None:
|
||||||
self.module.fail_json(msg='Error: Missing one or more required parameters for creating interface: %s'
|
self.module.fail_json(msg='Error: Missing one or more required parameters for creating interface: %s'
|
||||||
% ', '.join(keys))
|
% ', '.join(keys))
|
||||||
# if role is intercluster, protocol cannot be specified
|
# if role is intercluster, protocol cannot be specified
|
||||||
|
@ -313,7 +319,11 @@ class NetAppOntapInterface(object):
|
||||||
|
|
||||||
def create_interface(self):
|
def create_interface(self):
|
||||||
''' calling zapi to create interface '''
|
''' calling zapi to create interface '''
|
||||||
required_keys = set(['role', 'address', 'home_port', 'netmask'])
|
required_keys = set(['role', 'home_port'])
|
||||||
|
data_protocols_obj = None
|
||||||
|
if self.parameters.get('subnet_name') is None:
|
||||||
|
required_keys.add('address')
|
||||||
|
required_keys.add('netmask')
|
||||||
data_protocols_obj = self.set_protocol_option(required_keys)
|
data_protocols_obj = self.set_protocol_option(required_keys)
|
||||||
self.validate_create_parameters(required_keys)
|
self.validate_create_parameters(required_keys)
|
||||||
|
|
||||||
|
@ -321,7 +331,7 @@ class NetAppOntapInterface(object):
|
||||||
'role': self.parameters['role'],
|
'role': self.parameters['role'],
|
||||||
'home-node': self.parameters.get('home_node'),
|
'home-node': self.parameters.get('home_node'),
|
||||||
'vserver': self.parameters['vserver']}
|
'vserver': self.parameters['vserver']}
|
||||||
self.set_options(options, self.parameters)
|
NetAppOntapInterface.set_options(options, self.parameters)
|
||||||
interface_create = netapp_utils.zapi.NaElement.create_node_with_children('net-interface-create', **options)
|
interface_create = netapp_utils.zapi.NaElement.create_node_with_children('net-interface-create', **options)
|
||||||
if data_protocols_obj is not None:
|
if data_protocols_obj is not None:
|
||||||
interface_create.add_child_elem(data_protocols_obj)
|
interface_create.add_child_elem(data_protocols_obj)
|
||||||
|
@ -353,7 +363,7 @@ class NetAppOntapInterface(object):
|
||||||
options = {'interface-name': self.parameters['interface_name'],
|
options = {'interface-name': self.parameters['interface_name'],
|
||||||
'vserver': self.parameters['vserver']
|
'vserver': self.parameters['vserver']
|
||||||
}
|
}
|
||||||
self.set_options(options, modify)
|
NetAppOntapInterface.set_options(options, modify)
|
||||||
interface_modify = netapp_utils.zapi.NaElement.create_node_with_children('net-interface-modify', **options)
|
interface_modify = netapp_utils.zapi.NaElement.create_node_with_children('net-interface-modify', **options)
|
||||||
try:
|
try:
|
||||||
self.server.invoke_successfully(interface_modify, enable_tunneling=True)
|
self.server.invoke_successfully(interface_modify, enable_tunneling=True)
|
||||||
|
|
Loading…
Reference in a new issue