예제 #1
0
 def apply(self):
     """
     Apply action to SnapMirror
     """
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                vserver=results)
     netapp_utils.ems_log_event("na_ontap_snapmirror", cserver)
     self.check_parameters()
     current = self.snapmirror_get()
     cd_action = self.na_helper.get_cd_action(current, self.parameters)
     modify = self.na_helper.get_modified_attributes(
         current, self.parameters)
     if cd_action == 'create':
         self.snapmirror_create()
     elif cd_action == 'delete':
         if current['status'] == 'transferring':
             self.snapmirror_abort()
         else:
             self.delete_snapmirror()
     else:
         if modify:
             self.snapmirror_modify(modify)
         # check for initialize
         if current and current['mirror_state'] != 'snapmirrored':
             self.snapmirror_initialize()
             # set changed explicitly for initialize
             self.na_helper.changed = True
         # Update when create is called again, or modify is being called
         if self.parameters['state'] == 'present':
             self.snapmirror_update()
     self.module.exit_json(changed=self.na_helper.changed)
 def apply(self):
     """
     Apply action to job-schedule
     """
     changed = False
     job_schedule_exists = 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_job_schedule", cserver)
     job_details = self.get_job_schedule()
     if job_details:
         job_schedule_exists = True
         if self.state == 'absent':  # delete
             changed = True
         elif self.state == 'present':  # modify
             if job_details['job_minutes'] != str(self.job_minutes):
                 changed = True
     else:
         if self.state == 'present':  # create
             changed = True
     if changed:
         if self.module.check_mode:
             pass
         else:
             if self.state == 'present':  # execute create
                 if not job_schedule_exists:
                     self.create_job_schedule()
                 else:  # execute modify minute
                     self.modify_minute_job_schedule()
             elif self.state == 'absent':  # execute delete
                 self.delete_job_schedule()
     self.module.exit_json(changed=changed)
 def apply(self):
     """
     Run Module based on play book
     """
     changed = False
     broadcast_domain_details = self.get_broadcast_domain()
     broadcast_domain_exists = False
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                vserver=results)
     netapp_utils.ems_log_event("na_ontap_broadcast_domain", cserver)
     if broadcast_domain_details:
         broadcast_domain_exists = True
         if self.state == 'absent':  # delete
             changed = True
         elif self.state == 'present':  # modify
             if (self.mtu and self.mtu != broadcast_domain_details['mtu']) or \
                (self.ipspace and self.ipspace != broadcast_domain_details['ipspace']):
                 changed = True
     else:
         if self.state == 'present':  # create
             changed = True
     if changed:
         if self.module.check_mode:
             pass
         else:
             if self.state == 'present':  # execute create
                 if not broadcast_domain_exists:
                     self.create_broadcast_domain()
                 else:  # execute modify
                     self.modify_broadcast_domain()
             elif self.state == 'absent':  # execute delete
                 self.delete_broadcast_domain()
     self.module.exit_json(changed=changed)
예제 #4
0
    def apply(self):
        ''' calling all adapter features '''
        changed = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_ucadapter", cserver)
        adapter_detail = self.get_adapter()

        def need_to_change(expected, pending, current):
            if expected is None:
                return False
            if pending is not None:
                return pending != expected
            if current is not None:
                return current != expected
            return False

        if adapter_detail:
            changed = need_to_change(self.type, adapter_detail['pending-type'], adapter_detail['type']) or \
                need_to_change(self.mode, adapter_detail['pending-mode'], adapter_detail['mode'])

        if changed:
            if self.module.check_mode:
                pass
            else:
                self.offline_adapter()
                self.modify_adapter()
                self.online_adapter()

        self.module.exit_json(changed=changed)
