Esempio n. 1
0
 def apply(self):
     """
     Apply action to update ONTAP software
     """
     changed = False
     current = self.cluster_image_get()
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_ontap_zapi(module=self.module,
                                             vserver=results)
     netapp_utils.ems_log_event("na_ontap_software_update", cserver)
     if self.parameters.get('state') == 'present' and current:
         package_exists = self.cluster_image_package_download()
         if package_exists is False:
             cluster_download_progress = self.cluster_image_package_download_progress(
             )
             while cluster_download_progress.get(
                     'progress_status') == 'async_pkg_get_phase_running':
                 time.sleep(5)
                 cluster_download_progress = self.cluster_image_package_download_progress(
                 )
             if cluster_download_progress.get(
                     'progress_status') == 'async_pkg_get_phase_complete':
                 self.cluster_image_update()
                 changed = True
             else:
                 self.module.fail_json(
                     msg='Error downloading package: %s' %
                     (cluster_download_progress['failure_reason']))
         else:
             self.cluster_image_update()
             changed = True
     self.module.exit_json(changed=changed)
Esempio n. 2
0
    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']),
            name=dict(required=True, type='str'),
            flexvol_name=dict(type='str'),
            vserver=dict(required=True, type='str'),
        ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.flexvol_name = p['flexvol_name']
        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module, vserver=self.vserver)
Esempio n. 3
0
    def __init__(self):
        self.argument_spec = netapp_utils.ontap_sf_host_argument_spec()
        self.argument_spec.update(
            dict(
                serial_number=dict(required=False, type='str', default=None),
                remove_unused=dict(default=False, type='bool'),
                remove_expired=dict(default=False, type='bool'),
                licenses=dict(default=False, type='dict'),
            ))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=False)

        p = self.module.params

        # set up state variables
        self.serial_number = p['serial_number']
        self.remove_unused = p['remove_unused']
        self.remove_expired = p['remove_expired']
        self.licenses = p['licenses']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 4
0
    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']),
            name=dict(required=True, type='str'),

            command_directory_name=dict(required=True, type='str'),
            access_level=dict(required=False, type='str', default='all',
                              choices=['none', 'readonly', 'all']),

            vserver=dict(required=True, type='str'),
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            supports_check_mode=True
        )

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']

        self.command_directory_name = p['command_directory_name']
        self.access_level = p['access_level']

        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 5
0
    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']),
                 name=dict(required=True, type='str'),
                 disk_count=dict(required=False, type='int'),
                 raid_type=dict(
                     require=False,
                     type='str',
                     choices=['raid0', 'raid4', 'raid_dp', 'raid_tec'],
                     default='raid_dp')))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.disk_count = p['disk_count']
        self.raid_type = p['raid_type']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 6
0
    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']),
                name=dict(required=True, 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']),
            ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.root_volume = p['root_volume']
        self.root_volume_aggregate = p['root_volume_aggregate']
        self.root_volume_security_style = p['root_volume_security_style']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 7
0
    def __init__(self):
        self.argument_spec = netapp_utils.ontap_sf_host_argument_spec()
        self.argument_spec.update(dict(
            serial_number=dict(required=False, type='str', default=None),
            remove_unused=dict(default=False, type='bool'),
            remove_expired=dict(default=False, type='bool'),
            licenses=dict(default=False, type='dict'),
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            supports_check_mode=False
        )

        p = self.module.params

        # set up state variables
        self.serial_number = p['serial_number']
        self.remove_unused = p['remove_unused']
        self.remove_expired = p['remove_expired']
        self.licenses = p['licenses']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 8
0
    def __init__(self):

        self._size_unit_map = dict(bytes=1,
                                   b=1,
                                   kb=1024,
                                   mb=1024**2,
                                   gb=1024**3,
                                   tb=1024**4,
                                   pb=1024**5,
                                   eb=1024**6,
                                   zb=1024**7,
                                   yb=1024**8)

        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'),
                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(type='str'),
                vserver=dict(required=True, type='str'),
            ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.size_unit = p['size_unit']
        if p['size'] is not None:
            self.size = p['size'] * self._size_unit_map[self.size_unit]
        else:
            self.size = None
        self.force_resize = p['force_resize']
        self.force_remove = p['force_remove']
        self.force_remove_fenced = p['force_remove_fenced']
        self.flexvol_name = p['flexvol_name']
        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module,
                                                        vserver=self.vserver)
Esempio n. 9
0
 def autosupport_log(self):
     """
     Autosupport log for job_schedule
     :return: None
     """
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event("na_ontap_job_schedule", cserver)
    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'),
                 source_intercluster_lif=dict(required=False, type='str'),
                 dest_intercluster_lif=dict(required=False, type='str'),
                 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_lif',
                                        'dest_intercluster_lif', 'passphrase'
                                    ]],
                                    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_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_ontap_zapi(
                module=self.module)
