CMDB Asset Management system development "DAY26": Approving asset storage

Source: Internet
Author: User

Just like a memory, hard disk, network card, multiple words how to operate

There is only one piece of data

The following is a number of data

Verification of hard disk must field
    def __create_disk_component (self): Disk_info = Self.clean_data.get (' physical_disk_driver ') if Disk_info: For Disk_item in Disk_info:try:self.__verify_field (Disk_item, ' slots ', str) "Here is indeed a verification of a slot, the first to obtain data, 0 is not established, the slot is 0 this paragraph does not go, the client operation, resulting in this piece on the error" ' Self.__verify_field (Disk_item, ' capacity ', float) Self.__verify_field (disk_item, ' Iface_type ', str) Self.__verify_field (disk                         _item, ' model ', str) if not len (self.response[' error '): # no processing when there ' s no error happend                            Data_set = {' asset_id ': self.asset_obj.id, ' SN ': disk_item.get (' sn '), ' slot ': Disk_item.get (' slot '), ' capacity ' : Disk_item.get (' capacity '), ' model ': disk_item.get (' model '), ' iface _type ': Disk_item.get (' IFace_type '), ' manufactory ': Disk_item.get (' Manufactory '),} obj = models. Disk (**data_set) obj.save () except Exception as E:self.response_ MSG (' Error ', ' objectcreationexception ', ' Object [disk] '%s '% str (e)) else:self.response_msg (' Error ', ' L Ackofdata ', ' Disk info is not provied in your reporting data ')
Hard drive type not error

Workaround:
Except Exception as E:                    self.response_msg (' Error ', ' objectcreationexception ', ' Object [RAM]%s '% str (e)) ' Write except ValueError Exception as e no longer scratches the anomaly '
Hard Drive validation field bug results in not getting asset component information

    

Client command line error:

Logical parsing of asset table creation
def _create_server (self): Self.__create_server_info () self.__create_or_update_manufactory () self.__create_cpu_ Component () Self.__create_disk_component () self.__create_nic_component () self.__create_ram_component () log_msg = " Asset [<a href= '/admin/assets/asset/%s/' target= ' _blank ' >%s</a>] has been created! "% (Self.asset_obj.id, self.asset_obj) self.response_msg (' info ', ' newassetonline ', log_msg) '                        if the above all gets successful, I'll return a message that creates the asset successfully, you can '/admin /assets/asset/%s/' To this page, open this asset and record a log '                            
Create an asset to create a record successfully

   

Memory Capacity field type validation
    def __create_ram_component (self): Ram_info = self.clean_data.get (' Ram ') if Ram_info:for RAM_ Item in Ram_info:try:self.__verify_field (Ram_item, ' capacity ', int) ' Verifies that capacity must be int , if not int will not go down, memory does not create "if not len (self.response[' error ')"): # no processing when there's no error ha                            Ppend Data_set = {' asset_id ': self.asset_obj.id, ' Slot ': Ram_item.get ("slot"), ' SN ': ram_item.get (' sn '), ' Capaci                        Ty ': ram_item.get (' capacity '), ' model ': ram_item.get (' model '),} obj = models. RAM (**data_set) obj.save () except Exception as E:self.response_m SG (' ERROR ', ' objectcreationexception ', ' Object [RAM]%s '% str (e)) else:self.response_msg (' Error ', ' Lackofdata ', ' RAM info is not provied in your reporting data ') 
Network Card validation Field
    def __create_nic_component (self): Nic_info = Self.clean_data.get (' nic ') if Nic_info:for nic_ Item in Nic_info:try:self.__verify_field (Nic_item, ' macaddress ', str) ' IP address can be no, verify Mac                        Address must exist ' if not Len ' (self.response[' error '): # No processing when there's no error happend Data_set = {' asset_id ': self.asset_obj.id, ' Nam E ': Nic_item.get (' name '), ' SN ': nic_item.get (' sn '), ' macaddress ': NI C_item.get (' macaddress '), ' IPAddress ': Nic_item.get (' IPAddress '), ' B Onding ': nic_item.get (' bonding '), ' This network card is bound, is the client detection, my server side just detects this field ' ' Model ': nic_item.get (' Mo Del '), ' netmask ': Nic_item.get (' netmask '),} obj = Models. NIC (**data_set)                        Obj.save () except Exception as e:self.response_msg (' Error ', ' Ob Jectcreationexception ', ' Object [Nic]%s '% str (e)) else:self.response_msg (' Error ', ' Lackofdata ', ' NIC Info is not provied in your reporting data ')

  

CMDB Asset Management system development "DAY26": Approving asset storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.