예제 #5
0
    def apply(self):
        """Apply action to ntp-server"""

        changed = False
        ntp_modify = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_ntp", cserver)
        ntp_server_details = self.get_ntp_server()
        if ntp_server_details is not None:
            if self.state == 'absent':  # delete
                changed = True
            elif self.state == 'present' and self.version:
                # modify version
                if self.version != ntp_server_details['version']:
                    ntp_modify = True
                    changed = True
        else:
            if self.state == 'present':  # create
                changed = True

        if changed:
            if self.module.check_mode:
                pass
            else:
                if self.state == 'present':
                    if ntp_server_details is None:
                        self.create_ntp_server()
                    elif ntp_modify:
                        self.modify_version()
                elif self.state == 'absent':
                    self.delete_ntp_server()

        self.module.exit_json(changed=changed)
 def apply(self):
     """
     Run Module based on play book
     """
     changed = False
     settings_exist = self.get_config_backup_settings()
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event("na_ontap_backup_config", cserver)
     
     if settings_exist:
         if self.state == 'absent':  # delete
             changed = True
         elif self.state == 'present':  # settings exist=True and state is present, no changes. 
             changed = False
     else:
         if self.state == 'present':  # set config settings when settings_exist = None
             changed = True
     if changed:
         if self.module.check_mode:
             pass
         else:
             if self.state == 'present':  # execute set
                 self.set_config_settings()
             elif self.state == 'absent':  # execute delete
                 self.delete_config_settings()
     self.module.exit_json(changed=changed)
예제 #7
0
 def apply(self):
     """
     check the option in the playbook to see what needs to be done
     :return:
     """
     changed = False
     result = None
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event("na_ontap_net_vlan", cserver)
     existing_vlan = self.does_vlan_exist()
     if existing_vlan:
         if self.state == 'absent':  # delete
             changed = True
     else:
         if self.state == 'present':  # create
             changed = True
     if changed:
         if self.module.check_mode:
             pass
         else:
             if self.state == 'present':
                 self.create_vlan()
             elif self.state == 'absent':
                 self.delete_vlan()
     self.module.exit_json(changed=changed, meta=result)
예제 #8
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)
예제 #9
0
    def apply(self):
        """
        Apply action to cluster peer
        :return: None
        """
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_cluster_peer", cserver)
        source = self.cluster_peer_get('source')
        destination = self.cluster_peer_get('destination')
        source_action = self.na_helper.get_cd_action(source, self.parameters)
        destination_action = self.na_helper.get_cd_action(
            destination, self.parameters)
        self.na_helper.changed = False
        # create only if expected cluster peer relation is not present on both source and destination clusters
        if source_action == 'create' and destination_action == 'create':
            self.cluster_peer_create('source')
            self.cluster_peer_create('destination')
            self.na_helper.changed = True
        # delete peer relation in cluster where relation is present
        else:
            if source_action == 'delete':
                self.cluster_peer_delete('source')
                self.na_helper.changed = True
            if destination_action == 'delete':
                self.cluster_peer_delete('destination')
                self.na_helper.changed = True

        self.module.exit_json(changed=self.na_helper.changed)
예제 #10
0
    def apply(self):
        """
        Run Module based on play book
        """
        changed = False
        net_port_exists = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(
            module=self.module, vserver=results)
        netapp_utils.ems_log_event("na_ontap_net_port", cserver)
        net_port_details = self.get_net_port()
        if net_port_details:
            net_port_exists = True
            if self.state == 'present':
                if (self.mtu and self.mtu != net_port_details['mtu']) or \
                   (self.autonegotiate_admin and
                    self.autonegotiate_admin != net_port_details['autonegotiate_admin']) or \
                   (self.duplex_admin and
                    self.duplex_admin != net_port_details['duplex_admin']) or \
                   (self.speed_admin and
                    self.speed_admin != net_port_details['speed_admin']) or \
                   (self.flowcontrol_admin and
                        self.flowcontrol_admin != net_port_details['flowcontrol_admin']):
                    changed = True

        if changed:
            if self.module.check_mode:
                pass
            else:
                if self.state == 'present':
                    if net_port_exists:
                        self.modify_net_port()
        self.module.exit_json(changed=changed)
