コード例 #1
0
    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'),
                 cross_junction=dict(required=False,
                                     type='bool',
                                     default=False),
                 directory_recursion=dict(required=False,
                                          type='bool',
                                          default=False),
                 file_ext_to_exclude=dict(required=False,
                                          type='list',
                                          elements='str'),
                 file_ext_to_include=dict(required=False,
                                          type='list',
                                          elements='str'),
                 max_file_size=dict(required=False, type="str"),
                 paths_to_exclude=dict(required=False,
                                       type='list',
                                       elements='str'),
                 report_directory=dict(required=False, type='str'),
                 report_log_level=dict(required=False,
                                       type='str',
                                       choices=['verbose', 'info', 'error'],
                                       default='error'),
                 request_timeout=dict(required=False, type='str'),
                 scan_files_with_no_ext=dict(required=False,
                                             type='bool',
                                             default=True),
                 scan_paths=dict(required=False, type='list', elements='str'),
                 scan_priority=dict(required=False,
                                    type='str',
                                    choices=['low', 'normal'],
                                    default='low'),
                 schedule=dict(required=False, type="str"),
                 task_name=dict(required=True, type="str")))
        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=True,
                                    required_if=[[
                                        "state", "present",
                                        ["report_directory", "scan_paths"]
                                    ]])
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        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'])
コード例 #2
0
    def __init__(self):
        """
            Initialize the NetAppOntapVolumeClone class
        """
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(
            dict(
                state=dict(required=False,
                           type='str',
                           choices=['present'],
                           default='present'),
                parent_volume=dict(required=True, type='str'),
                name=dict(required=True, type='str', aliases=["volume"]),
                vserver=dict(required=True, type='str'),
                parent_snapshot=dict(required=False, type='str', default=None),
                parent_vserver=dict(required=False, type='str', default=None),
                qos_policy_group_name=dict(required=False,
                                           type='str',
                                           default=None),
                space_reserve=dict(required=False,
                                   type='str',
                                   choices=['volume', 'none'],
                                   default=None),
                volume_type=dict(required=False,
                                 type='str',
                                 choices=['rw', 'dp']),
                junction_path=dict(required=False, type='str', default=None),
                uid=dict(required=False, type='int'),
                gid=dict(required=False, type='int'),
                split=dict(required=False, type='bool', default=None),
            ))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=True,
                                    required_together=[['uid', 'gid']])

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            if self.parameters.get('parent_vserver'):
                # use cluster ZAPI, as vserver ZAPI does not support parent-vserser for create
                self.create_server = netapp_utils.setup_na_ontap_zapi(
                    module=self.module)
                # keep vserver for ems log and clone-get
                self.vserver = netapp_utils.setup_na_ontap_zapi(
                    module=self.module, vserver=self.parameters['vserver'])
            else:
                self.vserver = netapp_utils.setup_na_ontap_zapi(
                    module=self.module, vserver=self.parameters['vserver'])
                self.create_server = self.vserver
        return
    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'),
                 interface_name=dict(required=True, type='str'),
                 home_node=dict(required=False, type='str', default=None),
                 home_port=dict(required=False, type='str'),
                 role=dict(required=False, type='str'),
                 is_ipv4_link_local=dict(required=False,
                                         type='bool',
                                         default=None),
                 address=dict(required=False, type='str'),
                 netmask=dict(required=False, type='str'),
                 vserver=dict(required=True, type='str'),
                 firewall_policy=dict(required=False, type='str',
                                      default=None),
                 failover_policy=dict(required=False,
                                      type='str',
                                      default=None,
                                      choices=[
                                          'disabled', 'system-defined',
                                          'local-only', 'sfo-partner-only',
                                          'broadcast-domain-wide'
                                      ]),
                 failover_group=dict(required=False, type='str'),
                 admin_status=dict(required=False, choices=['up', 'down']),
                 subnet_name=dict(required=False, type='str'),
                 is_auto_revert=dict(required=False, type='bool',
                                     default=None),
                 protocols=dict(required=False, type='list'),
                 force_subnet_association=dict(required=False,
                                               type='bool',
                                               default=None),
                 dns_domain_name=dict(required=False, type='str'),
                 listen_for_dns_query=dict(required=False, type='bool'),
                 is_dns_update_enabled=dict(required=False, type='bool')))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            mutually_exclusive=[['subnet_name', 'address'],
                                ['subnet_name', 'netmask'],
                                ['is_ipv4_link_local', 'address'],
                                ['is_ipv4_link_local', 'netmask'],
                                ['is_ipv4_link_local', 'subnet_name']],
            supports_check_mode=True)
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        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)
コード例 #4
0
    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'),
                 source_intercluster_lifs=dict(
                     required=False,
                     type='list',
                     aliases=['source_intercluster_lif']),
                 dest_intercluster_lifs=dict(required=False,
                                             type='list',
                                             aliases=['dest_intercluster_lif'
                                                      ]),
                 passphrase=dict(required=False, type='str', no_log=True),
                 dest_hostname=dict(required=True, type='str'),
                 dest_username=dict(required=False, type='str'),
                 dest_password=dict(required=False, type='str', no_log=True),
                 source_cluster_name=dict(required=False, type='str'),
                 dest_cluster_name=dict(required=False, type='str')))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    required_together=[[
                                        'source_intercluster_lifs',
                                        'dest_intercluster_lifs'
                                    ]],
                                    required_if=[('state', 'absent', [
                                        'source_cluster_name',
                                        'dest_cluster_name'
                                    ])],
                                    supports_check_mode=True)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        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)
            # set destination server connection
            self.module.params['hostname'] = self.parameters['dest_hostname']
            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_server = netapp_utils.setup_na_ontap_zapi(
                module=self.module)
            # reset to source host connection for asup logs
            self.module.params['hostname'] = self.parameters['hostname']
