diff options
author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-04-05 05:00:41 +0000 |
---|---|---|
committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-04-05 15:13:53 +0000 |
commit | 7ae65242bd525ce08b1168100ba16a220f73fddd (patch) | |
tree | 496f12211e5527ff90f68dc03fb34b459ecb9147 | |
parent | c7532c62ea6afb4bfcf3d00e42a58cc72b12405b (diff) | |
download | nova-7ae65242bd525ce08b1168100ba16a220f73fddd.tar.gz nova-7ae65242bd525ce08b1168100ba16a220f73fddd.tar.xz nova-7ae65242bd525ce08b1168100ba16a220f73fddd.zip |
Combine call_xenapi and call_xenapi_request
The comment is incorrect and all commands can be used with either variant.
In XenAPI.py, they have somewhat different calling styles, but our
wrappers only differ by a tuple.
Change-Id: Ideadc0deb5bd870135f732ffadd9c09d90460c83
-rw-r--r-- | nova/virt/xenapi/vmops.py | 15 | ||||
-rw-r--r-- | nova/virt/xenapi_conn.py | 13 |
2 files changed, 8 insertions, 20 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index d2177f902..e1386a160 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1543,8 +1543,8 @@ class VMOps(object): hostname = hostname[:15] LOG.debug(_("injecting hostname to xs for vm: |%s|"), vm_ref) - self._session.call_xenapi_request("VM.add_to_xenstore_data", - (vm_ref, "vm-data/hostname", hostname)) + self._session.call_xenapi('VM.add_to_xenstore_data', + vm_ref, "vm-data/hostname", hostname) def list_from_xenstore(self, vm, path): """ @@ -1702,8 +1702,7 @@ class VMOps(object): return the values for those keys. """ vm_ref = self._get_vm_opaque_ref(instance_or_vm) - data = self._session.call_xenapi_request('VM.get_xenstore_data', - (vm_ref,)) + data = self._session.call_xenapi('VM.get_xenstore_data', vm_ref) ret = {} if keys is None: keys = data.keys() @@ -1726,8 +1725,8 @@ class VMOps(object): vm_ref = self._get_vm_opaque_ref(instance_or_vm) self.remove_from_param_xenstore(instance_or_vm, key) jsonval = json.dumps(val) - self._session.call_xenapi_request('VM.add_to_xenstore_data', - (vm_ref, key, jsonval)) + self._session.call_xenapi('VM.add_to_xenstore_data', + vm_ref, key, jsonval) def write_to_param_xenstore(self, instance_or_vm, mapping): """ @@ -1750,8 +1749,8 @@ class VMOps(object): else: keys = key_or_keys for key in keys: - self._session.call_xenapi_request('VM.remove_from_xenstore_data', - (vm_ref, key)) + self._session.call_xenapi('VM.remove_from_xenstore_data', + vm_ref, key) def clear_param_xenstore(self, instance_or_vm): """Removes all data from the xenstore parameter record for this VM.""" diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index e699fa03c..f080b67d5 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -568,19 +568,8 @@ class XenAPISession(object): def call_xenapi(self, method, *args): """Call the specified XenAPI method on a background thread.""" with self._get_session() as session: - f = session.xenapi - for m in method.split('.'): - f = getattr(f, m) - return tpool.execute(f, *args) - - def call_xenapi_request(self, method, *args): - """Some interactions with dom0, such as interacting with xenstore's - param record, require using the xenapi_request method of the session - object. This wraps that call on a background thread. - """ - with self._get_session() as session: f = session.xenapi_request - return tpool.execute(f, method, *args) + return tpool.execute(f, method, args) def call_plugin(self, plugin, fn, args): """Call host.call_plugin on a background thread.""" |