rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
repodata = {'id' : 'test-f12', 'name' : 'f12', 'arch' : 'i386', 'feed' : 'yum:http://mmccune.fedorapeople.org/pulp/'} repo = rconn.create(repodata)
repo = rconn.create('test-f12', 'f12','i386', 'yum:http://mmccune.fedorapeople.org/pulp/')
def clean(self): pass
consumerdata = { 'id' : "1", 'description' : 'prad.rdu.redhat.com', }
def clean(self): pass
print "Create Consumer", cconn.create(consumerdata)
print "Create Consumer", cconn.create("test", 'prad.rdu.redhat.com')
def clean(self): pass
packages = API.packages(id).avlues()
packages = API.packages(id).values()
def packages(self, id): """ Get a consumer's set of packages @param id: consumer id @return: consumer's installed packages """ valid_filters = ('name', 'arch') filters = self.filters(valid_filters) packages = API.packages(id).avlues() filtered_packages = self.filter_results(packages, filters, valid_filters) return self.ok(filtered_packages)
os.mkdir(self.published_path)
os.makedirs(self.published_path)
def _create_published_link(self, repo): if not os.path.isdir(self.published_path): os.mkdir(self.published_path) source_path = os.path.join(pulp.server.util.top_repos_location(), repo["relative_path"]) link_path = os.path.join(self.published_path, repo["relative_path"]) pulp.server.util.create_symlinks(source_path, link_path)
if not self.options.userlogin: print("userlogin required. Try --help")
if not self.options.newusername: print("newusername required. Try --help")
def _create(self): if not self.options.userlogin: print("userlogin required. Try --help") sys.exit(0) if not self.options.name: self.options.name = "" if not self.options.userpassword: self.options.userpassword = "" try: user = self.userconn.create(self.options.newusername, self.options.newpassword, self.options.name) print _(" Successfully created User [ %s ] with name [ %s ]" % \ (user['login'], user["name"])) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
if not self.options.userpassword: self.options.userpassword = ""
if not self.options.newpassword: self.options.newpassword = ""
def _create(self): if not self.options.userlogin: print("userlogin required. Try --help") sys.exit(0) if not self.options.name: self.options.name = "" if not self.options.userpassword: self.options.userpassword = "" try: user = self.userconn.create(self.options.newusername, self.options.newpassword, self.options.name) print _(" Successfully created User [ %s ] with name [ %s ]" % \ (user['login'], user["name"])) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
columns = ["login", "name"]
def _list(self): try: users = self.userconn.users() columns = ["login", "name"] if not len(users): print _("No users available to list") sys.exit(0) print "+-------------------------------------------+" print " Available Users " print "+-------------------------------------------+" for user in users: print constants.AVAILABLE_USERS_LIST % (user["login"], user["name"]) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
pids.append(pinfo) try: if pinfo: self.pconn.remove_package(id, pids) else: print _("Package [%s] is not part of the source repository [%s]" % (pkg, id)) except Exception: raise print _("Unable to remove package [%s] to repo [%s]" % (pkg, id)) print _("Successfully removed package(s) %s to repo [%s]." %(self.opts.pkgname, id))
try: if pinfo: self.pconn.remove_package(id, [pinfo]) print _("Successfully removed package %s from repo [%s]." %(pkg, id)) else: print _("Package [%s] does not exist in repository [%s]" % (pkg, id)) except Exception: print _("Unable to remove package [%s] to repo [%s]" % (pkg, id))
def run(self): id = self.get_required_option('id') if not self.opts.pkgname: system_exit(os.EX_USAGE, _("Error, atleast one package id is required to perform a delete.")) pids = [] for pkg in self.opts.pkgname: pinfo = self.pconn.get_package_by_filename(id, pkg) pids.append(pinfo) try: if pinfo: self.pconn.remove_package(id, pids) else: print _("Package [%s] is not part of the source repository [%s]" % (pkg, id)) except Exception: raise print _("Unable to remove package [%s] to repo [%s]" % (pkg, id)) print _("Successfully removed package(s) %s to repo [%s]." %(self.opts.pkgname, id))
raise print _("Unable to add errata [%s] to repo [%s]" % (errataids, id))
system_exit(os.EX_DATAERR, _("Unable to add errata [%s] to repo [%s]" % (errataids, id)))
def run(self): id = self.get_required_option('id') if not self.opts.errataid: system_exit(os.EX_USAGE, _("Error, atleast one erratum id is required to perform an add.")) if not self.opts.srcrepo: system_exit(os.EX_USAGE, _("Error, a source respository where erratum exists is required")) errataids = self.opts.errataid try: self.pconn.add_errata(id, errataids) except Exception: raise print _("Unable to add errata [%s] to repo [%s]" % (errataids, id)) print _("Successfully added Errata %s to repo [%s]." %(errataids, id))
raise
def run(self): id = self.get_required_option('id') if not self.opts.errataid: system_exit(os.EX_USAGE, _("Error, atleast one erratum id is required to perform a delete.")) errataids = self.opts.errataid try: self.pconn.delete_errata(id, errataids) except Exception: raise print _("Unable to remove errata [%s] to repo [%s]" % (errataids, id)) print _("Successfully removed Errata %s to repo [%s]." %(errataids, id))
print _(" Failed to Upload %s to Repo [ %s ] " % self.options.id)
print _(" Failed to Upload [%s] to Repo [ %s ] " % (pkginfo['pkgname'], self.options.id))
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ] " % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ] " % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
for path in self.keyfiles():
for path, content in self.keyfiles():
def relink(self): """ Relink GPG key files. """ linked = [] self.clean() for path in self.keyfiles(): fn = os.path.basename(path) dst = os.path.join(lnkdir(), self.path, fn) self.link(path, dst) entry = os.path.join(self.path, fn) linked.append(entry) return linked
print("repo id required. Try --help")
print _("repo id required. Try --help")
def _create(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) if not self.options.name: self.options.name = self.options.id if not self.options.arch: self.options.arch = "noarch"
print _(" Successfully created Repo [ %s ]" % repo['id'])
print _(" Successfully created Repo [ %s ]") % repo['id']
def _create(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) if not self.options.name: self.options.name = self.options.id if not self.options.arch: self.options.arch = "noarch"
print("repo id required. Try --help")
print _("repo id required. Try --help")
def _sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: task_object = self.pconn.sync(self.options.id, self.options.timeout) state = "waiting" print "Task created with ID::", task_object['id'] while state not in ["finished", "error", 'timed out', 'canceled']: time.sleep(5) status = self.pconn.sync_status(task_object['status_path']) if status is None: raise SyncError(_('No sync for repository [%s] found') % self.options.id) state = status['state'] print "Sync Status::", state packages = self.pconn.packages(self.options.id) pkg_count = 0 if packages: pkg_count = len(packages) if state == "error": raise SyncError(status['traceback'][-1]) else: print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages" % (self.options.id, pkg_count)) except RestlibException, re: log.info("REST Error.", exc_info=True) systemExit(re.code, re.msg) except SyncError, se: log.info("Sync Error: ", exc_info=True) systemExit("Error : %s" % se) except Exception, e: log.error("General Error: %s" % e) raise
print "Task created with ID::", task_object['id']
print _("Task created with ID::"), task_object['id']
def _sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: task_object = self.pconn.sync(self.options.id, self.options.timeout) state = "waiting" print "Task created with ID::", task_object['id'] while state not in ["finished", "error", 'timed out', 'canceled']: time.sleep(5) status = self.pconn.sync_status(task_object['status_path']) if status is None: raise SyncError(_('No sync for repository [%s] found') % self.options.id) state = status['state'] print "Sync Status::", state packages = self.pconn.packages(self.options.id) pkg_count = 0 if packages: pkg_count = len(packages) if state == "error": raise SyncError(status['traceback'][-1]) else: print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages" % (self.options.id, pkg_count)) except RestlibException, re: log.info("REST Error.", exc_info=True) systemExit(re.code, re.msg) except SyncError, se: log.info("Sync Error: ", exc_info=True) systemExit("Error : %s" % se) except Exception, e: log.error("General Error: %s" % e) raise
print "Sync Status::", state
print _("Sync Status::"), state
def _sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: task_object = self.pconn.sync(self.options.id, self.options.timeout) state = "waiting" print "Task created with ID::", task_object['id'] while state not in ["finished", "error", 'timed out', 'canceled']: time.sleep(5) status = self.pconn.sync_status(task_object['status_path']) if status is None: raise SyncError(_('No sync for repository [%s] found') % self.options.id) state = status['state'] print "Sync Status::", state packages = self.pconn.packages(self.options.id) pkg_count = 0 if packages: pkg_count = len(packages) if state == "error": raise SyncError(status['traceback'][-1]) else: print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages" % (self.options.id, pkg_count)) except RestlibException, re: log.info("REST Error.", exc_info=True) systemExit(re.code, re.msg) except SyncError, se: log.info("Sync Error: ", exc_info=True) systemExit("Error : %s" % se) except Exception, e: log.error("General Error: %s" % e) raise
print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages" % (self.options.id, pkg_count))
print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages") % \ (self.options.id, pkg_count)
def _sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: task_object = self.pconn.sync(self.options.id, self.options.timeout) state = "waiting" print "Task created with ID::", task_object['id'] while state not in ["finished", "error", 'timed out', 'canceled']: time.sleep(5) status = self.pconn.sync_status(task_object['status_path']) if status is None: raise SyncError(_('No sync for repository [%s] found') % self.options.id) state = status['state'] print "Sync Status::", state packages = self.pconn.packages(self.options.id) pkg_count = 0 if packages: pkg_count = len(packages) if state == "error": raise SyncError(status['traceback'][-1]) else: print _(" Sync Successful. Repo [ %s ] now has a total of [ %s ] packages" % (self.options.id, pkg_count)) except RestlibException, re: log.info("REST Error.", exc_info=True) systemExit(re.code, re.msg) except SyncError, se: log.info("Sync Error: ", exc_info=True) systemExit("Error : %s" % se) except Exception, e: log.error("General Error: %s" % e) raise
print("repo id required. Try --help")
print _("repo id required. Try --help")
def _cancel_sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) if not self.options.taskid: print("task id required. Try --help") sys.exit(0) try: repos = self.pconn.cancel_sync(self.options.id, self.options.taskid) print _(" Sync task %s cancelled") % self.options.taskid except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
print("task id required. Try --help")
print _("task id required. Try --help")
def _cancel_sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) if not self.options.taskid: print("task id required. Try --help") sys.exit(0) try: repos = self.pconn.cancel_sync(self.options.id, self.options.taskid) print _(" Sync task %s cancelled") % self.options.taskid except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
print _(" Sync task %s cancelled") % self.options.taskid
print _(" Sync task %s canceled") % self.options.taskid
def _cancel_sync(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) if not self.options.taskid: print("task id required. Try --help") sys.exit(0) try: repos = self.pconn.cancel_sync(self.options.id, self.options.taskid) print _(" Sync task %s cancelled") % self.options.taskid except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
print("repo id required. Try --help")
print _("repo id required. Try --help")
def _delete(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: self.pconn.delete(id=self.options.id) print _(" Successful deleted Repo [ %s ] " % self.options.id) except RestlibException, re: print _(" Deleted operation failed on Repo [ %s ] " % self.options.id) log.error("Error: %s" % re) sys.exit(-1) except Exception, e: print _(" Deleted operation failed on Repo [ %s ]. " % self.options.id) log.error("Error: %s" % e) sys.exit(-1)
print _(" Successful deleted Repo [ %s ] " % self.options.id) except RestlibException, re: print _(" Deleted operation failed on Repo [ %s ] " % self.options.id)
print _(" Successful deleted Repo [ %s ]") % self.options.id except RestlibException, re: print _(" Deleted operation failed on Repo [ %s ]") % self.options.id
def _delete(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: self.pconn.delete(id=self.options.id) print _(" Successful deleted Repo [ %s ] " % self.options.id) except RestlibException, re: print _(" Deleted operation failed on Repo [ %s ] " % self.options.id) log.error("Error: %s" % re) sys.exit(-1) except Exception, e: print _(" Deleted operation failed on Repo [ %s ]. " % self.options.id) log.error("Error: %s" % e) sys.exit(-1)
print _(" Deleted operation failed on Repo [ %s ]. " % self.options.id)
print _(" Deleted operation failed on Repo [ %s ].") % self.options.id
def _delete(self): if not self.options.id: print("repo id required. Try --help") sys.exit(0) try: self.pconn.delete(id=self.options.id) print _(" Successful deleted Repo [ %s ] " % self.options.id) except RestlibException, re: print _(" Deleted operation failed on Repo [ %s ] " % self.options.id) log.error("Error: %s" % re) sys.exit(-1) except Exception, e: print _(" Deleted operation failed on Repo [ %s ]. " % self.options.id) log.error("Error: %s" % e) sys.exit(-1)
print("repo id required. Try --help")
print _("repo id required. Try --help")
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
print("Need to provide atleast one file to perform upload")
print _("Need to provide at least one file to perform upload")
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
print('Error: %s' % e)
print _('Error: %s') % e
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
print("Package %s is Not an RPM Skipping" % frpm)
print _("Package %s is Not an RPM Skipping") % frpm
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id))
print _(" Successful uploaded [%s] to Repo [ %s ]") % \ (pkginfo['pkgname'], self.options.id)
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id)
print _(" Failed to Upload %s to Repo [ %s ]") % self.options.id
def _upload(self): (self.options, files) = self.parser.parse_args() # ignore the command and pick the files files = files[2:] if not self.options.id: print("repo id required. Try --help") sys.exit(0) if self.options.dir: files += utils.processDirectory(self.options.dir, "rpm") if not files: print("Need to provide atleast one file to perform upload") sys.exit(0) uploadinfo = {} uploadinfo['repo'] = self.options.id for frpm in files: try: pkginfo = utils.processRPM(frpm) except FileError, e: print('Error: %s' % e) continue if not pkginfo.has_key('nvrea'): print("Package %s is Not an RPM Skipping" % frpm) continue pkgstream = base64.b64encode(open(frpm).read()) try: status = self.pconn.upload(self.options.id, pkginfo, pkgstream) if status: print _(" Successful uploaded [%s] to Repo [ %s ]" % (pkginfo['pkgname'], self.options.id)) else: print _(" Failed to Upload %s to Repo [ %s ]" % self.options.id) except RestlibException, re: log.error("Error: %s" % re) raise #continue except Exception, e: log.error("Error: %s" % e) raise #continue
@remotemethod
@remote
def bark(self, words): return self.BRKMSG % words
r = agent.dog.bark('pulp rocks!')
r = dog.bark('pulp rocks!')
def testSynchronous(self): results = [] __agent = TestAgent(self.ID) agent = RemoteAgent(self.ID) dog = agent.Dog() r = agent.dog.bark('pulp rocks!') results.append(r) r = dog.wag(self.WAGS) results.append(r) self.validate(results) agent.close()
pattern = '%s/' % self.path
pattern = self.path if not pattern.endswith('/'): pattern += '/'
def delete(self, prev): """ Delete for this repository. Pattern matching used to be sure that only keys stored for this repository are deleted. A cloned repo may have it's parent's keys in the keylist. @param prev: The current list of (relateive paths) keys. @type prev: [str,..] @return: A list of deleted (relateive paths) keys. @rtype: [str,..] """ deleted = [] pattern = '%s/' % self.path for entry in prev: if pattern not in entry: continue deleted.append(entry) fn = os.path.basename(entry) path = os.path.join(self.abspath, fn) try: log.info('deleting: %s', path) os.unlink(path) except: pass return deleted
class InterruptableThread(threading.Thread):
class InterruptableThread(TrackableThread):
def _raise_exception_in_thread(tid, exc_type): """ Raises an exception in the threads with id tid. """ assert inspect.isclass(exc_type) # NOTE this returns the number of threads that it modified, which should # only be 1 or 0 (if the thread id wasn't found) long_tid = ctypes.c_long(tid) exc_ptr = ctypes.py_object(exc_type) num = ctypes.pythonapi.PyThreadState_SetAsyncExc(long_tid, exc_ptr) if num == 1: return if num == 0: raise ValueError('Invalid thread id') # NOTE if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect null_ptr = ctypes.py_object() ctypes.pythonapi.PyThreadState_SetAsyncExc(long_tid, null_ptr) raise SystemError('PyThreadState_SetAsyncExc failed')
return self.ok(consumer_api.list_package_updates(id))
return self.ok(consumer_api.list_package_updates(id)['packages'])
def package_updates(self, id): """ list applicable package updates for a given consumerid. @type id: str @param id: consumer id """ return self.ok(consumer_api.list_package_updates(id))
method = "/users/%s/" % consumergroup['id']
method = "/users/%s/" % user['id']
def update(self, user): method = "/users/%s/" % consumergroup['id'] return self.conn.request_put(method, params=user)
log.debug('Expected Package Location: %s' % pkg_location)
def sync(self, repo, repo_source, progress_callback=None): pkg_dir = urlparse(repo_source['url']).path.encode('ascii', 'ignore') log.debug("sync of %s for repo %s" % (pkg_dir, repo['id'])) try: repo_dir = "%s/%s" % (repos_location(), repo['id']) if not os.path.exists(pkg_dir): raise InvalidPathError("Path %s is invalid" % pkg_dir) if repo['use_symlinks']: log.info("create a symlink to src directory %s %s" % (pkg_dir, repo_dir)) os.symlink(pkg_dir, repo_dir) else: if not os.path.exists(repo_dir): os.makedirs(repo_dir)
pass
self.clean()
def tearDown(self): # self.clean() pass
log.error("Unable to parse comps info for %s" % (compspath))
log.error("Unable to parse comps info for %s" % (compsfile))
def import_groups_data(self, compsfile, repo): """ Reads a comps.xml or comps.xml.gz under repodata from dir Loads PackageGroup and Category info our db """ try: comps = yum.comps.Comps() comps.add(compsfile) for c in comps.categories: ctg = model.PackageGroupCategory(c.categoryid, c.name, c.description, c.display_order) groupids = [grp for grp in c.groups] ctg['packagegroupids'].extend(groupids) ctg['translated_name'] = c.translated_name ctg['translated_description'] = c.translated_description repo['packagegroupcategories'][ctg['id']] = ctg for g in comps.groups: grp = model.PackageGroup(g.groupid, g.name, g.description, g.user_visible, g.display_order, g.default, g.langonly) grp.mandatory_package_names.extend(g.mandatory_packages.keys()) grp.optional_package_names.extend(g.optional_packages.keys()) grp.default_package_names.extend(g.default_packages.keys()) grp.conditional_package_names = g.conditional_packages grp.translated_name = g.translated_name grp.translated_description = g.translated_description repo['packagegroups'][grp['id']] = grp except yum.Errors.CompsException: log.error("Unable to parse comps info for %s" % (compspath)) return False return True
self.actions = {"info" : "Register this system as a consumer",
self.actions = {"info" : "lookup information for a package",
def __init__(self): usage = "usage: %prog package [OPTIONS]" shortdesc = "package specific actions to pulp server." desc = ""
self.parser.add_option("-p", "--name", dest="name",
self.parser.add_option("-n", "--name", dest="name",
def generate_options(self): self.action = self._get_action() if self.action == "info": usage = "package info [OPTIONS]" self.setup_option_parser(usage, "", True) self.parser.add_option("-p", "--name", dest="name", help="package name to lookup") self.parser.add_option("--repoid", dest="repoid", help="Repository Label") if self.action == "install": usage = "package install [OPTIONS]" self.setup_option_parser(usage, "", True) self.parser.add_option("-p", "--name", action="append", dest="pnames", help="Packages to be installed. \ To specify multiple packages use multiple -p") self.parser.add_option("--consumerid", dest="consumerid", help="Consumer Id") self.parser.add_option("--consumergroupid", dest="consumergroupid", help="Consumer Group Id")
self.parser.add_option("-p", "--name", action="append", dest="pnames",
self.parser.add_option("-n", "--name", action="append", dest="pnames",
def generate_options(self): self.action = self._get_action() if self.action == "info": usage = "package info [OPTIONS]" self.setup_option_parser(usage, "", True) self.parser.add_option("-p", "--name", dest="name", help="package name to lookup") self.parser.add_option("--repoid", dest="repoid", help="Repository Label") if self.action == "install": usage = "package install [OPTIONS]" self.setup_option_parser(usage, "", True) self.parser.add_option("-p", "--name", action="append", dest="pnames", help="Packages to be installed. \ To specify multiple packages use multiple -p") self.parser.add_option("--consumerid", dest="consumerid", help="Consumer Id") self.parser.add_option("--consumergroupid", dest="consumergroupid", help="Consumer Group Id")
self.parser.add_option("--schedule", dest="schedule",
self.parser.add_option("--schedule", dest="sync_schedule",
def setup_parser(self): super(Update, self).setup_parser() self.parser.add_option("--name", dest="name", help=_("common repository name")) self.parser.add_option("--arch", dest="arch", help=_("package arch the repository should support")) self.parser.add_option("--feed", dest="feed", help=_("url feed to populate the repository")) self.parser.add_option("--cacert", dest="cacert", help=_("path location to ca certificate")) self.parser.add_option("--cert", dest="cert", help=_("path location to entitlement certificate key")) self.parser.add_option("--schedule", dest="schedule", help=_("schedule for automatically synchronizing the repository")) self.parser.add_option("--symlinks", action="store_true", dest="symlinks", help=_("use symlinks instead of copying bits locally; applicable for local syncs")) self.parser.add_option("--relativepath", dest="relativepath", help=_("relative path where the repository is stored and exposed to clients; this defaults to feed path if not specified")) self.parser.add_option("--groupid", dest="groupid", help=_("a group to which the repository belongs; this is just a string identifier")) self.parser.add_option("--addkeys", dest="addkeys", help=_("a ',' separated list of directories and/or files contining GPG keys")) self.parser.add_option("--rmkeys", dest="rmkeys", help=_("a ',' separated list of GPG key names"))
for p in sorted(packages): print ' ' + p
for p in sorted(packages, key=lambda p: p['filename']): print ' ' + p['filename']
def run(self): id = self.get_required_option('id') repo = self.pconn.repository(id) files = repo['files'] packages = self.pconn.packages(id) print_header(_('Contents of %s') % id) print _('files in %s:') % id if not files: print _(' none') else: for f in sorted(repo['files']): print ' ' + f print _('packages in %s:') % id if not packages: print _(' none') else: for p in sorted(packages): print ' ' + p
def GET(self, id, action_name):
def GET(self):
def GET(self, id, action_name): ''' Retrieve a map of all repository IDs to their associated synchronization schedules.
distro = self.dapi.create(id, None, None, []) assert(distro is not None) status = False try: distro = self.dapi.create(id, None, None, []) except DuplicateKeyError: status = True self.assertTrue(status)
distro1 = self.dapi.create(id, None, None, []) assert(distro1 is not None) distro2 = self.dapi.create(id, None, None, []) assert(distro2 is not None) self.assertTrue(distro1 == distro2)
def test_duplicate(self): id = 'test_duplicate_distro' distro = self.dapi.create(id, None, None, []) assert(distro is not None) status = False try: distro = self.dapi.create(id, None, None, []) except DuplicateKeyError: status = True self.assertTrue(status)
if (consumerids.contains(consumer["id"])):
if consumer["id"] in consumerids:
def _add_consumer(self, consumergroup, consumer): """ Responsible for properly associating a Consumer to a ConsumerGroup """ consumerids = consumergroup['consumerids'] if (consumerids.contains(consumer["id"])): # No need to update group return consumerids.append(consumer["id"]) consumergroup["consumerids"] = consumerids
data.append(info)
data.append(pkg)
def installpackages(self, id, packagenames=[]): """ Install packages on the consumer. @param id: A consumer id. @type id: str @param packagenames: The package names to install. @type packagenames: [str,..] """ agent = Agent(id) data = [] for pkg in packagenames: info = pkg.split('.') if len(info) > 1: data.append(('.'.join(info[:-1]), info[-1])) else: data.append(info) log.debug("Packages to Install: %s" % data) agent.packages.install(data) return packagenames
print('-----') print(info['name']) print(info['version']) print(info['epoch']) print(info['release']) print(info['arch'])
def import_package(self, pkg_path, repo): packages = repo['packages'] if (pkg_path.endswith(".rpm")): try: info = pulp.util.getRPMInformation(pkg_path) p = self.package_api.package(info['name']) if not p: p = self.package_api.create(info['name'], info['description'])
def __init__(self, id=getuuid(), host='localhost', port=5672):
def __init__(self, id=None, host='localhost', port=5672):
def __init__(self, id=getuuid(), host='localhost', port=5672): """ @param host: The broker fqdn or IP. @type host: str @param port: The broker port. @type port: str """ self.id = id self.host = host self.port = port self.__session = None self.connect() self.open()
self.id = id
self.id = ( id or getuuid() )
def __init__(self, id=getuuid(), host='localhost', port=5672): """ @param host: The broker fqdn or IP. @type host: str @param port: The broker port. @type port: str """ self.id = id self.host = host self.port = port self.__session = None self.connect() self.open()
self._dipatcher_timeout = dispatcher_timeout
def __init__(self, storage, dispatcher_timeout=0.5): """ @type dispatcher_timeout: float @param dispatcher_timeout: the max number of seconds before the dispatcher wakes up to run tasks """ self._storage = storage self._lock = threading.RLock() self._condition = threading.Condition(self._lock) self._dispatcher = threading.Thread(target=self._dispatch) self._dispatcher.daemon = True self._dispatcher.start() self._dipatcher_timeout = dispatcher_timeout
self._condition.wait(self._dipatcher_timeout)
self._condition.wait(self._dispatcher_timeout)
def _dispatch(self): """ Scheduling method that that executes the scheduling hooks This should not be overridden by a derived class """ self._lock.acquire() while True: self._condition.wait(self._dipatcher_timeout) self._initial_runs() for task in self._get_tasks(): self._pre_run(task) self._run(task) self._post_run(task) self._finalize_runs()
task = self.find_task(id)
task = self.find_task(action_id)
def DELETE(self, id, action_name, action_id): """ Cancel an action """ task = self.find_task(id) if task is None: return self.not_found('No %s with id %s found' % (action_name, action_id)) if self.cancel_task(id): return self.accepted({'status_uri': http.uri_path()}) # action is complete and, therfore, not cancelled # a no-content return means the client should *not* adjust its view of # the resource return self.no_content()
if self.cancel_task(id): return self.accepted({'status_uri': http.uri_path()})
if self.cancel_task(action_id): return self.accepted(self._task_to_dict(task))
def DELETE(self, id, action_name, action_id): """ Cancel an action """ task = self.find_task(id) if task is None: return self.not_found('No %s with id %s found' % (action_name, action_id)) if self.cancel_task(id): return self.accepted({'status_uri': http.uri_path()}) # action is complete and, therfore, not cancelled # a no-content return means the client should *not* adjust its view of # the resource return self.no_content()
user = self.uapi.create(login, id)
user = self.uapi.create(login=login, id=id)
def test_duplicate(self): id = uuid.uuid4() login = 'dupe-test' user = self.uapi.create(login, id) try: user = self.uapi.create(login, id) raise Exception, 'Duplicate allowed' except: pass
credentials = web.ctx.environ.get('HTTP_AUTHORIZATION', None) return credentials
return web.ctx.environ.get('HTTP_AUTHORIZATION', None)
def http_authorization(): """ Return the current http authorization credentials, if any @return: str representing the http authorization credentials if found, None otherwise """ credentials = web.ctx.environ.get('HTTP_AUTHORIZATION', None) return credentials
parts = [p for p in uri_path().split('/') if p][2:]
parts = [p for p in uri_path().split('/') if p] assert parts[:2] == ('pulp', 'api') parts = parts[2:]
def resource_path(): """ Return the uri path with the /pulp/api prefix stripped off @rtype: str @return: uri formatted path """ parts = [p for p in uri_path().split('/') if p][2:] if not parts: return '/' return '/%s/' % '/'.join(parts)
if hasattr(self, id):
if hasattr(self, 'id'):
def setup_parser(self): help = _("consumer identifier eg: foo.example.com") default = None if hasattr(self, id): help = SUPPRESS_HELP default = self.id self.parser.add_option("--id", dest="id", default=default, help=help)
repo['distributionid'].append(distro['id']) log.info("Created a distributionID %s" % distro['id'])
if distro['id'] not in repo['distributionid']: repo['distributionid'].append(distro['id']) log.info("Created a distributionID %s" % distro['id'])
def _process_repo_images(self, repodir, repo): log.debug("Processing any images synced as part of the repo") images_dir = os.path.join(repodir, "images") if not os.path.exists(images_dir): log.info("No image files to import to repo..") return # Handle distributions that are part of repo syncs files = pulp.server.util.listdir(images_dir) or [] id = description = "ks-" + repo['id'] + "-" + repo['arch'] distro = self.distro_api.create(id, description, repo["relative_path"], files) repo['distributionid'].append(distro['id']) log.info("Created a distributionID %s" % distro['id']) if not repo['publish']: # the repo is not published, dont expose the repo yet return distro_path = os.path.join(config.config.get('paths', 'local_storage'), "published", "ks") if not os.path.isdir(distro_path): os.mkdir(distro_path) source_path = os.path.join(pulp.server.util.top_repos_location(), repo["relative_path"]) link_path = os.path.join(distro_path, repo["relative_path"]) pulp.server.util.create_symlinks(source_path, link_path) log.debug("Associated distribution %s to repo %s" % (distro['id'], repo['id']))
yfetch.fetchYumRepo(config.config.get('paths', 'local_storage'))
yfetch.fetchYumRepo(config.config.get('paths', 'local_storage'), callback=progressCallback)
def sync(self, repo, repo_source): cacert = clicert = clikey = None if repo['ca'] and repo['cert'] and repo['key']: cacert = repo['ca'].encode('utf8') clicert = repo['cert'].encode('utf8') clikey = repo['key'].encode('utf8') yfetch = YumRepoGrinder(repo['id'], repo_source['url'].encode('ascii', 'ignore'), 1, cacert=cacert, clicert=clicert, clikey=clikey) yfetch.fetchYumRepo(config.config.get('paths', 'local_storage')) repo_dir = "%s/%s/" % (config.config.get('paths', 'local_storage'), repo['id']) return repo_dir
s.syncPackages(channel, savePath=dest_dir)
s.syncPackages(channel, savePath=dest_dir, callback=progressCallback)
def sync(self, repo, repo_source): # Parse the repo source for necessary pieces # Expected format: <server>/<channel> pieces = repo_source['url'].split('/') if len(pieces) < 2: raise PulpException('Feed format for RHN type must be <server>/<channel>. Feed: %s', repo_source['url'])
repo_dir = "%s/%s/" % (pulp.server.util.top_repos_location(), repo['id'])
repo_dir = "%s/%s/" % (pulp.server.util.top_repos_location(), repo['relative_path'])
def generate_updateinfo(repo): """ Method to generate updateinfo xml for a given repo, write to file and update repomd.xml with new updateinfo @param repo: repo object with errata to generate updateinfo.xml @type repo: repository object """ um = UpdateMetadata() un = UpdateNotice() eapi = ErrataApi() if not repo['errata']: #no errata to process, return return errataids = list(chain.from_iterable(repo['errata'].values())) for eid in errataids: e = eapi.erratum(eid) if not e['pkglist']: # for unit tests continue _md = { 'from' : e['from_str'], 'type' : e['type'], 'title' : e['title'], 'release' : e['release'], 'status' : e['status'], 'version' : e['version'], 'pushcount' : e['pushcount'], 'update_id' : e['id'], 'issued' : e['issued'], 'updated' : e['updated'], 'description' : e['description'], 'references' : e['references'], 'pkglist' : e['pkglist'], 'reboot_suggested' : e['reboot_suggested'] } un._md = _md um.add_notice(un) repo_dir = "%s/%s/" % (pulp.server.util.top_repos_location(), repo['id']) if not um._notices: # nothing to do return return updateinfo_path = None try: updateinfo_path = "%s/%s" % (repo_dir, "updateinfo.xml") updateinfo_xml = um.xml(fileobj=open(updateinfo_path, 'wt')) log.info("updateinfo.xml generated and written to file %s" % updateinfo_path) except: log.error("Error writing updateinfo.xml to path %s" % updateinfo_path) if updateinfo_path: log.debug("Modifying repo for updateinfo") pulp.server.upload.modify_repo(os.path.join(repo_dir, "repodata"), updateinfo_path)
assert _version_db is not None
_init_db()
def _get_latest_version(): """ Utility function to fetch the latest DataModelVersion model from the db. @rtype: L{DataModelVersion} instance @return: the data model intance with the most recent version """ assert _version_db is not None versions = _version_db.find() if not versions: return None versions.sort({'version': pymongo.DESCENDING}).limit(1) return list(versions)[0]
if not versions:
if versions.count() == 0:
def _get_latest_version(): """ Utility function to fetch the latest DataModelVersion model from the db. @rtype: L{DataModelVersion} instance @return: the data model intance with the most recent version """ assert _version_db is not None versions = _version_db.find() if not versions: return None versions.sort({'version': pymongo.DESCENDING}).limit(1) return list(versions)[0]
versions.sort({'version': pymongo.DESCENDING}).limit(1)
versions.sort('version', pymongo.DESCENDING).limit(1)
def _get_latest_version(): """ Utility function to fetch the latest DataModelVersion model from the db. @rtype: L{DataModelVersion} instance @return: the data model intance with the most recent version """ assert _version_db is not None versions = _version_db.find() if not versions: return None versions.sort({'version': pymongo.DESCENDING}).limit(1) return list(versions)[0]
assert _version_db is not None
def get_version_in_use(): """ Fetch the data model version currently in use in the db. @rtype: int @return: integer data model version """ assert _version_db is not None v = _get_latest_version() return v.version
assert _version_db is not None
def check_version(): """ Check for a version mismatch between the current data model version and the data model version in use in the db. If a mismatch is detected, the mismatch is logged and the application exits. """ assert _version_db is not None v = _get_latest_version() if v.version == VERSION: return _log.critical('data model version mismatch: %d in use, but needs to be %d' % v.version, VERSION) _log.critical('pulp exiting: please migrate your database to the latest data model') sys.exit(os.EX_DATAERR)
if v.version == VERSION:
if v is not None and v.version == VERSION:
def check_version(): """ Check for a version mismatch between the current data model version and the data model version in use in the db. If a mismatch is detected, the mismatch is logged and the application exits. """ assert _version_db is not None v = _get_latest_version() if v.version == VERSION: return _log.critical('data model version mismatch: %d in use, but needs to be %d' % v.version, VERSION) _log.critical('pulp exiting: please migrate your database to the latest data model') sys.exit(os.EX_DATAERR)
_log.critical('data model version mismatch: %d in use, but needs to be %d' % v.version, VERSION) _log.critical('pulp exiting: please migrate your database to the latest data model') sys.exit(os.EX_DATAERR)
msg = 'data model version mismatch: %s in use, but needs to be %s' % \ (v and v.version, VERSION) log = logging.getLogger('pulp') log.critical(msg) log.critical("use the 'pulp-migrate' tool to fix this before restarting the web server") raise RuntimeError(msg)
def check_version(): """ Check for a version mismatch between the current data model version and the data model version in use in the db. If a mismatch is detected, the mismatch is logged and the application exits. """ assert _version_db is not None v = _get_latest_version() if v.version == VERSION: return _log.critical('data model version mismatch: %d in use, but needs to be %d' % v.version, VERSION) _log.critical('pulp exiting: please migrate your database to the latest data model') sys.exit(os.EX_DATAERR)
assert _version_db is not None
def set_version(version): """ Set the data model version in the database. @type version: int @param version: data model version """ assert _version_db is not None v = DataModelVersion(version) _version_db.save(v, safe=True)
_version_db.save(v, safe=True)
_set_version(v)
def set_version(version): """ Set the data model version in the database. @type version: int @param version: data model version """ assert _version_db is not None v = DataModelVersion(version) _version_db.save(v, safe=True)
assert _version_db is not None
def is_validated(): """ Check to see if the latest data model version has been validated. @rtype: bool @return: True if the data model has been validated, False otherwise """ assert _version_db is not None v = _get_latest_version() return v.validated
assert _version_db is not None
def set_validated(): """ Flag the latest data model version as validated. """ assert _version_db is not None v = _get_latest_version() v.validated = True _version_db.save(v, safe=True)
_version_db.save(v, safe=True) _init_db() check_version()
_set_version(v)
def set_validated(): """ Flag the latest data model version as validated. """ assert _version_db is not None v = _get_latest_version() v.validated = True _version_db.save(v, safe=True)
log.info("Progress: %s on <%s>, %s/%s items %s/%s bytes" % values)
log.debug("Progress: %s on <%s>, %s/%s items %s/%s bytes" % values)
def yum_rhn_progress_callback(info): fields = ('status', 'item_name', 'items_left', 'items_total', 'size_left', 'size_total') values = tuple(getattr(info, f) for f in fields) log.info("Progress: %s on <%s>, %s/%s items %s/%s bytes" % values) return dict(zip(fields, values))
help="Repository Label")
help="package name to lookup")
def generate_options(self): possiblecmd = []
pv = self.packageVersionApi.create(p.packageid, info['epoch'],
pv = self.packageVersionApi.create(p["packageid"], info['epoch'],
def _add_packages_from_dir(self, dir, repo): dirList = os.listdir(dir) packages = repo['packages'] package_count = 0 for fname in dirList: if (fname.endswith(".rpm")): try: info = getRPMInformation(dir + fname) #p = self.packageApi.package(info['name']) p = self.package(repo["id"], info['name']) if not p: p = self.create_package(repo["id"], info['name'], info['description']) pv = self.packageVersionApi.create(p.packageid, info['epoch'], info['version'], info['release'], info['arch']) for dep in info['requires']: pv.requires.append(dep) for dep in info['provides']: pv.provides.append(dep) self.packageVersionApi.update(pv) p.versions.append(pv) #self.packageApi.update(p) packages[p["packageid"]] = p log.debug("repo = %s" % (repo)) log.debug("packages = %s" % (packages)) self.update(repo) # Need to send package_count = package_count + 1 log.debug("Repo <%s> added package <%s> with %s versions" % (repo["id"], p["packageid"], len(p["versions"]))) except Exception, e: log.debug("%s" % (traceback.format_exc())) log.error("error reading package %s" % (dir + fname)) log.debug("read [%s] packages" % package_count) self._read_comps_xml(dir, repo)
p.versions.append(pv)
p["versions"].append(pv)
def _add_packages_from_dir(self, dir, repo): dirList = os.listdir(dir) packages = repo['packages'] package_count = 0 for fname in dirList: if (fname.endswith(".rpm")): try: info = getRPMInformation(dir + fname) #p = self.packageApi.package(info['name']) p = self.package(repo["id"], info['name']) if not p: p = self.create_package(repo["id"], info['name'], info['description']) pv = self.packageVersionApi.create(p.packageid, info['epoch'], info['version'], info['release'], info['arch']) for dep in info['requires']: pv.requires.append(dep) for dep in info['provides']: pv.provides.append(dep) self.packageVersionApi.update(pv) p.versions.append(pv) #self.packageApi.update(p) packages[p["packageid"]] = p log.debug("repo = %s" % (repo)) log.debug("packages = %s" % (packages)) self.update(repo) # Need to send package_count = package_count + 1 log.debug("Repo <%s> added package <%s> with %s versions" % (repo["id"], p["packageid"], len(p["versions"]))) except Exception, e: log.debug("%s" % (traceback.format_exc())) log.error("error reading package %s" % (dir + fname)) log.debug("read [%s] packages" % package_count) self._read_comps_xml(dir, repo)
log.debug("repo = %s" % (repo)) log.debug("packages = %s" % (packages))
def _add_packages_from_dir(self, dir, repo): dirList = os.listdir(dir) packages = repo['packages'] package_count = 0 for fname in dirList: if (fname.endswith(".rpm")): try: info = getRPMInformation(dir + fname) #p = self.packageApi.package(info['name']) p = self.package(repo["id"], info['name']) if not p: p = self.create_package(repo["id"], info['name'], info['description']) pv = self.packageVersionApi.create(p.packageid, info['epoch'], info['version'], info['release'], info['arch']) for dep in info['requires']: pv.requires.append(dep) for dep in info['provides']: pv.provides.append(dep) self.packageVersionApi.update(pv) p.versions.append(pv) #self.packageApi.update(p) packages[p["packageid"]] = p log.debug("repo = %s" % (repo)) log.debug("packages = %s" % (packages)) self.update(repo) # Need to send package_count = package_count + 1 log.debug("Repo <%s> added package <%s> with %s versions" % (repo["id"], p["packageid"], len(p["versions"]))) except Exception, e: log.debug("%s" % (traceback.format_exc())) log.error("error reading package %s" % (dir + fname)) log.debug("read [%s] packages" % package_count) self._read_comps_xml(dir, repo)
conflicting_consumers = self.find_conflicting_keyvalues(id, key, value)
conflicting_consumers = self.find_consumers_with_conflicting_keyvalues(id, key, value)
def add_key_value_pair(self, id, key, value): """ Add key-value info to a consumer group. @param id: A consumer group id. @type id: str @param repoid: key @type repoid: str @param value: value @type: str @raise PulpException: When consumer group is not found. """ consumergroup = self.consumergroup(id) if not consumergroup: raise PulpException('Consumer Group [%s] does not exist', id) key_value_pairs = consumergroup['key_value_pairs'] if key not in key_value_pairs.keys(): conflicting_consumers = self.find_conflicting_keyvalues(id, key, value) if conflicting_consumers is []: key_value_pairs[key] = value else: raise PulpException('Given key [%s] has different values for consumers [%s] ' 'belonging to this group. You can use --force to ' 'delete consumers\' original values.', key, conflicting_consumers) else: raise PulpException('Given key [%s] already exists', key) consumergroup['key_value_pairs'] = key_value_pairs self.update(consumergroup)
conflicting_consumers = self.find_conflicting_keyvalues(id, key, value)
conflicting_consumers = self.find_consumers_with_conflicting_keyvalues(id, key, value)
def update_key_value_pair(self, id, key, value): """ Update key-value info of a consumer group. @param id: A consumer group id. @type id: str @param repoid: key @type repoid: str @param value: value @type: str @raise PulpException: When consumer group is not found. """ consumergroup = self.consumergroup(id) if not consumergroup: raise PulpException('Consumer Group [%s] does not exist', id) key_value_pairs = consumergroup['key_value_pairs'] if key not in key_value_pairs.keys(): raise PulpException('Given key [%s] does not exist', key) else: conflicting_consumers = self.find_conflicting_keyvalues(id, key, value) if conflicting_consumers is []: key_value_pairs[key] = value else: raise PulpException('Given key [%s] has different values for consumers [%s] ' 'belonging to this group. You can use --force to ' 'delete consumers\' original values.', key, conflicting_consumers)
user = self.userconn.create(self.options.newusername, self.options.newpassword, self.options.name)
user = self.userconn.create(login=self.options.newusername, password=self.options.newpassword, name=self.options.name)
def _create(self): if not self.options.newusername: print("newusername required. Try --help") sys.exit(0) if not self.options.name: self.options.name = "" if not self.options.newpassword: self.options.newpassword = "" try: user = self.userconn.create(self.options.newusername, self.options.newpassword, self.options.name) print _(" Successfully created User [ %s ] with name [ %s ]" % \ (user['login'], user["name"])) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
descendants.extend(_thread_tree.get(d(), [])) return [d() for d in descendants if d() is not None]
t = d() if t is None: continue descendants.extend(_thread_tree.get(t, [])) return filter(lambda d: d is not None, [d() for d in descendants])
def get_descendants(thread): """ Get a list of all the descendant threads for the given thread. @type thread: L{TrackedThread} instance @param thread: thread to find the descendants of @raise RuntimeError: if the thread is not an instance of TrackedThread @return: list of TrackedThread instances """ if not isinstance(thread, TrackedThread): raise RuntimeError('Cannot find descendants of an untracked thread') descendants = _thread_tree.get(thread, []) for d in descendants: descendants.extend(_thread_tree.get(d(), [])) return [d() for d in descendants if d() is not None]
exists.
exits.
def raise_exception(self, exc_type): """ Raise an exception in this thread. NOTE this is executed in the context of the calling thread and blocks until the exception has been delivered to this thread and this thread exists. """ # embedded methods to reduce code duplication def test_exception_event(): return not self.__exception_event.is_set()
os.system('chmod 3775 /var/www/pulp')
os.system('chmod 3775 /var/www/pub')
def install(opts): create_dirs(opts) currdir = os.path.abspath(os.path.dirname(__file__)) for l in LINKS: debug(opts, 'creating link: /%s' % l) if os.path.exists('/'+l): debug(opts, '/%s exists, skipping' % l) continue os.symlink(os.path.join(currdir, l), '/'+l) # Link between pulp and apache if not os.path.exists('/var/www/pub'): os.symlink('/var/lib/pulp', '/var/www/pub') # Grant apache write access to the pulp tools log file os.system('setfacl -m user:apache:rwx /var/log/pulp') # guarantee apache always has write permissions os.system('chmod 3775 /var/log/pulp') os.system('chmod 3775 /var/www/pulp') os.system('chmod 3775 /var/lib/pulp') # Disable existing SSL configuration if os.path.exists('/etc/httpd/conf.d/ssl.conf'): shutil.move('/etc/httpd/conf.d/ssl.conf', '/etc/httpd/conf.d/ssl.off') return os.EX_OK
self.name = "consumer"
def __init__(self): usage = "usage: %prog consumer [OPTIONS]" shortdesc = "consumer specific actions to pulp server." desc = ""
elif len(possiblecmd) == 1:
elif len(possiblecmd) == 1 and possiblecmd[0] == self.name:
def generate_options(self): possiblecmd = []
self.generate_options()
def _do_core(self): self.generate_options() self._validate_options() if self.action == "create": self._create() if self.action == "list": self._list() if self.action == "delete": self._delete() if self.action == "bind": self._bind() if self.action == "unbind": self._unbind()
elif len(possiblecmd) == 1:
elif len(possiblecmd) == 1 and possiblecmd[0] == self.name:
def generate_options(self):
self.generate_options()
def _do_core(self): self.generate_options() self._validate_options() if self.action == "create": self._create() if self.action == "list": self._list() if self.action == "sync": self._sync()
assert(found['relative_path'] == "mypath/")
assert(found['relative_path'] == "mypath")
def test_repository_with_relativepath(self): repo = self.rapi.create('some-id-mypath', 'some name', \ 'i386', 'yum:http://example.com/mypath', relative_path="/mypath/") found = self.rapi.repository('some-id-mypath') assert(found is not None) assert(found['id'] == 'some-id-mypath') assert(found['relative_path'] == "mypath/")
_log.info('%s called %s.%s on %s' % (principal, api, method_name, params_repr))
_log.info('%s called %s.%s' % (principal, api, method_name))
def _record_event(): _objdb.insert(event, safe=False, check_keys=False) _log.info('%s called %s.%s on %s' % (principal, api, method_name, params_repr))
tb = ''.join(traceback.format_exception_only(*exc))
tb = ''.join(traceback.format_exception(*exc))
def _record_event(): _objdb.insert(event, safe=False, check_keys=False) _log.info('%s called %s.%s on %s' % (principal, api, method_name, params_repr))
self.repolib.update()
if not self.is_admin: self.repolib.update()
def _bind(self): consumerid = self.getConsumer() if not self.options.repoid: print _("repo id required. Try --help") sys.exit(0) try: self.cconn.bind(consumerid, self.options.repoid) self.repolib.update() print _(" Successfully subscribed consumer [%s] to repo [%s]") % \ (consumerid, self.options.repoid) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
self.repolib.update()
if not self.is_admin: self.repolib.update()
def _unbind(self): consumerid = self.getConsumer() if not self.options.repoid: print _("repo id required. Try --help") sys.exit(0) try: self.cconn.unbind(consumerid, self.options.repoid) self.repolib.update() print _(" Successfully unsubscribed consumer [%s] from repo [%s]") % \ (consumerid, self.options.repoid) except RestlibException, re: log.error("Error: %s" % re) systemExit(re.code, re.msg) except Exception, e: log.error("Error: %s" % e) raise
user = api.create(user_data['login'], user_data['password'], user_data['name'])
user = api.create(login=user_data['login'], password=user_data['password'], name=user_data['name'])
def PUT(self): """ Create a new user @return: user that was created """ user_data = self.params() user = api.create(user_data['login'], user_data['password'], user_data['name']) return self.created(user['id'], user)
cert_files[key] = fname
cert_files[key] = str(fname)
def _write_certs_to_disk(self, repoid, cert_data): CONTENT_CERTS_PATH = config.config.get("repos", "content_cert_location") cert_dir = os.path.join(CONTENT_CERTS_PATH, repoid)
'{inbound} method %s()", not found' % (action)
'{inbound} method %s()", not found' % action
def inbound(cls, action): """ Find the handler B{inbound} method for the specified I{action}. @param action: The I{action} part of an event subject. @type action: str @return: The handler instance method. @rtype: instancemethod """ mutex.acquire() try: method = cls.inbounds.get(action) if method is None: raise Exception,\ '{inbound} method %s()", not found' % (action) else: return method finally: mutex.release()