コード例 #5
0
ファイル: na_ontap_debug.py プロジェクト: dkwon253/mycode
 def __init__(self):
     self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
     self.argument_spec.update(
         dict(vserver=dict(required=False, type="str"), ))
     self.module = AnsibleModule(argument_spec=self.argument_spec)
     self.na_helper = NetAppModule()
     self.parameters = self.na_helper.set_parameters(self.module.params)
     self.rest_api = netapp_utils.OntapRestAPI(self.module)
     self.log_list = []
     self.error_list = []
     self.server = None
コード例 #6
0
    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)
コード例 #7
0
ファイル: na_ontap_ntfs_dacl.py プロジェクト: gundalow/netapp
    def __init__(self):
        """
            Initialize the Ontap NTFS DACL 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'),
                security_descriptor=dict(required=True, type='str'),
                access_type=dict(required=True,
                                 choices=['allow', 'deny'],
                                 type='str'),
                account=dict(required=True, type='str'),
                rights=dict(required=False,
                            choices=[
                                'no_access', 'full_control', 'modify',
                                'read_and_execute', 'read', 'write'
                            ],
                            type='str'),
                apply_to=dict(required=False,
                              choices=['this_folder', 'sub_folders', 'files'],
                              type='list'),
                advanced_access_rights=dict(
                    required=False,
                    choices=[
                        'read_data', 'write_data', 'append_data', 'read_ea',
                        'write_ea', 'execute_file', 'delete_child',
                        'read_attr', 'write_attr', 'delete', 'read_perm',
                        'write_perm', 'write_owner', 'full_control'
                    ],
                    type='list'),
            ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            supports_check_mode=True,
            mutually_exclusive=[('rights', 'advanced_access_rights')],
        )

        # set up variables
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        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'])
コード例 #8
0
 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'])
コード例 #9
0
    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.")
コード例 #10
0
    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'])
コード例 #11
0
    def __init__(self):
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(dict(
            name=dict(required=True, type='str'),
            disks=dict(required=False, type='list', elements='str'),
            disk_count=dict(required=False, type='int', default=None),
            disk_size=dict(required=False, type='int'),
            disk_size_with_unit=dict(required=False, type='str'),
            disk_type=dict(required=False, choices=['ATA', 'BSAS', 'FCAL', 'FSAS', 'LUN', 'MSATA', 'SAS', 'SSD', 'VMDISK']),
            from_name=dict(required=False, type='str'),
            mirror_disks=dict(required=False, type='list', elements='str'),
            nodes=dict(required=False, type='list', elements='str'),
            is_mirrored=dict(required=False, type='bool'),
            raid_size=dict(required=False, type='int'),
            raid_type=dict(required=False, choices=['raid4', 'raid_dp', 'raid_tec', 'raid_0']),
            service_state=dict(required=False, choices=['online', 'offline']),
            spare_pool=dict(required=False, choices=['Pool0', 'Pool1']),
            state=dict(required=False, choices=['present', 'absent'], default='present'),
            unmount_volumes=dict(required=False, type='bool'),
            wait_for_online=dict(required=False, type='bool', default=False),
            time_out=dict(required=False, type='int', default=100),
            object_store_name=dict(required=False, type='str'),
            snaplock_type=dict(required=False, type='str', choices=['compliance', 'enterprise', 'non_snaplock']),
            ignore_pool_checks=dict(required=False, type='bool')
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            required_if=[
                ('service_state', 'offline', ['unmount_volumes']),
            ],
            mutually_exclusive=[
                ('is_mirrored', 'disks'),
                ('is_mirrored', 'mirror_disks'),
                ('is_mirrored', 'spare_pool'),
                ('spare_pool', 'disks'),
                ('disk_count', 'disks'),
                ('disk_size', 'disk_size_with_unit')
            ],
            supports_check_mode=True
        )

        self.na_helper = NetAppModule()
        self.using_vserver_msg = None   # This module should be run as cluster admin
        self.parameters = self.na_helper.set_parameters(self.module.params)
        if self.parameters.get('mirror_disks') is not None and self.parameters.get('disks') is None:
            self.module.fail_json(msg="mirror_disks require disks options to be set")
        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)
コード例 #12
0
    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'),
                 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'),
                 aggr_list=dict(type='list'),
                 ipspace=dict(type='str', required=False),
                 snapshot_policy=dict(type='str', required=False),
                 language=dict(type='str', required=False),
                 subtype=dict(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)

        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)
コード例 #13
0
    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.")
コード例 #14
0
    def __init__(self):
        """
        Parse arguments, setup state variables,
        check parameters and ensure request module is installed
        """
        self.argument_spec = netapp_utils.aws_cvs_host_argument_spec()
        self.argument_spec.update(dict(
            state=dict(required=True, choices=['present', 'absent']),
            region=dict(required=True, type='str'),
            creationToken=dict(required=True, type='str'),
            quotaInBytes=dict(required=False, type='int'),
            serviceLevel=dict(required=False, choices=['standard', 'premium', 'extreme']),
            exportPolicy=dict(
                type='dict',
                options=dict(
                    rules=dict(
                        type='list',
                        options=dict(
                            allowedClients=dict(required=False, type='str'),
                            cifs=dict(required=False, type='bool'),
                            nfsv3=dict(required=False, type='bool'),
                            nfsv4=dict(required=False, type='bool'),
                            ruleIndex=dict(required=False, type='int'),
                            unixReadOnly=dict(required=False, type='bool'),
                            unixReadWrite=dict(required=False, type='bool')
                        )
                    )
                )
            ),
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            required_if=[
                ('state', 'present', ['region', 'creationToken', 'quotaInBytes']),
            ],
            supports_check_mode=True
        )

        self.na_helper = NetAppModule()

        # set up state variables
        self.parameters = self.na_helper.set_parameters(self.module.params)

        # Calling generic AWSCVS restApi class
        self.restApi = AwsCvsRestAPI(self.module)

        self.data = {}
        for key in self.parameters.keys():
            self.data[key] = self.parameters[key]
コード例 #15
0
    def __init__(self):
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(
            dict(admin_server_ip=dict(required=False, default=None,
                                      type='str'),
                 admin_server_port=dict(required=False,
                                        default=None,
                                        type='str'),
                 clock_skew=dict(required=False, default=None, type='str'),
                 comment=dict(required=False, default=None, type='str'),
                 kdc_ip=dict(required_if=[["state", "present"]],
                             default=None,
                             type='str'),
                 kdc_port=dict(required=False, default=None, type='str'),
                 kdc_vendor=dict(required_if=[["state", "present"]],
                                 default=None,
                                 type='str',
                                 choices=['Microsoft', 'Other']),
                 pw_server_ip=dict(required=False, default=None, type='str'),
                 pw_server_port=dict(required=False, default=None, type='str'),
                 realm=dict(required=True, type='str'),
                 state=dict(required=False,
                            choices=['present', 'absent'],
                            default='present'),
                 vserver=dict(required=True, type='str')))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            supports_check_mode=True,
            required_if=[('state', 'present', ['kdc_vendor', 'kdc_ip'])],
        )
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        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'])

        self.simple_attributes = [
            'admin_server_ip',
            'admin_server_port',
            'clock_skew',
            'kdc_ip',
            'kdc_port',
            'kdc_vendor',
        ]
コード例 #16
0
    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'),
                origin_volume=dict(required=False, type='str'),
                origin_vserver=dict(required=False, type='str'),
                origin_cluster=dict(required=False, type='str'),
                auto_provision_as=dict(required=False, type='str'),
                volume=dict(required=True, type='str'),
                junction_path=dict(required=False, type='str'),
                size=dict(required=False, type='int'),
                size_unit=dict(default='gb',
                               choices=[
                                   'bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb',
                                   'eb', 'zb', 'yb'
                               ],
                               type='str'),
                vserver=dict(required=True, type='str'),
                aggr_list=dict(required=False, type='list', elements='str'),
                aggr_list_multiplier=dict(required=False, type='int'),
                force_offline=dict(required=False, type='bool', default=False),
                force_unmount=dict(required=False, type='bool', default=False),
                time_out=dict(required=False, type='int', default=180),
            ))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    mutually_exclusive=[
                                        ('aggr_list', 'auto_provision_as'),
                                    ],
                                    supports_check_mode=True)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        if self.parameters.get('size'):
            self.parameters['size'] = self.parameters['size'] * \
                netapp_utils.POW2_BYTE_MAP[self.parameters['size_unit']]
        # setup later if required
        self.origin_server = None
        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'])
コード例 #17
0
 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'),
              policy_name=dict(required=True, type='str'),
              comment=dict(required=False, type='str'),
              duration=dict(required=False, type='int'),
              enabled=dict(required=False, type='bool'),
              policy_type=dict(required=False,
                               choices=['threshold', 'scheduled']),
              qos_policy=dict(required=False,
                              choices=['background', 'best_effort']),
              schedule=dict(reuired=False, type='str'),
              vserver=dict(required=True, type='str'),
              changelog_threshold_percent=dict(required=False, type='int')))
     self.module = AnsibleModule(
         argument_spec=self.argument_spec,
         supports_check_mode=True,
         mutually_exclusive=[('changelog_threshold_percent', 'duration'),
                             ('changelog_threshold_percent', 'schedule')])
     self.na_helper = NetAppModule()
     self.parameters = self.na_helper.set_parameters(self.module.params)
     self.set_playbook_zapi_key_map()
     if self.parameters.get('policy_type'):
         if self.parameters['policy_type'] == 'threshold':
             if self.parameters.get('duration'):
                 self.module.fail_json(
                     msg="duration cannot be set if policy_type is threshold"
                 )
             if self.parameters.get('schedule'):
                 self.module.fail_json(
                     msg='schedule cannot be set if policy_type is threshold'
                 )
         # if policy_type is 'scheduled'
         else:
             if self.parameters.get('changelog_threshold_percent'):
                 self.module.fail_json(
                     msg=
                     'changelog_threshold_percent cannot be set if policy_type is scheduled'
                 )
     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'])
コード例 #18
0
    def __init__(self):
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(
            dict(state=dict(required=False, type='str', default='present'),
                 node=dict(required=False, type='str'),
                 firmware_type=dict(
                     required=True,
                     type='str',
                     choices=['service-processor', 'shelf', 'acp', 'disk']),
                 clear_logs=dict(required=False, type='bool', default=True),
                 package=dict(required=False, type='str'),
                 install_baseline_image=dict(required=False,
                                             type='bool',
                                             default=False),
                 update_type=dict(required=False, type='str'),
                 shelf_module_fw=dict(required=False, type='str'),
                 disk_fw=dict(required=False, type='str')))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    required_if=[
                                        ('firmware_type', 'acp', ['node']),
                                        ('firmware_type', 'disk', ['node']),
                                        ('firmware_type', 'service-processor',
                                         ['node', 'update_type']),
                                    ],
                                    supports_check_mode=True)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        if self.parameters.get('firmware_type') == 'service-processor':
            if self.parameters.get(
                    'install_baseline_image') and self.parameters.get(
                        'package') is not None:
                self.module.fail_json(
                    msg=
                    'Do not specify both package and install_baseline_image: true'
                )
            if not self.parameters.get('package') and self.parameters.get(
                    'install_baseline_image') == 'False':
                self.module.fail_json(
                    msg=
                    'Specify at least one of package or install_baseline_image'
                )
        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)
コード例 #19
0
ファイル: na_ontap_quotas.py プロジェクト: dkwon253/mycode
    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'),
            vserver=dict(required=True, type='str'),
            volume=dict(required=True, type='str'),
            quota_target=dict(required=False, type='str'),
            qtree=dict(required=False, type='str', default=""),
            type=dict(required=False, type='str', choices=['user', 'group', 'tree']),
            policy=dict(required=False, type='str'),
            set_quota_status=dict(required=False, type='bool'),
            perform_user_mapping=dict(required=False, type='bool'),
            file_limit=dict(required=False, type='str'),
            disk_limit=dict(required=False, type='str'),
            soft_file_limit=dict(required=False, type='str'),
            soft_disk_limit=dict(required=False, type='str'),
            threshold=dict(required=False, type='str'),
            activate_quota_on_change=dict(required=False, type='str', choices=['resize', 'reinitialize', 'none'], default='resize')
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            required_by={
                'policy': ['quota_target', 'type'],
                'perform_user_mapping': ['quota_target', 'type'],
                'file_limit': ['quota_target', 'type'],
                'disk_limit': ['quota_target', 'type'],
                'soft_file_limit': ['quota_target', 'type'],
                'soft_disk_limit': ['quota_target', 'type'],
                'threshold': ['quota_target', 'type'],
            },
            required_together=[['quota_target', 'type']],
            supports_check_mode=True
        )

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        # converted blank parameter to * as shown in vsim
        if self.parameters.get('quota_target') == "":
            self.parameters['quota_target'] = '*'

        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'])
コード例 #20
0
    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'),
                size=dict(type='int'),
                size_unit=dict(default='gb',
                               choices=[
                                   'bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb',
                                   'eb', 'zb', 'yb'
                               ],
                               type='str'),
                force_resize=dict(default=False, type='bool'),
                force_remove=dict(default=False, type='bool'),
                force_remove_fenced=dict(default=False, type='bool'),
                flexvol_name=dict(required=True, type='str'),
                vserver=dict(required=True, type='str'),
                ostype=dict(required=False, type='str', default='image'),
                space_reserve=dict(required=False, type='bool', default=True),
                space_allocation=dict(required=False,
                                      type='bool',
                                      default=False),
                use_exact_size=dict(required=False, type='bool', default=True),
            ))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    required_if=[('state', 'present', ['size'])
                                                 ],
                                    supports_check_mode=True)

        # set up state variables
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        if self.parameters.get('size') is not None:
            self.parameters['size'] *= netapp_utils.POW2_BYTE_MAP[
                self.parameters['size_unit']]

        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'])
コード例 #21
0
    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
コード例 #22
0
    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)
コード例 #23
0
    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'])
コード例 #24
0
    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'])
コード例 #25
0
ファイル: na_ontap_disks.py プロジェクト: thehackshop/netapp
    def __init__(self):
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(
            dict(node=dict(required=True, type='str'),
                 disk_count=dict(required=False, type='int')))

        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_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)
コード例 #26
0
    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'])
コード例 #27
0
    def __init__(self):

        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(
            dict(vserver=dict(required=True, type='str'),
                 kerberos_clock_skew=dict(required=False, type='int'),
                 kerberos_ticket_age=dict(required=False, type='int'),
                 kerberos_renew_age=dict(required=False, type='int'),
                 kerberos_kdc_timeout=dict(required=False, type='int'),
                 is_signing_required=dict(required=False, type='bool'),
                 is_password_complexity_required=dict(required=False,
                                                      type='bool'),
                 is_aes_encryption_enabled=dict(required=False, type='bool'),
                 is_smb_encryption_required=dict(required=False, type='bool'),
                 lm_compatibility_level=dict(required=False,
                                             choices=[
                                                 'lm_ntlm_ntlmv2_krb',
                                                 'ntlm_ntlmv2_krb',
                                                 'ntlmv2_krb', 'krb'
                                             ]),
                 referral_enabled_for_ad_ldap=dict(required=False,
                                                   type='bool'),
                 session_security_for_ad_ldap=dict(
                     required=False, choices=['none', 'sign', 'seal']),
                 smb1_enabled_for_dc_connections=dict(
                     required=False,
                     choices=['false', 'true', 'system_default']),
                 smb2_enabled_for_dc_connections=dict(
                     required=False,
                     choices=['false', 'true', 'system_default']),
                 use_start_tls_for_ad_ldap=dict(required=False, type='bool')))

        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()

        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'])
コード例 #28
0
    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')
コード例 #29
0
    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'),
                 peer_vserver=dict(required=True, type='str'),
                 peer_cluster=dict(required=False, type='str'),
                 applications=dict(required=False,
                                   type='list',
                                   choices=[
                                       'snapmirror', 'file_copy', 'lun_copy',
                                       'flexcache'
                                   ]),
                 dest_hostname=dict(required=False, 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)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        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)
            if self.parameters.get('dest_hostname'):
                self.module.params['hostname'] = self.parameters[
                    'dest_hostname']
                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_server = netapp_utils.setup_na_ontap_zapi(
                    module=self.module)
                # reset to source host connection for asup logs
                self.module.params['hostname'] = self.parameters['hostname']
コード例 #30
0
    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'), ))
        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_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)