Esempio n. 11
0
    def __init__(self):

        self._size_unit_map = dict(
            bytes=1,
            b=1,
            kb=1024,
            mb=1024 ** 2,
            gb=1024 ** 3,
            tb=1024 ** 4,
            pb=1024 ** 5,
            eb=1024 ** 6,
            zb=1024 ** 7,
            yb=1024 ** 8
        )

        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'),
            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(type='str'),
            vserver=dict(required=True, type='str'),
        ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.size_unit = p['size_unit']
        if p['size'] is not None:
            self.size = p['size'] * self._size_unit_map[self.size_unit]
        else:
            self.size = None
        self.force_resize = p['force_resize']
        self.force_remove = p['force_remove']
        self.force_remove_fenced = p['force_remove_fenced']
        self.flexvol_name = p['flexvol_name']
        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module, vserver=self.vserver)
Esempio n. 12
0
    def __init__(self, module):
        self.module = module
        self.netapp_info = dict()

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 13
0
    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'),
                 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']),
                 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,
                                    required_if=[('state', 'present',
                                                  ['dest_hostname'])],
                                    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_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_ontap_zapi(
                    module=self.module)
Esempio n. 14
0
 def set_source_cluster_connection(self):
     """
     Setup ontap ZAPI server connection for source hostname
     :return: None
     """
     if self.parameters.get('source_username'):
         self.module.params['username'] = self.parameters['source_username']
     if self.parameters.get('source_password'):
         self.module.params['password'] = self.parameters['source_password']
     self.module.params['hostname'] = self.parameters['source_hostname']
     self.source_server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 15
0
    def apply(self):
        changed = False
        vserver_details = self.get_vserver()
        if vserver_details is not None:
            results = netapp_utils.get_cserver(self.server)
            cserver = netapp_utils.setup_ontap_zapi(
                module=self.module, vserver=results)
            netapp_utils.ems_log_event("na_ontap_svm", cserver)

        rename_vserver = False
        modify_protocols = False
        modify_aggr_list = False
        obj = open('vserver-log', 'a')
        if vserver_details is not None:
            if self.state == 'absent':
                changed = True
            elif self.state == 'present':
                if self.new_name is not None and self.new_name != self.name:
                    rename_vserver = True
                    changed = True
                if self.allowed_protocols is not None:
                    self.allowed_protocols.sort()
                    vserver_details['allowed_protocols'].sort()
                    if self.allowed_protocols != vserver_details['allowed_protocols']:
                        modify_protocols = True
                        changed = True
                if self.aggr_list is not None:
                    self.aggr_list.sort()
                    vserver_details['aggr_list'].sort()
                    if self.aggr_list != vserver_details['aggr_list']:
                        modify_aggr_list = True
                        changed = True
        else:
            if self.state == 'present':
                changed = True
        if changed:
            if self.module.check_mode:
                pass
            else:
                if self.state == 'present':
                    if vserver_details is None:
                        self.create_vserver()
                    else:
                        if rename_vserver:
                            self.rename_vserver()
                        if modify_protocols or modify_aggr_list:
                            self.modify_vserver(
                                modify_protocols, modify_aggr_list)
                elif self.state == 'absent':
                    self.delete_vserver()

        self.module.exit_json(changed=changed)
Esempio n. 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'),
                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_ontap_zapi(
                module=self.module, vserver=self.parameters['vserver'])
Esempio n. 17
0
    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']),
                name=dict(required=True, type='str'),
                application=dict(required=True,
                                 type='str',
                                 choices=[
                                     'console', 'http', 'ontapi', 'rsh',
                                     'snmp', 'sp', 'ssh', 'telnet'
                                 ]),
                authentication_method=dict(required=True,
                                           type='str',
                                           choices=[
                                               'community', 'password',
                                               'publickey', 'domain',
                                               'nsswitch', 'usm'
                                           ]),
                set_password=dict(required=False, type='str', default=None),
                role_name=dict(required=False, type='str'),
                vserver=dict(required=True, type='str'),
            ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']

        self.application = p['application']
        self.authentication_method = p['authentication_method']
        self.set_password = p['set_password']
        self.role_name = p['role_name']

        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 18
