def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(modify_cluster_full_threshold=dict( type='dict', options=dict(stage2_aware_threshold=dict(type='int', default=None), stage3_block_threshold_percent=dict(type='int', default=None), max_metadata_over_provision_factor=dict( type='int', default=None))), encryption_at_rest=dict(type='str', choices=['present', 'absent']), set_ntp_info=dict(type='dict', options=dict( broadcastclient=dict(type='bool', default=False), ntp_servers=dict(type='list', elements='str'))), enable_virtual_volumes=dict(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 HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module)
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(skip=dict(required=False, type='str', default=None, choices=['mvip', 'svip']), mvip=dict(required=False, type='str', default=None), svip=dict(required=False, type='str', default=None))) self.module = AnsibleModule(argument_spec=self.argument_spec, required_if=[('skip', 'svip', ['mvip']), ('skip', 'mvip', ['svip'])], supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.module.params.copy() self.msg = "" if HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the ElementSW Python SDK") else: self.elem = netapp_utils.create_sf_connection(self.module, port=442)
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_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'), qos=dict(required=False, type='dict'), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) # Set up state variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.qos_policy_id = None if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module) self.elementsw_helper = NaElementSWModule(self.sfe) # add telemetry attributes self.attributes = self.elementsw_helper.set_element_attributes(source='na_elementsw_qos_policy')
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( state=dict(type='str', choices=['present', 'absent'], default='present'), snmp_v3_enabled=dict(type='bool'), networks=dict(type='dict', options=dict(access=dict( type='str', choices=['ro', 'rw', 'rosys']), cidr=dict(type='int', default=None), community=dict(type='str', default=None), network=dict(type='str', default=None))), usm_users=dict( type='dict', options=dict( access=dict(type='str', choices=['rouser', 'rwuser', 'rosys']), name=dict(type='str', default=None), password=dict(type='str', default=None), passphrase=dict(type='str', default=None), secLevel=dict(type='str', choices=['auth', 'noauth', 'priv']))), )) self.module = AnsibleModule( argument_spec=self.argument_spec, required_if=[('state', 'present', ['snmp_v3_enabled']), ('snmp_v3_enabled', True, ['usm_users']), ('snmp_v3_enabled', False, ['networks'])], supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) if self.parameters.get('state') == "present": if self.parameters.get('usm_users') is not None: # Getting the configuration details to configure SNMP Version3 self.access_usm = self.parameters.get('usm_users')['access'] self.name = self.parameters.get('usm_users')['name'] self.password = self.parameters.get('usm_users')['password'] self.passphrase = self.parameters.get( 'usm_users')['passphrase'] self.secLevel = self.parameters.get('usm_users')['secLevel'] if self.parameters.get('networks') is not None: # Getting the configuration details to configure SNMP Version2 self.access_network = self.parameters.get('networks')['access'] self.cidr = self.parameters.get('networks')['cidr'] self.community = self.parameters.get('networks')['community'] self.network = self.parameters.get('networks')['network'] if HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module)
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update(dict( gather_subsets=dict(type='list', elements='str', aliases=['gather_subset'], default='all'), filter=dict(type='dict'), fail_on_error=dict(type='bool', default=False), fail_on_key_not_found=dict(type='bool', default=True), fail_on_record_not_found=dict(type='bool', default=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) self.debug = list() if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the SolidFire Python SDK") # 442 for node APIs, 443 (default) for cluster APIs for role, port in [('node', 442), ('cluster', 443)]: try: conn = netapp_utils.create_sf_connection(module=self.module, raise_on_connection_error=True, port=port) if role == 'node': self.sfe_node = conn else: self.sfe_cluster = conn except netapp_utils.solidfire.common.ApiConnectionError as exc: if str(exc) == "Bad Credentials": msg = ' Make sure to use valid %s credentials for username and password.' % 'node' if port == 442 else 'cluster' msg += '%s reported: %s' % ('Node' if port == 442 else 'Cluster', repr(exc)) else: msg = 'Failed to create connection for %s:%d - %s' % (self.parameters['hostname'], port, repr(exc)) self.module.fail_json(msg=msg) except Exception as exc: self.module.fail_json(msg='Failed to connect for %s:%d - %s' % (self.parameters['hostname'], port, repr(exc))) # TODO: add new node methods here self.node_methods = dict( node_config=self.sfe_node.get_config, ) # TODO: add new cluster methods here self.cluster_methods = dict( cluster_accounts=self.sfe_cluster.list_accounts ) self.methods = dict(self.node_methods) self.methods.update(self.cluster_methods)
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( initiators=dict(type='list', options=dict( name=dict(type='str', required=True), alias=dict(type='str', default=None), initiator_id=dict(type='int', default=None), volume_access_groups=dict(type='list', default=None), volume_access_group_id=dict(type='int', default=None), attributes=dict(type='dict', default=None), )), state=dict(choices=['present', 'absent'], default='present'), )) 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 HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the SolidFire Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module) self.elementsw_helper = NaElementSWModule(self.sfe) # iterate over each user-provided initiator for initiator in self.parameters.get('initiators'): # add telemetry attributes if 'attributes' in initiator: initiator['attributes'].update( self.elementsw_helper.set_element_attributes( source='na_elementsw_initiators')) else: initiator[ 'attributes'] = self.elementsw_helper.set_element_attributes( source='na_elementsw_initiators')
def __init__(self): """ Setup Ansible parameters and SolidFire connection """ self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), src_volume=dict(required=True, type='str'), src_account=dict(required=True, type='str'), dest_volume=dict(required=True, type='str'), dest_account=dict(required=True, type='str'), mode=dict(required=False, type='str', choices=['async', 'sync', 'snapshotsonly'], default='async'), dest_mvip=dict(required=True, type='str'), dest_username=dict(required=False, type='str'), dest_password=dict(required=False, type='str', no_log=True))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) if HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the SolidFire Python SDK") else: self.elem = netapp_utils.create_sf_connection(module=self.module) self.elementsw_helper = NaElementSWModule(self.elem) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) # get element_sw_connection for destination cluster # overwrite existing source host, user and password with destination credentials self.module.params['hostname'] = self.parameters['dest_mvip'] # username and password is same as source, # if dest_username and dest_password aren't specified if self.parameters.get('dest_username'): self.module.params['username'] = self.parameters['dest_username'] if self.parameters.get('dest_password'): self.module.params['password'] = self.parameters['dest_password'] self.dest_elem = netapp_utils.create_sf_connection(module=self.module) self.dest_elementsw_helper = NaElementSWModule(self.dest_elem)
def __init__(self): """ Setup Ansible parameters and ElementSW connection """ self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), name=dict(required=False, type='str'), vlan_tag=dict(required=True, type='str'), svip=dict(required=False, type='str'), netmask=dict(required=False, type='str'), gateway=dict(required=False, type='str'), namespace=dict(required=False, type='bool'), attributes=dict(required=False, type='dict'), address_blocks=dict(required=False, type='list'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) if HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the SolidFire Python SDK") else: self.elem = netapp_utils.create_sf_connection(module=self.module) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.elementsw_helper = NaElementSWModule(self.elem) # add telemetry attributes if self.parameters.get('attributes') is not None: self.parameters['attributes'].update( self.elementsw_helper.set_element_attributes( source='na_elementsw_vlan')) else: self.parameters[ 'attributes'] = self.elementsw_helper.set_element_attributes( source='na_elementsw_vlan')