def save_profile(profile=None, key=None, secret=None, region=None, user_profile=False): '''Save profile in credentials and config files''' credentials_file = get_credentials_path(user_profile) if not credentials_file or not os.path.exists(credentials_file): return config_file = get_config_path(user_profile) if not config_file or not os.path.exists(config_file): return # Read credentials file config = iniparse.ConfigParser() config.read(credentials_file) # Update config if not config.has_section(profile): config.add_section(profile) config.set(profile, 'aws_access_key_id', key) config.set(profile, 'aws_secret_access_key', secret) # Write config with open(credentials_file, 'w') as output: config.write(output) # Read config file config = iniparse.ConfigParser() config.read(config_file) # Update config if not config.has_section(profile): config.add_section(profile) config.set(profile, 'region', region) # Write config with open(config_file, 'w') as output: config.write(output)
def delete_profile(profile=None, user_profile=False): '''Delete profile in credentials and config files''' credentials_file = get_credentials_path(user_profile) if not credentials_file or not os.path.exists(credentials_file): return config_file = get_config_path(user_profile) if not config_file or not os.path.exists(config_file): return # Read credentials file config = iniparse.ConfigParser() config.read(credentials_file) # Update config if config.has_section(profile): config.remove_section(profile) # Write config with open(credentials_file, 'w') as output: config.write(output) # Read config file config = iniparse.ConfigParser() config.read(config_file) # Update config if config.has_section(profile): config.remove_section(profile) # Write config with open(config_file, 'w') as output: config.write(output)
def sections(self): """ Return the list of ini file section names. """ c = iniparse.ConfigParser() c.read(self.inipath) return c.sections()
def __init__(self, configfile, name=None, kickstart=None, release=None, tdl=None): self._repo = None self._name = name self._tdl = tdl self._kickstart = kickstart assert release is not None defaults = { 'workdir': None, 'pkgdatadir': os.environ['OSTBUILD_DATADIR'], 'yum_baseurl': None, 'local_overrides': None } if not os.path.exists(configfile): fail_msg("No config file: " + configfile) settings = iniparse.ConfigParser() settings.read(configfile) for attr in self.ATTRS: try: val = settings.get(release, attr) except (iniparse.NoOptionError, iniparse.NoSectionError), e: try: val = settings.get('DEFAULT', attr) except iniparse.NoOptionError, e: val = defaults.get(attr)
def live_migration_supported(): config = iniparse.ConfigParser() if (config.read(TEMPEST_CONF_FILE) and config.has_section('compute-feature-enabled') and config.has_option('compute-feature-enabled', 'live_migration')): return config.getboolean('compute-feature-enabled', 'live_migration') return False
def accounts_configuration(self): # pylint: disable=no-self-use cur_dir = os.path.dirname(os.path.realpath(__file__)) try: accounts_cfg = iniparse.ConfigParser() accounts_cfg.read(os.path.join(cur_dir, 'accounts.cfg')) except: log.error('I cannot load configuration of the online accounts. ' + 'I cannot continue!') raise return accounts_cfg
def live_migration_supported(): """Determine is live migration is supported.""" config = iniparse.ConfigParser() if (config.read(RallyBase.TEMPEST_CONF_FILE) and config.has_section('compute-feature-enabled') and config.has_option('compute-feature-enabled', 'live_migration')): return config.getboolean('compute-feature-enabled', 'live_migration') return False
def move_conf(original_file, new_file, mapping): """ move each entry in mapping from the original file to the new file. """ # open the original file original = iniparse.ConfigParser() original.readfp(open(original_file)) # open the new file new = iniparse.ConfigParser() new.readfp(open(new_file)) # The mappings dictionary look similar to the deprecation mappings: # (original_section, original_key): (new_section, new_key) for (original_section, original_key) in mapping: try: original_value = original.get(original_section, original_key) except NoOptionError: # the original file does not contain this mapping so continue continue new_section, new_key = mapping.get((original_section, original_key)) if new_section != 'DEFAULT' and not new.has_section(new_section): new.add_section(new_section) print 'Moving [%s] %s from %s to [%s] %s in %s' % \ (original_section, original_key, original_file, new_section, new_key, new_file) # set the option in the new file new.set(new_section, new_key, original_value) # remove the option from the old file original.remove_option(original_section, original_key) with open(original_file, 'wb+') as fh: original.write(fh) with open(new_file, 'wb+') as fh: new.write(fh)
def print_existing_profile(credentials_file): '''Print existing credentials profiles''' if not credentials_file or not os.path.exists(credentials_file): return # Read credentials file config = iniparse.ConfigParser() config.read(credentials_file) if config.sections(): print( f'Already existing profile from {credentials_file}: {config.sections()}' )
def main(): options = parseArgs() # fetch the script options from the ini file iniFile = iniparse.ConfigParser() iniFile.read(options.ini) # Get Server optins from ini server = iniFile.get("Server_Settings", "server") user = iniFile.get("Server_Settings", "user") destination = iniFile.get("Server_Settings", "destination") # Decrypt Passed word using key value in script key = open(iniFile.get("Server_Settings", "keyFile"), "rb").read() f = Fernet(key) password = f.decrypt(iniFile.get("Server_Settings", "password")) # Set max number of backups to keep if iniFile.has_section("Backup_Settings"): limit = int(iniFile.get("Backup_Settings", "limit")) log('Backup Limit set to: %s from INI file\n' % limit) else: limit = options.limit log('Backup Limit set to: %s from Args/default\n' % limit) # Make a note of time of day just before back starts nowKey = datetime.datetime.now().strftime("%Y%m%d%H%M%S") print("Backup Started: %s\n" % nowKey) log("Backup Started: %s\n" % nowKey) ret = createBackup(limit) # Get list of files created during backup # Prevents older EOS-Image files from being copied fileList = getBackupFiles() # Compare file keys and only copy more recent files scpdFiles = [] for path, entry in fileList: if filter(str.isdigit, entry) >= nowKey: dest = destination + entry print("Copying %s to %s %s\n" % (entry, server, dest)) log("Copying %s to %s %s\n" % (entry, server, dest)) if scpFile(path, dest, server, user, password): scpdFiles.append(entry) print('Backup Files copied') pprint(scpdFiles) log("Backup Files copied:\n %s\n" % scpdFiles) nowKey = datetime.datetime.now().strftime("%Y%m%d%H%M%S") print("Backup Finished: %s\n" % nowKey) log("Backup Finished: %s\n" % nowKey) return int(ret)
def _copyexternals(self, params): """ We're generating a new copy of the treefile, so we need to also copy over any files it references. """ treefile_base = os.path.dirname(self.tree_file) repo_dict = {} # map repository names to .repo files for basename in os.listdir(treefile_base): if not basename.endswith('.repo'): continue repo_data = iniparse.ConfigParser() try: repo_data.read(os.path.join(treefile_base, basename)) except ConfigParser.Error as e: fail_msg("Error parsing file {0}: {1}".format( basename, e.message)) for repo_name in repo_data.sections(): repo_dict[repo_name] = basename copy_files = {} repos = params.get('repos', []) for repo_name in repos: try: basename = repo_dict[repo_name] except KeyError: fail_msg( "Unable to find repo '%s' as declared in the json input file(s)" % repo_name) copy_orig = os.path.join(treefile_base, basename) copy_dest = os.path.join(self.workdir, basename) copy_files[copy_orig] = copy_dest for copy_orig, copy_dest in copy_files.items(): try: shutil.copyfile(copy_orig, copy_dest) except: fail_msg("Unable to copy {0} to tempdir".format(copy_orig)) post_script = params.get('postprocess-script') if post_script is not None: shutil.copy2(os.path.join(treefile_base, post_script), self.workdir) for key in ['check-passwd', 'check-groups']: check = params.get(key) if check and check['type'] == 'file': filename = check['filename'] shutil.copy2(os.path.join(treefile_base, filename), self.workdir)
def parseDesktopFile(self): """ Getting all necessary data from *.dektop file of the app """ cmd = "rpm -qlf $(which %s)" % self.appCommand cmd += '| grep "^/usr/share/applications/.*%s.desktop$"' \ % self.desktopFileName proc = Popen(cmd, shell=True, stdout=PIPE) # !HAVE TO check if the command and its desktop file exist if proc.wait() != 0: raise Exception("*.desktop file of the app not found") output = proc.communicate()[0].rstrip() desktopConfig = iniparse.ConfigParser() desktopConfig.read(output) return desktopConfig
def opt(self, sSect, sOpt, newval=None): """ Get or set an option in any section of the ini file. Intended for internal use in this class. """ c = iniparse.ConfigParser() c.read(self.inipath) curval = self.getopt(c, sSect, sOpt, "") if newval is None: return curval try: c.set(sSect, sOpt, newval) except iniparse.NoSectionError: c.add_section(sSect) c.set(sSect, sOpt, newval) c.write(open(self.inipath, "w")) return self.opt(sSect, sOpt)
def checkConfigFile(): configfile = user_config_dir("lliurex-connect") + "/config.ini" Config = iniparse.ConfigParser() try: Config.read(configfile) showConfig = Config.get("main", "ShowAlways") #print(showConfig); except Exception as e: #print ("Exception..."); showConfig = 'True' #print ("showCongif is "+str(showConfig)); return showConfig pass
def quit(self, self2): configdir = user_config_dir("lliurex-connect") if not os.path.exists(configdir): os.makedirs(configdir) configfile = configdir + "/config.ini" Config = iniparse.ConfigParser() Config.add_section('main') Config.set("main", "ShowAlways", str(self.active)) with open(configfile, "w") as configfile: Config.write(configfile) Gtk.main_quit() pass ''' ids del info.html...
def checkHelp(self): # requires python3-appdirs # requires python3-iniparse configfile = user_config_dir("lliurex-connect") + "/config.ini" Config = iniparse.ConfigParser() try: print("Reading " + str(configfile)) Config.read(configfile) showConfig = Config.get("main", "ShowAlways") except Exception as e: print("Exception...") showConfig = 'True' print("showCongif is " + str(showConfig)) if (showConfig == 'True'): os.system("./splash.py") pass
def main(): options = parseArgs() # fetch the script options from the ini file iniFile = iniparse.ConfigParser() iniFile.read(options.ini) if iniFile.has_section("Server_Settings"): # Get Server optins from ini changeKey = True while changeKey: newKeyFile = raw_input(" Please enter New Key File name: ") print(" Key File will be %s" % (newKeyFile)) proceed = raw_input( " Would you like to create key and password? (y/n) ") if "y" in proceed.lower(): newPassword = newKey(newKeyFile) if newPassword: iniFile.set("Server_Settings", "keyFile", newKeyFile) iniFile.set("Server_Settings", "password", newPassword) with open(options.ini, 'w') as fp: iniFile.write(fp) print(" Key File and Password have been updated") print(" new Key File is %s" % newKeyFile) print(" Server_settings in %s have been updated" % options.ini) changeKey = False else: print(" Problem with key generation and password") proceed = raw_input( " Would you like to try again? (y/n) ") if "n" in proceed.lower(): changeKey = False else: proceed = raw_input(" Would you like to try again? (y/n) ") if "n" in proceed.lower(): changeKey = False else: print( " Ini file is missing Server_Settings section\nPlease check: %s is the INI file for the backup scrip" % options.ini)
config = './multi-region.conf' else: usage(parser.usage) else: if not options.config.startswith("./"): config = "./%s" % options.config else: config = options.config except Exception, e: usage(parser.usage) return config config = get_options(sys.argv) conf = iniparse.ConfigParser() conf.readfp(open(config)) os_region = conf.get('region', 'os_region') public_vip = conf.get('region', 'public_vip') internal_vip = conf.get('region', 'internal_vip') region_desc = conf.get('region', 'description') node_role = conf.get('region', 'node_role') admin_tenant_id = conf.get('authtoken', 'admin_tenant_id') admin_tenant_name = conf.get('authtoken', 'admin_tenant_name') auth_region = conf.get('authtoken', 'auth_region') admin_user = conf.get('authtoken', 'admin_user') admin_password = conf.get('authtoken', 'admin_password') auth_vip = conf.get('authtoken', 'auth_vip') domain_id = conf.get('authtoken', 'domain_id')
def modify_conf(old_file, mapping=None, exception_list=None): """ Copy over all uncommented options from the old configuration file. In addition, look for deprecated section/keys and convert them to the new section/key. """ if not os.path.exists(old_file): return new_file = old_file + '.new' # open the previous version old = iniparse.ConfigParser() old.readfp(open(old_file)) # open the new version new = iniparse.ConfigParser() try: new.readfp(open(new_file)) except IOError as err: if err.errno == errno.ENOENT: # The upgrade did not deliver a .new file so, return print "%s not found - continuing with %s" % (new_file, old_file) return else: raise print "\nupdating %s" % old_file # walk every single section for uncommented options default_items = set(old.items('DEFAULT')) for old_section in old.sections() + ['DEFAULT']: # DEFAULT items show up in every section so remove them if old_section != 'DEFAULT': section_items = set(old.items(old_section)) - default_items else: section_items = default_items for old_key, value in section_items: # Look for deprecated section/keys if mapping is not None: new_section, new_key = update_mapping(old_section, old_key, mapping) if new_section is None and new_key is None: # option is deprecated so continue continue else: # no deprecated values for this file so just copy the values # over new_section, new_key = old_section, old_key # Look for exceptions if exception_list: if (new_section, new_key) in exception_list: if (new_section != 'DEFAULT' and not new.has_section(new_section)): new.add_section(new_section) print "Preserving [%s] %s = %s" % \ (new_section, new_key, value) new.set(new_section, new_key, value) continue if new_section != 'DEFAULT' and not new.has_section(new_section): new.add_section(new_section) # print to the log when a value for old_section.old_key is changing # to a new value try: new_value = new.get(new_section, new_key) if new_value != value and '%SERVICE' not in new_value: print "Changing [%s] %s:\n- %s\n+ %s" % \ (old_section, old_key, value, new_value) print except NoOptionError: # the new configuration file does not have this option set so # just continue pass # Only copy the old value to the new conf file if the entry doesn't # exist in the new file or if it contains '%SERVICE' if not new.has_option(new_section, new_key) or \ '%SERVICE' in new.get(new_section, new_key): new.set(new_section, new_key, value) # copy the new conf file in place with open(old_file, 'wb+') as fh: new.write(fh)
def __init__(self, args, cmd, profile=None): self._repo = None self.args = args configfile = args.config assert profile is not None defaults = { 'workdir': None, 'pkgdatadir': os.environ['OSTBUILD_DATADIR'], 'yum_baseurl': None, 'local_overrides': None, 'selinux': True } if not os.path.isfile(configfile): fail_msg("No config file: " + configfile) settings = iniparse.ConfigParser() try: settings.read(configfile) except ConfigParser.ParsingError as e: fail_msg("Error parsing your config file {0}: {1}".format( configfile, e.message)) self.outputdir = os.getcwd() if os.path.isdir(self.outputdir + "/.git"): fail_msg( "Found .git in the current directory; you most likely don't want to build in source directory" ) for attr in self.ATTRS: val = self.getConfigValue(attr, settings, profile, defValue=defaults.get(attr)) print(attr, val) setattr(self, attr, val) self.ref = getattr(self, 'ref') # Checking ostreerepo self.ostree_port = None self.ostree_repo_is_remote = False self.httpd_path = "" self.httpd_host = "" if args.ostreerepo is not None: self.ostree_repo = args.ostreerepo # The ostree_repo is given in URL format if 'http' in self.ostree_repo: self.ostree_repo_is_remote = True urlp = urlparse.urlparse(self.ostree_repo) # FIXME # When ostree creates the summary file by default, re-enable this. # try: # summaryfile = urllib2.urlopen(urlparse.urljoin(self.ostree_repo, "summary")).read() # except urllib2.HTTPError, e: # fail_msg("Unable to open the ostree sumarry file with the URL {0} due to {1}".format(self.ostree_repo, str(e))) # except urllib2.URLError, e: # fail_msg("Unable to open the ostree summary file with the URL {0} due to {1}".format(self.ostree_repo, str(e))) self.httpd_port = str( urlp.port if urlp.port is not None else 80) self.httpd_path = urlp.path self.httpd_host = urlp.hostname # FIXME # When ostree creates the summary file by default, re-enable this. # if not self.checkRefExists(getattr(self,'ref'), summaryfile): # fail_msg("The ref {0} cannot be found in in the URL {1}".format(getattr(self,'ref'), self.ostree_repo)) else: self.ostree_repo = self.outputdir + '/repo' release = getattr(self, 'release') # Check for configdir in attrs, else fallback to dir holding config if getattr(self, 'configdir') is None: setattr(self, 'configdir', os.path.dirname(os.path.realpath(configfile))) if self.tree_file is None: fail_msg("No tree file was provided") else: self.tree_file = os.path.join(self.configdir, self.tree_file) # Look for virtnetwork if 'virtnetwork' in args: self.virtnetwork = args.virtnetwork self.os_nr = "{0}-{1}".format(getattr(self, 'os_name'), getattr(self, 'release')) # Set kickstart file from args, else fallback to default if cmd in ["imagefactory"]: if 'kickstart' in args and args.kickstart is not None: setattr(self, 'kickstart', args.kickstart) else: defks = "{0}.ks".format(self.os_nr) setattr( self, 'kickstart', '{0}'.format( os.path.join(getattr(self, 'configdir'), defks))) if not os.path.exists(getattr(self, 'kickstart')): fail_msg( "No kickstart was passed with -k and {0} does not exist" .format(getattr(self, 'kickstart'))) # Set KS for liveimage if cmd in ["liveimage"]: if 'kickstart' in args and args.kickstart is not None: setattr(self, 'kickstart', args.kickstart) else: fail_msg( "No kickstart for creating a live image was passed with -k" ) # Set tdl from args, else fallback to default if cmd in ["imagefactory", "liveimage"] or (cmd in ['installer'] and args.virt): if 'tdl' in args and args.tdl is not None: setattr(self, 'tdl', args.tdl) else: deftdl = "{0}.tdl".format(self.os_nr) setattr( self, 'tdl', '{0}'.format( os.path.join(getattr(self, 'configdir'), deftdl))) if not os.path.exists(getattr(self, 'tdl')): fail_msg( "No TDL file was passed with --tdl and {0} does not exist" .format(getattr(self, 'tdl'))) # Set name from args, else fallback to default if 'name' in args and args.name is not None: setattr(self, 'name', args.name) else: setattr(self, 'name', '{0}'.format(self.os_nr)) if cmd == "installer": if not self.yum_baseurl and args.yum_baseurl == None: fail_msg( "No yum_baseurl was provided in your config.ini or with installer -b." ) # Set util_uuid self.util_uuid = args.util_uuid if not args.util_uuid and not args.util_tdl and args.virt: fail_msg( "You must provide a TDL for your utility image with --util_tdl" ) else: self.util_tdl = args.util_tdl if self.http_proxy: os.environ['http_proxy'] = self.http_proxy self.workdir_is_tmp = False if self.workdir is None: self.workdir = tempfile.mkdtemp('.tmp', 'atomic-treecompose') self.workdir_is_tmp = True self.buildjson() return
def main(): options = parseArgs() # fetch the script options from the ini file iniFile = iniparse.ConfigParser() iniFile.read(options.ini) if iniFile.has_section("Server_Settings"): # Get Server optins from ini server_settings = {} for option, value in iniFile.items("Server_Settings"): server_settings[option] = value # List and edit Options print("\n##### Current Server Settings #####\n") for option in server_settings: print(" %s : %s" % (option, server_settings[option])) print("") decision = raw_input("Would you like to edit these settings? (y/n) ") if "y" in decision.lower(): print("Change Value or hit Enter to use current\n") for option in server_settings: if option == "password": if "keyfile" in server_settings.keys(): print(" %s : %s" % (option, server_settings[option])) newPassword = chngPasswd(server_settings['password'], server_settings['keyfile']) if newPassword: server_settings['password'] = newPassword else: print(" %s : %s - MISSING KEY" % (option, server_settings[option])) elif option == "keyfile": if "password" in server_settings.keys(): print(" %s : %s" % (option, server_settings[option])) newKeyFile, newPwd = chngKey( server_settings['password'], server_settings['keyfile']) if newPwd: server_settings['password'] = newPwd if newKeyFile: server_settings['keyfile'] = newKeyFile else: print(" %s : %s - MISSING PASSWORD" % (option, server_settings[option])) else: change = raw_input(" %s : %s " % (option, server_settings[option])) if change == "": pass else: server_settings[option] = change print(" %s changed to %s" % (option, change)) print("\n\n##### New Server Settings #####\n") for option in server_settings: if option == "password": if "keyfile" in server_settings.keys(): password = decryptPwd(server_settings[option], server_settings['keyfile']) print(" %s : %s" % (option, server_settings[option])) else: print(" %s : %s - MISSING KEY" % (option, server_settings[option])) else: print(" %s : %s" % (option, server_settings[option])) # Update INI file print("\n\n##### Updating %s Server_Settings #####\n" % options.ini) for key in server_settings: iniFile.set("Server_Settings", key, server_settings[key]) with open(options.ini, 'w') as fp: iniFile.write(fp) if iniFile.has_section("Backup_Settings"): # Get Backup options from ini backup_settings = {} for option, value in iniFile.items("Backup_Settings"): backup_settings[option] = value # List and edit Options print("\n ##### Current Backup Settings #####\n") for option in backup_settings: print(" %s : %s" % (option, backup_settings[option])) print("") decision = raw_input("Would you like to edit these settings? (y/n) ") if "y" in decision.lower(): print("Change Value or hit Enter to use current\n") for option in backup_settings: change = raw_input(" %s : %s " % (option, backup_settings[option])) if change == "": pass else: backup_settings[option] = change print(" %s changed to %s" % (option, change)) print("\n\n##### New Backup Settings #####\n") for option in backup_settings: print(" %s : %s" % (option, backup_settings[option])) # Update INI file print("\n\n##### Updating %s Backup_Settings #####\n" % options.ini) for key in backup_settings: iniFile.set("Backup_Settings", key, backup_settings[key]) with open(options.ini, 'w') as fp: iniFile.write(fp)
def __init__(self, args, cmd, profile=None): self.workdir = None self.tree_file = None self.rpmostree_cache_dir = None self.pkgdatadir = None self.os_name = None self.ostree_remote = None self.os_pretty_name = None self.tree_name = None self.tree_file = None self.arch = None self.release = None self.ref = None self.yum_baseurl = None self.lorax_additional_repos = None self.is_final = None self.lorax_inherit_repos = None self.lorax_exclude_packages = None self.lorax_include_packages = None self.lorax_rootfs_size = None self.local_overrides = None self.http_proxy = None self.selinux = None self.configdir = None self.docker_os_name = None self._repo = None self.args = args configfile = args.config assert profile is not None defaults = { 'workdir': None, 'pkgdatadir': os.environ['OSTBUILD_DATADIR'], 'yum_baseurl': None, 'local_overrides': None, 'selinux': True } if not os.path.isfile(configfile): fail_msg("No config file: " + configfile) settings = iniparse.ConfigParser() try: settings.read(configfile) except ConfigParser.ParsingError as e: fail_msg("Error parsing your config file {0}: {1}".format( configfile, e.message)) self.outputdir = os.getcwd() if os.path.isdir(self.outputdir + "/.git"): fail_msg( "Found .git in the current directory; you most likely don't want to build in source directory" ) for attr in self.ATTRS: val = self.getConfigValue(attr, settings, profile, defValue=defaults.get(attr)) setattr(self, attr, val) # Checking ostreerepo self.ostree_port = None self.ostree_repo_is_remote = False self.httpd_path = "" self.httpd_host = "" if args.ostreerepo is not None: self.ostree_repo = args.ostreerepo # The ostree_repo is given in URL format if 'http' in self.ostree_repo: self.ostree_repo_is_remote = True urlp = urlparse.urlparse(self.ostree_repo) # FIXME # When ostree creates the summary file by default, re-enable this. # try: # summaryfile = urllib2.urlopen(urlparse.urljoin(self.ostree_repo, "summary")).read() # except urllib2.HTTPError, e: # fail_msg("Unable to open the ostree sumarry file with the URL {0} due to {1}".format(self.ostree_repo, str(e))) # except urllib2.URLError, e: # fail_msg("Unable to open the ostree summary file with the URL {0} due to {1}".format(self.ostree_repo, str(e))) self.httpd_port = str( urlp.port if urlp.port is not None else 80) self.httpd_path = urlp.path self.httpd_host = urlp.hostname # FIXME # When ostree creates the summary file by default, re-enable this. # if not self.checkRefExists(getattr(self,'ref'), summaryfile): # fail_msg("The ref {0} cannot be found in in the URL {1}".format(getattr(self,'ref'), self.ostree_repo)) if not self.ostree_repo: self.ostree_repo = os.environ.get('OSTREE_REPO') if not self.ostree_repo: self.ostree_repo = self.outputdir + '/repo' if not self.ostree_remote: self.ostree_remote = self.os_name release = self.release # Check for configdir in attrs, else fallback to dir holding config if self.configdir is None: self.configdir = os.path.dirname(os.path.realpath(configfile)) if self.tree_file is None: fail_msg("No tree file was provided") else: self.tree_file = os.path.join(self.configdir, self.tree_file) # Look for virtnetwork if 'virtnetwork' in args: self.virtnetwork = args.virtnetwork else: self.virtnetwork = None self.os_nr = "{0}-{1}".format(self.os_name, self.release) # Set name from args, else fallback to default if 'name' in args and args.name is not None: self.name = args.name else: self.name = self.os_nr if cmd == "installer": if not self.yum_baseurl and args.yum_baseurl == None: fail_msg( "No yum_baseurl was provided in your config.ini or with installer -b." ) if self.http_proxy: os.environ['http_proxy'] = self.http_proxy self.workdir_is_tmp = False if self.workdir is None: self.workdir = tempfile.mkdtemp('.tmp', 'atomic-treecompose') self.workdir_is_tmp = True self.buildjson() return
def get_conf(cfgfile): # get conf conf = iniparse.ConfigParser() conf.readfp(open(cfgfile)) return conf