def InventorySysLinux(self, mac, inventory, ip_address): """ Minimal inventory received from PXE. @param mac: MAC address @type mac: str @param inventory: inventory from PXE @type inventory: str @rtype: deferred """ logging.getLogger().debug("INJECT INVENTORY NEXT HOSTNAME AND ENTITY") m = re.search('<REQUEST>.*<\/REQUEST>', inventory) file_content = str(m.group(0)) ipadress = self.ip_adressexml(file_content) mac1= self.mac_adressexml(file_content) hostnamexml = self.hostname_xml(file_content) inventory ="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n%s"%(file_content) ip_address = ipadress mac = mac1 self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") if not "Mc" in inventory : inventory = inventory + "\nMAC Address:%s\n" % mac else : inventory = inventory.replace("Mc", "MAC Address") parsed_inventory1 = BootInventory() parsed_inventory1.initialise(file_content) parsed_inventory = parsed_inventory1.dump() self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") d = self.api.injectInventory(mac, parsed_inventory) # 2nd step - send inventory by HTTP POST to inventory server d.addCallback(self._injectedInventoryOk, mac, inventory) d.addErrback(self._injectedInventoryError) #self.send_inventory(parsed_inventory1., hostname) return d
def InventorySysLinux(self, mac, inventory, ip_address): """ Minimal inventory received from PXE. @param mac: MAC address @type mac: str @param inventory: inventory from PXE @type inventory: str @rtype: deferred """ logging.getLogger().debug("INJECT INVENTORY NEXT HOSTNAME AND ENTITY") m = re.search('<REQUEST>.*<\/REQUEST>', inventory) file_content = str(m.group(0)) ipadress = self.ip_adressexml(file_content) mac1 = self.mac_adressexml(file_content) hostnamexml = self.hostname_xml(file_content) inventory = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n%s" % ( file_content) ip_address = ipadress mac = mac1 self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") if not "Mc" in inventory: inventory = inventory + "\nMAC Address:%s\n" % mac else: inventory = inventory.replace("Mc", "MAC Address") parsed_inventory1 = BootInventory() parsed_inventory1.initialise(file_content) parsed_inventory = parsed_inventory1.dump() self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") d = self.api.injectInventory(mac, parsed_inventory) # 2nd step - send inventory by HTTP POST to inventory server d.addCallback(self._injectedInventoryOk, mac, inventory) d.addErrback(self._injectedInventoryError) #self.send_inventory(parsed_inventory1., hostname) return d
def injectInventory(self, mac, inventory, ip_address): """ Minimal inventory received from PXE. @param mac: MAC address @type mac: str @param inventory: inventory from PXE @type inventory: str @rtype: deferred """ # XXX - A little hack to add networking info on GLPI mode logging.getLogger().debug("injectInventory mac %s ip : %s \n\n" % (mac, ip_address)) if not "Mc" in inventory: inventory = inventory + "\nMAC Address:%s\n" % mac else: inventory = inventory.replace("Mc", "MAC Address") if not "IPADDR" in inventory: inventory = inventory + "\nIP Address:%\n" % ip_address else: inventory = inventory.replace("IPADDR", "IP Address") inventory = [ i.strip(' \t\n\r').lstrip('\x00\x00').strip() for i in inventory.split("\n") ] logging.getLogger().debug("low level inventory: %s\n" % (inventory)) parsed_inventory1 = BootInventory(inventory) parsed_inventory = parsed_inventory1.dump() self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") # 1st step - inject inventory trough imaging (only disk info) d = self.api.injectInventory(mac, parsed_inventory) # 2nd step - send inventory by HTTP POST to inventory server d.addCallback(self._injectedInventoryOk, mac, inventory) d.addErrback(self._injectedInventoryError) #self.send_inventory(parsed_inventory1., hostname) return d
def injectInventory(self, mac, inventory, ip_address): """ Minimal inventory received from PXE. @param mac: MAC address @type mac: str @param inventory: inventory from PXE @type inventory: str @rtype: deferred """ # XXX - A little hack to add networking info on GLPI mode logging.getLogger().debug("injectInventory mac %s ip : %s \n\n" %(mac,ip_address)) if not "Mc" in inventory : inventory = inventory + "\nMAC Address:%s\n" % mac else : inventory = inventory.replace("Mc", "MAC Address") if not "IPADDR" in inventory : inventory = inventory + "\nIP Address:%\n" % ip_address else : inventory = inventory.replace("IPADDR", "IP Address") inventory = [i.strip(' \t\n\r').lstrip('\x00\x00').strip() for i in inventory.split("\n")] logging.getLogger().debug("low level inventory: %s\n" %(inventory)) parsed_inventory1 = BootInventory(inventory) parsed_inventory = parsed_inventory1.dump() self.api.logClientAction(mac, LOG_LEVEL.DEBUG, LOG_STATE.MENU, "boot menu shown") # 1st step - inject inventory trough imaging (only disk info) d = self.api.injectInventory(mac, parsed_inventory) # 2nd step - send inventory by HTTP POST to inventory server d.addCallback(self._injectedInventoryOk, mac, inventory) d.addErrback(self._injectedInventoryError) #self.send_inventory(parsed_inventory1., hostname) return d