def filter_type(self):
VirtualServerInfo.objects.all().delete()
NetWorkInfo.objects.all().delete()
PhysicalServerInfo.objects.all().delete()
for item,item_val in self.key_dic_map.items():
mac_addr = self.return_key_mac(item_val[-3])
sn_key = self.return_true_string(item_val[-2])
if re.search("KVM",item_val[-1]) or re.search("QEMU",item_val[-1]):
VirtualServerInfo.objects.create(server_ip=item_val[0],server_type=item_val[-1],system_ver=item_val[6],sys_hostname=item_val[7],mac=item_val[-3],sn=item_val[-2],vir_phy_id=1,conn_vir_id=int(self.key_sn_relate[mac_addr]))
elif re.search("VMware",item_val[-1]):
mac_addr = self.return_key_mac(item_val[-3])
VirtualServerInfo.objects.create(server_ip=item_val[0],server_type=item_val[-1],system_ver=item_val[6],sys_hostname=item_val[7],mac=item_val[-3],sn=item_val[-2],vir_phy_id=1,conn_vir_id=int(self.key_sn_relate[sn_key]))
elif re.search("Network",item_val[-1]):
NetWorkInfo.objects.create(host_ip=item_val[0],host_name=item_val[7],net_cab_id=1,sn=item_val[-2])
# print "Network...........",item_val[-1]
else:
self.key_ip_relate[item] = item_val[0].split(',')[0]
if sn_key and sn_key != 'NotSpecified':
PhysicalServerInfo.objects.create(server_ip=item_val[0],machine_brand=item_val[-1],system_ver=item_val[6],sys_hostname=item_val[7],mac=item_val[-3],sn=item_val[-2],ser_cabin_id=1,conn_phy_id=int(self.key_sn_relate[sn_key]))
else:
PhysicalServerInfo.objects.create(server_ip=item_val[0],machine_brand=item_val[-1],system_ver=item_val[6],sys_hostname=item_val[7],mac=item_val[-3],sn=item_val[-2],ser_cabin_id=1,conn_phy_id=int(self.key_sn_relate[mac_addr]))
# print "Machine............",item_val[-1]
return True
当然执行了,你看PhysicalServerInfo入库这段的逻辑,是非"KVM"、"WMware"、"Network"类型的设备才会执行入库PhysicalServerInfo。key_dic_map.items(),你先把这段内容打印下。调试下原因,分析下