summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-02-17 22:50:17 +0000
committerTarmac <>2011-02-17 22:50:17 +0000
commit76a82e57dfbca67e1e70a12db4f4b5c2111e4d93 (patch)
treead470c12b3650141ec74051386af8e87e6515999 /plugins
parent5688fbd7a06ea47e18f38e4c900be4dbb50b921c (diff)
parentc0972233901774598fe6c836fcc3a0dd1f28f180 (diff)
downloadnova-76a82e57dfbca67e1e70a12db4f4b5c2111e4d93.tar.gz
nova-76a82e57dfbca67e1e70a12db4f4b5c2111e4d93.tar.xz
nova-76a82e57dfbca67e1e70a12db4f4b5c2111e4d93.zip
Added support for feature parity with the current Rackspace Cloud Servers practice of "injecting" files into newly-created instances for configuration, etc. However, this is in no way restricted to only writing files to the guest when it is first created.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/agent5
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py10
2 files changed, 11 insertions, 4 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
index f99ea4082..94eaabe73 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
@@ -93,9 +93,8 @@ def password(self, arg_dict):
@jsonify
def resetnetwork(self, arg_dict):
- """
- Writes a resquest to xenstore that tells the agent to reset networking.
-
+ """Writes a resquest to xenstore that tells the agent
+ to reset networking.
"""
arg_dict['value'] = json.dumps({'name': 'resetnetwork', 'value': ''})
request_id = arg_dict['id']
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
index 695bf3448..a35ccd6ab 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
@@ -36,7 +36,15 @@ pluginlib.configure_logging("xenstore")
def jsonify(fnc):
def wrapper(*args, **kwargs):
- return json.dumps(fnc(*args, **kwargs))
+ ret = fnc(*args, **kwargs)
+ try:
+ json.loads(ret)
+ except ValueError:
+ # Value should already be JSON-encoded, but some operations
+ # may write raw sting values; this will catch those and
+ # properly encode them.
+ ret = json.dumps(ret)
+ return ret
return wrapper