def get_config(self): config = None parser = SafeConfigParser() parser.add_section(self.config_name) for field in self.all_fields: value = getattr(self, field) if value: parser.set(self.config_name, field, value) for section in parser.sections(): config = Config.fromParser(section, parser) return config
def get_config(self, file=False): config = None parser = SafeConfigParser() parser.add_section(self.config_name) self.set_rhsm_prefix() for field in self.all_fields: # Don't want to print clear text password in the file if file: if field == "sat_password" and self.sat_encrypt_pass or \ field == "rhsm_password" and self.rhsm_encrypt_pass or \ field == "rhsm_proxy_password" and self.rhsm_encrypt_pass or \ field == "password" and self.encrypt_pass: continue # Based on the validation codes in virt-who: # - Environment is not used in non-remote libvirt connection # - Owner is not used in non-remote libvirt connection # Thus, force owner and env to None if self.type == 'libvirt' and not self.server and field in [ "owner", "env" ]: continue value = getattr(self, field) if value: parser.set(self.config_name, field, value) for section in parser.sections(): config = Config.fromParser(section, parser) if file: return parser else: return config