예제 #11
0
    def commit_changes(self):
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_motd", cserver)
        if self.parameters['state'] == 'absent':
            # Just make sure it is empty
            self.parameters['message'] = ''

        call = self._create_call()

        try:
            _call_result = self.server.invoke_successfully(
                call, enable_tunneling=False)
        except netapp_utils.zapi.NaApiError as err:
            self.module.fail_json(msg="Error calling API %s: %s" %
                                  ('vserver-motd-modify-iter', to_native(err)),
                                  exception=traceback.format_exc())

        _dict_num_succeeded = xmltodict.parse(
            _call_result.get_child_by_name('num-succeeded').to_string(),
            xml_attribs=False)

        num_succeeded = int(_dict_num_succeeded['num-succeeded'])

        changed = bool(num_succeeded >= 1)

        result = {'state': self.parameters['state'], 'changed': changed}
        self.module.exit_json(**result)
예제 #12
0
 def apply(self):
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                vserver=results)
     netapp_utils.ems_log_event("na_ontap_firewall_policy", cserver)
     changed = False
     if self.parameters['state'] == 'present':
         policy = self.get_firewall_policy()
         if not policy:
             self.create_firewall_policy()
             if not self.check_config(self.get_firewall_config()):
                 self.modify_firewall_config()
             changed = True
         else:
             if self.check_policy(policy):
                 self.modify_firewall_policy()
                 changed = True
             if not self.check_config(self.get_firewall_config()):
                 self.modify_firewall_config()
                 changed = True
     else:
         if self.get_firewall_policy():
             self.destroy_firewall_policy()
             if not self.check_config(self.get_firewall_config()):
                 self.modify_firewall_config()
             changed = True
         else:
             if not self.check_config(self.get_firewall_config()):
                 self.modify_firewall_config()
                 changed = True
     self.module.exit_json(changed=changed)
예제 #13
0
 def apply(self):
     """
     Run Module based on play book
     """
     changed = False
     broadcast_domain_details = self.get_broadcast_domain_ports()
     broadcast_domain_exists = False
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                vserver=results)
     netapp_utils.ems_log_event("na_ontap_broadcast_domain_ports", cserver)
     if broadcast_domain_details:
         broadcast_domain_exists = True
         if self.state == 'absent':  # delete
             changed = True
         elif self.state == 'present':  # create
             changed = True
     else:
         pass
     if changed:
         if self.module.check_mode:
             pass
         else:
             if broadcast_domain_exists:
                 if self.state == 'present':  # execute create
                     changed = self.create_broadcast_domain_ports()
                 elif self.state == 'absent':  # execute delete
                     changed = self.delete_broadcast_domain_ports()
     self.module.exit_json(changed=changed)
    def apply(self):
        """
        Run Module based on play book
        """
        changed = False
        broadcast_domain_details = self.get_broadcast_domain_ports()
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_broadcast_domain_ports", cserver)
        if broadcast_domain_details is None:
            self.module.fail_json(msg='Error broadcast domain not found: %s' %
                                  self.broadcast_domain)
        if self.module.check_mode:
            pass
        else:
            if self.state == 'present':  # execute create
                ports_to_add = [
                    port for port in self.ports
                    if port not in broadcast_domain_details['ports']
                ]
                if len(ports_to_add) > 0:
                    changed = self.create_broadcast_domain_ports(ports_to_add)
            elif self.state == 'absent':  # execute delete
                ports_to_delete = [
                    port for port in self.ports
                    if port in broadcast_domain_details['ports']
                ]
                if len(ports_to_delete) > 0:
                    changed = self.delete_broadcast_domain_ports(
                        ports_to_delete)

        self.module.exit_json(changed=changed)
예제 #15
0
 def apply(self):
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event("na_ontap_fcp", cserver)
     exists = self.get_fcp()
     changed = False
     if self.parameters['state'] == 'present':
         if exists:
             if self.parameters['status'] == 'up':
                 if not self.current_status():
                     self.start_fcp()
                     changed = True
             else:
                 if self.current_status():
                     self.stop_fcp()
                     changed = True
         else:
             self.create_fcp()
             if self.parameters['status'] == 'up':
                 self.start_fcp()
             elif self.parameters['status'] == 'down':
                 self.stop_fcp()
             changed = True
     else:
         if exists:
             if self.current_status():
                 self.stop_fcp()
             self.destroy_fcp()
             changed = True
     self.module.exit_json(changed=changed)
