def __init__(self, req): """ init with http request object """ # FIXME: should rename some things: # self.bodyFd --> self.body or self.data or ? # self.caChain --> self.caCert self.req = req # turn wsgi.input object into a SmartIO instance so it can be read # more than once if 'wsgi.input' in self.req.headers_in: smartFd = SmartIO(max_mem_size=CFG.MAX_MEM_FILE_SIZE) smartFd.write(self.req.headers_in['wsgi.input'].read()) self.req.headers_in['wsgi.input'] = smartFd self.responseContext = ResponseContext() self.uri = None # '' # Common settings for both the proxy and the redirect # broker and redirect immediately alter these for their own purposes self.caChain = CFG.CA_CHAIN self.httpProxy = CFG.HTTP_PROXY self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD if not self.httpProxyUsername: self.httpProxyPassword = '' self.rhnParent = CFG.RHN_PARENT or '' self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(':')[0] CFG.set('RHN_PARENT', self.rhnParent)
def __init__(self, req): """ init with http request object """ # FIXME: should rename some things: # self.bodyFd --> self.body or self.data or ? # self.caChain --> self.caCert self.req = req # turn wsgi.input object into a SmartIO instance so it can be read # more than once if 'wsgi.input' in self.req.headers_in: smartFd = SmartIO(max_mem_size=CFG.MAX_MEM_FILE_SIZE) smartFd.write(self.req.headers_in['wsgi.input'].read()) self.req.headers_in['wsgi.input'] = smartFd self.responseContext = ResponseContext() self.uri = None # '' # Common settings for both the proxy and the redirect # broker and redirect immediately alter these for their own purposes self.caChain = CFG.CA_CHAIN self.httpProxy = CFG.HTTP_PROXY self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD if not self.httpProxyUsername: self.httpProxyPassword = '' self.rhnParent = CFG.RHN_PARENT or '' self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(':')[0] CFG.set('RHN_PARENT', self.rhnParent)
def __init__(self, req): """ init with http request object """ # FIXME: should rename some things: # self.bodyFd --> self.body or self.data or ? # self.caChain --> self.caCert self.req = req self.responseContext = ResponseContext() self.uri = None # '' # Common settings for both the proxy and the redirect # broker and redirect immediately alter these for their own purposes self.caChain = CFG.CA_CHAIN self.httpProxy = CFG.HTTP_PROXY self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD if not self.httpProxyUsername: self.httpProxyPassword = '' self.rhnParent = CFG.RHN_PARENT or '' self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(':')[0] CFG.set('RHN_PARENT', self.rhnParent)
def __init__(self, req): """ init with http request object """ # FIXME: should rename some things: # self.bodyFd --> self.body or self.data or ? # self.caChain --> self.caCert self.req = req self.responseContext = ResponseContext() self.uri = None # '' # Common settings for both the proxy and the redirect # broker and redirect immediately alter these for their own purposes self.caChain = CFG.CA_CHAIN self.httpProxy = CFG.HTTP_PROXY self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD if not self.httpProxyUsername: self.httpProxyPassword = "" self.rhnParent = CFG.RHN_PARENT or "" self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(":")[0] CFG.set("RHN_PARENT", self.rhnParent)
def processCommandline(): options = [ Option('--sanity-only', action='store_true', help="confirm certificate sanity. Does not activate " + "the Red Hat Satellite locally or remotely."), Option('--ignore-expiration', action='store_true', help='execute regardless of the expiration ' + 'of the RHN Certificate (not recommended).'), Option('--ignore-version-mismatch', action='store_true', help='execute regardless of version ' + 'mismatch of existing and new certificate.'), Option('-v', '--verbose', action='count', help='be verbose ' + '(accumulable: -vvv means "be *really* verbose").'), Option('--dump-version', action='store', help="requested version of XML dump"), Option('--manifest', action='store', help='the RHSM manifest path/filename to activate for CDN'), Option('--rhn-cert', action='store', help='this option is deprecated, use --manifest instead'), Option('--deactivate', action='store_true', help='deactivate CDN-activated Satellite'), Option('--disconnected', action='store_true', help="activate locally, not subscribe to remote repository"), Option('--manifest-info', action='store_true', help="show information about currently activated manifest"), Option('--manifest-download', action='store_true', help="download new manifest from RHSM to temporary location"), Option('--manifest-refresh', action='store_true', help="download new manifest from RHSM and activate it"), Option('--manifest-reconcile-request', action='store_true', help="request regeneration of entitlement certificates") ] parser = OptionParser(option_list=options) options, args = parser.parse_args() initCFG('server.satellite') if options.verbose is None: options.verbose = 0 CFG.set('DEBUG', options.verbose) rhnLog.initLOG(LOG_PATH, options.verbose) log2disk(0, "Command: %s" % str(sys.argv)) # we take no extra commandline arguments that are not linked to an option if args: writeError( "These arguments make no sense in this context (try --help): %s" % repr(args)) sys.exit(1) # No need to check further if deactivating if options.deactivate: return options if options.sanity_only: options.disconnected = 1 if options.manifest_refresh: options.manifest_download = 1 if CFG.DISCONNECTED and not options.disconnected: msg = """Satellite server has been setup to run in disconnected mode. Either correct server configuration in /etc/rhn/rhn.conf or use --disconnected to activate it locally.""" writeError(msg) sys.exit(1) options.http_proxy = idn_ascii_to_puny(CFG.HTTP_PROXY) options.http_proxy_username = CFG.HTTP_PROXY_USERNAME options.http_proxy_password = CFG.HTTP_PROXY_PASSWORD log(1, 'HTTP_PROXY: %s' % options.http_proxy) log(1, 'HTTP_PROXY_USERNAME: %s' % options.http_proxy_username) log(1, 'HTTP_PROXY_PASSWORD: <password>') return options
def __init__(self, channel_label, repo_type, url=None, fail=False, filters=None, no_errata=False, sync_kickstart=False, latest=False, metadata_only=False, strict=0, excluded_urls=None, no_packages=False, log_dir="reposync", log_level=None, force_kickstart=False, force_all_errata=False, check_ssl_dates=False, force_null_org_content=False): self.regen = False self.fail = fail self.filters = filters or [] self.no_packages = no_packages self.no_errata = no_errata self.sync_kickstart = sync_kickstart self.force_all_errata = force_all_errata self.force_kickstart = force_kickstart self.latest = latest self.metadata_only = metadata_only self.ks_tree_type = 'externally-managed' self.ks_install_type = None initCFG('server.satellite') rhnSQL.initDB() # setup logging log_filename = channel_label + '.log' log_path = default_log_location + log_dir + '/' + log_filename if log_level is None: log_level = 0 CFG.set('DEBUG', log_level) rhnLog.initLOG(log_path, log_level) # os.fchown isn't in 2.4 :/ if isSUSE(): os.system("chgrp www " + log_path) else: os.system("chgrp apache " + log_path) log2disk(0, "Command: %s" % str(sys.argv)) log2disk(0, "Sync of channel started.") self.channel_label = channel_label self.channel = self.load_channel() if not self.channel: log(0, "Channel %s does not exist." % channel_label) if not self.channel['org_id'] or force_null_org_content: self.org_id = None else: self.org_id = int(self.channel['org_id']) if not url: # TODO:need to look at user security across orgs h = rhnSQL.prepare("""select s.id, s.source_url, s.label from rhnContentSource s, rhnChannelContentSource cs where s.id = cs.source_id and cs.channel_id = :channel_id""") h.execute(channel_id=int(self.channel['id'])) source_data = h.fetchall_dict() self.urls = [] if excluded_urls is None: excluded_urls = [] if source_data: for row in source_data: if row['source_url'] not in excluded_urls: self.urls.append( (row['id'], row['source_url'], row['label'])) else: self.urls = [(None, u, None) for u in url] if not self.urls: log2(0, 0, "Channel %s has no URL associated" % channel_label, stream=sys.stderr) self.repo_plugin = self.load_plugin(repo_type) self.strict = strict self.all_packages = [] self.check_ssl_dates = check_ssl_dates # Init cache for computed checksums to not compute it on each reposync run again self.checksum_cache = rhnCache.get(checksum_cache_filename) if self.checksum_cache is None: self.checksum_cache = {}
def __init__(self, channel_label, repo_type, url=None, fail=False, filters=None, no_errata=False, sync_kickstart=False, latest=False, metadata_only=False, strict=0, excluded_urls=None, no_packages=False, log_dir="reposync", log_level=None): self.regen = False self.fail = fail self.filters = filters or [] self.no_packages = no_packages self.no_errata = no_errata self.sync_kickstart = sync_kickstart self.latest = latest self.metadata_only = metadata_only self.ks_tree_type = 'externally-managed' self.ks_install_type = 'generic_rpm' initCFG('server.satellite') rhnSQL.initDB() # setup logging log_filename = channel_label + '.log' log_path = default_log_location + log_dir + '/' + log_filename if log_level is None: log_level = 0 CFG.set('DEBUG', log_level) rhnLog.initLOG(log_path, log_level) # os.fchown isn't in 2.4 :/ if isSUSE(): os.system("chgrp www " + log_path) else: os.system("chgrp apache " + log_path) log2disk(0, "Command: %s" % str(sys.argv)) log2disk(0, "Sync of channel started.") self.channel_label = channel_label self.channel = self.load_channel() if not self.channel: log(0, "Channel %s does not exist." % channel_label) if not url: # TODO:need to look at user security across orgs h = rhnSQL.prepare("""select s.id, s.source_url, s.label, fm.channel_family_id from rhnContentSource s, rhnChannelContentSource cs, rhnChannelFamilyMembers fm where s.id = cs.source_id and cs.channel_id = fm.channel_id and cs.channel_id = :channel_id""") h.execute(channel_id=int(self.channel['id'])) source_data = h.fetchall_dict() self.urls = [] if excluded_urls is None: excluded_urls = [] if source_data: for row in source_data: if row['source_url'] not in excluded_urls: self.urls.append((row['id'], row['source_url'], row['label'], row['channel_family_id'])) else: self.urls = [(None, u, None, None) for u in url] if not self.urls: log2stderr(0, "Channel %s has no URL associated" % channel_label) self.repo_plugin = self.load_plugin(repo_type) self.strict = strict self.all_packages = []
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None, mount_point=None, consider_full=False, force_kickstarts=False, force_all_errata=False, email=False, import_batch_size=None): if log_level is None: log_level = 0 self.log_level = log_level CFG.set('DEBUG', log_level) self.email = email if self.email: initEMAIL_LOG() rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') self.cdn_repository_manager = CdnRepositoryManager(mount_point) self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms if self.no_packages and self.no_rpms: log(0, "Parameter --no-rpms has no effect.") self.no_kickstarts = no_kickstarts self.force_all_errata = force_all_errata self.force_kickstarts = force_kickstarts if self.no_kickstarts and self.force_kickstarts: log(0, "Parameter --force-kickstarts has no effect.") if mount_point: self.mount_point = "file://" + mount_point self.consider_full = consider_full else: self.mount_point = CFG.CDN_ROOT self.consider_full = True verify_mappings() f = None # try block in try block - this is hack for python 2.4 compatibility # to support finally try: try: # Channel families mapping to channels f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') self.families = json.load(f) f.close() # Channel metadata f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r') self.channel_metadata = json.load(f) f.close() # Dist/Release channel mapping f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') self.channel_dist_mapping = json.load(f) f.close() # Kickstart metadata f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r') self.kickstart_metadata = json.load(f) f.close() except IOError: e = sys.exc_info()[1] log(1, "Ignoring channel mappings: %s" % e) self.families = {} self.channel_metadata = {} self.channel_dist_mapping = {} self.kickstart_metadata = {} finally: if f is not None: f.close() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels, entitled null-org channels and custom channels with associated # CDN repositories h = rhnSQL.prepare(""" select distinct c.label, c.org_id from rhnChannelFamilyPermissions cfp inner join rhnChannelFamily cf on cfp.channel_family_id = cf.id inner join rhnChannelFamilyMembers cfm on cf.id = cfm.channel_family_id inner join rhnChannel c on cfm.channel_id = c.id where c.org_id is null or (c.org_id is not null and exists ( select cs.id from rhnContentSource cs inner join rhnChannelContentSource ccs on ccs.source_id = cs.id where ccs.channel_id = c.id and cs.org_id is null ) ) order by c.org_id nulls first, label """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = {} for channel in channels: # Custom channel repositories not available, don't mark as synced if channel['org_id']: repos = self.cdn_repository_manager.list_associated_repos( channel['label']) if not all([ self.cdn_repository_manager. check_repository_availability(r) for r in repos ]): continue self.synced_channels[channel['label']] = channel['org_id'] # Select available channel families from DB h = rhnSQL.prepare(""" select distinct label from rhnChannelFamilyPermissions cfp inner join rhnChannelFamily cf on cfp.channel_family_id = cf.id where cf.org_id is null """) h.execute() families = h.fetchall_dict() or [] self.entitled_families = [f['label'] for f in families] self.import_batch_size = import_batch_size
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None): self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms self.no_kickstarts = no_kickstarts if log_level is None: log_level = 0 self.log_level = log_level CFG.set('DEBUG', log_level) rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') f = None # try block in try block - this is hack for python 2.4 compatibility # to support finally try: try: # Channel families mapping to channels f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') self.families = json.load(f) f.close() # Channel metadata f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r') self.channel_metadata = json.load(f) f.close() # Dist/Release channel mapping f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') self.channel_dist_mapping = json.load(f) f.close() # Channel to repositories mapping f = open(constants.CONTENT_SOURCE_MAPPING_PATH, 'r') self.content_source_mapping = json.load(f) f.close() # Kickstart metadata f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r') self.kickstart_metadata = json.load(f) f.close() # Channel to kickstart repositories mapping f = open(constants.KICKSTART_SOURCE_MAPPING_PATH, 'r') self.kickstart_source_mapping = json.load(f) f.close() except IOError: e = sys.exc_info()[1] log2stderr(0, "ERROR: Problem with loading file: %s" % e) raise CdnMappingsLoadError() finally: if f is not None: f.close() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels h = rhnSQL.prepare(""" select label from rhnChannel where org_id is null """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = [ch['label'] for ch in channels] # Set SSL-keys for channel family self.family_keys = {}
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None, mount_point=None, consider_full=False): self.cdn_repository_manager = CdnRepositoryManager(mount_point) self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms self.no_kickstarts = no_kickstarts if log_level is None: log_level = 0 self.log_level = log_level if mount_point: self.mount_point = "file://" + mount_point self.consider_full = consider_full else: self.mount_point = CFG.CDN_ROOT self.consider_full = True CFG.set('DEBUG', log_level) rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') verify_mappings() f = None # try block in try block - this is hack for python 2.4 compatibility # to support finally try: try: # Channel families mapping to channels f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') self.families = json.load(f) f.close() # Channel metadata f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r') self.channel_metadata = json.load(f) f.close() # Dist/Release channel mapping f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') self.channel_dist_mapping = json.load(f) f.close() # Kickstart metadata f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r') self.kickstart_metadata = json.load(f) f.close() except IOError: e = sys.exc_info()[1] raise CdnMappingsLoadError("Problem with loading file: %s" % e) finally: if f is not None: f.close() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels h = rhnSQL.prepare(""" select label from rhnChannel where org_id is null """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = [ch['label'] for ch in channels]
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None, mount_point=None, consider_full=False, force_kickstarts=False, force_all_errata=False, email=False, import_batch_size=None): if log_level is None: log_level = 0 self.log_level = log_level CFG.set('DEBUG', log_level) self.email = email if self.email: initEMAIL_LOG() rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') self.cdn_repository_manager = CdnRepositoryManager(mount_point) self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms if self.no_packages and self.no_rpms: log(0, "Parameter --no-rpms has no effect.") self.no_kickstarts = no_kickstarts self.force_all_errata = force_all_errata self.force_kickstarts = force_kickstarts if self.no_kickstarts and self.force_kickstarts: log(0, "Parameter --force-kickstarts has no effect.") if mount_point: self.mount_point = "file://" + mount_point self.consider_full = consider_full else: self.mount_point = CFG.CDN_ROOT self.consider_full = True verify_mappings() f = None # try block in try block - this is hack for python 2.4 compatibility # to support finally try: try: # Channel families mapping to channels f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') self.families = json.load(f) f.close() # Channel metadata f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r') self.channel_metadata = json.load(f) f.close() # Dist/Release channel mapping f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') self.channel_dist_mapping = json.load(f) f.close() # Kickstart metadata f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r') self.kickstart_metadata = json.load(f) f.close() except IOError: e = sys.exc_info()[1] log(1, "Ignoring channel mappings: %s" % e) self.families = {} self.channel_metadata = {} self.channel_dist_mapping = {} self.kickstart_metadata = {} finally: if f is not None: f.close() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels, entitled null-org channels and custom channels with associated # CDN repositories h = rhnSQL.prepare(""" select distinct c.label, c.org_id from rhnChannelFamilyPermissions cfp inner join rhnChannelFamily cf on cfp.channel_family_id = cf.id inner join rhnChannelFamilyMembers cfm on cf.id = cfm.channel_family_id inner join rhnChannel c on cfm.channel_id = c.id where c.org_id is null or (c.org_id is not null and exists ( select cs.id from rhnContentSource cs inner join rhnChannelContentSource ccs on ccs.source_id = cs.id where ccs.channel_id = c.id and cs.org_id is null ) ) order by c.org_id nulls first, label """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = {} for channel in channels: # Custom channel repositories not available, don't mark as synced if channel['org_id']: repos = self.cdn_repository_manager.list_associated_repos(channel['label']) if not all([self.cdn_repository_manager.check_repository_availability(r) for r in repos]): continue self.synced_channels[channel['label']] = channel['org_id'] # Select available channel families from DB h = rhnSQL.prepare(""" select distinct label from rhnChannelFamilyPermissions cfp inner join rhnChannelFamily cf on cfp.channel_family_id = cf.id where cf.org_id is null """) h.execute() families = h.fetchall_dict() or [] self.entitled_families = [f['label'] for f in families] self.import_batch_size = import_batch_size
def processCommandline(): options = [ Option('--sanity-only', action='store_true', help="confirm certificate sanity. Does not activate " + "the Red Hat Satellite locally or remotely."), Option('--ignore-expiration', action='store_true', help='execute regardless of the expiration ' + 'of the RHN Certificate (not recommended).'), Option('--ignore-version-mismatch', action='store_true', help='execute regardless of version ' + 'mismatch of existing and new certificate.'), Option('-v', '--verbose', action='count', help='be verbose ' + '(accumulable: -vvv means "be *really* verbose").'), Option('--dump-version', action='store', help="requested version of XML dump"), Option('--manifest', action='store', help='the RHSM manifest path/filename to activate for CDN'), Option('--rhn-cert', action='store', help='this option is deprecated, use --manifest instead'), Option('--deactivate', action='store_true', help='deactivate CDN-activated Satellite'), Option('--disconnected', action='store_true', help="activate locally, not subscribe to remote repository"), Option('--manifest-info', action='store_true', help="show information about currently activated manifest"), Option('--manifest-download', action='store_true', help="download new manifest from RHSM to temporary location"), Option('--manifest-refresh', action='store_true', help="download new manifest from RHSM and activate it"), Option('--manifest-reconcile-request', action='store_true', help="request regeneration of entitlement certificates") ] parser = OptionParser(option_list=options) options, args = parser.parse_args() initCFG('server.satellite') if options.verbose is None: options.verbose = 0 CFG.set('DEBUG', options.verbose) rhnLog.initLOG(LOG_PATH, options.verbose) log2disk(0, "Command: %s" % str(sys.argv)) # we take no extra commandline arguments that are not linked to an option if args: writeError("These arguments make no sense in this context (try --help): %s" % repr(args)) sys.exit(1) # No need to check further if deactivating if options.deactivate: return options if options.sanity_only: options.disconnected = 1 if options.manifest_refresh: options.manifest_download = 1 if CFG.DISCONNECTED and not options.disconnected: msg = """Satellite server has been setup to run in disconnected mode. Either correct server configuration in /etc/rhn/rhn.conf or use --disconnected to activate it locally.""" writeError(msg) sys.exit(1) options.http_proxy = idn_ascii_to_puny(CFG.HTTP_PROXY) options.http_proxy_username = CFG.HTTP_PROXY_USERNAME options.http_proxy_password = CFG.HTTP_PROXY_PASSWORD log(1, 'HTTP_PROXY: %s' % options.http_proxy) log(1, 'HTTP_PROXY_USERNAME: %s' % options.http_proxy_username) log(1, 'HTTP_PROXY_PASSWORD: <password>') return options
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None, mount_point=None, consider_full=False): self.cdn_repository_manager = CdnRepositoryManager(mount_point) self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms self.no_kickstarts = no_kickstarts if log_level is None: log_level = 0 self.log_level = log_level if mount_point: self.mount_point = "file://" + mount_point self.consider_full = consider_full else: self.mount_point = CFG.CDN_ROOT self.consider_full = True CFG.set('DEBUG', log_level) rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') verify_mappings() f = None # try block in try block - this is hack for python 2.4 compatibility # to support finally try: try: # Channel families mapping to channels f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') self.families = json.load(f) f.close() # Channel metadata f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r') self.channel_metadata = json.load(f) f.close() # Dist/Release channel mapping f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') self.channel_dist_mapping = json.load(f) f.close() # Kickstart metadata f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r') self.kickstart_metadata = json.load(f) f.close() except IOError: e = sys.exc_info()[1] raise CdnMappingsLoadError("Problem with loading file: %s" % e) finally: if f is not None: f.close() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels h = rhnSQL.prepare(""" select label from rhnChannel where org_id is null """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = [ch['label'] for ch in channels]
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False, log_level=None): self.no_packages = no_packages self.no_errata = no_errata self.no_rpms = no_rpms self.no_kickstarts = no_kickstarts if log_level is None: log_level = 0 self.log_level = log_level CFG.set('DEBUG', log_level) rhnLog.initLOG(self.log_path, self.log_level) log2disk(0, "Command: %s" % str(sys.argv)) rhnSQL.initDB() initCFG('server.satellite') try: # Channel families mapping to channels with open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') as f: self.families = json.load(f) # Channel metadata with open(constants.CHANNEL_DEFINITIONS_PATH, 'r') as f: self.channel_metadata = json.load(f) # Dist/Release channel mapping with open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') as f: self.channel_dist_mapping = json.load(f) # Channel to repositories mapping with open(constants.CONTENT_SOURCE_MAPPING_PATH, 'r') as f: self.content_source_mapping = json.load(f) # Kickstart metadata with open(constants.KICKSTART_DEFINITIONS_PATH, 'r') as f: self.kickstart_metadata = json.load(f) # Channel to kickstart repositories mapping with open(constants.KICKSTART_SOURCE_MAPPING_PATH, 'r') as f: self.kickstart_source_mapping = json.load(f) except IOError: e = sys.exc_info()[1] log2stderr(0, "ERROR: Problem with loading file: %s" % e) raise CdnMappingsLoadError() # Map channels to their channel family self.channel_to_family = {} for family in self.families: for channel in self.families[family]['channels']: self.channel_to_family[channel] = family # Set already synced channels h = rhnSQL.prepare(""" select label from rhnChannel where org_id is null """) h.execute() channels = h.fetchall_dict() or [] self.synced_channels = [ch['label'] for ch in channels] # Set SSL-keys for channel family self.family_keys = {}