def check(self): """ @return: True if the computer can be archived, else False @rtype: bool """ # Get computer folder and boot menu self.cfolder = os.path.join( self.config.imaging_api['base_folder'], self.config.imaging_api['computers_folder'], self.computerUUID) self.bootmenu = os.path.join( self.config.imaging_api['base_folder'], self.config.imaging_api['bootmenus_folder'], reduceMACAddress(self.macAddress)) if not os.path.exists(self.cfolder): self.logger.error( "Looks like computer %s is not registered, so it can't be archived" % self.computerUUID) return False # Build valid image list for image in self.imageList: ifolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], image) if isPulse2Image(ifolder): self.images.append(ifolder) else: self.logger.error("Invalid image, won't be archived: %s" % image) return True
def check(self): """ @return: True if the computer can be archived, else False @rtype: bool """ # Get computer folder and boot menu self.cfolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['computers_folder'], self.computerUUID) self.bootmenu = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['bootmenus_folder'], reduceMACAddress(self.macAddress)) if not os.path.exists(self.cfolder): self.logger.error("Looks like computer %s is not registered, so it can't be archived" % self.computerUUID) return False # Build valid image list for image in self.imageList: ifolder = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], image) if isPulse2Image(ifolder): self.images.append(ifolder) else: self.logger.error("Invalid image, won't be archived: %s" % image) return True
def test_02registerComputer(self): """ Check computer registration """ mac = '00:11:22:33:44:ff' result = SERVER.computerRegister('foobar', 'BADMAC') self.assertFalse(result) result = SERVER.computerRegister('bad _ name', mac) self.assertFalse(result) result = SERVER.computerRegister('foobar', mac) self.assertTrue(result) self.assertTrue(os.path.exists('/var/lib/pulse2/imaging/uuid-cache.txt')) self.assertTrue(os.path.isdir('/var/lib/pulse2/imaging/computers/%s' % 'UUID2')) # Wait a bit for the menu to be generated asynchronously sleep(5) self.assertTrue(os.path.exists('/var/lib/pulse2/imaging/bootmenus/%s' % reduceMACAddress(mac))) # No exclude file should be there self.assertFalse(os.path.exists('/var/lib/pulse2/imaging/computers/%s/exclude' % 'UUID2'))
def test_02registerComputer(self): """ Check computer registration """ mac = "00:11:22:33:44:ff" result = SERVER.computerRegister("foobar", "BADMAC") self.assertFalse(result) result = SERVER.computerRegister("bad _ name", mac) self.assertFalse(result) result = SERVER.computerRegister("foobar", mac) self.assertTrue(result) self.assertTrue(os.path.exists("/var/lib/pulse2/imaging/uuid-cache.txt")) self.assertTrue(os.path.isdir("/var/lib/pulse2/imaging/computers/%s" % "UUID2")) # Wait a bit for the menu to be generated asynchronously sleep(5) self.assertTrue(os.path.exists("/var/lib/pulse2/imaging/bootmenus/%s" % reduceMACAddress(mac))) # No exclude file should be there self.assertFalse(os.path.exists("/var/lib/pulse2/imaging/computers/%s/exclude" % "UUID2"))
def test_02registerComputer(self): """ Check computer registration """ mac = '00:11:22:33:44:ff' result = SERVER.computerRegister('foobar', 'BADMAC') self.assertFalse(result) result = SERVER.computerRegister('bad _ name', mac) self.assertFalse(result) result = SERVER.computerRegister('foobar', mac) self.assertTrue(result) self.assertTrue( os.path.exists('/var/lib/pulse2/imaging/uuid-cache.txt')) self.assertTrue( os.path.isdir('/var/lib/pulse2/imaging/computers/%s' % 'UUID2')) # Wait a bit for the menu to be generated asynchronously sleep(5) self.assertTrue( os.path.exists('/var/lib/pulse2/imaging/bootmenus/%s' % reduceMACAddress(mac))) # No exclude file should be there self.assertFalse( os.path.exists('/var/lib/pulse2/imaging/computers/%s/exclude' % 'UUID2'))