예제 #16
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 autosupport_log(self):
     """
     Autosupport log for ucadater
     :return:
     """
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event("na_ontap_ucadapter", cserver)
예제 #18
0
 def autosupport_log(self):
     """
     Autosupport log for software_update
     :return:
     """
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                vserver=results)
     netapp_utils.ems_log_event("na_ontap_firmware_upgrade", cserver)
예제 #19
0
 def asup_log_for_cserver(self, event_name):
     """
     Fetch admin vserver for the given cluster
     Create and Autosupport log event with the given module name
     :param event_name: Name of the event log
     :return: None
     """
     results = netapp_utils.get_cserver(self.server)
     cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
     netapp_utils.ems_log_event(event_name, cserver)
예제 #20
0
    def apply(self):
        '''Apply action to aggregate'''
        changed = False
        size_changed = False
        aggregate_exists = self.get_aggr()
        rename_aggregate = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_aggregate", cserver)

        # check if anything needs to be changed (add/delete/update)

        if aggregate_exists:
            if self.state == 'absent':
                changed = True

            elif self.state == 'present':
                if self.service_state:
                    changed = True
                if self.rename is not None and self.name != \
                        self.rename:
                    rename_aggregate = True
                    changed = True

        else:
            if self.state == 'present':
                # Aggregate does not exist, but requested state is present.
                if (self.rename is None) and self.disk_count:
                    changed = True

        if changed:
            if self.module.check_mode:
                pass
            else:
                if self.state == 'present':
                    if not aggregate_exists:
                        self.create_aggr()
                        if self.service_state == 'offline':
                            self.aggregate_offline()
                    else:
                        if self.service_state == 'online':
                            size_changed = self.aggregate_online()
                        elif self.service_state == 'offline':
                            size_changed = self.aggregate_offline()
                        if rename_aggregate:
                            self.rename_aggregate()
                        if not size_changed and not rename_aggregate:
                            changed = False

                elif self.state == 'absent':
                    if self.service_state == 'offline':
                        self.aggregate_offline()
                    self.delete_aggr()
        self.module.exit_json(changed=changed)
예제 #21
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)
예제 #22
0
    def apply(self):
        '''Apply action to disks'''
        changed = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(
            module=self.module, vserver=results)
        netapp_utils.ems_log_event("na_ontap_disks", cserver)

        # check if anything needs to be changed (add/delete/update)
        unowned_disks = self.disk_check()
        if unowned_disks == 'true':
            self.disk_assign()
            changed = True
        self.module.exit_json(changed=changed)
    def apply(self):
        changed = False
        ifgroup_exists = False
        add_ports_exists = True
        remove_ports_exists = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_net_ifgrp", cserver)
        if_group_detail = self.get_if_grp()
        if if_group_detail:
            ifgroup_exists = True
            ifgrp_ports_detail = self.get_if_grp_ports()
            if self.state == 'absent':
                changed = True
                if self.port:
                    if self.port in ifgrp_ports_detail['ports']:
                        remove_ports_exists = True
            elif self.state == 'present':
                if self.port:
                    if not ifgrp_ports_detail['ports']:
                        add_ports_exists = False
                        changed = True
                    else:
                        if self.port not in ifgrp_ports_detail['ports']:
                            add_ports_exists = False
                            changed = True
        else:
            if self.state == 'present':
                changed = True

        if changed:
            if self.module.check_mode:
                pass
            else:
                if self.state == 'present':
                    if not ifgroup_exists:
                        self.create_if_grp()
                        if self.port:
                            self.add_port_to_if_grp()
                    else:
                        if not add_ports_exists:
                            self.add_port_to_if_grp()
                elif self.state == 'absent':
                    if remove_ports_exists:
                        self.remove_port_to_if_grp()
                    self.delete_if_grp()

        self.module.exit_json(changed=changed)
