def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), from_name=dict(required=False, type='str'), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module) return
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), job_minutes=dict(required=False, type='list', elements='str'), job_months=dict(required=False, type='list', elements='str'), job_hours=dict(required=False, type='list', elements='str'), job_days_of_month=dict(required=False, type='list', elements='str'), job_days_of_week=dict(required=False, type='list', elements='str') )) self.uuid = None self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.set_playbook_zapi_key_map() self.set_playbook_api_key_map() self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module)
def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), auth_type=dict(required=False, type='str', choices=['chap', 'none', 'deny']), inbound_password=dict(required=False, type='str', no_log=True), inbound_username=dict(required=False, type='str'), initiator=dict(required=True, type='str'), address_ranges=dict(required=False, type='list', elements='str'), outbound_password=dict(required=False, type='str', no_log=True), outbound_username=dict(required=False, type='str'), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True, required_if=[ ['auth_type', 'chap', ['inbound_username', 'inbound_password']] ], required_together=[ ['inbound_username', 'inbound_password'], ['outbound_username', 'outbound_password'], ], ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) self.uuid = self.get_svm_uuid()
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(name=dict(required=False, type='str'), autosupport_message=dict(required=False, type='str', aliases=["message"]), type=dict(required=False, choices=['test', 'performance', 'all'], default='all'), uri=dict(required=False, type='str'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # REST API should be used for ONTAP 9.6 or higher. self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: if not HAS_NETAPP_LIB: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module)
def __init__(self): """ Initialize the ONTAP Storage auto giveback class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(name=dict(required=True, type='str'), auto_giveback_enabled=dict(required=True, type='bool'), auto_giveback_after_panic_enabled=dict(required=False, type='bool'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: if not netapp_utils.has_netapp_lib(): self.module.fail_json( msg='The python NetApp-Lib module is required') else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module)
def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), name=dict(required=True, type='str'), allow_privileged_access=dict(required=False, type='bool'), engine=dict(required=False, type='str'), events=dict(required=True, type='list', elements='str'), is_mandatory=dict(required=False, type='bool'), is_passthrough_read_enabled=dict(required=False, type='bool'), privileged_user_name=dict(required=False, type='str') )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: if not netapp_utils.has_netapp_lib(): self.module.fail_json(msg=netapp_utils.netapp_lib_is_required()) else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(vserver=dict(required=True, type='str'), banner=dict(required=False, type='str'), motd_message=dict(required=False, type='str', aliases=['message']), show_cluster_motd=dict(default=True, type='bool'))) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True, required_one_of=[['show_cluster_motd', 'banner', 'motd_message']]) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict( api=dict(required=True, type='str'), method=dict(required=False, type='str', default='GET'), query=dict(required=False, type='dict'), body=dict(required=False, type='dict', aliases=['info']), vserver_name=dict(required=False, type='str'), vserver_uuid=dict(required=False, type='str'), hal_linking=dict(required=False, type='bool', default=False), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=False) parameters = self.module.params # set up state variables self.api = parameters['api'] self.method = parameters['method'] self.query = parameters['query'] self.body = parameters['body'] self.vserver_name = parameters['vserver_name'] self.vserver_uuid = parameters['vserver_uuid'] self.hal_linking = parameters['hal_linking'] self.restApi = OntapRestAPI(self.module)
def __init__(self): """ Initialize the Ontap Net Route class """ self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=[ 'present', 'absent'], default='present'), vserver=dict(required=True, type='str'), destination=dict(required=True, type='str'), gateway=dict(required=True, type='str'), metric=dict(required=False, type='str'), from_destination=dict(required=False, type='str', default=None), from_gateway=dict(required=False, type='str', default=None), from_metric=dict(required=False, type='str', default=None), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.restApi = OntapRestAPI(self.module) if self.restApi.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json(msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver']) return
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(name=dict(required=True, type='str'), state=dict(required=False, choices=['present', 'absent'], default='present'), provider_type=dict(required=False, type='str'), server=dict(required=False, type='str'), container=dict(required=False, type='str'), access_key=dict(required=False, type='str'), secret_password=dict(required=False, type='str', no_log=True))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # API should be used for ONTAP 9.6 or higher, Zapi for lower version self.restApi = OntapRestAPI(self.module) if self.restApi.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module)
def __init__(self): """ Parse arguments, setup state variables, check paramenters and ensure request module is installed """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(type='str', choices=['info'], default='info', required=False), gather_subset=dict(default=['all'], type='list', elements='str', required=False), max_records=dict(type='int', default=1024, required=False), fields=dict(type='list', elements='str', required=False), parameters=dict(type='dict', required=False))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.fields = list() self.rest_api = OntapRestAPI(self.module)
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( command=dict(required=True, type='str'), verb=dict(required=True, type='str', choices=['GET', 'POST', 'PATCH', 'DELETE']), params=dict(required=False, type='dict', default={}), body=dict(required=False, type='dict', default={}) )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.restApi = OntapRestAPI(self.module) parameters = self.module.params # set up state variables self.command = parameters['command'] self.verb = parameters['verb'] self.params = parameters['params'] self.body = parameters['body'] if self.restApi.is_rest(): self.use_rest = True else: self.module.fail_json(msg="use na_ontap_command for non-rest cli")
def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), wwpn=dict(required=False, type='str'), vserver=dict(required=True, type='str'))) self.module = AnsibleModule(argument_spec=self.argument_spec, required_if=[('state', 'present', ['wwpn']) ], supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # REST API should be used for ONTAP 9.6 or higher. self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: self.module.fail_json( msg=self.rest_api.requires_ontap_9_6('na_ontap_wwpn_alias'))
def __init__(self): """ Initialize the Ontap Storage failover class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=['present', 'absent'], default='present'), node_name=dict(required=True, type='str'), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) if self.parameters['state'] == 'present': self.parameters['is_enabled'] = True else: self.parameters['is_enabled'] = False self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json(msg='The python NetApp-Lib module is required') else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module)
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), from_name=dict(required=False, type='str'), root_volume=dict(type='str'), root_volume_aggregate=dict(type='str'), root_volume_security_style=dict( type='str', choices=['unix', 'ntfs', 'mixed', 'unified']), allowed_protocols=dict(type='list', elements='str'), aggr_list=dict(type='list', elements='str'), ipspace=dict(type='str', required=False), snapshot_policy=dict(type='str', required=False), language=dict(type='str', required=False), subtype=dict(type='str', choices=[ 'default', 'dp_destination', 'sync_source', 'sync_destination' ]), comment=dict(type="str", required=False))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # Ontap documentation uses C.UTF-8, but actually stores as c.utf_8. if 'language' in self.parameters and self.parameters['language'].lower( ) == 'c.utf-8': self.parameters['language'] = 'c.utf_8' self.restApi = OntapRestAPI(self.module) # with REST, to force synchronous operations self.timeout = self.restApi.timeout # root volume not supported with rest api unsupported_rest_properties = [ 'root_volume', 'root_volume_aggregate', 'root_volume_security_style' ] used_unsupported_rest_properties = [ x for x in unsupported_rest_properties if x in self.parameters ] self.use_rest, error = self.restApi.is_rest( used_unsupported_rest_properties) if error is not None: self.module.fail_json(msg=error) if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module)
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.modifiable_options = dict( abort_on_disk_error=dict(required=False, type='bool'), authtype=dict(required=False, type='list'), backup_log_enable=dict(required=False, type='bool'), data_port_range=dict(required=False, type='str'), debug_enable=dict(required=False, type='bool'), debug_filter=dict(required=False, type='str'), dump_detailed_stats=dict(required=False, type='bool'), dump_logical_find=dict(required=False, type='str'), enable=dict(required=False, type='bool'), fh_dir_retry_interval=dict(required=False, type='int'), fh_node_retry_interval=dict(required=False, type='int'), ignore_ctime_enabled=dict(required=False, type='bool'), is_secure_control_connection_enabled=dict(required=False, type='bool'), offset_map_enable=dict(required=False, type='bool'), per_qtree_exclude_enable=dict(required=False, type='bool'), preferred_interface_role=dict(required=False, type='list'), restore_vm_cache_size=dict(required=False, type='int'), secondary_debug_filter=dict(required=False, type='str'), tcpnodelay=dict(required=False, type='bool'), tcpwinsize=dict(required=False, type='int') ) self.argument_spec.update(dict( vserver=dict(required=True, type='str') )) self.argument_spec.update(self.modifiable_options) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # API should be used for ONTAP 9.6 or higher, ZAPI for lower version self.restApi = OntapRestAPI(self.module) unsupported_rest_properties = ['abort_on_disk_error', 'backup_log_enable', 'data_port_range', 'debug_enable', 'debug_filter', 'dump_detailed_stats', 'dump_logical_find', 'fh_dir_retry_interval', 'fh_node_retry_interval', 'ignore_ctime_enabled', 'is_secure_control_connection_enabled', 'offset_map_enable', 'per_qtree_exclude_enable', 'preferred_interface_role', 'restore_vm_cache_size', 'secondary_debug_filter', 'tcpnodelay', 'tcpwinsize'] used_unsupported_rest_properties = [x for x in unsupported_rest_properties if x in self.parameters] self.use_rest, error = self.restApi.is_rest(used_unsupported_rest_properties) if error is not None: self.module.fail_json(msg=error) if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json(msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver'])
def __init__(self): """ Initialize the ONTAP Security Config class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(name=dict(required=False, type='str', default='ssl'), is_fips_enabled=dict(required=False, type='bool'), supported_ciphers=dict(required=False, type='str'), supported_protocols=dict( required=False, type='list', elements='str', choices=['TLSv1.2', 'TLSv1.1', 'TLSv1']))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) if 'is_fips_enabled' in self.parameters and 'supported_ciphers' in self.parameters: # if fips is enabled, supported ciphers should not be specified. if self.parameters['is_fips_enabled']: self.module.fail_json( msg= 'is_fips_enabled was specified as true and supported_ciphers was specified. \ If fips is enabled then supported ciphers should not be specified' ) if 'is_fips_enabled' in self.parameters and 'supported_protocols' in self.parameters: # if fips is enabled, TLSv1 is not a supported protocol. if self.parameters[ 'is_fips_enabled'] and 'TLSv1' in self.parameters[ 'supported_protocols']: self.module.fail_json( msg= 'is_fips_enabled was specified as true and TLSv1 was specified as a supported protocol. \ If fips is enabled then TLSv1 is not a supported protocol') if 'supported_ciphers' in self.parameters: self.parameters['supported_ciphers'] = self.parameters[ 'supported_ciphers'].replace('\\', '') self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg='The python NetApp-Lib module is required') else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module)
class NetAppONTAPCommandREST(object): ''' calls a CLI command ''' def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( command=dict(required=True, type='str'), verb=dict(required=True, type='str', choices=['GET', 'POST', 'PATCH', 'DELETE']), params=dict(required=False, type='dict', default={}), body=dict(required=False, type='dict', default={}) )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.restApi = OntapRestAPI(self.module) parameters = self.module.params # set up state variables self.command = parameters['command'] self.verb = parameters['verb'] self.params = parameters['params'] self.body = parameters['body'] if self.restApi.is_rest(): self.use_rest = True else: self.module.fail_json(msg="use na_ontap_command for non-rest cli") def run_command(self): api = "private/cli/" + self.command if self.verb == 'POST': message, error = self.restApi.post(api, self.body, self.params) elif self.verb == 'GET': message, error = self.restApi.get(api, self.params) elif self.verb == 'PATCH': message, error = self.restApi.patch(api, self.body, self.params) elif self.verb == 'DELETE': message, error = self.restApi.delete(api, self.body, self.params) else: self.module.fail_json(msg='Error running command %s:' % self.command, exception=traceback.format_exc()) if error: self.module.fail_json(msg=error) return message def apply(self): ''' calls the command and returns raw output ''' changed = True output = self.run_command() self.module.exit_json(changed=changed, msg=output)
def __init__(self): self.use_rest = False # Volume_autosize returns KB and not B like Volume so values are shifted down 1 self._size_unit_map = dict( k=1, m=1024, g=1024**2, t=1024**3, ) self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(volume=dict(required=True, type="str"), mode=dict(required=False, choices=['grow', 'grow_shrink', 'off']), vserver=dict(required=True, type='str'), grow_threshold_percent=dict(required=False, type='int'), increment_size=dict(required=False, type='str'), maximum_size=dict(required=False, type='str'), minimum_size=dict(required=False, type='str'), reset=dict(required=False, type='bool'), shrink_threshold_percent=dict(required=False, type='int'))) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True, mutually_exclusive=[['reset', 'maximum_size'], ['reset', 'increment_size'], ['reset', 'minimum_size'], ['reset', 'grow_threshold_percent'], ['reset', 'shrink_threshold_percent'], ['reset', 'mode']]) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # API should be used for ONTAP 9.6 or higher, ZAPI for lower version self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True # increment size and reset are not supported with rest api if self.parameters.get('increment_size'): self.module.fail_json( msg= "Rest API does not support increment size, please switch to ZAPI" ) if self.parameters.get('reset'): self.module.fail_json( msg="Rest API does not support reset, please switch to ZAPI" ) else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), applications=dict(required=True, type='list', elements='str', aliases=['application'], choices=['console', 'http', 'ontapi', 'rsh', 'snmp', 'sp', 'service-processor', 'ssh', 'telnet'],), authentication_method=dict(required=True, type='str', choices=['community', 'password', 'publickey', 'domain', 'nsswitch', 'usm', 'cert']), set_password=dict(required=False, type='str', no_log=True), role_name=dict(required=False, type='str'), lock_user=dict(required=False, type='bool'), vserver=dict(required=True, type='str', aliases=['svm']), authentication_protocol=dict(required=False, type='str', choices=['none', 'md5', 'sha', 'sha2-256']), authentication_password=dict(required=False, type='str', no_log=True), engine_id=dict(required=False, type='str'), privacy_protocol=dict(required=False, type='str', choices=['none', 'des', 'aes128']), privacy_password=dict(required=False, type='str', no_log=True), remote_switch_ipaddress=dict(required=False, type='str') )) self.module = AnsibleModule( argument_spec=self.argument_spec, required_if=[ ('state', 'present', ['role_name']) ], supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # REST API should be used for ONTAP 9.6 or higher self.restApi = OntapRestAPI(self.module) # some attributes are not supported in earlier REST implementation unsupported_rest_properties = ['authentication_password', 'authentication_protocol', 'engine_id', 'privacy_password', 'privacy_protocol'] used_unsupported_rest_properties = [x for x in unsupported_rest_properties if x in self.parameters] self.use_rest, error = self.restApi.is_rest(used_unsupported_rest_properties) if error is not None: self.module.fail_json(msg=error) if not self.use_rest: if not HAS_NETAPP_LIB: self.module.fail_json(msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver']) else: if 'snmp' in self.parameters['applications']: self.module.fail_json(msg="Snmp as application is not supported in REST.")
def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), from_name=dict(required=False, type='str', default=None), os_type=dict(required=False, type='str', aliases=['ostype']), initiator_group_type=dict(required=False, type='str', choices=['fcp', 'iscsi', 'mixed'], aliases=['protocol']), initiators=dict(required=False, type='list', elements='str', aliases=['initiator']), vserver=dict(required=True, type='str'), force_remove_initiator=dict(required=False, type='bool', default=False, aliases=['allow_delete_while_mapped']), bind_portset=dict(required=False, type='str') )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_modify_zapi_to_rest = dict( # initiator_group_type (protocol) cannot be changed after create bind_portset='portset', name='name', os_type='os_type' ) if self.module.params.get('initiators') is not None: self.parameters['initiators'] = [self.na_helper.sanitize_wwn(initiator) for initiator in self.module.params['initiators']] self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() def too_old_for_rest(minimum_generation, minimum_major): return self.use_rest and self.rest_api.get_ontap_version() < (minimum_generation, minimum_major) ontap_99_options = ['bind_portset'] if too_old_for_rest(9, 9) and any(x in self.parameters for x in ontap_99_options): self.module.warn('Warning: falling back to ZAPI: %s' % self.rest_api.options_require_ontap_version(ontap_99_options, version='9.9')) self.use_rest = False if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(common_name=dict(required=False, type='str'), name=dict(required=False, type='str'), state=dict(required=False, choices=['present', 'absent'], default='present'), type=dict(required=False, choices=[ 'client', 'server', 'client_ca', 'server_ca', 'root_ca' ]), svm=dict(required=False, type='str', aliases=['vserver']), public_certificate=dict(required=False, type='str'), private_key=dict(required=False, type='str'), signing_request=dict(required=False, type='str'), expiry_time=dict(required=False, type='str'), key_size=dict(required=False, type='int'), hash_function=dict(required=False, type='str'), intermediate_certificates=dict(required=False, type='list', elements='str'), ignore_name_if_not_supported=dict(required=False, type='bool', default=True))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) if self.parameters.get('name') is None: if self.parameters.get( 'common_name') is None or self.parameters.get( 'type') is None: error = "'name' or ('common_name' and 'type') are required parameters." self.module.fail_json(msg=error) # ONTAP 9.6 and 9.7 do not support name. We'll change this to True if we detect an issue. self.ignore_name_param = False # API should be used for ONTAP 9.6 or higher self.restApi = OntapRestAPI(self.module) if self.restApi.is_rest(): self.use_rest = True else: self.module.fail_json( msg="this module requires ONTAP 9.6 or later.")
def __init__(self): """ Initialize the Ontap Net Route class """ self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), destination=dict(required=True, type='str'), gateway=dict(required=True, type='str'), metric=dict(required=False, type='int'), from_destination=dict(required=False, type='str', default=None), from_gateway=dict(required=False, type='str', default=None), from_metric=dict(required=False, type='int', default=None), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.restApi = OntapRestAPI(self.module) # some attributes are not supported in earlier REST implementation unsupported_rest_properties = ['metric', 'from_metric'] used_unsupported_rest_properties = [ x for x in unsupported_rest_properties if x in self.parameters ] self.use_rest, error = self.restApi.is_rest( used_unsupported_rest_properties) if error is not None: self.module.fail_json(msg=error) if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver']) return
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), hostnames=dict(required=False, type='list', elements='str'), privileged_users=dict(required=False, type='list', elements='str'), scanner_pool=dict(required=True, type='str'), scanner_policy=dict(required=False, type='str', choices=['primary', 'secondary', 'idle']))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.restApi = OntapRestAPI(self.module) if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver'])
def __init__(self): """ Initialize the Ontap Volume Efficiency class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), path=dict(required=True, type='str'), schedule=dict(required=False, type='str'), policy=dict(required=False, choices=['auto', 'default', 'inline-only'], type='str'), enable_inline_compression=dict(required=False, type='bool'), enable_compression=dict(required=False, type='bool'), enable_inline_dedupe=dict(required=False, type='bool'), enable_data_compaction=dict(required=False, type='bool'), enable_cross_volume_inline_dedupe=dict(required=False, type='bool'), enable_cross_volume_background_dedupe=dict(required=False, type='bool'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True, mutually_exclusive=[('policy', 'schedule') ]) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) if self.parameters['state'] == 'present': self.parameters['enabled'] = 'enabled' else: self.parameters['enabled'] = 'disabled' self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver'])
def __init__(self): """ Initialize the Ontap SnapMirror policy class """ self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), policy_name=dict(required=True, type='str'), comment=dict(required=False, type='str'), policy_type=dict(required=False, type='str', choices=['vault', 'async_mirror', 'mirror_vault', 'strict_sync_mirror', 'sync_mirror']), tries=dict(required=False, type='str'), transfer_priority=dict(required=False, type='str', choices=['low', 'normal']), common_snapshot_schedule=dict(required=False, type='str'), ignore_atime=dict(required=False, type='bool'), is_network_compression_enabled=dict(required=False, type='bool'), owner=dict(required=False, type='str', choices=['cluster_admin', 'vserver_admin']), restart=dict(required=False, type='str', choices=['always', 'never', 'default']), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # API should be used for ONTAP 9.6 or higher, Zapi for lower version self.restApi = OntapRestAPI(self.module) # some attributes are not supported in earlier REST implementation unsupported_rest_properties = ['owner', 'restart', 'transfer_priority', 'tries', 'ignore_atime', 'common_snapshot_schedule'] used_unsupported_rest_properties = [x for x in unsupported_rest_properties if x in self.parameters] self.use_rest, error = self.restApi.is_rest(used_unsupported_rest_properties) if error: self.module.fail_json(msg=error) if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json(msg='The python NetApp-Lib module is required') else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), name=dict(required=True, type='str'), from_name=dict(required=False, type='str'), flexvol_name=dict(required=True, type='str'), vserver=dict(required=True, type='str'), export_policy=dict(required=False, type='str'), security_style=dict(required=False, type='str', choices=['unix', 'ntfs', 'mixed']), oplocks=dict(required=False, type='str', choices=['enabled', 'disabled']), unix_permissions=dict(required=False, type='str'), force_delete=dict(required=False, type='bool', default=True), wait_for_completion=dict(required=False, type='bool', default=True), time_out=dict(required=False, type='int', default=180), )) self.module = AnsibleModule(argument_spec=self.argument_spec, required_if=[('state', 'present', ['flexvol_name'])], supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) if self.rest_api.is_rest(): self.use_rest = True else: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver'])
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), domains=dict(required=False, type='list'), nameservers=dict(required=False, type='list'), skip_validation=dict(required=False, type='bool'))) self.module = AnsibleModule(argument_spec=self.argument_spec, required_if=[('state', 'present', ['domains', 'nameservers'])], supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # Cluster vserver and data vserver use different REST API. self.is_cluster = False # REST API should be used for ONTAP 9.6 or higher, ZAPI for lower version self.restApi = OntapRestAPI(self.module) # some attributes are not supported in earlier REST implementation unsupported_rest_properties = ['skip_validation'] used_unsupported_rest_properties = [ x for x in unsupported_rest_properties if x in self.parameters ] self.use_rest, error = self.restApi.is_rest( used_unsupported_rest_properties) if error is not None: self.module.fail_json(msg=error) if not self.use_rest: if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=self.parameters['vserver']) return
def __init__(self): self.use_rest = False self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict( state=dict(required=False, type='str', choices=['present', 'absent'], default='present'), ip_address=dict(required=True, type='str'), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.restApi = OntapRestAPI(self.module) if not self.restApi.is_rest(): self.module.fail_json( msg="na_ontap_snmp_traphosts only support Rest and ONTAP 9.6+")
def __init__(self): """ Initialize the ONTAP domain tunnel class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update( dict(state=dict(choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: self.module.fail_json(msg=self.rest_api.requires_ontap_version( 'na_ontap_domain_tunnel', '9.7'))