0
    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']),
            name=dict(required=True, type='str'),

            application=dict(required=True, type='str', choices=[
                'console', 'http', 'ontapi', 'rsh',
                'snmp', 'sp', 'ssh', 'telnet']),
            authentication_method=dict(required=True, type='str',
                                       choices=['community', 'password',
                                                'publickey', 'domain',
                                                'nsswitch', 'usm']),
            set_password=dict(required=False, type='str', default=None),
            role_name=dict(required=False, type='str'),

            vserver=dict(required=True, type='str'),
        ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']

        self.application = p['application']
        self.authentication_method = p['authentication_method']
        self.set_password = p['set_password']
        self.role_name = p['role_name']

        self.vserver = p['vserver']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 19
0
    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'),
                 source_vserver=dict(required=False, type='str'),
                 destination_vserver=dict(required=False, type='str'),
                 source_volume=dict(required=False, type='str'),
                 destination_volume=dict(required=False, type='str'),
                 source_path=dict(required=False, type='str'),
                 destination_path=dict(required=False, type='str'),
                 schedule=dict(required=False, type='str'),
                 relationship_type=dict(required=False,
                                        type='str',
                                        choices=[
                                            'data_protection', 'load_sharing',
                                            'vault', 'restore',
                                            'transition_data_protection',
                                            'extended_data_protection'
                                        ]),
                 source_hostname=dict(required=False, type='str'),
                 source_username=dict(required=False, type='str'),
                 source_password=dict(required=False, type='str',
                                      no_log=True)))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            required_together=(['source_volume', 'destination_volume'],
                               ['source_vserver', 'destination_vserver']),
            supports_check_mode=True)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        # setup later if required
        self.source_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_ontap_zapi(module=self.module)
Esempio n. 20
0
 def delete_snapmirror(self):
     """
     Delete a SnapMirror relationship
     #1. Quiesce the SnapMirror relationship at destination
     #2. Break the SnapMirror relationship at the source
     #3. Release the SnapMirror at destination
     #4. Delete SnapMirror at destination
     """
     if not self.parameters.get('source_hostname'):
         self.module.fail_json(msg='Missing parameters for delete: Please specify the '
                                   'source cluster to release the SnapMirror relation')
     if self.parameters.get('source_username'):
         self.module.params['username'] = self.parameters['dest_username']
     if self.parameters.get('source_password'):
         self.module.params['password'] = self.parameters['dest_password']
     self.source_server = netapp_utils.setup_ontap_zapi(module=self.module)
     self.snapmirror_quiesce()
     self.snapmirror_break()
     if self.get_destination():
         self.snapmirror_release()
     self.snapmirror_delete()
 def apply(self):
     """
     Run Module based on play book
     """
     changed = False
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_ontap_zapi(module=self.module,
                                             vserver=results)
     netapp_utils.ems_log_event("na_ontap_service_processor_network",
                                cserver)
     spn_details = self.get_service_processor_network()
     spn_exists = False
     if spn_details:
         spn_exists = True
         if self.state == 'present':  # modify
             if (self.dhcp is not None and
                 self.dhcp != spn_details['dhcp_value']) or \
                (self.gateway_ip_address is not None and
                 self.gateway_ip_address != spn_details['gateway_ip_address_value']) or \
                (self.ip_address is not None and
                 self.ip_address != spn_details['ip_address_value']) or \
                (self.netmask is not None and
                 self.netmask != spn_details['netmask_value']) or \
                (self.prefix_length is not None and str(self.prefix_length)
                     != spn_details['prefix_length_value']) or \
                (self.is_enabled is not None and str(self.is_enabled).lower()
                     != spn_details['is_enabled_value']):
                 changed = True
     else:
         self.module.fail_json(
             msg='Error No Service Processor for node: %s' % self.node)
     if changed:
         if self.module.check_mode:
             pass
         else:
             if self.state == 'present':  # execute modify
                 if spn_exists:
                     self.modify_service_processor_network()
     self.module.exit_json(changed=changed)
