def push_object(self, commit=True): if commit: self.logger(message="Pushing " + self._CONFIG_NAME + " configuration: " + str(self.name)) else: self.logger(message="Adding to the handle " + self._CONFIG_NAME + " configuration: " + str(self.name) + ", waiting for a commit") if hasattr(self._parent, '_dn'): parent_mo = self._parent._dn else: self.logger(level="error", message="Impossible to find the parent dn of " + self._CONFIG_NAME + " : " + str(self.name)) return False mo_equipment_chassis_profile = EquipmentChassisProfile( parent_mo_or_dn=parent_mo, disk_zoning_policy_name=self.disk_zoning_policy, descr=self.descr, type=self.type, name=self.name, chassis_fw_policy_name=self.chassis_firmware_policy, compute_conn_policy_name=self.compute_connection_policy, maint_policy_name=self.chassis_maintenance_policy, sas_expander_config_policy_name=self. sas_expander_configuration_policy) if self.type == "instance" and self.chassis_assignment_id: EquipmentBinding(parent_mo_or_dn=mo_equipment_chassis_profile, chassis_dn="sys/chassis-" + self.chassis_assignment_id, restrict_migration=self.restrict_migration) self._handle.add_mo(mo=mo_equipment_chassis_profile, modify_present=True) if commit: if self.commit(detail=self.name) != True: return False return True
def instantiate_profile(self): self.logger(message="Instantiating " + self._CONFIG_NAME + " configuration from " + str(self.chassis_profile_template)) if hasattr(self._parent, '_dn'): parent_mo = self._parent._dn else: self.logger(level="error", message="Impossible to find the parent dn of " + self._CONFIG_NAME + " : " + str(self.name)) return False if not hasattr(self, 'suffix_start_number'): self.suffix_start_number = "1" if not hasattr(self, 'number_of_instances'): self.number_of_instances = "1" if self.suffix_start_number and self.number_of_instances: dn_set = DnSet() for i in range( int(self.suffix_start_number), int(self.number_of_instances) + int(self.suffix_start_number)): dn = Dn() dn.attr_set("value", str(self.name + str(i))) dn_set.child_add(dn) elem = equipment_instantiate_n_named_template( cookie=self._handle.cookie, dn=parent_mo + "/cp-" + self.chassis_profile_template, in_error_on_existing="false", in_name_set=dn_set, in_target_org=parent_mo, in_hierarchical="false") for i in range(self._device.push_attempts): try: if i: self.logger( level="warning", message= "Trying to push again the instantiated chassis profile(s) from " + str(self.chassis_profile_template)) self._handle.process_xml_elem(elem) self.logger(level='debug', message=self.number_of_instances + " " + self._CONFIG_NAME + " instantiated from " + str(self.chassis_profile_template) + " starting with " + str(self.name) + self.suffix_start_number) return True except ConnectionRefusedError: self.logger( level="error", message= "Connection refused while trying to instantiate from " + str(self.chassis_profile_template)) except UcsException as err: self.logger( level="error", message="Error while trying to instantiate from " + str(self.chassis_profile_template) + " " + err.error_descr) except urllib.error.URLError: self.logger( level="error", message="Timeout while trying to instantiate from " + str(self.chassis_profile_template)) else: elem = equipment_instantiate_template( cookie=self._handle.cookie, dn=parent_mo + "/cp-" + self.chassis_profile_template, in_error_on_existing="false", in_chassis_profile_name=self.name, in_target_org=parent_mo, in_hierarchical="false") for i in range(self._device.push_attempts): try: if i: self.logger( level="warning", message= "Trying to push again the instantiated chassis profile(s) from " + str(self.chassis_profile_template)) self._handle.process_xml_elem(elem) self.logger(level='debug', message=self._CONFIG_NAME + " " + str(self.name) + " instantiated from " + str(self.chassis_profile_template)) # We now need to associate the instantiated Chassis Profile to the Chassis ID if provided if self.type == "instance" and self.chassis_assignment_id: mo_equipment_chassis_profile = EquipmentChassisProfile( parent_mo_or_dn=parent_mo, name=self.name) EquipmentBinding( parent_mo_or_dn=mo_equipment_chassis_profile, chassis_dn="sys/chassis-" + self.chassis_assignment_id, restrict_migration=self.restrict_migration) self._handle.add_mo(mo=mo_equipment_chassis_profile, modify_present=True) if self.commit(detail=self.name) != True: return False return True except ConnectionRefusedError: self.logger( level="error", message= "Connection refused while trying to instantiate from " + str(self.chassis_profile_template)) except UcsException as err: self.logger( level="error", message="Error while trying to instantiate from " + str(self.chassis_profile_template) + " " + err.error_descr) except urllib.error.URLError: self.logger( level="error", message="Timeout while trying to instantiate from " + str(self.chassis_profile_template))