diff options
| author | Dan Prince <dan.prince@rackspace.com> | 2011-07-16 23:30:47 -0400 |
|---|---|---|
| committer | Dan Prince <dan.prince@rackspace.com> | 2011-07-16 23:30:47 -0400 |
| commit | 3233d6cafb22305f09c1384ba30e677751cace6a (patch) | |
| tree | f20ddcae4e1f707277102e2d5f2141b71d279e5b /plugins | |
| parent | 58eb29ebe4376a276a54f4fd984802a0e50fb8e3 (diff) | |
| download | nova-3233d6cafb22305f09c1384ba30e677751cace6a.tar.gz nova-3233d6cafb22305f09c1384ba30e677751cace6a.tar.xz nova-3233d6cafb22305f09c1384ba30e677751cace6a.zip | |
Change _agent_has_method to _get_agent_features. Update the inject
files function so that it calls _get_agent_features only once per injected
file.
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/agent | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent index b169a74bf..1321c820e 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent @@ -129,13 +129,14 @@ def inject_file(self, arg_dict): b64_path = arg_dict["b64_path"] b64_file = arg_dict["b64_contents"] request_id = arg_dict["id"] - if _agent_has_method(self, "file_inject", arg_dict): + agent_features = _get_agent_features(self, arg_dict) + if "file_inject" in agent_features: # New version of the agent. Agent should receive a 'value' # key whose value is a dictionary containing 'b64_path' and # 'b64_file'. See old version below. arg_dict["value"] = json.dumps({"name": "file_inject", "value": {"b64_path": b64_path, "b64_file": b64_file}}) - elif _agent_has_method(self, "injectfile", arg_dict): + elif "injectfile" in agent_features: # Old agent requires file path and file contents to be # combined into one base64 value. raw_path = base64.b64decode(b64_path) @@ -174,10 +175,8 @@ def agent_update(self, arg_dict): return resp -def _agent_has_method(self, method, arg_dict): - """Check that the agent has a particular method by checking its - features. - """ +def _get_agent_features(self, arg_dict): + """Return an array of features that an agent supports.""" tmp_id = commands.getoutput("uuidgen") dct = {} dct.update(arg_dict) @@ -189,9 +188,7 @@ def _agent_has_method(self, method, arg_dict): except TimeoutError, e: raise PluginError(e) response = json.loads(resp) - method_arr = response["message"].split(",") - # The agent returns a comma-separated list of methods in the message - return method in method_arr + return response["message"].split(",") def _wait_for_agent(self, request_id, arg_dict): |
