def get_secret(self, _id): sec = None try: item = gnomekeyring.item_get_info_sync(self.keyring, _id) attrs = gnomekeyring.item_get_attributes_sync(self.keyring, _id) sec = vmmSecret(item.get_display_name(), item.get_secret(), attrs) except: pass return sec
def set_console_password(self, vm, password, username=""): if not (self.has_keyring()): return # Nb, we don't bother to check if there is an existing # secret, because gnome-keyring auto-replaces an existing # one if the attributes match - which they will since UUID # is our unique key secret = vmmSecret(self.get_secret_name(vm), password, { "uuid": vm.get_uuid(), "hvuri": vm.conn.get_uri() }) _id = self.keyring.add_secret(secret) if _id != None: self.conf.set_int( self.conf_dir + "/console/passwords/" + vm.get_uuid(), _id) self.conf.set_string( self.conf_dir + "/console/usernames/" + vm.get_uuid(), username)