def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(account_id=dict(required=True, type='str'), src_volume_id=dict(required=True, type='str'), dest_volume_name=dict(required=True, type='str'), src_snapshot_id=dict(required=True, type='str'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) input_params = self.module.params self.account_id = input_params['account_id'] self.src_volume_id = input_params['src_volume_id'] self.dest_volume_name = input_params['dest_volume_name'] self.src_snapshot_id = input_params['src_snapshot_id'] 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_snapshot_restore')
def __init__(self): """ Initialize the NetAppElementSWAdminUser class. """ self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(state=dict(required=True, choices=['present', 'absent']), element_username=dict(required=True, type='str'), element_password=dict(required=False, type='str', no_log=True), acceptEula=dict(required=False, type='bool'), access=dict(required=False, type='list'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) param = self.module.params # set up state variables self.state = param['state'] self.element_username = param['element_username'] self.element_password = param['element_password'] self.acceptEula = param['acceptEula'] self.access = param['access'] 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_admin_users')
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( state=dict(required=True, choices=['present', 'absent']), src_access_group_id=dict(required=False, type='str'), new_name=dict(required=False, type='str'), initiators=dict(required=False, type='list'), volumes=dict(required=False, type='list'), virtual_network_id=dict(required=False, type='list'), virtual_network_tags=dict(required=False, type='list'), attributes=dict(required=False, type='dict'), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) input_params = self.module.params # Set up state variables self.state = input_params['state'] self.src_access_group_id = input_params['src_access_group_id'] self.new_name = input_params['new_name'] self.initiators = input_params['initiators'] self.volumes = input_params['volumes'] self.virtual_network_id = input_params['virtual_network_id'] self.virtual_network_tags = input_params['virtual_network_tags'] self.attributes = input_params['attributes'] if self.state == "absent" and self.src_access_group_id is None: self.module.fail_json( msg= "For delete operation, src_access_group_id parameter is required" ) if self.state == 'present' and self.new_name is None and self.src_access_group_id is None: self.module.fail_json( msg= "new_name parameter or src_access_group is required parameter") 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 if self.attributes is not None: self.attributes.update( self.elementsw_helper.set_element_attributes( source='na_elementsw_access_group')) else: self.attributes = self.elementsw_helper.set_element_attributes( source='na_elementsw_access_group')
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): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(state=dict(required=False, choices=['present', 'absent'], default='present'), account_id=dict(required=True, type='str'), name=dict(required=False, type='str'), src_volume_id=dict(required=True, type='str'), retention=dict(required=False, type='str'), src_snapshot_id=dict(required=False, type='str'), enable_remote_replication=dict(required=False, type='bool'), expiration_time=dict(required=False, type='str'), snap_mirror_label=dict(required=False, type='str'))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) input_params = self.module.params self.state = input_params['state'] self.name = input_params['name'] self.account_id = input_params['account_id'] self.src_volume_id = input_params['src_volume_id'] self.src_snapshot_id = input_params['src_snapshot_id'] self.retention = input_params['retention'] self.properties_provided = False self.expiration_time = input_params['expiration_time'] if input_params['expiration_time'] is not None: self.properties_provided = True self.enable_remote_replication = input_params[ 'enable_remote_replication'] if input_params['enable_remote_replication'] is not None: self.properties_provided = True self.snap_mirror_label = input_params['snap_mirror_label'] if input_params['snap_mirror_label'] is not None: self.properties_provided = True if self.state == 'absent' and self.src_snapshot_id is None: self.module.fail_json( msg="Please provide required parameter : snapshot_id") 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_snapshot')
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict(management_virtual_ip=dict(required=True, type='str'), storage_virtual_ip=dict(required=True, type='str'), replica_count=dict(required=False, type='str', default='2'), cluster_admin_username=dict(required=False, type='str'), cluster_admin_password=dict(required=False, type='str', no_log=True), accept_eula=dict(required=True, type='bool'), nodes=dict(required=False, type=list, default=None), attributes=dict(required=False, type=list, default=None))) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) input_params = self.module.params self.management_virtual_ip = input_params['management_virtual_ip'] self.storage_virtual_ip = input_params['storage_virtual_ip'] self.replica_count = input_params['replica_count'] self.accept_eula = input_params['accept_eula'] self.attributes = input_params['attributes'] self.nodes = input_params['nodes'] if input_params['cluster_admin_username'] is None: self.cluster_admin_username = self.username else: self.cluster_admin_username = input_params[ 'cluster_admin_username'] if input_params['cluster_admin_password']: self.cluster_admin_password = self.password else: self.cluster_admin_password = input_params[ 'cluster_admin_password'] 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, port=442) self.elementsw_helper = NaElementSWModule(self.sfe) # add telemetry attributes if self.attributes is not None: self.attributes.update( self.elementsw_helper.set_element_attributes( source='na_elementsw_cluster')) else: self.attributes = self.elementsw_helper.set_element_attributes( source='na_elementsw_cluster')
def __init__(self): """ Setup Ansible parameters and SolidFire connection """ self.argument_spec = {} self.argument_spec.update(dict( src_hostname=dict(aliases=['hostname'], required=True, type='str'), src_username=dict(aliases=['username', 'user'], required=True, type='str'), src_password=dict(aliases=['password', 'pass'], required=True, type='str', no_log=True), src_volume_id=dict(aliases=['volume_id'], required=True, type='str'), dest_hostname=dict(required=False, type='str'), dest_username=dict(required=False, type='str'), dest_password=dict(required=False, type='str', no_log=True), dest_volume_id=dict(required=True, type='str'), format=dict(required=False, choices=['native', 'uncompressed'], default='native'), script=dict(required=False, type='str'), script_parameters=dict(required=False, type='dict') )) self.module = AnsibleModule( argument_spec=self.argument_spec, required_together=[['script', 'script_parameters']], supports_check_mode=True ) if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the SolidFire Python SDK") # If destination cluster details are not specified , set the destination to be the same as the source if self.module.params["dest_hostname"] is None: self.module.params["dest_hostname"] = self.module.params["src_hostname"] if self.module.params["dest_username"] is None: self.module.params["dest_username"] = self.module.params["src_username"] if self.module.params["dest_password"] is None: self.module.params["dest_password"] = self.module.params["src_password"] params = self.module.params # establish a connection to both source and destination sf clusters self.module.params["username"] = params["src_username"] self.module.params["password"] = params["src_password"] self.module.params["hostname"] = params["src_hostname"] self.src_connection = netapp_utils.create_sf_connection(self.module) self.module.params["username"] = params["dest_username"] self.module.params["password"] = params["dest_password"] self.module.params["hostname"] = params["dest_hostname"] self.dest_connection = netapp_utils.create_sf_connection(self.module) self.elementsw_helper = NaElementSWModule(self.sfe) # add telemetry attributes self.attributes = self.elementsw_helper.set_element_attributes(source='na_elementsw_backup')
def set_element_connection(self, kind): if kind == 'source': self.module.params['hostname'] = self.parameters['source_hostname'] self.module.params['username'] = self.parameters['source_username'] self.module.params['password'] = self.parameters['source_password'] elif kind == 'destination': self.module.params['hostname'] = self.parameters['hostname'] self.module.params['username'] = self.parameters['username'] self.module.params['password'] = self.parameters['password'] elem = netapp_utils.create_sf_connection(module=self.module) elementsw_helper = NaElementSWModule(elem) return elementsw_helper, elem
def __init__(self): self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( state=dict(required=True, choices=['present', 'absent']), element_username=dict(required=True, type='str'), account_id=dict(required=False, type='int', default=None), new_element_username=dict(required=False, type='str', default=None), initiator_secret=dict(required=False, type='str'), target_secret=dict(required=False, type='str'), attributes=dict(required=False, type='dict'), status=dict(required=False, type='str'), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) params = self.module.params # set up state variables self.state = params['state'] self.element_username = params['element_username'] self.account_id = params['account_id'] self.new_element_username = params['new_element_username'] self.initiator_secret = params['initiator_secret'] self.target_secret = params['target_secret'] self.attributes = params['attributes'] self.status = params['status'] if HAS_SF_SDK is False: self.module.fail_json( msg="Unable to import the Element SW Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module) self.elementsw_helper = NaElementSWModule(self.sfe) # add telemetry attributes if self.attributes is not None: self.attributes.update( self.elementsw_helper.set_element_attributes( source='na_elementsw_account')) else: self.attributes = self.elementsw_helper.set_element_attributes( source='na_elementsw_account')
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.sfe) # add telemetry attributes if self.parameters['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')
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): """ Parse arguments, setup state variables, check paramenters and ensure SDK is installed """ self._size_unit_map = netapp_utils.SF_BYTE_MAP self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update(dict( state=dict(required=True, choices=['present', 'absent']), name=dict(required=True, type='str'), account_id=dict(required=True), enable512e=dict(type='bool', aliases=['512emulation']), qos=dict(required=False, type='dict', default=None), attributes=dict(required=False, type='dict', default=None), size=dict(type='int'), size_unit=dict(default='gb', choices=['bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb'], type='str'), access=dict(required=False, type='str', default=None, choices=['readOnly', 'readWrite', 'locked', 'replicationTarget']), )) self.module = AnsibleModule( argument_spec=self.argument_spec, required_if=[ ('state', 'present', ['size', 'enable512e']) ], supports_check_mode=True ) param = self.module.params # set up state variables self.state = param['state'] self.name = param['name'] self.account_id = param['account_id'] self.enable512e = param['enable512e'] self.qos = param['qos'] self.attributes = param['attributes'] self.access = param['access'] self.size_unit = param['size_unit'] if param['size'] is not None: self.size = param['size'] * self._size_unit_map[self.size_unit] else: self.size = None if HAS_SF_SDK is False: self.module.fail_json(msg="Unable to import the ElementSW Python SDK") else: try: self.sfe = netapp_utils.create_sf_connection(module=self.module) except solidfire.common.ApiServerError: self.module.fail_json(msg="Unable to create the connection") self.elementsw_helper = NaElementSWModule(self.sfe) # add telemetry attributes if self.attributes is not None: self.attributes.update(self.elementsw_helper.set_element_attributes(source='na_elementsw_volume')) else: self.attributes = self.elementsw_helper.set_element_attributes(source='na_elementsw_volume')
def __init__(self): """ Parse arguments, setup state variables, check paramenters and ensure SDK is installed """ self._size_unit_map = netapp_utils.SF_BYTE_MAP self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( name=dict(required=True), src_volume_id=dict(required=True), src_snapshot_id=dict(), account_id=dict(required=True), attributes=dict(type='dict', default=None), size=dict(type='int'), size_unit=dict(default='gb', choices=[ 'bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb' ], type='str'), access=dict(type='str', default=None, choices=[ 'readOnly', 'readWrite', 'locked', 'replicationTarget' ]), )) self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) parameters = self.module.params # set up state variables self.name = parameters['name'] self.src_volume_id = parameters['src_volume_id'] self.src_snapshot_id = parameters['src_snapshot_id'] self.account_id = parameters['account_id'] self.attributes = parameters['attributes'] self.size_unit = parameters['size_unit'] if parameters['size'] is not None: self.size = parameters['size'] * \ self._size_unit_map[self.size_unit] else: self.size = None self.access = parameters['access'] 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 if self.attributes is not None: self.attributes.update( self.elementsw_helper.set_element_attributes( source='na_elementsw_volume_clone')) else: self.attributes = self.elementsw_helper.set_element_attributes( source='na_elementsw_volume_clone')
def __init__(self): """ Parse arguments, setup state variables, check paramenters and ensure SDK is installed """ self.argument_spec = netapp_utils.ontap_sf_host_argument_spec() self.argument_spec.update( dict( state=dict(required=True, choices=['present', 'absent']), name=dict(required=True, type='str'), schedule_type=dict(required=False, choices=[ 'DaysOfWeekFrequency', 'DaysOfMonthFrequency', 'TimeIntervalFrequency' ]), time_interval_days=dict(required=False, type='int', default=1), time_interval_hours=dict(required=False, type='int', default=0), time_interval_minutes=dict(required=False, type='int', default=0), days_of_week_weekdays=dict(required=False, type='list'), days_of_week_hours=dict(required=False, type='int', default=0), days_of_week_minutes=dict(required=False, type='int', default=0), days_of_month_monthdays=dict(required=False, type='list'), days_of_month_hours=dict(required=False, type='int', default=0), days_of_month_minutes=dict(required=False, type='int', default=0), paused=dict(required=False, type='bool'), recurring=dict(required=False, type='bool'), starting_date=dict(required=False, type='str'), snapshot_name=dict(required=False, type='str'), volumes=dict(required=False, type='list'), account_id=dict(required=False, type='str'), retention=dict(required=False, type='str'), )) self.module = AnsibleModule( argument_spec=self.argument_spec, required_if=[('state', 'present', ['account_id', 'volumes', 'schedule_type']), ('schedule_type', 'DaysOfMonthFrequency', ['days_of_month_monthdays']), ('schedule_type', 'DaysOfWeekFrequency', ['days_of_week_weekdays'])], supports_check_mode=True) param = self.module.params # set up state variables self.state = param['state'] self.name = param['name'] self.schedule_type = param['schedule_type'] self.days_of_week_weekdays = param['days_of_week_weekdays'] self.days_of_week_hours = param['days_of_week_hours'] self.days_of_week_minutes = param['days_of_week_minutes'] self.days_of_month_monthdays = param['days_of_month_monthdays'] self.days_of_month_hours = param['days_of_month_hours'] self.days_of_month_minutes = param['days_of_month_minutes'] self.time_interval_days = param['time_interval_days'] self.time_interval_hours = param['time_interval_hours'] self.time_interval_minutes = param['time_interval_minutes'] self.paused = param['paused'] self.recurring = param['recurring'] if self.schedule_type == 'DaysOfWeekFrequency': # Create self.weekday list if self.schedule_type is days_of_week if self.days_of_week_weekdays is not None: # Create self.weekday list if self.schedule_type is days_of_week self.weekdays = [] for day in self.days_of_week_weekdays: if str(day).isdigit(): # If id specified, return appropriate day self.weekdays.append(Weekday.from_id(int(day))) else: # If name specified, return appropriate day self.weekdays.append( Weekday.from_name(day.capitalize())) if self.state == 'present' and self.schedule_type is None: # Mandate schedule_type for create operation self.module.fail_json( msg="Please provide required parameter: schedule_type") # Mandate schedule name for delete operation if self.state == 'absent' and self.name is None: self.module.fail_json( msg="Please provide required parameter: name") self.starting_date = param['starting_date'] self.snapshot_name = param['snapshot_name'] self.volumes = param['volumes'] self.account_id = param['account_id'] self.retention = param['retention'] self.create_schedule_result = None if HAS_SF_SDK is False: # Create ElementSW connection self.module.fail_json( msg="Unable to import the ElementSW Python SDK") else: self.sfe = netapp_utils.create_sf_connection(module=self.module) self.elementsw_helper = NaElementSWModule(self.sfe)