def _establish_passwords(self, component_order, instances): kr = pw.KeyringProxy(self.keyring_path, self.keyring_encrypted, self.prompt_for_passwords, True) LOG.info("Reading passwords using a %s", kr) to_save = {} self.passwords.clear() already_gotten = set() for c in component_order: instance = instances[c] wanted_passwords = instance.get_option('wanted_passwords') if not wanted_passwords: continue for (name, prompt) in wanted_passwords.items(): if name in already_gotten: continue (from_keyring, pw_provided) = kr.read(name, prompt) if not from_keyring and self.store_passwords: to_save[name] = pw_provided self.passwords[name] = pw_provided already_gotten.add(name) if to_save: LOG.info("Saving %s passwords using a %s", len(to_save), kr) for (name, pw_provided) in to_save.items(): kr.save(name, pw_provided)
def get_password(user): pw_storage = passwords.KeyringProxy(path='/etc/anvil/passwords.cfg') lookup_name = "%s_password" % (user) prompt = "Please enter the keystone password for user %s: " % (user) (exists, pw) = pw_storage.read(lookup_name, prompt) if not exists: pw_storage.save(lookup_name, pw) return pw
def get_token(): pw_storage = passwords.KeyringProxy(path='/etc/anvil/passwords.cfg') lookup_name = "service_token" prompt = "Please enter the password for %s: " % ( '/etc/anvil/passwords.cfg') (exists, token) = pw_storage.read(lookup_name, prompt) if not exists: pw_storage.save(lookup_name, token) return token