diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-02-04 12:12:43 -0500 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-02-05 14:00:51 -0500 |
| commit | 5d8868a4d58122dce6fdc81fa0ed17ae7fc55672 (patch) | |
| tree | 534e767c153b7cdf9530c4c343c9011a043e0c94 /nova/virt | |
| parent | 139d15a40557066a39a1c2ba48c81711a9dd3730 (diff) | |
Refactor server password metadata to avoid direct db usage
This refactors the set_password() method in the server_password
API extension to merely format the metadata and return it, leaving
the job of updating the database to the caller. In the API extension
case, the update can be done immediately against the database as
before. In the case of the metadata API handler and the xenapi virt
driver making the call, conductor can be used to update the instance's
system_metadata, thereby avoiding a direct database access.
Related to blueprint no-db-compute
Change-Id: I0563feaa97d768a96f950c148b1dbf51c356c4ac
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/agent.py | 11 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/nova/virt/xenapi/agent.py b/nova/virt/xenapi/agent.py index e8a81f552..8220fb67b 100644 --- a/nova/virt/xenapi/agent.py +++ b/nova/virt/xenapi/agent.py @@ -123,8 +123,9 @@ def _get_agent_version(session, instance, vm_ref): class XenAPIBasedAgent(object): - def __init__(self, session, instance, vm_ref): + def __init__(self, session, virtapi, instance, vm_ref): self.session = session + self.virtapi = virtapi self.instance = instance self.vm_ref = vm_ref @@ -212,9 +213,13 @@ class XenAPIBasedAgent(object): sshkey = self.instance.get('key_data') if sshkey: + ctxt = context.get_admin_context() enc = crypto.ssh_encrypt_text(sshkey, new_pass) - password.set_password(context.get_admin_context(), - self.instance['uuid'], base64.b64encode(enc)) + sys_meta = utils.metadata_to_dict(self.instance['system_metadata']) + sys_meta.update(password.convert_password(ctxt, + base64.b64encode(enc))) + self.virtapi.instance_update(ctxt, self.instance['uuid'], + {'system_metadata': sys_meta}) return resp['message'] diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 8a76f3368..9124b4dbe 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -176,7 +176,8 @@ class VMOps(object): def _get_agent(self, instance, vm_ref): if self.agent_enabled: - return xapi_agent.XenAPIBasedAgent(self._session, instance, vm_ref) + return xapi_agent.XenAPIBasedAgent(self._session, self._virtapi, + instance, vm_ref) raise exception.NovaException(_("Error: Agent is disabled")) def list_instances(self): |
