rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
imaging = None
def packageDetectSmartMethod(self): return ', '.join(map(lambda x:self.detectSmartMethod[x], self.package_detect_smart_method))
def computerPrepareImagingDirectory(self, MACAddress, imagingData = None):
def computerPrepareImagingDirectory(self, MACAddress, imagingData = False):
def computerPrepareImagingDirectory(self, MACAddress, imagingData = None): """ Asks the Package Server to create the file system structure for the given computer uuid thanks to imagingData content. If imagingData is None, the package server queries the MMC agent for the imaging data. """ if not isMACAddress(MACAddress)...
If imagingData is None, the package server queries the MMC agent for the imaging data.
If imagingData is False, the package server queries the MMC agent for the imaging data.
def computerPrepareImagingDirectory(self, MACAddress, imagingData = None): """ Asks the Package Server to create the file system structure for the given computer uuid thanks to imagingData content. If imagingData is None, the package server queries the MMC agent for the imaging data. """ if not isMACAddress(MACAddress)...
logging.getLogger().error("Attribute %s isn't defined on ldap" % nameattribute)
logging.getLogger().error("Attribute %s isn't defined on LDAP" % nameattribute)
def setPPolicyAttribute(self, nameattribute, value): """ Set the value of the given LDAP attribute.
def removePPolicyObjectClass(self, uid):
def removePPolicyObjectClass(self):
def addPPolicyObjectClass(self): """ Add the pwdPolicy objectClass to the current user.
UserPPolicy(uid).removeUserObjectClass(uid, 'pwdPolicy')
self.removeUserObjectClass(self.userUid, 'pwdPolicy')
def removePPolicyObjectClass(self, uid): """ Remove the pwdPolicy objectClass to the current user.
self.getDetailedUser(self.userUid, operational = True) return
user = self.getUserEntry(self.userUid, operational = True) if 'pwdAccountLockedTime' in user: ret = self._strpTime(user['pwdAccountLockedTime'][0]) else: ret = 0 return ret def unlockAccount(self): """ Unlock a LDAP account """ user = self.getUserEntry(self.userUid, operational = True) if 'pwdAccountLockedTime' in use...
def isAccountLocked(self): """ Check if the user account is locked. @returns: -1 if the user account has been locked permanently, 0 if not, else the lock timestamp @rtype: int """ self.getDetailedUser(self.userUid, operational = True) return
self.assertEqual([['hostname1', '00:11:22:33:44:dd'], ['hostname2', '00:11:22:33:44:ee']], result)
self.assertEqual(['UUID2', 'UUID3'], result)
def test_03registerComputers(self): """ Check mass computers registration """ arg = [ ('hostname1', '00:11:22:33:44:dd', { 'uuid' : 'UUID2', 'menu' : { 'UUID2' : MENU }}), ('hostname2', '00:11:22:33:44:ee', { 'uuid' : 'UUID3', 'menu' : { 'UUID3' : MENU }}), ] result = SERVER.computersRegister(arg) self.assertEqual([['h...
result = SERVER.computersMenuSet(menus)
result = SERVER.computersMenuSet(MENUS)
def atest_computersMenuSet(self): #result = SERVER.computersMenuSet([('UUID17', {})]) #self.assertEqual(['UUID1'], result) result = SERVER.computersMenuSet(menus) self.assertEqual(['UUID27'], result)
Check if MenuItem mi is a local boot service FIXME : This should be fixed - entity.fk_default_menu do not exists anymore - but I reaaly don't see how
Check if MenuItem mi is a local boot service owned by an imaging server, or a global boot service.
def isLocalBootService(self, mi_uuid, session = None): """ Check if MenuItem mi is a local boot service FIXME : This should be fixed - entity.fk_default_menu do not exists anymore - but I reaaly don't see how """ session_need_to_close = False if session == None: session_need_to_close = True session = create_session()
im_total = 0 im_rescue = 0
im_total = set() im_rescue = set()
def getEntityStatus(self, location): session = create_session() q = session.query(Target).add_entity(Image).select_from(self.target \ .join(self.imaging_server, self.target.c.fk_entity == self.imaging_server.c.fk_entity) \ .join(self.entity, self.entity.c.id == self.target.c.fk_entity) \ .outerjoin(self.imaging_log, se...
im_total += 1 if i != None: im_rescue += 1
im_total.add(t) if i != None and not i.is_master: im_rescue.add(t)
def getEntityStatus(self, location): session = create_session() q = session.query(Target).add_entity(Image).select_from(self.target \ .join(self.imaging_server, self.target.c.fk_entity == self.imaging_server.c.fk_entity) \ .join(self.entity, self.entity.c.id == self.target.c.fk_entity) \ .outerjoin(self.imaging_log, se...
return {'total': im_total, 'master': im_master, 'rescue': im_rescue}
return {'total' : len(im_total), 'rescue' : len(im_rescue), 'master' : im_master}
def getEntityStatus(self, location): session = create_session() q = session.query(Target).add_entity(Image).select_from(self.target \ .join(self.imaging_server, self.target.c.fk_entity == self.imaging_server.c.fk_entity) \ .join(self.entity, self.entity.c.id == self.target.c.fk_entity) \ .outerjoin(self.imaging_log, se...
userdn = self.searchUserDN(uid) r = AF().log(PLUGIN_NAME, AA.SAMBA_CHANGE_SAMBA_ATTR, [(userdn, AT.USER)], attributes)
logs = [] userdn = self.searchUserDN(uid)
def changeSambaAttributes(self, uid, attributes): """ Change the SAMBA attributes for an user. If an attribute is an empty string, it is deleted.
r.commit()
for log in logs: log.commit()
def changeSambaAttributes(self, uid, attributes): """ Change the SAMBA attributes for an user. If an attribute is an empty string, it is deleted.
url = self.__chooseImagingApiUrl(location) i = ImagingApi(url.encode('utf8')) if i != None: def treatResults(results):
def processResults(results): assert(type(results) == dict) if results:
def getGlobalStatus(self, location): """ get an imaging server status
return xmlrpcCleanup(results) d = i.imagingServerStatus() d.addCallback(treatResults) return d return {}
return xmlrpcCleanup(results) url = self.__chooseImagingApiUrl(location) d = ImagingApi(url).imagingServerStatus() d.addCallback(processResults) return d
def treatResults(results): # add short_status from the database status = ImagingDatabase().getEntityStatus(location) results['short_status'] = status return xmlrpcCleanup(results)
['computernet', 'string', 'Computer\'s network address']
['computernet', 'string', 'Computer\'s netmask address']
def neededParamsAddComputer(self): return [ ['computerip', 'string', 'Computer\'s IP address'], ['computermac', 'string', 'Computer\'s MAC address'], ['computernet', 'string', 'Computer\'s network address'] ]
def xmlrpc_computerRegister(self, computerName, MACAddress, imagingData = None):
def xmlrpc_computerRegister(self, computerName, MACAddress, imagingData = False):
def xmlrpc_computerRegister(self, computerName, MACAddress, imagingData = None): """ Method to register a new computer.
h_macaddresses = ComputerManager().getMachineMac(ctx, {'uuids':uuids}) macaddresses = h_macaddresses.values() if not len(uuids): logger.info("There is no computers in the profile %s"%profileUUID) ret = 1 else:
if len(uuids): h_macaddresses = ComputerManager().getMachineMac(ctx, {'uuids':uuids}) macaddresses = h_macaddresses.values()
def checkProfileForImaging(self, profileUUID): """ @return: 0 if the profile can be registered into the imaging module @rtype: int """ logger = logging.getLogger() ret = 0 ctx = self.currentContext uuids = map(lambda c: c.uuid, ComputerProfileManager().getProfileContent(profileUUID)) h_macaddresses = ComputerManager()....
if type(hostnames) == list: for computer in hostnames: h_hostnames[computer['uuid']] = computer['hostname'] else: h_hostnames[hostnames['uuid']] = hostnames['hostname']
if hostnames: if type(hostnames) == list: for computer in hostnames: h_hostnames[computer['uuid']] = computer['hostname'] else: h_hostnames[hostnames['uuid']] = hostnames['hostname']
def treatRegister(result, location = location, uuid = uuid, db = db): if result: db.changeTargetsSynchroState([uuid], target_type, P2ISS.DONE) return [True] else: # revert the target registering! db.changeTargetsSynchroState([uuid], target_type, P2ISS.INIT_ERROR) return [False, 'P2ISS.INIT_ERROR']
if type(macaddress) == list: for computer in macaddress: h_macaddress[uuids[index]] = computer[0] index += 1 else: h_macaddress[uuids[0]] = macaddress
for computer in macaddress: h_macaddress[uuids[index]] = computer[0] index += 1
def treatRegister(result, location = location, uuid = uuid, db = db): if result: db.changeTargetsSynchroState([uuid], target_type, P2ISS.DONE) return [True] else: # revert the target registering! db.changeTargetsSynchroState([uuid], target_type, P2ISS.INIT_ERROR) return [False, 'P2ISS.INIT_ERROR']
ret = db.setProfileMenuTarget(uuids, pid, params)
db.setProfileMenuTarget(uuids, pid, params)
def treatRegister(result, location = location, uuid = uuid, db = db): if result: db.changeTargetsSynchroState([uuid], target_type, P2ISS.DONE) return [True] else: # revert the target registering! db.changeTargetsSynchroState([uuid], target_type, P2ISS.INIT_ERROR) return [False, 'P2ISS.INIT_ERROR']
"objectClass" : ["top", "dhcpServer"]
"objectClass" : ["top", "dhcpServer", "dhcpOptions"], "dhcpOption" : "local-pac-server code 252 = text"
def addServer(self, name, dhcpServiceDN = None): """ Add a DHCP server in directory """ if dhcpServiceDN: raise "NYI" else: dhcpServiceDN = self.getServiceConfig()[0][0] dn = "cn=" + name + "," + self.configDhcp.dhcpDN entry = { "cn" : name, "dhcpServiceDN" : dhcpServiceDN, "objectClass" : ["top", "dhcpServer"] } attri...
d = self.callRemote("computerPrepareImagingDirectory", uuid, imagingData) d.addErrback(self.onErrorRaise, "Imaging:computerPrepareImagingDirectory", [uuid, imagingData])
d = self.callRemote("computerPrepareImagingDirectory", MACAddress, imagingData) d.addErrback(self.onErrorRaise, "Imaging:computerPrepareImagingDirectory", [MACAddress, imagingData])
def computerPrepareImagingDirectory(self, MACAddress, imagingData = None): """ Asks the Package Server to create the file system structure for the given computer uuid thanks to imagingData content. If imagingData is None, the package server queries the MMC agent for the imaging data. """ if not isMACAddress(MACAddress)...
assert(type(position) == int and position > 0)
assert(type(position) == int and position >= 0)
def addImageEntry(self, position, entry): """ Add the ImagingEntry entry to our menu """ assert(type(position) == int and position > 0) if position in self.menuitems: raise ValueError('Position %d in menu already taken' % position) item = ImagingImageItem(entry) self.menuitems[position] = item
assert(type(position) == int and position > 0)
assert(type(position) == int and position >= 0)
def addBootServiceEntry(self, position, entry): """ Add the ImagingEntry entry to our menu """ assert(type(position) == int and position > 0) if position in self.menuitems: raise ValueError('Position %d in menu already taken' % position) self.menuitems[position] = ImagingBootServiceItem(entry)
if os.path.exits(path):
if os.path.exists(path):
def xmlrpc_imagingServerImageDelete(self, imageUUID): """ Delete an image (backup or master) from the imaging server. The corresponding directory is simply removed.
return process.getStderr()
return process.getStdErr()
def getProcessStderr(id): process = ProcessList().getProcess(id) if process: return process.getStderr() return None
if type(value == str):
if type(value) == str:
def setSplashImage(self, value): if type(value == str): value = value.decode('utf-8') assert(type(value) == unicode) self.splashimage = value
if type(value == str):
if type(value) == str:
def setMessage(self, value): if type(value == str): value = value.decode('utf-8') assert(type(value) == unicode) self.message = value
except KeyError, IndexError:
except (KeyError, IndexError):
def isLocked(self, login): """ Return True if the user is locked, else False. An user is locked if there is a L in its samba account flags """ u = self.getDetailedUser(login) try: ret = "L" in u["sambaAcctFlags"][0] except KeyError, IndexError: ret = False return ret
if not image : return False return image.logs
if not image: ret = False else: ret = image.logs
def xmlrpc_getImageLogs(self, imageUUID): """ Send image logs by XMLRPC """ if not isUUID(imageUUID): self.logger.error("Bad image UUID %s" % str(imageUUID)) return False path = os.path.join(self.config.imaging_api['base_folder'], self.config.imaging_api['masters_folder'], imageUUID) image = Pulse2Image(path) if not i...
Remote loging.
Remote logging.
def xmlrpc_logClientAction(self, mac, level, phase, message): """ Remote loging.
self.logger.warn('Imaging: Failed resolving UUID for client %s : %s' % (mac, result))
self.logger.warn('Imaging: Failed resolving UUID for client %s : %s' % (MACAddress, result))
def _getmacCB(result): if result and type(result) == dict : client = self._getXMLRPCClient() func = 'imaging.injectInventory' args = (result['uuid'], Inventory) d = client.callRemote(func, *args) d.addCallbacks(lambda x : True, client.onError, errbackArgs = (func, args, 0)) return d self.logger.warn('Imaging: Failed re...
if not isMACAddress(mac):
if not isMACAddress(MACAddress):
def _getmacCB(result): if result and type(result) == dict : client = self._getXMLRPCClient() func = 'imaging.injectInventory' args = (result['uuid'], Inventory) d = client.callRemote(func, *args) d.addCallbacks(lambda x : True, client.onError, errbackArgs = (func, args, 0)) return d self.logger.warn('Imaging: Failed re...
for uuid, menu in menus:
for cuuid, menu in menus:
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.logger.error("Invalid menu structure for computer UUID %s" % uuid) ret.append(uuid)
self.logger.error("Invalid menu structure for computer UUID %s" % cuuid) ret.append(cuuid)
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
macaddress = self.myUUIDCache.getByUUID(uuid)
macaddress = self.myUUIDCache.getByUUID(cuuid)
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.logger.error("Can't get MAC address for UUID %s" % uuid) ret.append(uuid)
self.logger.error("Can't get MAC address for UUID %s" % cuuid) ret.append(cuuid)
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.logger.debug('Setting menu for computer UUID/MAC %s/%s' % (uuid, macaddress))
self.logger.debug('Setting menu for computer UUID/MAC %s/%s' % (cuuid, macaddress))
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.logger.error("Error while setting new menu of computer uuid/mac %s: %s" % (uuid, str(e))) ret.append(uuid)
self.logger.error("Error while setting new menu of computer uuid/mac %s: %s" % (cuuid, str(e))) ret.append(cuuid)
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
userdn = searchUserDN(uid)
userdn = self.searchUserDN(uid)
def moveHome(self,uid,newHome): """ Move an home directory. @param uid: user name @type uid: str @param newHome: new home path ex: /home/coin @type newHome: str """ oldHome = self.getDetailedUser(uid)['homeDirectory'][0] if newHome != oldHome: userdn = searchUserDN(uid) r = AF().log(PLUGIN_NAME, AA.BASE_MOVE_USER_HOM...
config = pulse2.imaging.config.ImagingConfig(CONFIG_FILE) config.setup()
config = pulse2.imaging.config.ImagingConfig() config.setup(CONFIG_FILE)
def callFunction(deffered): """ XMLRPC request handling attach callBack() and errorBack() to the deferred """ deffered.addCallbacks( # deferred handling callBack, errorBack )
logging.getLogger.error("Pulse2Image : can't read %s" % (fd_grub_file, e))
logging.getLogger().error("Pulse2Image : can't read %s" % (fd_grub_file, e))
def __init__(self, directory): """ Return Image stats (from conf.txt and others) """ assert isPulse2Image(directory)
logging.getLogger.error("Pulse2Image : can't read %s : %s" % (fd_size_file, e))
logging.getLogger().error("Pulse2Image : can't read %s : %s" % (fd_size_file, e))
def __init__(self, directory): """ Return Image stats (from conf.txt and others) """ assert isPulse2Image(directory)
ctx = _digest.new(password)
ctx = _digest(password)
def _generatePassword(self, password, scheme = None): """ Generate a string suitable for the LDAP userPassword field
self.logger.warning('Imaging: While processing result %s for %s : %s' % (MACAddress, result, e))
self.logger.warning('Imaging: While processing result %s for %s : %s' % (result, MACAddress, e))
def onSuccess(result): try: if result[0]: self.myUUIDCache.set(result[1]['uuid'], MACAddress, result[1]['shortname'], result[1]['fqdn']) self.logger.info('Imaging: Updating cache for %s' % (MACAddress)) return result[1] except Exception, e: self.logger.warning('Imaging: While processing result %s for %s : %s' % (MACAdd...
def init(self, name = 'imaging', conffile = None): self.dbsection = "database" self.name = name if not conffile: self.conffile = mmctools.getConfigFile(name) else: self.conffile = conffile
def __init__(self, name = 'imaging', conffile = None): if not hasattr(self, 'initdone'): PluginConfig.__init__(self, name, conffile) ImagingDatabaseConfig.__init__(self) self.initdone = True
def init(self, name = 'imaging', conffile = None): self.dbsection = "database" self.name = name if not conffile: self.conffile = mmctools.getConfigFile(name) else: self.conffile = conffile
self.setup(self.conffile) def setup(self, conf_file): """ Read the module configuration Currently used params: - section "imaging": + revopath + publicdir """ self.disable = self.cp.getboolean("main", "disable") if self.cp.has_section("web"): for i in ('date_fmt', 'default_protocol', 'default_menu_name', 'default_ti...
if self.has_section("web"): for i in ('date_fmt', 'default_protocol', 'default_menu_name', 'default_timeout', 'default_background_uri', 'default_message'): full_name = "web_def_%s" % i if self.has_option("web", full_name): setattr(self, full_name, self.get("web", full_name))
def init(self, name = 'imaging', conffile = None): self.dbsection = "database" self.name = name if not conffile: self.conffile = mmctools.getConfigFile(name) else: self.conffile = conffile
return ProcessList().getZombieCount()
return ProcessList().getZombiesCount()
def getZombiesCount(): return ProcessList().getZombieCount()
buffer += 'timeout %s\n' % self.timeout
if self.timeout: buffer += 'timeout %s\n' % self.timeout
def write(self): """ write the client menu """ # takes global items, one by one
buffer += self._applyReplacement('splashscreen %s\n' % self.splashscreen)
if self.splashscreen: buffer += self._applyReplacement('splashscreen %s\n' % self.splashscreen)
def write(self): """ write the client menu """ # takes global items, one by one
if type(mac_addr) != str:
if type(mac_addr) not in [str, unicode]:
def isCiscoMacAddress(mac_addr): """ Check that the given MAC adress is a cisco-formatted MAC Address. @type mac_addr: str @param mac_addr: the mac addr to check @returns: returns True if the given MAC address is valid @rtype: bool """ if type(mac_addr) != str: return False regex = '^([0-9a-f]{4}\.[0-9a-f]{4}\.[0-9a-f...
if type(mac_addr) != str:
if type(mac_addr) not in [str, unicode]:
def isLinuxMacAddress(mac_addr): """ Check that the given MAC adress is a linux-formatted MAC Address. @type mac_addr: str @param mac_addr: the mac addr to check @returns: returns True if the given MAC address is valid @rtype: bool """ if type(mac_addr) != str: return False regex = '^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a...
if type(mac_addr) != str:
if type(mac_addr) not in [str, unicode]:
def isWinMacAddress(mac_addr): """ Check that the given MAC adress is a windows-formatted MAC Address. @type mac_addr: str @param mac_addr: the mac addr to check @returns: returns True if the given MAC address is valid @rtype: bool """ if type(mac_addr) != str: return False regex = '^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9...
if type(mac_addr) != str:
if type(mac_addr) not in [str, unicode]:
def isShortMacAddress(mac_addr): """ Check that the given MAC adress is a short-formatted MAC Address. @type mac_addr: str @param mac_addr: the mac addr to check @returns: returns True if the given MAC address is valid @rtype: bool """ if type(mac_addr) != str: return False regex = '^(([0-9a-fA-F]){12})$' return re.m...
if type(mac_addr) != str and type(mac_addr) != unicode: return False
def isMACAddress(mac_addr): """ Check that the given MAC adress seems to be a MAC Address. @type mac_addr: str @param mac_addr: the mac addr to check @returns: returns True if the given MAC address is valid @rtype: bool """ if type(mac_addr) != str and type(mac_addr) != unicode: return False return isCiscoMacAddress(m...
result=serverM.getFilePath("43f38f712223725ac3e220b96889484b")
result=serverM.getFilePath("5d3ff03e396aa072f5cae2b2ddcd88b9")
def test102getFilePath (self): result=serverM.getFilePath("43f38f712223725ac3e220b96889484b") self.assertEqual (result,"%s://%s:9990/mirror1_files/test/MD5SUMS" %(protocol,ipserver))
result=serverM.getFileURI("43f38f712223725ac3e220b96889484b")
result=serverM.getFileURI("5d3ff03e396aa072f5cae2b2ddcd88b9")
def test103getFileURI (self): result=serverM.getFileURI("43f38f712223725ac3e220b96889484b") self.assertEqual (result,"%s://%s:9990/mirror1_files/test/MD5SUMS" %(protocol,ipserver))
result=serverM.getFilesURI(["43f38f712223725ac3e220b96889484b","baf68c123b04d61856f71fe07b7bd84b"])
result=serverM.getFilesURI(["5d3ff03e396aa072f5cae2b2ddcd88b9","7885517b39317add6a1d362968b01774"])
def test104getFilesURI (self): result=serverM.getFilesURI(["43f38f712223725ac3e220b96889484b","baf68c123b04d61856f71fe07b7bd84b"]) self.assertEqual (result,['%s://%s:9990/mirror1_files/test/MD5SUMS' %(protocol,ipserver), '%s://%s:9990/mirror1_files/test/install.bat' %(protocol,ipserver)])
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
def test302getAllPackages (self): result=serverP.getAllPackages({'mountpoint': '/mirror1', 'server': ipserver, 'protocol': protocol, 'uuid': 'UUID/mirror1', 'port': '9990'}) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'i...
self.assertEqual (result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci est...
self.assertEqual (result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci est...
def test305getPackageDetail (self): result=serverP.getPackageDetail("test") SupEsp(result) self.assertEqual (result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f71222372...
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
def test306getPackagesDetail (self): result = serverP.getPackagesDetail(["test","test"]) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '...
self.assertEqual (result,[{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}])
self.assertEqual (result,[{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}])
def test308getPackageFiles (self): result=serverP.getPackageFiles("test") SupEsp(result) self.assertEqual (result,[{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}])
self.assertEqual (result,72)
self.assertEqual(result, PKGSIZE)
def test315getPackageSize (self): result=serverP.getPackageSize("test") self.assertEqual (result,72)
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e220b96889484b'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
def test317getServerDetails (self): result=serverP.getServerDetails() SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': 'baf68c123b04d61856f71fe07b7bd84b'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '43f38f712223725ac3e...
for package in serverM.getFilesURI(["baf68c123b04d61856f71fe07b7bd84b","43f38f712223725ac3e220b96889484b"]):
for package in serverM.getFilesURI(["7885517b39317add6a1d362968b01774","5d3ff03e396aa072f5cae2b2ddcd88b9"]):
def test501valid_url(self): for package in serverM.getFilesURI(["baf68c123b04d61856f71fe07b7bd84b","43f38f712223725ac3e220b96889484b"]): package1=string.split(package) cpackage=string.joinfields(package1,"%20") urllib2.urlopen(cpackage)
root_id = self.__getUser('root')
root_id = self.__getUser('root').id
def __allgroups_query(self, ctx, params, session = None, type = 0): """ return a query on group filtered by several flags like canShow, dynamic, static, type (0 = group, 1 = profile) and filters like filter (on the group name with wildcards) and name (on the group name without wildcards) """ (select_from, filter_on) = ...
schema = ldapObj.getSchema("lmcUserObject") if len(schema) <= 0: logger.error("MMC schema seems not be include in LDAP directory"); return False
schema = ldapObj.getSchema("lmcUserObject") if len(schema) <= 0: logger.error("MMC schema seems not be include in LDAP directory") return False
def activate(): """ this function define if the module "base" can be activated. @return: return True if this module can be activate @rtype: boolean """ logger = logging.getLogger() try: ldapObj = ldapUserGroupControl() except ldap.INVALID_CREDENTIALS: logger.error("Can't bind to LDAP: invalid credentials.") return Fals...
ret = self.l.search_s(self.userdn, ldap.SCOPE_BASE)
ret = lugc.l.search_s(self.userdn, ldap.SCOPE_BASE)
def getUserEntry(self): try: ret = self.l.search_s(self.userdn, ldap.SCOPE_BASE) except ldap.NO_SUCH_OBJECT: # If the user is defined in OpenLDAP slapd.conf, we may bind even # if the user has no LDAP entry. ret = None return ret
result=serverP.getAllPackages({'mountpoint': '/mirror1', 'server': ipserver, 'protocol': protocol, 'uuid': 'UUID/mirror1', 'port': '9990'}) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01...
result = serverP.getAllPackages({'mountpoint': '/mirror1', 'server': ipserver, 'protocol': protocol, 'uuid': 'UUID/mirror1', 'port': '9990'}) SupEsp(result) self.assertTrue(checkValues(result, [{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add...
def test302getAllPackages (self): result=serverP.getAllPackages({'mountpoint': '/mirror1', 'server': ipserver, 'protocol': protocol, 'uuid': 'UUID/mirror1', 'port': '9990'}) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'i...
result=serverP.getPackageDetail("test") SupEsp(result) self.assertEqual (result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit'...
result = serverP.getPackageDetail("test") SupEsp(result) self.assertTrue(checkValues(result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], '...
def test305getPackageDetail (self): result=serverP.getPackageDetail("test") SupEsp(result) self.assertEqual (result,{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa0...
result = serverP.getPackagesDetail(["test","test"]) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], ...
result = serverP.getPackagesDetail(["test", "test"]) SupEsp(result) self.assertTrue(checkValues(result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2dd...
def test306getPackagesDetail (self): result = serverP.getPackagesDetail(["test","test"]) SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '...
result=serverP.getPackageFiles("test") SupEsp(result) self.assertEqual (result,[{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}])
result = serverP.getPackageFiles("test") result.sort() SupEsp(result) wanted = [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}] wanted.sort() self.assertEqual(result, wanted)
def test308getPackageFiles (self): result=serverP.getPackageFiles("test") SupEsp(result) self.assertEqual (result,[{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}])
self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description': 'Ceci es...
self.assertTrue(checkValues(result, [{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5cae2b2ddcd88b9'}], 'installInit': {'command': '', 'name': ''}, 'description...
def test317getServerDetails (self): result=serverP.getServerDetails() SupEsp(result) self.assertEqual (result,[{'postCommandSuccess': {'command': '', 'name': ''}, 'files': [{'path': '/test', 'name': 'install.bat', 'id': '7885517b39317add6a1d362968b01774'}, {'path': '/test', 'name': 'MD5SUMS', 'id': '5d3ff03e396aa072f5c...
@return: a deferred object resulting to 1 if registration was successful, else 0. @rtype: int
@return: a deferred object resulting to True if registration was successful, else False. @rtype: bool
def xmlrpc_computerRegister(self, computerName, MACAddress): """ Method to register a new computer.
self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result)))
self.logger.warn('Imaging: Couldn\'t register client %s (%s) : %s' % (computerName, MACAddress, str(result)))
def onSuccess(result): if type(result) == dict : self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result))) return False
self.logger.info('Imaging: Registred client %s (%s) as %s' % (computerName, MACAddress, uuid))
self.logger.info('Imaging: Register client %s (%s) as %s' % (computerName, MACAddress, uuid)) self.myUUIDCache.set(uuid, MACAddress)
def onSuccess(result): if type(result) == dict : self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result))) return False
if not isMACAddress(MACAddress): raise TypeError if not len(computerName): raise TypeError
def onSuccess(result): if type(result) == dict : self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result))) return False
self.logger.info('Imaging: Won\'t register %s as %s : %s' % (MACAddress, computerName, e))
self.logger.error('Imaging: Won\'t register %s as %s : %s' % (MACAddress, computerName, e))
def onSuccess(result): if type(result) == dict : self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result))) return False
d.addCallbacks(onSuccess, client.onError, errbackArgs = (func, args, 0))
d.addCallbacks(onSuccess, client.onError, errbackArgs = (func, args, False))
def onSuccess(result): if type(result) == dict : self.logger.warn('Imaging: Couldn\'t registred client %s (%s) : %s' % (computerName, MACAddress, str(result))) return False
def computerSetDefaultMenuItem(self, uuid, num):
def computerChangeDefaultMenuItem(self, uuid, num):
def computerSetDefaultMenuItem(self, uuid, num): """ Ask the pserver to change the default item in a menu """ d = self.callRemote("computerSetDefaultMenuItem", uuid, num) d.addErrback(self.onErrorRaise, "Imaging:computerSetDefaultMenuItem", uuid, num) return d
d = self.callRemote("computerSetDefaultMenuItem", uuid, num) d.addErrback(self.onErrorRaise, "Imaging:computerSetDefaultMenuItem", uuid, num)
d = self.callRemote("computerChangeDefaultMenuItem", uuid, num) d.addErrback(self.onErrorRaise, "Imaging:computerChangeDefaultMenuItem", uuid, num)
def computerSetDefaultMenuItem(self, uuid, num): """ Ask the pserver to change the default item in a menu """ d = self.callRemote("computerSetDefaultMenuItem", uuid, num) d.addErrback(self.onErrorRaise, "Imaging:computerSetDefaultMenuItem", uuid, num) return d
return [True, {'uuid': "UUID%s" % computer.uuid, 'mac': mac, 'shortname': computer.hostname, 'fqdn': computer.hostname}]
return [True, {'uuid': "UUID%s" % computer['uuid'], 'mac': mac, 'shortname': computer['hostname'], 'fqdn': computer['hostname']}]
def getComputerByMac(self, mac): """ Called by the package server, to obtain a computer UUID/shortname/fqdn in exchange of its MAC address """ assert pulse2.utils.isMACAddress(mac) computer = ComputerManager().getComputerByMac(mac) if not computer: return [False, "imaging.getComputerByMac() : I was unable to find a com...
def test103hasInventory(self):
def test102hasInventory(self):
def test103hasInventory(self): # Load the full inventory to test each part separately inventory = client.inventory.getLastMachineInventoryFull({}) # Assert that the inventory is not empty for the parts which are # necessarly used for part in inventory: if part == 'Hardware' or part == 'Software': self.assertNotEqual(in...
def test104ubuntuInject(self):
def test103ubuntuInject(self):
def test104ubuntuInject(self): """ Inject an Ubuntu UTF-8 inventory containing latin-1 chars """ os.system('gunzip -c ../data/ocs-ubuntu-10.04-lts.xml.gz | $PULSE2/services/contrib/Ocsinventory_local.pl -u http://127.0.0.1:9999 --stdin') time.sleep(20) result = client.inventory.inventoryExists('UUID4') self.assertTrue(...
d.addCallbacks(lambda x: True, client.onError, errbackArgs=(func, args, 0))
d.addCallbacks(_onSuccess, client.onError, errbackArgs=(func, args, 0))
def _getmacCB(result): if result and type(result) == dict: client = self._getXMLRPCClient() func = 'imaging.injectInventory' args = (self.config.imaging_api['uuid'], result['uuid'], inventory) d = client.callRemote(func, *args) d.addCallbacks(lambda x: True, client.onError, errbackArgs=(func, args, 0)) return d self.lo...
def onSuccess(result):
def _onSuccess(result):
def onSuccess(result): if type(result) == dict and "faultCode" in result: self.logger.warning('Imaging: While processing result for %s : %s' % (MACAddress, result['faultTraceback'])) return False try: if result[0]: self.myUUIDCache.set(result[1]['uuid'], MACAddress, result[1]['shortname'], result[1]['fqdn']) self.logge...
d.addCallbacks(onSuccess, client.onError, errbackArgs=(func, args, 0))
d.addCallbacks(_onSuccess, client.onError, errbackArgs=(func, args, 0))
def onSuccess(result): if type(result) == dict and "faultCode" in result: self.logger.warning('Imaging: While processing result for %s : %s' % (MACAddress, result['faultTraceback'])) return False try: if result[0]: self.myUUIDCache.set(result[1]['uuid'], MACAddress, result[1]['shortname'], result[1]['fqdn']) self.logge...
self.logger.warn('Imaging: New image %s for client %s' % (image_uuid, computer_uuid))
self.logger.info('Imaging: New image %s for client %s' % (image_uuid, computer_uuid))
def _getmacCB(result): if result and type(result) == dict : computer_uuid = result['uuid'] self.logger.warn('Imaging: New image %s for client %s' % (image_uuid, computer_uuid)) return image_uuid
def onSuccess(result):
def _onSuccess(result):
def onSuccess(result): if type(result) != list and len(result) != 2: self.logger.error('Imaging: Couldn\'t set default entry on %s for %s : %s' % (num, computerUUID, str(result))) ret = False elif not result[0]: self.logger.error('Imaging: Couldn\'t set default entry on %s for %s : %s' % (num, computerUUID, str(result)...
d.addCallbacks(onSuccess, client.onError, errbackArgs = (func, args, False))
d.addCallbacks(_onSuccess, client.onError, errbackArgs = (func, args, False))
def onSuccess(result): if type(result) != list and len(result) != 2: self.logger.error('Imaging: Couldn\'t set default entry on %s for %s : %s' % (num, computerUUID, str(result))) ret = False elif not result[0]: self.logger.error('Imaging: Couldn\'t set default entry on %s for %s : %s' % (num, computerUUID, str(result)...
buf += 'keybfr\n'
buf += 'kbdfr\n'
def buildMenu(self): """ @return: the GRUB boot menu as a string encoded using CP-437 @rtype: str """ # takes global items, one by one buf = '# Auto-generated by Pulse 2 Imaging Server on %s \n\n' % time.asctime()
raise ValueError, 'Position %d in menu already taken' % position
raise ValueError('Position %d in menu already taken' % position)
def addImageEntry(self, position, entry): """ Add the ImagingEntry entry to our menu """ assert(type(position) == int and position > 0) if position in self.menuitems: raise ValueError, 'Position %d in menu already taken' % position item = ImagingImageItem(entry) self.menuitems[position] = item
raise ValueError, 'Position %d in menu already taken' % position
raise ValueError('Position %d in menu already taken' % position)
def addBootServiceEntry(self, position, entry): """ Add the ImagingEntry entry to our menu """ assert(type(position) == int and position > 0) if position in self.menuitems: raise ValueError, 'Position %d in menu already taken' % position self.menuitems[position] = ImagingBootServiceItem(entry)
imb = ImagingMenuBuilder()
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
imenu = imb.make(self.config, uuid, menu)
self.logger.debug('Setting menu for computer UUID/MAC %s/%s' % (uuid, macaddress)) imb = ImagingMenuBuilder(self.config, macaddress, menu) imenu = imb.make()
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.logger.error("Error while setting new menu of computer %s: %s" % (uuid, str(e)))
self.logger.error("Error while setting new menu of computer uuid/mac %s: %s" % (uuid, str(e)))
def xmlrpc_computersMenuSet(self, menus): """ Set computers imaging boot menu.
self.IMAGE_UUID = result
global IMAGE_UUID IMAGE_UUID = result
def test_06computerCreateImageDirectory(self): """ Create a directory to store a Pulse 2 image """ result = SERVER.computerCreateImageDirectory('00:11:22:33:44:ff') self.assertTrue(isUUID(result)) self.assertTrue(os.path.exists('/var/lib/pulse2/imaging/masters/%s' % result)) self.IMAGE_UUID = result