rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
cache = self.cmd.run("equery -q list")[1] | ret, cache = self.cmd.run("equery -q list") if ret == 2: cache = self.cmd.run("equery -q list '*'")[1] | def RefreshPackages(self): '''Refresh memory hashes of packages''' cache = self.cmd.run("equery -q list")[1] pattern = re.compile('(.*)-(\d.*)') self.installed = {} for pkg in cache: if pattern.match(pkg): name = pattern.match(pkg).group(1) version = pattern.match(pkg).group(2) self.installed[name] = version else: self... |
if arch not in metadata.groups + ['global']: | if arch not in metadata.groups + set(['global']): | def get_vpkgs(self, metadata): rv = Source.get_vpkgs(self, metadata) for arch, fmdata in self.filemap.iteritems(): if arch not in metadata.groups + ['global']: continue for filename, pkgs in fmdata.iteritems(): rv[filename] = pkgs return rv |
ypname = pkgname | d = {} d['name'] = pkgname | def build_yname(pkgname, inst): """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' if inst.get('epoch', False): ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) if inst.get('r... |
ypname += '-' | d['version'] = inst.get('version') | def build_yname(pkgname, inst): """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' if inst.get('epoch', False): ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) if inst.get('r... |
ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) | d['epoch'] = inst.get('epoch') | def build_yname(pkgname, inst): """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' if inst.get('epoch', False): ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) if inst.get('r... |
ypname += "-%s" % (inst.get('release')) | d['release'] = inst.get('release') | def build_yname(pkgname, inst): """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' if inst.get('epoch', False): ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) if inst.get('r... |
ypname += ".%s" % (inst.get('arch')) return ypname | d['arch'] = inst.get('arch') return d | def build_yname(pkgname, inst): """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' if inst.get('epoch', False): ypname += "%s:" % inst.get('epoch') if inst.get('version', False) and inst.get('version') != 'any': ypname += "%s" % (inst.get('version')) if inst.get('r... |
self.logger.info("Installing GPG keys.") | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. | |
key_arg = os.path.join(self.instance_status[inst].get('pkg').get('uri'), \ | key_file = os.path.join(self.instance_status[inst].get('pkg').get('uri'), \ | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. |
cmdrc, output = self.cmd.run("rpm --import %s" % key_arg) if cmdrc != 0: self.logger.debug("Unable to install %s-%s" % \ (self.instance_status[inst].get('pkg').get('name'), \ self.str_evra(inst))) else: self.logger.debug("Installed %s-%s-%s" % \ (self.instance_status[inst].get('pkg').get('name'), \ inst.get('version'),... | self._installGPGKey(inst, key_file) | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. |
if YAD: pkgtool = "/usr/bin/yum -d0 -y install %s" else: pkgtool = "/usr/bin/yum -d0 install %s" install_args = [] | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. | |
install_args.append(build_yname(pkg_arg, inst)) cmdrc, output = self.cmd.run(pkgtool % " ".join(install_args)) if cmdrc == 0: self.logger.info("Single Pass for Install Succeeded") self.RefreshPackages() else: self.logger.error("Single Pass Install of Packages Failed") installed_instances = [] for inst in install_pk... | self.yb.install(**build_yname(pkg_arg, inst)) | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. |
if YAD: pkgtool = "/usr/bin/yum -d0 -y update %s" else: pkgtool = "/usr/bin/yum -d0 update %s" upgrade_args = [] | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. | |
pkg_arg = build_yname(self.instance_status[inst].get('pkg').get('name'), inst) upgrade_args.append(pkg_arg) cmdrc, output = self.cmd.run(pkgtool % " ".join(upgrade_args)) if cmdrc == 0: self.logger.info("Single Pass for Install Succeeded") self.RefreshPackages() else: self.logger.error("Single Pass Install of Packa... | pkg_arg = self.instance_status[inst].get('pkg').get('name') self.yb.update(**build_yname(pkg_arg, inst)) self._runYumTransaction() | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. |
if YAD: pkgtool = "/usr/bin/yum -d0 -y erase %s" else: pkgtool = "/usr/bin/yum -d0 erase %s" | def RemovePackages(self, packages): """ Remove specified entries. | |
pkg_arg = pkg.get('name') + '-' if inst.get('epoch', False): pkg_arg = pkg_arg + inst.get('epoch') + ':' pkg_arg = pkg_arg + inst.get('version') + '-' + inst.get('release') if inst.get('arch', False): pkg_arg = pkg_arg + '.' + inst.get('arch') erase_args.append(pkg_arg) | self.yb.remove(**nevra) self.modified.append(pkg) | def RemovePackages(self, packages): """ Remove specified entries. |
pkgspec = { 'name':pkg.get('name'), 'version':inst.get('version'), 'release':inst.get('release')} self.logger.info("WARNING: gpg-pubkey package not in configuration %s %s"\ % (pkgspec.get('name'), self.str_evra(pkgspec))) self.logger.info(" This package will be deleted in a future version of the RPMng driver.")... | self.logger.info("WARNING: gpg-pubkey package not in configuration %s %s-%s"\ % (nevra['name'], nevra['version'], nevra['release'])) self.logger.info(" This package will be deleted in a future version of the YUMng driver.") self._runYumTransaction() | def RemovePackages(self, packages): """ Remove specified entries. |
request.shutdown(2) | def close_request(self, request): request.unwrap() request.shutdown(2) request.close() | |
if arch not in metadata.groups + set(['global']): | if arch not in metadata.groups and arch != 'global': | def get_vpkgs(self, metadata): rv = Source.get_vpkgs(self, metadata) for arch, fmdata in self.filemap.iteritems(): if arch not in metadata.groups + set(['global']): continue for filename, pkgs in fmdata.iteritems(): rv[filename] = pkgs return rv |
output = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name'))[1][0] | try: output = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name'))[1][0] except IndexError: self.logger.error("Service %s not an Upstart service" % \ entry.get('name')) return False | def VerifyService(self, entry, _): '''Verify Service status for entry |
__req__ = {'Package': ['name', 'version'], | __req__ = {'Package': ['name'], | def __init__(self, logger): self.logger = logger |
__new_req__ = {'Package': ['name'], 'Instance': ['version', 'release', 'arch']} __new_ireq__ = {'Package': ['name'], \ 'Instance': []} __gpg_req__ = {'Package': ['name', 'version']} __gpg_ireq__ = {'Package': ['name', 'version']} __new_gpg_req__ = {'Package': ['name'], 'Instance': ['version', 'release']} __new_gpg_... | def __init__(self, logger): self.logger = logger | |
if entry.get('mode', 'default') == 'supervised': pstatus, pout = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name')) if pstatus: self.cmd.run('/usr/sbin/service %s start' % (entry.get('name'))) return True | if entry.get('status') == 'on': pstatus = self.cmd.run(self.get_svc_command(entry, 'start'))[0] elif entry.get('status') == 'off': pstatus = self.cmd.run(self.get_svc_command(entry, 'stop'))[0] return not pstatus | def InstallService(self, entry): """Install Service for entry.""" if entry.get('mode', 'default') == 'supervised': pstatus, pout = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name')) if pstatus: self.cmd.run('/usr/sbin/service %s start' % (entry.get('name'))) return True |
opts, args = getopt(argv[1:], "hvudc:s:", ["help", "verbose", "updates" , | opts, args = getopt(argv[1:], "hvudc:s:C", ["help", "verbose", "updates" , | def load_stats(cdata, sdata, vlevel, quick=False, location=''): cursor = connection.cursor() clients = {} cursor.execute("SELECT name, id from reports_client;") [clients.__setitem__(a, b) for a, b in cursor.fetchall()] for node in sdata.findall('Node'): name = node.get('name') if not name in clients: cursor.execute(\ ... |
self.__important__ = [entry.get('name') for struct in config for entry in struct \ if entry.tag in ['Path', 'ConfigFile'] and \ entry.get('name').startswith('/etc/yum.d') or entry.get('name') == '/etc/yum.conf'] | self.__important__ = [entry.get('name') for struct in config \ for entry in struct \ if entry.tag in ['Path', 'ConfigFile'] and \ entry.get('name').startswith('/etc/yum.d') \ or entry.get('name') == '/etc/yum.conf'] | def __init__(self, logger, setup, config): Bcfg2.Client.Tools.RPMng.RPMng.__init__(self, logger, setup, config) self.__important__ = [entry.get('name') for struct in config for entry in struct \ if entry.tag in ['Path', 'ConfigFile'] and \ entry.get('name').startswith('/etc/yum.d') or entry.get('name') == '/etc/yum.con... |
view, args, kw = resolve(request.path) | view, args, kw = resolve(request.META['PATH_INFO']) | def _handle_timeview(request, **kwargs): """Send any posts back.""" if request.method == 'POST': cal_date = request.POST['cal_date'] try: fmt = "%Y/%m/%d" if cal_date.find(' ') > -1: fmt += " %H:%M" timestamp = datetime(*strptime(cal_date, fmt)[0:6]) view, args, kw = resolve(request.path) kw['year'] = "%0.4d" % timesta... |
self.session_cache[address] = (time.time(), user) | self.session_cache[address] = (time.time(), client) | def AuthenticateConnection(self, cert, user, password, address): '''This function checks auth creds''' if cert: id_method = 'cert' certinfo = dict([x[0] for x in cert['subject']]) # look at cert.cN client = certinfo['commonName'] self.debug_log("Got cN %s; using as client name" % client) auth_type = self.auth.get(clien... |
cursor.close() connection.close() | try: cursor.close() connection.close() except: pass | def dosync(): """Function to do the syncronisation for the models""" # try to detect if it's a fresh new database try: cursor = connection.cursor() # If this table goes missing then don't forget to change it to the new one cursor.execute("Select * from reports_client") # if we get here with no error then the database h... |
if event.filename[0] == '/' or event.filename.startswith('CAs'): | if event.filename[0] == '/': | def HandleEvent(self, event=None): """ Updates which files this plugin handles based upon filesystem events. Allows configuration items to be added/removed without server restarts. """ action = event.code2str() if event.filename[0] == '/' or event.filename.startswith('CAs'): return epath = "".join([self.data, self.hand... |
self.ca_passphrases[ca] = cp.get('sslca', ca+'_passphrase') | self.CAs[ca] = dict(cp.items('sslca_'+ca)) | def HandleEvent(self, event=None): """ Updates which files this plugin handles based upon filesystem events. Allows configuration items to be added/removed without server restarts. """ action = event.code2str() if event.filename[0] == '/' or event.filename.startswith('CAs'): return epath = "".join([self.data, self.hand... |
ca_config = "".join([self.data, '/CAs/', ca, '/', 'openssl.cnf']) | ca_config = self.CAs[ca]['config'] | def build_cert(self, entry, metadata): """ creates a new certificate according to the specification """ req_config = self.build_req_config(entry, metadata) req = self.build_request(req_config, entry) ca = self.cert_specs[entry.get('name')]['ca'] ca_config = "".join([self.data, '/CAs/', ca, '/', 'openssl.cnf']) days = s... |
passphrase = self.ca_passphrases[ca] cmd = "openssl ca -config %s -in %s -days %s -batch -passin pass:%s" % (ca_config, req, days, passphrase) | passphrase = self.CAs[ca].get('passphrase') if passphrase: cmd = "openssl ca -config %s -in %s -days %s -batch -passin pass:%s" % (ca_config, req, days, passphrase) else: cmd = "openssl ca -config %s -in %s -days %s -batch" % (ca_config, req, days) | def build_cert(self, entry, metadata): """ creates a new certificate according to the specification """ req_config = self.build_req_config(entry, metadata) req = self.build_request(req_config, entry) ca = self.cert_specs[entry.get('name')]['ca'] ca_config = "".join([self.data, '/CAs/', ca, '/', 'openssl.cnf']) days = s... |
__req__ = {'Package': ['name', 'version']} | __req__ = {'Package': ['name', 'version'], 'Path': ['type']} | def __init__(self, logger): self.logger = logger |
if entry.get('type') == 'ignore' ] | if entry.tag == 'Path' and \ entry.get('type') == 'ignore' ] | def __init__(self, logger, setup, config): self.yb = yum.YumBase() Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config) self.ignores = [ entry.get('name') for struct in config \ for entry in struct \ if entry.get('type') == 'ignore' ] self.instance_status = {} self.extra_instances = [] self.modlists = {} se... |
self.__important__ = [entry.get('name') for struct in config for entry in struct \ | self.__important__ = [entry.get('name') \ for struct in config for entry in struct \ | def __init__(self, logger, setup, config): self.__important__ = [entry.get('name') for struct in config for entry in struct \ if entry.tag == 'Path' and \ entry.get('important') in ['true', 'True']] self.setup = setup self.logger = logger if not hasattr(self, '__ireq__'): self.__ireq__ = self.__req__ self.config = conf... |
self.logger.debug('Setting state to true for pkg %s' % (entry.get('name'))) | self.logger.debug('Setting state to true for pkg %s' % \ (entry.get('name'))) | def Install(self, packages, states): """ Run a one-pass install, followed by single pkg installs in case of failure. """ self.logger.info("Trying single pass package install for pkgtype %s" % \ self.pkgtype) |
self.logger.info("Forcing state to true for pkg %s" % (pkg.get('name'))) | self.logger.info("Forcing state to true for pkg %s" % \ (pkg.get('name'))) | def Install(self, packages, states): """ Run a one-pass install, followed by single pkg installs in case of failure. """ self.logger.info("Trying single pass package install for pkgtype %s" % \ self.pkgtype) |
self.logger.error("Failed to install package %s" % (pkg.get('name'))) | self.logger.error("Failed to install package %s" % \ (pkg.get('name'))) | def Install(self, packages, states): """ Run a one-pass install, followed by single pkg installs in case of failure. """ self.logger.info("Trying single pass package install for pkgtype %s" % \ self.pkgtype) |
status = (rc == 0) | return (rc == 0) | def InstallService(self, entry): ''' Install Service entry In supervised mode we also take care it's (not) running ''' self.logger.info('Installing Service %s' % entry.get('name')) if entry.get('status') == 'on': # make sure it's enabled cmd = '/sbin/rc-update add %s default' rc = self.cmd.run(cmd % entry.get('name'))[... |
return status | return False | def InstallService(self, entry): ''' Install Service entry In supervised mode we also take care it's (not) running ''' self.logger.info('Installing Service %s' % entry.get('name')) if entry.get('status') == 'on': # make sure it's enabled cmd = '/sbin/rc-update add %s default' rc = self.cmd.run(cmd % entry.get('name'))[... |
elif words[0] == 'Depends': | elif words[0] in ['Depends', 'Pre-Depends']: | def read_files(self): bdeps = dict() bprov = dict() for fname in self.files: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] if barch not in bdeps: bdeps[barch] = dict() bprov[barch] = dict() try: reader = gzip.GzipFile(fname) except: print("Failed to read file %s" % fname) raise for line in rea... |
self.gpg_keyids = self.getinstalledgpg() | def queuePkg(pkg, inst, queue): if pkg.get('name') == 'gpg-pubkey': gpg_keys.append(inst) else: queue.append(inst) | |
elif "is not installed" in item: | elif "is not installed" in item or "missing file" in item: | def VerifyDebsums(self, entry, modlist): output = self.cmd.run("/usr/bin/debsums -as %s" % entry.get('name'))[1] if len(output) == 1 and "no md5sums for" in output[0]: self.logger.info("Package %s has no md5sums. Cannot verify" % \ entry.get('name')) entry.set('qtext', "Reinstall Package %s-%s to setup md5sums? (y/N) "... |
return item in self.packages['global'] or item in self.packages[arch[0]] | return (item in self.packages['global'] or item in self.packages[arch[0]]) and \ item not in self.blacklist and \ ((len(self.whitelist) == 0) or item in self.whitelist) | def is_package(self, metadata, item): arch = [a for a in self.arches if a in metadata.groups] if not arch: return False return item in self.packages['global'] or item in self.packages[arch[0]] |
return pkg in self.pkgnames | return pkg in self.pkgnames and \ pkg not in self.blacklist and \ (len(self.whitelist) == 0 or pkg in self.whitelist) | def is_package(self, _, pkg): return pkg in self.pkgnames |
blacklisted = set() for source in sources: blacklisted.update(source.blacklist) | def complete(self, meta, input_requirements, debug=False): '''Build the transitive closure of all package dependencies | |
if current in blacklisted: continue | def complete(self, meta, input_requirements, debug=False): '''Build the transitive closure of all package dependencies | |
try: deps = source.get_deps(meta, current) break except: continue | if source.is_pkg(meta, current): try: deps = source.get_deps(meta, current) break except: continue | def complete(self, meta, input_requirements, debug=False): '''Build the transitive closure of all package dependencies |
try: deps = source.get_deps(meta, pkgname) except: continue for rpkg in deps: if rpkg in pkgnames: redundant.add(rpkg) | if source.is_pkg(meta, current): try: deps = source.get_deps(meta, pkgname) except: continue for rpkg in deps: if rpkg in pkgnames: redundant.add(rpkg) | def make_non_redundant(self, meta, plname=None, plist=None): '''build a non-redundant version of a list of packages |
self.installed_action = 'install' self.pkg_checks = 'true' self.pkg_verify = 'true' self.version_fail_action = 'upgrade' self.verify_fail_action = 'reinstall' self.installed_action = CP.get(self.name, "installed_action", self.installed_action) self.pkg_checks = CP.get(self.name, "pkg_checks", self.pkg_checks) self.pkg... | truth = ['true', 'yes', '1'] self.pkg_checks = CP.get(self.name, "pkg_checks", "true").lower() \ in truth self.pkg_verify = CP.get(self.name, "pkg_verify", "true").lower() \ in truth self.doInstall = CP.get(self.name, "installed_action", "install").lower() == "install" self.doUpgrade = CP.get(self.name, "version_fail... | def _loadConfig(self): # Process the YUMng section from the config file. CP = Parser() CP.read(self.setup.get('setup')) |
self.logger.debug("YUMng: installed_action = %s" \ % self.installed_action) self.logger.debug("YUMng: pkg_checks = %s" % self.pkg_checks) self.logger.debug("YUMng: pkg_verify = %s" % self.pkg_verify) self.logger.debug("YUMng: version_fail_action = %s" \ % self.version_fail_action) self.logger.debug("YUMng: verify_fail_... | self.logger.debug("YUMng: Install missing: %s" \ % self.doInstall) self.logger.debug("YUMng: pkg_checks: %s" % self.pkg_checks) self.logger.debug("YUMng: pkg_verify: %s" % self.pkg_verify) self.logger.debug("YUMng: Upgrade on version fail: %s" \ % self.doUpgrade) self.logger.debug("YUMng: Reinstall on verify fail: %s" ... | def _loadConfig(self): # Process the YUMng section from the config file. CP = Parser() CP.read(self.setup.get('setup')) |
pkg_checks = self.pkg_checks.lower() == 'true' and \ | pkg_checks = self.pkg_checks and \ | def VerifyPackage(self, entry, modlist, pinned_version=None): """ Verify Package status for entry. Performs the following: - Checks for the presence of required Package Instances. - Compares the evra 'version' info against self.installed{}. - RPM level package verify (rpm --verify). - Checks for the presence of unrequi... |
pkg_verify = self.pkg_verify.lower() == 'true' and \ | pkg_verify = self.pkg_verify and \ | def VerifyPackage(self, entry, modlist, pinned_version=None): """ Verify Package status for entry. Performs the following: - Checks for the presence of required Package Instances. - Compares the evra 'version' info against self.installed{}. - RPM level package verify (rpm --verify). - Checks for the presence of unrequi... |
try: vResult = _POs[0].verify(fast=self.setup.get('quick', False)) except TypeError: vResult = _POs[0].verify() | vResult = self._verifyHelper(_POs[0]) | def VerifyPackage(self, entry, modlist, pinned_version=None): """ Verify Package status for entry. Performs the following: - Checks for the presence of required Package Instances. - Compares the evra 'version' info against self.installed{}. - RPM level package verify (rpm --verify). - Checks for the presence of unrequi... |
Try and fix everything that RPMng.VerifyPackages() found wrong for | Try and fix everything that YUMng.VerifyPackages() found wrong for | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. |
NOTE: YUM can not reinstall a package that it thinks is already installed. | def Install(self, packages, states): """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded or upgraded. | |
if status.get('installed', False) == False: | if not status.get('installed', False) and self.doInstall: | def queuePkg(pkg, inst, queue): if pkg.get('name') == 'gpg-pubkey': gpg_keys.append(inst) else: queue.append(inst) |
elif status.get('version_fail', False) == True: | elif status.get('version_fail', False) and self.doUpgrade: | def queuePkg(pkg, inst, queue): if pkg.get('name') == 'gpg-pubkey': gpg_keys.append(inst) else: queue.append(inst) |
elif status.get('verify_fail', False) == True: | elif status.get('verify_fail', False) and self.doReinst: | def queuePkg(pkg, inst, queue): if pkg.get('name') == 'gpg-pubkey': gpg_keys.append(inst) else: queue.append(inst) |
msg = "Internal error install/upgrade/reinstall-ing: " self.logger.error("YUMng: %s%s" % \ (msg, pkg.get('name'))) | pass | def queuePkg(pkg, inst, queue): if pkg.get('name') == 'gpg-pubkey': gpg_keys.append(inst) else: queue.append(inst) |
if output.split(' ')[1].split('/')[1].startswith('running'): entry.set('current_status', 'on') if entry.get('status') == 'off': status = False | try: running = output.split(' ')[1].split('/')[1].startswith('running') if running: entry.set('current_status', 'on') if entry.get('status') == 'off': status = False else: status = True | def VerifyService(self, entry, _): '''Verify Service status for entry |
status = True else: | entry.set('current_status', 'off') if entry.get('status') == 'on': status = False else: status = True except IndexError: | def VerifyService(self, entry, _): '''Verify Service status for entry |
if entry.get('status') == 'on': status = False else: status = True | status = False | def VerifyService(self, entry, _): '''Verify Service status for entry |
'''Unified interface for handling group-specific data (e.g. .G | def bind_entry(self, entry, metadata): '''Return the appropriate interpreted template from the set of available templates''' self.bind_info_to_entry(entry, metadata) matching = self.get_matching(metadata) | |
gprofiles = [profile for profile in self.profiles if \ self.groups[profile][1].issuperset(groups)] return self.get_client_names_by_profiles(gprofiles) | mdata = [self.core.build_metadata(client) for client in self.clients.keys()] return [md.hostname for md in mdata if md.groups.issuperset(groups)] | def get_client_names_by_groups(self, groups): gprofiles = [profile for profile in self.profiles if \ self.groups[profile][1].issuperset(groups)] return self.get_client_names_by_profiles(gprofiles) |
django.core.management.call_command("loaddata", fixture_labels=['initial_version'], verbosity=0) | django.core.management.call_command("loaddata", 'initial_version.xml', verbosity=0) | def dosync(): """Function to do the syncronisation for the models""" # try to detect if it's a fresh new database try: cursor = connection.cursor() # If this table goes missing then don't forget to change it to the new one cursor.execute("Select * from reports_client") # if we get here with no error then the database h... |
open(fileloc, 'w').write(open(temploc).read()) open(publoc, 'w').write(open("%s.pub" % temploc).read()) | shutil.copy(temploc, fileloc) shutil.copy("%s.pub" % temploc, publoc) | def GenerateHostKeys(self, client): '''Generate new host keys for client''' keylist = [keytmpl % client for keytmpl in self.hostkeys] for hostkey in keylist: if 'ssh_host_rsa_key.H_' == hostkey[:19]: keytype = 'rsa' elif 'ssh_host_dsa_key.H_' == hostkey[:19]: keytype = 'dsa' else: keytype = 'rsa1' |
bdeps[barch][pkgname] = [] | def read_files(self): bdeps = dict() bprov = dict() for fname in self.files: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] if barch not in bdeps: bdeps[barch] = dict() bprov[barch] = dict() try: reader = gzip.GzipFile(fname) except: print("Failed to read file %s" % fname) raise for line in rea... | |
sock.settimeout(90) | def get_request(self): (sock, sockinfo) = self.socket.accept() sock.settimeout(90) sslsock = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile, keyfile=self.keyfile, cert_reqs=self.mode, ca_certs=self.ca, ssl_version=self.ssl_protocol) return sslsock, sockinfo | |
self.connection.unwrap() self.connection.close() os.close(self.connection.fileno()) | def finish(self): # shut down the connection if not self.wfile.closed: self.wfile.flush() self.wfile.close() self.rfile.close() self.connection.unwrap() self.connection.close() os.close(self.connection.fileno()) | |
if xsource.find('Recommended').text is not None: | if xsource.find('Recommended').text == 'true': | def source_from_xml(xsource): ret = dict([('rawurl', False), ('url', False)]) for key, tag in [('groups', 'Group'), ('components', 'Component'), ('arches', 'Arch'), ('blacklist', 'Blacklist')]: ret[key] = [item.text for item in xsource.findall(tag)] # version and component need to both contain data for sources to work ... |
self.cachefile = self.escape_url(self.url + '@' + version) + '.data' | if not self.rawurl: self.cachefile = self.escape_url(self.url + '@' + self.version) + '.data' else: self.cachefile = self.escape_url(self.rawurl) + '.data' | def __init__(self, basepath, url, version, arches, components, groups, rawurl, blacklist, recommended): Source.__init__(self, basepath, url, version, arches, components, groups, rawurl, blacklist, recommended) self.cachefile = self.escape_url(self.url + '@' + version) + '.data' self.pkgnames = set() |
return ["%sdists/%s/%s/binary-%s/Packages.gz" % \ (self.url, self.version, part, arch) for part in self.components \ for arch in self.arches] | if not self.rawurl: return ["%sdists/%s/%s/binary-%s/Packages.gz" % \ (self.url, self.version, part, arch) for part in self.components \ for arch in self.arches] else: return ["%sPackages.gz" % (self.rawurl)] | def get_urls(self): return ["%sdists/%s/%s/binary-%s/Packages.gz" % \ (self.url, self.version, part, arch) for part in self.components \ for arch in self.arches] |
def get_aptsrc(self): return ["deb %s %s %s" % (self.url, self.version, " ".join(self.components)), "deb-src %s %s %s" % (self.url, self.version, " ".join(self.components))] | def get_urls(self): return ["%sdists/%s/%s/binary-%s/Packages.gz" % \ (self.url, self.version, part, arch) for part in self.components \ for arch in self.arches] | |
barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] | if not self.rawurl: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] else: barch = self.arches[0] | def read_files(self): bdeps = dict() bprov = dict() if self.recommended: depfnames = ['Depends', 'Pre-Depends', 'Recommends'] else: depfnames = ['Depends', 'Pre-Depends'] for fname in self.files: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] if barch not in bdeps: bdeps[barch] = dict() bprov[b... |
s = "YUMng: chosing: %s" % pkg.name | s = "YUMng: choosing: %s" % pkg.name | def VerifyPackage(self, entry, modlist): pinned_version = None if entry.get('version', False) == 'auto': # old style entry; synthesize Instances from current installed if entry.get('name') not in self.yum_installed and \ entry.get('name') not in self.yum_avail: # new entry; fall back to default entry.set('version', 'an... |
raise self.send_response(500) self.end_headers() | try: self.send_response(500) self.end_headers() except: (type, msg) = sys.exc_info()[:2] self.logger.error("Error sending 500 response (%s): %s" % \ (type, msg)) raise | def do_POST(self): try: max_chunk_size = 10*1024*1024 size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: try: select.select([self.rfile.fileno()], [], [], 3) except select.error: print "got select timeout" raise chunk_size = min(size_remaining, max_chunk_size) L.append(self.rfile.read(chu... |
self.send_response(200) self.send_header("Content-type", "text/xml") self.send_header("Content-length", str(len(response))) self.end_headers() self.wfile.write(response) | try: self.send_response(200) self.send_header("Content-type", "text/xml") self.send_header("Content-length", str(len(response))) self.end_headers() failcount = 0 while True: try: self.wfile.write(response) break except ssl.SSLError, e: if str(e).find("SSL3_WRITE_PENDING") < 0: raise self.logger.error("SSL3_WRITE_PENDI... | def do_POST(self): try: max_chunk_size = 10*1024*1024 size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: try: select.select([self.rfile.fileno()], [], [], 3) except select.error: print "got select timeout" raise chunk_size = min(size_remaining, max_chunk_size) L.append(self.rfile.read(chu... |
logger.error("Packages: File read failed; falling back to file download") | logger.error("Packages: File read failed; " "falling back to file download") | def setup_data(self, force_update=False): should_read = True should_download = False if os.path.exists(self.cachefile): try: self.load_state() should_read = False except: logger.error("Cachefile %s load failed; falling back to file read"\ % (self.cachefile)) if should_read: try: self.read_files() except: logger.error("... |
raw_dep = re.sub('\(.*\)', '', dep) if '|' in raw_dep: | if '|' in dep: cdeps = [re.sub('\(.*\)', '', cdep) for cdep in dep.split('|')] | def read_files(self): bdeps = dict() bprov = dict() for fname in self.files: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] if barch not in bdeps: bdeps[barch] = dict() bprov[barch] = dict() try: reader = gzip.GzipFile(fname) except: print("Failed to read file %s" % fname) raise for line in rea... |
dyn_list = [x.strip() for x in raw_dep.split('|')] bprov[barch][dyn_dname] = set(dyn_list) | bprov[barch][dyn_dname] = set(cdeps) | def read_files(self): bdeps = dict() bprov = dict() for fname in self.files: barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:] if barch not in bdeps: bdeps[barch] = dict() bprov[barch] = dict() try: reader = gzip.GzipFile(fname) except: print("Failed to read file %s" % fname) raise for line in rea... |
for plugin in self.bcore.plugins.values(): if isinstance(plugin, Bcfg2.Server.Plugin.Version): | for vcsplugin in self.bcore.plugins.values(): if isinstance(vcsplugin, Bcfg2.Server.Plugin.Version): | def PullEntry(self, client, etype, ename): """Make currently recorded client state correct for entry.""" new_entry = self.BuildNewEntry(client, etype, ename) |
plugin.commit_data([files], comment) | vcsplugin.commit_data([files], comment) | def PullEntry(self, client, etype, ename): """Make currently recorded client state correct for entry.""" new_entry = self.BuildNewEntry(client, etype, ename) |
Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup) | Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, cfg) | def __init__(self, logger, setup, cfg): self.installed = {} self.pending_upgrades = set() self.image = image.Image() self.image.find_root('/', False) self.image.load_config() Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup) self.cfg = cfg |
names[cmeta.hostname].update(newips) if True: for ip in newips: try: names[cmeta.hostname].update(self.get_namecache_entry(ip)) except: continue | names[cmeta.hostname].update(newips) if True: for ip in newips: try: names[cmeta.hostname].update(self.get_namecache_entry(ip)) except: continue names[cmeta.hostname] = sorted(names[cmeta.hostname]) | def get_skn(self): '''build memory cache of the ssh known hosts file''' if not self.__skn: self.__skn = "\n".join([value.data for key, value in \ self.entries.iteritems() if \ key.endswith('.static')]) names = dict() # if no metadata is registered yet, defer if len(self.core.metadata.query.all()) == 0: self.__skn = Fal... |
def __init__(self, logger, cfg, setup): | def __init__(self, logger, setup, cfg): | def __init__(self, logger, cfg, setup): self.installed = {} self.pending_upgrades = set() self.image = image.Image() self.image.find_root('/', False) self.image.load_config() Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup) self.cfg = cfg |
options = {'plugins': Bcfg2.Options.SERVER_PLUGINS} | options = {'plugins': Bcfg2.Options.SERVER_PLUGINS, 'configfile': Bcfg2.Options.CFILE} | def __init__(self, configfile, usage, pwhitelist=None, pblacklist=None): Mode.__init__(self, configfile) options = {'plugins': Bcfg2.Options.SERVER_PLUGINS} setup = Bcfg2.Options.OptionParser(options) setup.hm = usage setup.parse(sys.argv[1:]) if pwhitelist is not None: setup['plugins'] = [x for x in setup['plugins'] i... |
def Verifynonexistent(self, entry, _): return True def Installnonexistent(self, entry): return True | def Verifynonexistent(self, entry, _): # FIXME: not implemented return True | |
cert = self.build_cert(entry, metadata) | cert = self.build_cert(key_filename, entry, metadata) | def get_cert(self, entry, metadata): """ either grabs a prexisting cert hostfile, or triggers the generation of a new cert if one doesn't exist. """ # set path type and permissions, otherwise bcfg2 won't bind the file permdata = {'owner':'root', 'group':'root', 'type':'file', 'perms':'644'} [entry.attrib.__setitem__(ke... |
cert = "".join([self.data, '/', filename]) | cert = self.data + filename | def verify_cert(self, filename, entry): """ check that a certificate validates against the ca cert, and that it has not expired. """ chaincert = self.CAs[self.cert_specs[entry.get('name')]['ca']].get('chaincert') cert = "".join([self.data, '/', filename]) cmd = "openssl verify -CAfile %s %s" % (chaincert, cert) proc = ... |
proc = Popen(cmd, shell=True) proc.communicate() if proc.returncode != 0: return False return True def build_cert(self, entry, metadata): | res = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT).stdout.read() if res == cert + ": OK\n" return True return False def build_cert(self, key_filename, entry, metadata): | def verify_cert(self, filename, entry): """ check that a certificate validates against the ca cert, and that it has not expired. """ chaincert = self.CAs[self.cert_specs[entry.get('name')]['ca']].get('chaincert') cert = "".join([self.data, '/', filename]) cmd = "openssl verify -CAfile %s %s" % (chaincert, cert) proc = ... |
req = self.build_request(req_config, entry) | req = self.build_request(key_filename, req_config, entry) | def build_cert(self, entry, metadata): """ creates a new certificate according to the specification """ req_config = self.build_req_config(entry, metadata) req = self.build_request(req_config, entry) ca = self.cert_specs[entry.get('name')]['ca'] ca_config = self.CAs[ca]['config'] days = self.cert_specs[entry.get('name'... |
deps = set() pname = list(provset)[0] | pkg_to_add = list(provset)[0] elif satisfiers: if item_is_pkg and requirement in satisfiers: pkg_to_add = requirement else: pkg_to_add = list(satisfiers)[0] elif item_is_pkg: pkg_to_add = requirement else: raise SomeData if debug: logger.debug("Adding Package %s for %s" % (pkg_to_add, requirement)) try: deps = self... | def resolve_requirement(self, metadata, requirement, packages, debug=False): '''Resolve requirement to packages and or additional requirements |
logger.debug("Adding Package %s for %s" % (pname, requirement)) try: deps = self.get_deps(metadata, pname) if debug: logger.debug("Package %s: adding new deps %s" \ % (pname, deps)) except: pass return (set([pname]), deps) satisfiers = provset.intersection(packages) if satisfiers: if debug: logger.debug("Requirement ... | logger.debug("Package %s: adding new deps %s" \ % (pkg_to_add, deps)) except: pass return (set([pkg_to_add]), deps) | def resolve_requirement(self, metadata, requirement, packages, debug=False): '''Resolve requirement to packages and or additional requirements |
self.cachefile = self.escape_url(self.baseurl) + '.data' | self.cachefile = self.escape_url(self.baseurl + '@' + version) + '.data' | def __init__(self, basepath, url, version, arches, components, groups, rawurl): Source.__init__(self, basepath, url, version, arches, components, groups, rawurl) if not self.rawurl: self.baseurl = self.url + '%(version)s/%(component)s/%(arch)s/' else: self.baseurl = self.rawurl self.cachefile = self.escape_url(self.bas... |
self.cachefile = self.escape_url(self.url) + '.data' | self.cachefile = self.escape_url(self.url + '@' + version) + '.data' | def __init__(self, basepath, url, version, arches, components, groups, rawurl): Source.__init__(self, basepath, url, version, arches, components, groups, rawurl) self.cachefile = self.escape_url(self.url) + '.data' self.pkgnames = set() |
def delete(self, groupId, adminInfo): | def delete(self, groupId): | def delete(self, groupId, adminInfo): assert groupId, 'No group ID' assert adminInfo, 'No admin' if type(groupId) == unicode: groupId = groupId.encode('ascii', 'ignore') |
assert adminInfo, 'No admin' | def delete(self, groupId, adminInfo): assert groupId, 'No group ID' assert adminInfo, 'No admin' if type(groupId) == unicode: groupId = groupId.encode('ascii', 'ignore') | |
groupInfo = createObject('groupserver.UserFromId', self.siteInfo.siteObj, groupId) | def delete(self, groupId, adminInfo): assert groupId, 'No group ID' assert adminInfo, 'No admin' if type(groupId) == unicode: groupId = groupId.encode('ascii', 'ignore') | |
self.delete_user_group() self.delete_list() | self.delete_user_group(groupId) self.delete_list(groupId) | def delete(self, groupId, adminInfo): assert groupId, 'No group ID' assert adminInfo, 'No admin' if type(groupId) == unicode: groupId = groupId.encode('ascii', 'ignore') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.