diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-10-24 22:36:11 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-10-24 22:36:11 +0000 |
commit | 609d10684259c16f6893c8a783f9c9c8e405e0f5 (patch) | |
tree | 4f384dcc51aa70d5eb0743aa0441af10d07fc047 | |
parent | fe739ce459ba6fbfab991baa0e295d76d05a40e0 (diff) | |
parent | e668b3ae6daf3f69ceb868a9d5599298ca6a8b5a (diff) | |
download | nova-609d10684259c16f6893c8a783f9c9c8e405e0f5.tar.gz nova-609d10684259c16f6893c8a783f9c9c8e405e0f5.tar.xz nova-609d10684259c16f6893c8a783f9c9c8e405e0f5.zip |
Merge "Refactor: move find_guest_agent to xenapi.agent"
-rw-r--r-- | nova/virt/xenapi/agent.py | 37 | ||||
-rw-r--r-- | nova/virt/xenapi/driver.py | 7 | ||||
-rw-r--r-- | nova/virt/xenapi/vm_utils.py | 32 |
3 files changed, 39 insertions, 37 deletions
diff --git a/nova/virt/xenapi/agent.py b/nova/virt/xenapi/agent.py index 1186692ef..e3288a47b 100644 --- a/nova/virt/xenapi/agent.py +++ b/nova/virt/xenapi/agent.py @@ -42,6 +42,13 @@ xenapi_agent_opts = [ default=60, help='number of seconds to wait for agent reply ' 'to resetnetwork request'), + cfg.StrOpt('xenapi_agent_path', + default='usr/sbin/xe-update-networking', + help='Specifies the path in which the xenapi guest agent ' + 'should be located. If the agent is present, network ' + 'configuration is not injected into the image. ' + 'Used if compute_driver=xenapi.XenAPIDriver and ' + ' flat_injected=True'), ] FLAGS = flags.FLAGS @@ -225,6 +232,36 @@ def resetnetwork(session, instance, vm_ref): return resp['message'] +def find_guest_agent(base_dir): + """ + tries to locate a guest agent at the path + specificed by agent_rel_path + """ + agent_rel_path = FLAGS.xenapi_agent_path + agent_path = os.path.join(base_dir, agent_rel_path) + if os.path.isfile(agent_path): + # The presence of the guest agent + # file indicates that this instance can + # reconfigure the network from xenstore data, + # so manipulation of files in /etc is not + # required + LOG.info(_('XenServer tools installed in this ' + 'image are capable of network injection. ' + 'Networking files will not be' + 'manipulated')) + return True + xe_daemon_filename = os.path.join(base_dir, + 'usr', 'sbin', 'xe-daemon') + if os.path.isfile(xe_daemon_filename): + LOG.info(_('XenServer tools are present ' + 'in this image but are not capable ' + 'of network injection')) + else: + LOG.info(_('XenServer tools are not ' + 'installed in this image')) + return False + + class SimpleDH(object): """ This class wraps all the functionality needed to implement diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index c03ad4ba8..003acdaed 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -91,13 +91,6 @@ xenapi_opts = [ default=5, help='Max number of times to poll for VHD to coalesce. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), - cfg.StrOpt('xenapi_agent_path', - default='usr/sbin/xe-update-networking', - help='Specifies the path in which the xenapi guest agent ' - 'should be located. If the agent is present, network ' - 'configuration is not injected into the image. ' - 'Used if compute_driver=xenapi.XenAPIDriver and ' - ' flat_injected=True'), cfg.StrOpt('xenapi_sr_base_path', default='/var/run/sr-mount', help='Base path to the storage repository'), diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 1f8875d2c..14061829e 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -47,6 +47,7 @@ from nova.openstack.common import log as logging from nova import utils from nova.virt.disk import api as disk from nova.virt import driver +from nova.virt.xenapi import agent from nova.virt.xenapi import volume_utils @@ -2062,35 +2063,6 @@ def _mount_filesystem(dev_path, dir): return err -def _find_guest_agent(base_dir, agent_rel_path): - """ - tries to locate a guest agent at the path - specificed by agent_rel_path - """ - agent_path = os.path.join(base_dir, agent_rel_path) - if os.path.isfile(agent_path): - # The presence of the guest agent - # file indicates that this instance can - # reconfigure the network from xenstore data, - # so manipulation of files in /etc is not - # required - LOG.info(_('XenServer tools installed in this ' - 'image are capable of network injection. ' - 'Networking files will not be' - 'manipulated')) - return True - xe_daemon_filename = os.path.join(base_dir, - 'usr', 'sbin', 'xe-daemon') - if os.path.isfile(xe_daemon_filename): - LOG.info(_('XenServer tools are present ' - 'in this image but are not capable ' - 'of network injection')) - else: - LOG.info(_('XenServer tools are not ' - 'installed in this image')) - return False - - def _mounted_processing(device, key, net, metadata): """Callback which runs with the image VDI attached""" # NB: Partition 1 hardcoded @@ -2101,7 +2073,7 @@ def _mounted_processing(device, key, net, metadata): if not err: try: # This try block ensures that the umount occurs - if not _find_guest_agent(tmpdir, FLAGS.xenapi_agent_path): + if not agent.find_guest_agent(tmpdir): LOG.info(_('Manipulating interface files directly')) # for xenapi, we don't 'inject' admin_password here, # it's handled at instance startup time, nor do we |