Esempio n. 22
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'),
                node_name=dict(required=True, type='str'),
                transport=dict(required=False,
                               type='str',
                               choices=['smtp', 'http', 'https']),
                noteto=dict(required=False, type='list'),
                post_url=dict(reuired=False, type='str'),
                support=dict(required=False, type='bool'),
                mail_hosts=dict(required=False, type='list'),
                from_address=dict(required=False, type='str'),
                partner_addresses=dict(required=False, type='list'),
                to_addresses=dict(required=False, type='list'),
                proxy_url=dict(required=False, type='str'),
                hostname_in_subject=dict(required=False, type='bool'),
            ))

        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=False)

        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)
        # present or absent requires modifying state to enabled or disabled
        self.parameters['service_state'] = 'started' if self.parameters[
            'state'] == 'present' else 'stopped'
        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_ontap_zapi(module=self.module)
Esempio n. 23
0
    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']),
            name=dict(required=True, 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'
                                                                 ]),
        ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.root_volume = p['root_volume']
        self.root_volume_aggregate = p['root_volume_aggregate']
        self.root_volume_security_style = p['root_volume_security_style']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module)
Esempio n. 24
0
    def __init__(self):

        self._size_unit_map = dict(
            bytes=1,
            b=1,
            kb=1024,
            mb=1024 ** 2,
            gb=1024 ** 3,
            tb=1024 ** 4,
            pb=1024 ** 5,
            eb=1024 ** 6,
            zb=1024 ** 7,
            yb=1024 ** 8
        )

        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'),
            is_infinite=dict(required=False, type='bool', default=False, aliases=['infinite']),
            is_online=dict(required=False, type='bool', default=True, aliases=['online']),
            size=dict(type='int'),
            size_unit=dict(default='gb',
                           choices=['bytes', 'b', 'kb', 'mb', 'gb', 'tb',
                                    'pb', 'eb', 'zb', 'yb'], type='str'),
            aggregate_name=dict(type='str'),
            vserver=dict(required=True, type='str', default=None),
            junction_path=dict(required=False, type='str', default=None),
            export_policy=dict(required=False, type='str', default='default'),
            snapshot_policy=dict(required=False, type='str', default='default'),
        ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.is_infinite = p['is_infinite']
        self.is_online = p['is_online']
        self.size_unit = p['size_unit']
        self.vserver = p['vserver']
        self.junction_path = p['junction_path']
        self.export_policy = p['export_policy']
        self.snapshot_policy = p['snapshot_policy']

        if p['size'] is not None:
            self.size = p['size'] * self._size_unit_map[self.size_unit]
        else:
            self.size = None
        self.aggregate_name = p['aggregate_name']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module, vserver=self.vserver)
Esempio n. 25
0
    def __init__(self):

        self._size_unit_map = dict(bytes=1,
                                   b=1,
                                   kb=1024,
                                   mb=1024**2,
                                   gb=1024**3,
                                   tb=1024**4,
                                   pb=1024**5,
                                   eb=1024**6,
                                   zb=1024**7,
                                   yb=1024**8)

        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'),
                is_infinite=dict(required=False,
                                 type='bool',
                                 default=False,
                                 aliases=['infinite']),
                is_online=dict(required=False,
                               type='bool',
                               default=True,
                               aliases=['online']),
                size=dict(type='int'),
                size_unit=dict(default='gb',
                               choices=[
                                   'bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb',
                                   'eb', 'zb', 'yb'
                               ],
                               type='str'),
                aggregate_name=dict(type='str'),
                vserver=dict(required=True, type='str', default=None),
                junction_path=dict(required=False, type='str', default=None),
                export_policy=dict(required=False,
                                   type='str',
                                   default='default'),
                snapshot_policy=dict(required=False,
                                     type='str',
                                     default='default'),
            ))

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

        p = self.module.params

        # set up state variables
        self.state = p['state']
        self.name = p['name']
        self.is_infinite = p['is_infinite']
        self.is_online = p['is_online']
        self.size_unit = p['size_unit']
        self.vserver = p['vserver']
        self.junction_path = p['junction_path']
        self.export_policy = p['export_policy']
        self.snapshot_policy = p['snapshot_policy']

        if p['size'] is not None:
            self.size = p['size'] * self._size_unit_map[self.size_unit]
        else:
            self.size = None
        self.aggregate_name = p['aggregate_name']

        if HAS_NETAPP_LIB is False:
            self.module.fail_json(
                msg="the python NetApp-Lib module is required")
        else:
            self.server = netapp_utils.setup_ontap_zapi(module=self.module,
                                                        vserver=self.vserver)