def _create_cpu_info(self): cpu_obj = models.CPU( asset=self.asset_obj, model=self.asset_data.get("cpu_information").get("cpu_model"), count=self.asset_data.get("cpu_information").get("cpu_count"), core_count=self.asset_data.get("cpu_information").get( "cpu_core_count"), ) cpu_obj.save() logmsg = "新增CPU,型号:%s,数量(个): %s" % (cpu_obj.model, cpu_obj.count) self.log_handler(2, detail=logmsg)
def __create_cpu_component(self,ignore_errs=False): try: self.__verify_field(self.clean_data,'model',str) self.__verify_field(self.clean_data,'cpu_count',int) self.__verify_field(self.clean_data,'cpu_core_count',int) if not len(self.response['error']) or ignore_errs == True: #no processing when there's no error happend data_set = { 'asset_id' : self.asset_obj.id, 'cpu_model': self.clean_data.get('cpu_model'), 'cpu_count':self.clean_data.get('cpu_count'), 'cpu_core_count':self.clean_data.get('cpu_core_count'), } obj = models.CPU(**data_set) obj.save() log_msg = "Asset[%s] --> has added new [cpu] component with data [%s]" %(self.asset_obj,data_set) self.response_msg('info','NewComponentAdded',log_msg) return obj except Exception as e: self.response_msg('error','ObjectCreationException','Object [cpu] %s' % str(e) )
def __create_cpu_component(self, ignore_errs=False): try: self.__verify_field(self.data, "model", str) self.__verify_field(self.data, "cpu_count", int) self.__verify_field(self.data, "cpu_core_count", int) if not len(self.response["error"]) or ignore_errs == True: data_set = { "asset_id": self.asset_obj.id, "cpu_model": self.data.get("cpu_model"), "cpu_count": self.data.get("cpu_count"), "cpu_core_count": self.data.get("cpu_core_count"), } obj = models.CPU(**data_set) obj.save() log_msg = "Asset[%s] --> has added new [cpu] component with data [%s]" % ( self.asset_obj, data_set) return obj except Exception as e: self.response_msg("error", "ObjectCreationException", "Object [cpu] %s" % str(e))