예제 #24
0
    def apply(self):
        """
        Apply action to cluster HA
        """
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_cluster_ha", cserver)
        current = self.get_cluster_ha_enabled()
        cd_action = self.na_helper.get_cd_action(current, self.parameters)
        if cd_action == 'create':
            self.modify_cluster_ha("true")
        elif cd_action == 'delete':
            self.modify_cluster_ha("false")

        self.module.exit_json(changed=self.na_helper.changed)
예제 #25
0
    def apply(self):
        """
        Apply action to cluster HA
        """
        changed = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
        netapp_utils.ems_log_event("na_ontap_cluster", cserver)
        if self.state == 'present':
            self.modify_cluster_ha("true")
            changed = True
        elif self.state == 'absent':
            self.modify_cluster_ha("false")
            changed = True

        self.module.exit_json(changed=changed)
예제 #26
0
    def get_all(self, gather_subset):
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
        netapp_utils.ems_log_event("na_ontap_gather_facts", cserver)

        self.netapp_info['ontap_version'] = self.ontapi()

        run_subset = self.get_subset(gather_subset, self.netapp_info['ontap_version'])
        if 'help' in gather_subset:
            self.netapp_info['help'] = sorted(run_subset)
        else:
            for subset in run_subset:
                call = self.fact_subsets[subset]
                self.netapp_info[subset] = call['method'](**call['kwargs'])

        return self.netapp_info
예제 #27
0
    def apply(self):
        """
        Apply action to create/delete or accept vserver peer
        """
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_vserver_peer", cserver)
        current = self.vserver_peer_get()
        cd_action = self.na_helper.get_cd_action(current, self.parameters)
        if cd_action == 'create':
            self.vserver_peer_create()
            self.vserver_peer_accept()
        elif cd_action == 'delete':
            self.vserver_peer_delete()

        self.module.exit_json(changed=self.na_helper.changed)
예제 #28
0
    def apply(self):
        """
        Apply action to autosupport
        """
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results)
        netapp_utils.ems_log_event("na_ontap_autosupport", cserver)

        current = self.get_autosupport_config()
        modify = self.na_helper.get_modified_attributes(current, self.parameters)
        if self.na_helper.changed:
            if self.module.check_mode:
                pass
            else:
                if modify:
                    self.modify_autosupport_config(modify)
        self.module.exit_json(changed=self.na_helper.changed)
예제 #29
0
    def apply(self):
        """
        Run Module based on play book
        """
        changed = False
        settings_need_changing = self.get_lldp_enable_value()
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("lldp_enable", cserver)

        if settings_need_changing:
            changed = True
        else:
            changed = False
        if changed:
            self.set_lldp_enable_value()
        self.module.exit_json(changed=changed)
예제 #30
0
    def apply(self):
        '''Call add, delete or modify methods'''
        changed = False
        create_license = False
        remove_license = False
        results = netapp_utils.get_cserver(self.server)
        cserver = netapp_utils.setup_na_ontap_zapi(module=self.module,
                                                   vserver=results)
        netapp_utils.ems_log_event("na_ontap_license", cserver)
        # Add / Update licenses.
        license_status = self.get_licensing_status()

        if self.state == 'absent':  # delete
            changed = True
        else:  # add or update
            if self.license_codes is not None:
                create_license = True
                changed = True
            if self.remove_unused is not None:
                remove_license = True
                changed = True
            if self.remove_expired is not None:
                remove_license = True
                changed = True
        if changed:
            if self.state == 'present':  # execute create
                if create_license:
                    self.add_licenses()
                if self.remove_unused is not None:
                    self.remove_unused_licenses()
                if self.remove_expired is not None:
                    self.remove_expired_licenses()
                if create_license or remove_license:
                    new_license_status = self.get_licensing_status()
                    if local_cmp(license_status, new_license_status) == 0:
                        changed = False
            else:  # execute delete
                license_deleted = False
                for package in self.license_names:
                    license_deleted |= self.remove_licenses(package)
                    changed = license_deleted

        self.module.exit_json(changed=changed)