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)
def apply(self): '''Apply action to subnet''' 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_subnet", cserver) current = self.get_subnet() cd_action, rename = None, None if self.parameters.get('from_name'): rename = self.na_helper.is_rename_action( self.get_subnet(self.parameters.get('from_name')), current) if rename is False: self.module.fail_json( msg="Error renaming: subnet %s does not exist" % self.parameters.get('from_name')) else: cd_action = self.na_helper.get_cd_action(current, self.parameters) modify = self.na_helper.get_modified_attributes( current, self.parameters) for attribute in modify: if attribute in ['broadcast_domain']: self.module.fail_json( msg= 'Error modifying subnet %s: cannot modify broadcast_domain parameter.' % self.parameters.get('name')) if self.na_helper.changed: if self.module.check_mode: pass else: if rename: self.rename_subnet() # If rename is True, cd_action is NOne but modify could be true if cd_action == 'create': for attribute in ['subnet', 'broadcast_domain']: if not self.parameters.get(attribute): self.module.fail_json( msg='Error - missing required arguments: %s.' % attribute) self.create_subnet() elif cd_action == 'delete': self.delete_subnet() elif modify: self.modify_subnet() self.module.exit_json(changed=self.na_helper.changed)
def get_all(self, gather_subset): '''Method to get all subsets''' 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
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() # accept only if the peer relationship is on a remote cluster if self.is_remote_peer(): self.vserver_peer_accept() elif cd_action == 'delete': self.vserver_peer_delete() self.module.exit_json(changed=self.na_helper.changed)
def apply(self): """ Apply action to SNMP community This module is not idempotent: Add doesn't fail the playbook if user is trying to add an already existing snmp community """ 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_snmp", cserver) if self.state == 'present': # add if self.add_snmp_community(): changed = True elif self.state == 'absent': # delete if self.delete_snmp_community(): changed = True self.module.exit_json(changed=changed)
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)
def apply(self): # logging ems event results = netapp_utils.get_cserver(self.cluster) cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results) netapp_utils.ems_log_event("na_ontap_node", cserver) exists = self.get_node(self.parameters['name']) from_exists = self.get_node(self.parameters['from_name']) changed = False if exists: pass else: if from_exists: self.rename_node() changed = True else: self.module.fail_json( msg='Error renaming node, from_name %s does not exist' % self.parameters['from_name']) 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)
def autosupport_log(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_autosupport", cserver)