summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-17 18:03:18 +0000
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-17 18:03:18 +0000
commitda6474283bc926d41d221024a48072b08f45fb3e (patch)
treee8eade4d7e485693c4d469cf300e9a6552547937 /nova/virt
parent373562b150824856be2ea32abcb9dd10cd9b553f (diff)
parent699abfe9e645ddbc854b42725247ab8fcd61517e (diff)
merge trunk
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/libvirt_conn.py17
-rw-r--r--nova/virt/xenapi/vmops.py33
2 files changed, 27 insertions, 23 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 7b18ce122..46ed35177 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -500,7 +500,7 @@ class LibvirtConnection(object):
cmd = 'netcat', '0.0.0.0', port, '-w', '1'
try:
stdout, stderr = utils.execute(*cmd, process_input='')
- except ProcessExecutionError:
+ except exception.ProcessExecutionError:
return port
raise Exception(_('Unable to find an open port'))
@@ -967,18 +967,19 @@ class LibvirtConnection(object):
xml = self._conn.getCapabilities()
xml = libxml2.parseDoc(xml)
- nodes = xml.xpathEval('//cpu')
+ nodes = xml.xpathEval('//host/cpu')
if len(nodes) != 1:
raise exception.Invalid(_("Invalid xml. '<cpu>' must be 1,"
"but %d\n") % len(nodes)
+ xml.serialize())
cpu_info = dict()
- cpu_info['arch'] = xml.xpathEval('//cpu/arch')[0].getContent()
- cpu_info['model'] = xml.xpathEval('//cpu/model')[0].getContent()
- cpu_info['vendor'] = xml.xpathEval('//cpu/vendor')[0].getContent()
+ cpu_info['arch'] = xml.xpathEval('//host/cpu/arch')[0].getContent()
+ cpu_info['model'] = xml.xpathEval('//host/cpu/model')[0].getContent()
+ cpu_info['vendor'] = xml.xpathEval('//host/cpu/vendor')[0].getContent()
- topology_node = xml.xpathEval('//cpu/topology')[0].get_properties()
+ topology_node = xml.xpathEval('//host/cpu/topology')[0]\
+ .get_properties()
topology = dict()
while topology_node != None:
name = topology_node.get_name()
@@ -992,7 +993,7 @@ class LibvirtConnection(object):
raise exception.Invalid(_("Invalid xml: topology(%(topology)s) "
"must have %(ks)s") % locals())
- feature_nodes = xml.xpathEval('//cpu/feature')
+ feature_nodes = xml.xpathEval('//host/cpu/feature')
features = list()
for nodes in feature_nodes:
features.append(nodes.get_properties().getContent())
@@ -1580,6 +1581,8 @@ class IptablesFirewallDriver(FirewallDriver):
self.iptables.ipv4['filter'].add_chain('sg-fallback')
self.iptables.ipv4['filter'].add_rule('sg-fallback', '-j DROP')
+ self.iptables.ipv6['filter'].add_chain('sg-fallback')
+ self.iptables.ipv6['filter'].add_rule('sg-fallback', '-j DROP')
def setup_basic_filtering(self, instance):
"""Use NWFilter from libvirt for this."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index ec5b1baee..48f333369 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -19,6 +19,7 @@
Management class for VM-related functions (spawn, reboot, etc).
"""
+import base64
import json
import M2Crypto
import os
@@ -141,19 +142,20 @@ class VMOps(object):
LOG.info(_('Spawning VM %(instance_name)s created %(vm_ref)s.')
% locals())
- def _inject_onset_files():
- onset_files = instance.onset_files
- if onset_files:
+ def _inject_files():
+ injected_files = instance.injected_files
+ if injected_files:
# Check if this is a JSON-encoded string and convert if needed.
- if isinstance(onset_files, basestring):
+ if isinstance(injected_files, basestring):
try:
- onset_files = json.loads(onset_files)
+ injected_files = json.loads(injected_files)
except ValueError:
- LOG.exception(_("Invalid value for onset_files: '%s'")
- % onset_files)
- onset_files = []
+ LOG.exception(
+ _("Invalid value for injected_files: '%s'")
+ % injected_files)
+ injected_files = []
# Inject any files, if specified
- for path, contents in instance.onset_files:
+ for path, contents in instance.injected_files:
LOG.debug(_("Injecting file path: '%s'") % path)
self.inject_file(instance, path, contents)
# NOTE(armando): Do we really need to do this in virt?
@@ -169,8 +171,8 @@ class VMOps(object):
instance['id'], state)
if state == power_state.RUNNING:
LOG.debug(_('Instance %s: booted'), instance_name)
- _inject_onset_files()
timer.stop()
+ _inject_files()
return True
except Exception, exc:
LOG.warn(exc)
@@ -405,17 +407,16 @@ class VMOps(object):
raise RuntimeError(resp_dict['message'])
return resp_dict['message']
- def inject_file(self, instance, b64_path, b64_contents):
+ def inject_file(self, instance, path, contents):
"""Write a file to the VM instance. The path to which it is to be
- written and the contents of the file need to be supplied; both should
+ written and the contents of the file need to be supplied; both will
be base64-encoded to prevent errors with non-ASCII characters being
transmitted. If the agent does not support file injection, or the user
has disabled it, a NotImplementedError will be raised.
"""
- # Files/paths *should* be base64-encoded at this point, but
- # double-check to make sure.
- b64_path = utils.ensure_b64_encoding(b64_path)
- b64_contents = utils.ensure_b64_encoding(b64_contents)
+ # Files/paths must be base64-encoded for transmission to agent
+ b64_path = base64.b64encode(path)
+ b64_contents = base64.b64encode(contents)
# Need to uniquely identify this request.
transaction_id = str(uuid.uuid4())