xenapi: Move settings to their own config section

This commit changes xenapi_* config options to their own section
with the xenapi_ prefix removed where appropriate.  The change
is done in a backwards compatible fashion such that previous
nova.conf files still work.

As part of this update the sample file and text strings are
also updated to reflect new config options.  Test cases have
been adjusted to handle the config hierarchy.

2642897d6f was followed to
implement this change.

Change-Id: I2e9f720ddce284fc112d6a5651fd277e6e31a17a
Closes-Bug: 1207253
DocImpact
This commit is contained in:
Christopher Lefelhocz 2013-10-30 07:57:43 +00:00 committed by Gerrit Code Review
parent 9c5b9762a3
commit 4f7cedbeb0
15 changed files with 613 additions and 479 deletions

View File

@ -2209,229 +2209,6 @@
#powervm_img_local_path=/tmp
#
# Options defined in nova.virt.xenapi.agent
#
# number of seconds to wait for agent reply (integer value)
#agent_timeout=30
# number of seconds to wait for agent to be fully operational
# (integer value)
#agent_version_timeout=300
# number of seconds to wait for agent reply to resetnetwork
# request (integer value)
#agent_resetnetwork_timeout=60
# 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
# (string value)
#xenapi_agent_path=usr/sbin/xe-update-networking
# Disables the use of the XenAPI agent in any image regardless
# of what image properties are present. (boolean value)
#xenapi_disable_agent=false
# Determines if the xenapi agent should be used when the image
# used does not contain a hint to declare if the agent is
# present or not. The hint is a glance property
# "xenapi_use_agent" that has the value "true" or "false".
# Note that waiting for the agent when it is not present will
# significantly increase server boot times. (boolean value)
#xenapi_use_agent_default=false
#
# Options defined in nova.virt.xenapi.driver
#
# URL for connection to XenServer/Xen Cloud Platform. A
# special value of unix://local can be used to connect to the
# local unix socket. Required if
# compute_driver=xenapi.XenAPIDriver (string value)
#xenapi_connection_url=<None>
# Username for connection to XenServer/Xen Cloud Platform.
# Used only if compute_driver=xenapi.XenAPIDriver (string
# value)
#xenapi_connection_username=root
# Password for connection to XenServer/Xen Cloud Platform.
# Used only if compute_driver=xenapi.XenAPIDriver (string
# value)
#xenapi_connection_password=<None>
# Maximum number of concurrent XenAPI connections. Used only
# if compute_driver=xenapi.XenAPIDriver (integer value)
#xenapi_connection_concurrent=5
# The interval used for polling of coalescing vhds. Used only
# if compute_driver=xenapi.XenAPIDriver (floating point value)
#xenapi_vhd_coalesce_poll_interval=5.0
# Ensure compute service is running on host XenAPI connects
# to. (boolean value)
#xenapi_check_host=true
# Max number of times to poll for VHD to coalesce. Used only
# if compute_driver=xenapi.XenAPIDriver (integer value)
#xenapi_vhd_coalesce_max_attempts=5
# Base path to the storage repository (string value)
#xenapi_sr_base_path=/var/run/sr-mount
# iSCSI Target Host (string value)
#target_host=<None>
# iSCSI Target Port, 3260 Default (string value)
#target_port=3260
# IQN Prefix (string value)
#iqn_prefix=iqn.2010-10.org.openstack
# Used to enable the remapping of VBD dev (Works around an
# issue in Ubuntu Maverick) (boolean value)
#xenapi_remap_vbd_dev=false
# Specify prefix to remap VBD dev to (ex. /dev/xvdb ->
# /dev/sdb) (string value)
#xenapi_remap_vbd_dev_prefix=sd
# Timeout in seconds for XenAPI login. (integer value)
#xenapi_login_timeout=10
#
# Options defined in nova.virt.xenapi.image.bittorrent
#
# Base URL for torrent files. (string value)
#xenapi_torrent_base_url=<None>
# Probability that peer will become a seeder. (1.0 = 100%)
# (floating point value)
#xenapi_torrent_seed_chance=1.0
# Number of seconds after downloading an image via BitTorrent
# that it should be seeded for other peers. (integer value)
#xenapi_torrent_seed_duration=3600
# Cached torrent files not accessed within this number of
# seconds can be reaped (integer value)
#xenapi_torrent_max_last_accessed=86400
# Beginning of port range to listen on (integer value)
#xenapi_torrent_listen_port_start=6881
# End of port range to listen on (integer value)
#xenapi_torrent_listen_port_end=6891
# Number of seconds a download can remain at the same progress
# percentage w/o being considered a stall (integer value)
#xenapi_torrent_download_stall_cutoff=600
# Maximum number of seeder processes to run concurrently
# within a given dom0. (-1 = no limit) (integer value)
#xenapi_torrent_max_seeder_processes_per_host=1
#
# Options defined in nova.virt.xenapi.pool
#
# To use for hosts with different CPUs (boolean value)
#use_join_force=true
#
# Options defined in nova.virt.xenapi.vif
#
# Name of Integration Bridge used by Open vSwitch (string
# value)
#xenapi_ovs_integration_bridge=xapi1
#
# Options defined in nova.virt.xenapi.vm_utils
#
# Cache glance images locally. `all` will cache all images,
# `some` will only cache images that have the image_property
# `cache_in_nova=True`, and `none` turns off caching entirely
# (string value)
#cache_images=all
# Compression level for images, e.g., 9 for gzip -9. Range is
# 1-9, 9 being most compressed but most CPU intensive on dom0.
# (integer value)
#xenapi_image_compression_level=<None>
# Default OS type (string value)
#default_os_type=linux
# Time to wait for a block device to be created (integer
# value)
#block_device_creation_timeout=10
# Maximum size in bytes of kernel or ramdisk images (integer
# value)
#max_kernel_ramdisk_size=16777216
# Filter for finding the SR to be used to install guest
# instances on. To use the Local Storage in default
# XenServer/XCP installations set this flag to other-config
# :i18n-key=local-storage. To select an SR with a different
# matching criteria, you could set it to other-
# config:my_favorite_sr=true. On the other hand, to fall back
# on the Default SR, as displayed by XenCenter, set this flag
# to: default-sr:true (string value)
#sr_matching_filter=default-sr:true
# Whether to use sparse_copy for copying data on a resize down
# (False will use standard dd). This speeds up resizes down
# considerably since large runs of zeros won't have to be
# rsynced (boolean value)
#xenapi_sparse_copy=true
# Maximum number of retries to unplug VBD (integer value)
#xenapi_num_vbd_unplug_retries=10
# Whether or not to download images via Bit Torrent
# (all|some|none). (string value)
#xenapi_torrent_images=none
# Name of network to use for booting iPXE ISOs (string value)
#xenapi_ipxe_network_name=<None>
# URL to the iPXE boot menu (string value)
#xenapi_ipxe_boot_menu_url=<None>
# Name and optionally path of the tool used for ISO image
# creation (string value)
#xenapi_ipxe_mkisofs_cmd=mkisofs
#
# Options defined in nova.virt.xenapi.vmops
#
# number of seconds to wait for instance to go to running
# state (integer value)
#xenapi_running_timeout=60
# The XenAPI VIF driver using XenServer Network APIs. (string
# value)
#xenapi_vif_driver=nova.virt.xenapi.vif.XenAPIBridgeDriver
# Dom0 plugin driver used to handle image uploads. (string
# value)
#xenapi_image_upload_handler=nova.virt.xenapi.image.glance.GlanceStore
#
# Options defined in nova.vnc
#
@ -3091,6 +2868,231 @@
#password=<None>
[xenserver]
#
# Options defined in nova.virt.xenapi.agent
#
# number of seconds to wait for agent reply (integer value)
#agent_timeout=30
# number of seconds to wait for agent to be fully operational
# (integer value)
#agent_version_timeout=300
# number of seconds to wait for agent reply to resetnetwork
# request (integer value)
#agent_resetnetwork_timeout=60
# 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
# (string value)
#agent_path=usr/sbin/xe-update-networking
# Disables the use of the XenAPI agent in any image regardless
# of what image properties are present. (boolean value)
#disable_agent=false
# Determines if the xenapi agent should be used when the image
# used does not contain a hint to declare if the agent is
# present or not. The hint is a glance property
# "xenapi_use_agent" that has the value "true" or "false".
# Note that waiting for the agent when it is not present will
# significantly increase server boot times. (boolean value)
#use_agent_default=false
#
# Options defined in nova.virt.xenapi.driver
#
# URL for connection to XenServer/Xen Cloud Platform. A
# special value of unix://local can be used to connect to the
# local unix socket. Required if
# compute_driver=xenapi.XenAPIDriver (string value)
#connection_url=<None>
# Username for connection to XenServer/Xen Cloud Platform.
# Used only if compute_driver=xenapi.XenAPIDriver (string
# value)
#connection_username=root
# Password for connection to XenServer/Xen Cloud Platform.
# Used only if compute_driver=xenapi.XenAPIDriver (string
# value)
#connection_password=<None>
# Maximum number of concurrent XenAPI connections. Used only
# if compute_driver=xenapi.XenAPIDriver (integer value)
#connection_concurrent=5
# The interval used for polling of coalescing vhds. Used only
# if compute_driver=xenapi.XenAPIDriver (floating point value)
#vhd_coalesce_poll_interval=5.0
# Ensure compute service is running on host XenAPI connects
# to. (boolean value)
#check_host=true
# Max number of times to poll for VHD to coalesce. Used only
# if compute_driver=xenapi.XenAPIDriver (integer value)
#vhd_coalesce_max_attempts=5
# Base path to the storage repository (string value)
#sr_base_path=/var/run/sr-mount
# iSCSI Target Host (string value)
#target_host=<None>
# iSCSI Target Port, 3260 Default (string value)
#target_port=3260
# IQN Prefix (string value)
#iqn_prefix=iqn.2010-10.org.openstack
# Used to enable the remapping of VBD dev (Works around an
# issue in Ubuntu Maverick) (boolean value)
#remap_vbd_dev=false
# Specify prefix to remap VBD dev to (ex. /dev/xvdb ->
# /dev/sdb) (string value)
#remap_vbd_dev_prefix=sd
# Timeout in seconds for XenAPI login. (integer value)
#login_timeout=10
#
# Options defined in nova.virt.xenapi.image.bittorrent
#
# Base URL for torrent files. (string value)
#torrent_base_url=<None>
# Probability that peer will become a seeder. (1.0 = 100%)
# (floating point value)
#torrent_seed_chance=1.0
# Number of seconds after downloading an image via BitTorrent
# that it should be seeded for other peers. (integer value)
#torrent_seed_duration=3600
# Cached torrent files not accessed within this number of
# seconds can be reaped (integer value)
#torrent_max_last_accessed=86400
# Beginning of port range to listen on (integer value)
#torrent_listen_port_start=6881
# End of port range to listen on (integer value)
#torrent_listen_port_end=6891
# Number of seconds a download can remain at the same progress
# percentage w/o being considered a stall (integer value)
#torrent_download_stall_cutoff=600
# Maximum number of seeder processes to run concurrently
# within a given dom0. (-1 = no limit) (integer value)
#torrent_max_seeder_processes_per_host=1
#
# Options defined in nova.virt.xenapi.pool
#
# To use for hosts with different CPUs (boolean value)
#use_join_force=true
#
# Options defined in nova.virt.xenapi.vif
#
# Name of Integration Bridge used by Open vSwitch (string
# value)
#ovs_integration_bridge=xapi1
#
# Options defined in nova.virt.xenapi.vm_utils
#
# Cache glance images locally. `all` will cache all images,
# `some` will only cache images that have the image_property
# `cache_in_nova=True`, and `none` turns off caching entirely
# (string value)
#cache_images=all
# Compression level for images, e.g., 9 for gzip -9. Range is
# 1-9, 9 being most compressed but most CPU intensive on dom0.
# (integer value)
#image_compression_level=<None>
# Default OS type (string value)
#default_os_type=linux
# Time to wait for a block device to be created (integer
# value)
#block_device_creation_timeout=10
# Maximum size in bytes of kernel or ramdisk images (integer
# value)
#max_kernel_ramdisk_size=16777216
# Filter for finding the SR to be used to install guest
# instances on. To use the Local Storage in default
# XenServer/XCP installations set this flag to other-config
# :i18n-key=local-storage. To select an SR with a different
# matching criteria, you could set it to other-
# config:my_favorite_sr=true. On the other hand, to fall back
# on the Default SR, as displayed by XenCenter, set this flag
# to: default-sr:true (string value)
#sr_matching_filter=default-sr:true
# Whether to use sparse_copy for copying data on a resize down
# (False will use standard dd). This speeds up resizes down
# considerably since large runs of zeros won't have to be
# rsynced (boolean value)
#sparse_copy=true
# Maximum number of retries to unplug VBD (integer value)
#num_vbd_unplug_retries=10
# Whether or not to download images via Bit Torrent
# (all|some|none). (string value)
#torrent_images=none
# Name of network to use for booting iPXE ISOs (string value)
#ipxe_network_name=<None>
# URL to the iPXE boot menu (string value)
#ipxe_boot_menu_url=<None>
# Name and optionally path of the tool used for ISO image
# creation (string value)
#ipxe_mkisofs_cmd=mkisofs
#
# Options defined in nova.virt.xenapi.vmops
#
# number of seconds to wait for instance to go to running
# state (integer value)
#running_timeout=60
# The XenAPI VIF driver using XenServer Network APIs. (string
# value)
#vif_driver=nova.virt.xenapi.vif.XenAPIBridgeDriver
# Dom0 plugin driver used to handle image uploads. (string
# value)
#image_upload_handler=nova.virt.xenapi.image.glance.GlanceStore
[ssl]
#

View File

@ -30,9 +30,10 @@ CONF.import_opt('compute_driver', 'nova.virt.driver')
class ComputeXenTestCase(stubs.XenAPITestBaseNoDB):
def setUp(self):
super(ComputeXenTestCase, self).setUp()
self.flags(compute_driver='xenapi.XenAPIDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
self.flags(compute_driver='xenapi.XenAPIDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
self.compute = importutils.import_object(CONF.compute_manager)

View File

@ -35,9 +35,10 @@ class TestBittorrentStore(stubs.XenAPITestBaseNoDB):
self.store = bittorrent.BittorrentStore()
self.mox = mox.Mox()
self.flags(xenapi_torrent_base_url='http://foo',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
self.flags(torrent_base_url='http://foo',
connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.context = context.RequestContext(
'user', 'project', auth_token='foobar')
@ -121,18 +122,20 @@ class LookupTorrentURLTestCase(test.NoDBTestCase):
return []
def test_default_fetch_url_no_base_url_set(self):
self.flags(xenapi_torrent_base_url=None)
self.flags(torrent_base_url=None,
group='xenserver')
self.stubs.Set(pkg_resources, 'iter_entry_points',
self._mock_iter_none)
exc = self.assertRaises(
RuntimeError, self.store._lookup_torrent_url_fn)
self.assertEqual(_('Cannot create default bittorrent URL without'
' xenapi_torrent_base_url set'),
' torrent_base_url set'),
str(exc))
def test_default_fetch_url_base_url_is_set(self):
self.flags(xenapi_torrent_base_url='http://foo')
self.flags(torrent_base_url='http://foo',
group='xenserver')
self.stubs.Set(pkg_resources, 'iter_entry_points',
self._mock_iter_none)

View File

@ -33,9 +33,10 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB):
self.flags(glance_host='1.1.1.1',
glance_port=123,
glance_api_insecure=False,
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
glance_api_insecure=False)
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.context = context.RequestContext(
'user', 'project', auth_token='foobar')

View File

@ -53,31 +53,31 @@ class AgentTestCaseBase(test.NoDBTestCase):
class AgentImageFlagsTestCase(AgentTestCaseBase):
def test_agent_is_present(self):
self.flags(xenapi_use_agent_default=False)
self.flags(use_agent_default=False, group='xenserver')
instance = {"system_metadata":
[{"key": "image_xenapi_use_agent", "value": "true"}]}
self.assertTrue(agent.should_use_agent(instance))
def test_agent_is_disabled(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True, group='xenserver')
instance = {"system_metadata":
[{"key": "image_xenapi_use_agent", "value": "false"}]}
self.assertFalse(agent.should_use_agent(instance))
def test_agent_uses_deafault_when_prop_invalid(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True, group='xenserver')
instance = {"system_metadata":
[{"key": "image_xenapi_use_agent", "value": "bob"}],
"uuid": "uuid"}
self.assertTrue(agent.should_use_agent(instance))
def test_agent_default_not_present(self):
self.flags(xenapi_use_agent_default=False)
self.flags(use_agent_default=False, group='xenserver')
instance = {"system_metadata": []}
self.assertFalse(agent.should_use_agent(instance))
def test_agent_default_present(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True, group='xenserver')
instance = {"system_metadata": []}
self.assertTrue(agent.should_use_agent(instance))

View File

@ -36,8 +36,8 @@ class XenAPIDriverTestCase(stubs.XenAPITestBaseNoDB):
'host_cpu_info': {'cpu_count': 50}}
def test_available_resource(self):
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
self.flags(connection_url='test_url',
connection_password='test_pass', group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
driver = xenapi.XenAPIDriver(fake.FakeVirtAPI(), False)
@ -58,8 +58,8 @@ class XenAPIDriverTestCase(stubs.XenAPITestBaseNoDB):
self.assertEqual(50, resources['cpu_info'])
def test_overhead(self):
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
self.flags(connection_url='test_url',
connection_password='test_pass', group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
driver = xenapi.XenAPIDriver(fake.FakeVirtAPI(), False)
instance = {'memory_mb': 30720}

View File

@ -325,9 +325,10 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_fetch_vhd_image_works_with_bittorrent(self):
cfg.CONF.import_opt('xenapi_torrent_base_url',
'nova.virt.xenapi.image.bittorrent')
self.flags(xenapi_torrent_base_url='http://foo')
cfg.CONF.import_opt('torrent_base_url',
'nova.virt.xenapi.image.bittorrent',
group='xenserver')
self.flags(torrent_base_url='http://foo', group='xenserver')
self.mox.StubOutWithMock(vm_utils, '_image_uses_bittorrent')
vm_utils._image_uses_bittorrent(
@ -384,9 +385,10 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_fallback_to_default_handler(self):
cfg.CONF.import_opt('xenapi_torrent_base_url',
'nova.virt.xenapi.image.bittorrent')
self.flags(xenapi_torrent_base_url='http://foo')
cfg.CONF.import_opt('torrent_base_url',
'nova.virt.xenapi.image.bittorrent',
group='xenserver')
self.flags(torrent_base_url='http://foo', group='xenserver')
self.mox.StubOutWithMock(vm_utils, '_image_uses_bittorrent')
vm_utils._image_uses_bittorrent(
@ -417,9 +419,10 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_default_handler_doesnt_fallback_to_itself(self):
cfg.CONF.import_opt('xenapi_torrent_base_url',
'nova.virt.xenapi.image.bittorrent')
self.flags(xenapi_torrent_base_url='http://foo')
cfg.CONF.import_opt('torrent_base_url',
'nova.virt.xenapi.image.bittorrent',
group='xenserver')
self.flags(torrent_base_url='http://foo', group='xenserver')
self.mox.StubOutWithMock(vm_utils, '_image_uses_bittorrent')
vm_utils._image_uses_bittorrent(
@ -439,11 +442,11 @@ class TestImageCompression(VMUtilsTestBase):
def test_image_compression(self):
# Testing for nova.conf, too low, negative, and a correct value.
self.assertIsNone(vm_utils.get_compression_level())
self.flags(xenapi_image_compression_level=0)
self.flags(image_compression_level=0, group='xenserver')
self.assertIsNone(vm_utils.get_compression_level())
self.flags(xenapi_image_compression_level=-6)
self.flags(image_compression_level=-6, group='xenserver')
self.assertIsNone(vm_utils.get_compression_level())
self.flags(xenapi_image_compression_level=6)
self.flags(image_compression_level=6, group='xenserver')
self.assertEqual(vm_utils.get_compression_level(), 6)
@ -604,9 +607,10 @@ class GetInstanceForVdisForSrTestCase(VMUtilsTestBase):
self.flags(disable_process_locking=True,
instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',)
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
def test_get_instance_vdis_for_sr(self):
vm_ref = fake.create_vm("foo", "Running")
@ -731,13 +735,13 @@ class BittorrentTestCase(VMUtilsTestBase):
def test_image_uses_bittorrent(self):
instance = {'system_metadata': {'image_bittorrent': True}}
self.flags(xenapi_torrent_images='some')
self.flags(torrent_images='some', group='xenserver')
self.assertTrue(vm_utils._image_uses_bittorrent(self.context,
instance))
def _test_create_image(self, cache_type):
instance = {'system_metadata': {'image_cache_in_nova': True}}
self.flags(cache_images=cache_type)
self.flags(cache_images=cache_type, group='xenserver')
was = {'called': None}
@ -960,7 +964,7 @@ class VDIOtherConfigTestCase(VMUtilsTestBase):
def test_create_image(self):
# Other images are registered implicitly when they are dropped into
# the SR by a dom0 plugin or some other process
self.flags(cache_images='none')
self.flags(cache_images='none', group='xenserver')
def fake_fetch_image(*args):
return {'root': {'uuid': 'fake-uuid'}}
@ -1025,9 +1029,10 @@ class GenerateDiskTestCase(VMUtilsTestBase):
self.flags(disable_process_locking=True,
instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',)
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
stubs.stubout_session(self.stubs, fake.SessionBase)
driver = xenapi_conn.XenAPIDriver(False)
self.session = driver._session
@ -1255,9 +1260,10 @@ class VMUtilsSRPath(VMUtilsTestBase):
self.flags(disable_process_locking=True,
instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',)
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
stubs.stubout_session(self.stubs, fake.SessionBase)
driver = xenapi_conn.XenAPIDriver(False)
self.session = driver._session
@ -1427,9 +1433,10 @@ class AllowVSSProviderTest(VMUtilsTestBase):
self.flags(disable_process_locking=True,
instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',)
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
stubs.stubout_session(self.stubs, fake.SessionBase)
driver = xenapi_conn.XenAPIDriver(False)
self.session = driver._session

View File

@ -200,9 +200,10 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBaseNoDB):
super(XenAPIVolumeTestCase, self).setUp()
self.flags(disable_process_locking=True,
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.instance = fake_instance.fake_db_instance(name='foo')
@ -290,9 +291,10 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.flags(disable_process_locking=True,
instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',)
'Dom0IptablesFirewallDriver')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
db_fakes.stub_out_db_instance_api(self.stubs)
xenapi_fake.create_network('fake', 'fake_br1')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
@ -380,7 +382,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.assertEqual(set(uuids), set(instance_uuids))
def test_get_rrd_server(self):
self.flags(xenapi_connection_url='myscheme://myaddress/')
self.flags(connection_url='myscheme://myaddress/',
group='xenserver')
server_info = vm_utils._get_rrd_server()
self.assertEqual(server_info[0], 'myscheme')
self.assertEqual(server_info[1], 'myaddress')
@ -655,17 +658,17 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.assertEqual(self.vm['HVM_boot_policy'], '')
def _list_vdis(self):
url = CONF.xenapi_connection_url
username = CONF.xenapi_connection_username
password = CONF.xenapi_connection_password
url = CONF.xenserver.connection_url
username = CONF.xenserver.connection_username
password = CONF.xenserver.connection_password
session = xenapi_conn.XenAPISession(url, username, password,
fake.FakeVirtAPI())
return session.call_xenapi('VDI.get_all')
def _list_vms(self):
url = CONF.xenapi_connection_url
username = CONF.xenapi_connection_username
password = CONF.xenapi_connection_password
url = CONF.xenserver.connection_url
username = CONF.xenserver.connection_username
password = CONF.xenserver.connection_password
session = xenapi_conn.XenAPISession(url, username, password,
fake.FakeVirtAPI())
return session.call_xenapi('VM.get_all')
@ -736,9 +739,10 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.mox.StubOutWithMock(vm_utils, 'get_sr_path')
vm_utils.get_sr_path(mox.IgnoreArg()).AndReturn('/sr/path')
self.flags(xenapi_ipxe_network_name='test1',
xenapi_ipxe_boot_menu_url='http://boot.example.com',
xenapi_ipxe_mkisofs_cmd='/root/mkisofs')
self.flags(ipxe_network_name='test1',
ipxe_boot_menu_url='http://boot.example.com',
ipxe_mkisofs_cmd='/root/mkisofs',
group='xenserver')
self.mox.StubOutWithMock(self.conn._session, 'call_plugin_serialized')
self.conn._session.call_plugin_serialized(
'ipxe', 'inject', '/sr/path', mox.IgnoreArg(),
@ -749,8 +753,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self._test_spawn(IMAGE_IPXE_ISO, None, None)
def test_spawn_ipxe_iso_no_network_name(self):
self.flags(xenapi_ipxe_network_name=None,
xenapi_ipxe_boot_menu_url='http://boot.example.com')
self.flags(ipxe_network_name=None,
ipxe_boot_menu_url='http://boot.example.com',
group='xenserver')
# call_plugin_serialized shouldn't be called
self.mox.StubOutWithMock(self.conn._session, 'call_plugin_serialized')
@ -759,8 +764,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self._test_spawn(IMAGE_IPXE_ISO, None, None)
def test_spawn_ipxe_iso_no_boot_menu_url(self):
self.flags(xenapi_ipxe_network_name='test1',
xenapi_ipxe_boot_menu_url=None)
self.flags(ipxe_network_name='test1',
ipxe_boot_menu_url=None,
group='xenserver')
# call_plugin_serialized shouldn't be called
self.mox.StubOutWithMock(self.conn._session, 'call_plugin_serialized')
@ -769,8 +775,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self._test_spawn(IMAGE_IPXE_ISO, None, None)
def test_spawn_ipxe_iso_unknown_network_name(self):
self.flags(xenapi_ipxe_network_name='test2',
xenapi_ipxe_boot_menu_url='http://boot.example.com')
self.flags(ipxe_network_name='test2',
ipxe_boot_menu_url='http://boot.example.com',
group='xenserver')
# call_plugin_serialized shouldn't be called
self.mox.StubOutWithMock(self.conn._session, 'call_plugin_serialized')
@ -1024,7 +1031,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_spawn_ssh_key_injection(self):
# Test spawning with key_data on an instance. Should use
# agent file injection.
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
actual_injected_files = []
def fake_inject_file(self, method, args):
@ -1054,7 +1062,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_spawn_ssh_key_injection_non_rsa(self):
# Test spawning with key_data on an instance. Should use
# agent file injection.
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
actual_injected_files = []
def fake_inject_file(self, method, args):
@ -1082,7 +1091,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_spawn_injected_files(self):
# Test spawning with injected_files.
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
actual_injected_files = []
def fake_inject_file(self, method, args):
@ -1101,7 +1111,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.assertEqual(actual_injected_files, injected_files)
def test_spawn_agent_upgrade(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
actual_injected_files = []
def fake_agent_build(_self, *args):
@ -1116,7 +1127,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
os_type="linux", architecture="x86-64")
def test_spawn_agent_upgrade_fails_silently(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
actual_injected_files = []
def fake_agent_build(_self, *args):
@ -1137,7 +1149,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
os_type="linux", architecture="x86-64")
def test_spawn_with_resetnetwork_alternative_returncode(self):
self.flags(xenapi_use_agent_default=True)
self.flags(use_agent_default=True,
group='xenserver')
def fake_resetnetwork(self, method, args):
fake_resetnetwork.called = True
@ -1153,8 +1166,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.assertTrue(fake_resetnetwork.called)
def _test_spawn_fails_silently_with(self, trigger, expected_exception):
self.flags(xenapi_use_agent_default=True)
self.flags(agent_version_timeout=0)
self.flags(use_agent_default=True,
agent_version_timeout=0,
group='xenserver')
actual_injected_files = []
def fake_agent_version(self, method, args):
@ -1185,8 +1199,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
exception.AgentError)
def test_spawn_fails_with_agent_bad_return(self):
self.flags(xenapi_use_agent_default=True)
self.flags(agent_version_timeout=0)
self.flags(use_agent_default=True,
agent_version_timeout=0,
group='xenserver')
actual_injected_files = []
def fake_agent_version(self, method, args):
@ -1200,8 +1215,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_spawn_fails_agent_not_implemented(self):
# Test spawning with injected_files.
self.flags(xenapi_use_agent_default=True)
self.flags(agent_version_timeout=0)
self.flags(use_agent_default=True,
agent_version_timeout=0,
group='xenserver')
actual_injected_files = []
def fake_agent_version(self, method, args):
@ -1572,9 +1588,10 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
def setUp(self):
super(XenAPIMigrateInstance, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
db_fakes.stub_out_db_instance_api(self.stubs)
@ -2028,8 +2045,9 @@ class XenAPIHostTestCase(stubs.XenAPITestBase):
def setUp(self):
super(XenAPIHostTestCase, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass')
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
self.context = context.get_admin_context()
self.flags(use_local=True, group='conductor')
@ -2168,9 +2186,10 @@ class ToSupportedInstancesTestCase(test.NoDBTestCase):
class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase):
def setUp(self):
super(XenAPIAutoDiskConfigTestCase, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
@ -2264,9 +2283,10 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
"""Test generating of local disks, like swap and ephemeral."""
def setUp(self):
super(XenAPIGenerateLocal, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
db_fakes.stub_out_db_instance_api(self.stubs)
@ -2378,9 +2398,10 @@ class XenAPIBWCountersTestCase(stubs.XenAPITestBaseNoDB):
super(XenAPIBWCountersTestCase, self).setUp()
self.stubs.Set(vm_utils, 'list_vms',
XenAPIBWCountersTestCase._fake_list_vms)
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
@ -2510,9 +2531,10 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
def setUp(self):
super(XenAPIDom0IptablesFirewallTestCase, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
instance_name_template='%d',
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
self.user_id = 'mappin'
@ -2775,7 +2797,7 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBaseNoDB):
"""Unit tests for testing we find the right SR."""
def test_safe_find_sr_raise_exception(self):
# Ensure StorageRepositoryNotFound is raise when wrong filter.
self.flags(sr_matching_filter='yadayadayada')
self.flags(sr_matching_filter='yadayadayada', group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
fake.FakeVirtAPI())
@ -2784,7 +2806,8 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBaseNoDB):
def test_safe_find_sr_local_storage(self):
# Ensure the default local-storage is found.
self.flags(sr_matching_filter='other-config:i18n-key=local-storage')
self.flags(sr_matching_filter='other-config:i18n-key=local-storage',
group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
fake.FakeVirtAPI())
@ -2804,7 +2827,8 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBaseNoDB):
def test_safe_find_sr_by_other_criteria(self):
# Ensure the SR is found when using a different filter.
self.flags(sr_matching_filter='other-config:my_fake_sr=true')
self.flags(sr_matching_filter='other-config:my_fake_sr=true',
group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
fake.FakeVirtAPI())
@ -2818,7 +2842,8 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBaseNoDB):
def test_safe_find_sr_default(self):
# Ensure the default SR is found regardless of other-config.
self.flags(sr_matching_filter='default-sr:true')
self.flags(sr_matching_filter='default-sr:true',
group='xenserver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
fake.FakeVirtAPI())
@ -2846,10 +2871,11 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase):
"""Unit tests for aggregate operations."""
def setUp(self):
super(XenAPIAggregateTestCase, self).setUp()
self.flags(xenapi_connection_url='http://test_url',
xenapi_connection_username='test_user',
xenapi_connection_password='test_pass',
instance_name_template='%d',
self.flags(connection_url='http://test_url',
connection_username='test_user',
connection_password='test_pass',
group='xenserver')
self.flags(instance_name_template='%d',
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
host='host',
@ -3219,9 +3245,10 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBaseNoDB):
"""Unit tests for live_migration."""
def setUp(self):
super(XenAPILiveMigrateTestCase, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver',
host='host')
db_fakes.stub_out_db_instance_api(self.stubs)
@ -3679,9 +3706,10 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBaseNoDB):
class XenAPIInjectMetadataTestCase(stubs.XenAPITestBaseNoDB):
def setUp(self):
super(XenAPIInjectMetadataTestCase, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
firewall_driver='nova.virt.xenapi.firewall.'
self.flags(connection_url='test_url',
connection_password='test_pass',
group='xenserver')
self.flags(firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)

View File

@ -51,39 +51,51 @@ LOG = logging.getLogger(__name__)
xenapi_agent_opts = [
cfg.IntOpt('agent_timeout',
default=30,
deprecated_name='agent_timeout',
deprecated_group='DEFAULT',
help='number of seconds to wait for agent reply'),
cfg.IntOpt('agent_version_timeout',
default=300,
deprecated_name='agent_version_timeout',
deprecated_group='DEFAULT',
help='number of seconds to wait for agent '
'to be fully operational'),
cfg.IntOpt('agent_resetnetwork_timeout',
deprecated_name='agent_resetnetwork_timeout',
deprecated_group='DEFAULT',
default=60,
help='number of seconds to wait for agent reply '
'to resetnetwork request'),
cfg.StrOpt('xenapi_agent_path',
cfg.StrOpt('agent_path',
default='usr/sbin/xe-update-networking',
deprecated_name='xenapi_agent_path',
deprecated_group='DEFAULT',
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.BoolOpt('xenapi_disable_agent',
default=False,
help='Disables the use of the XenAPI agent in any image '
'regardless of what image properties are present.'),
cfg.BoolOpt('xenapi_use_agent_default',
default=False,
help='Determines if the xenapi agent should be used when '
'the image used does not contain a hint to declare if '
'the agent is present or not. '
'The hint is a glance property "' + USE_AGENT_KEY + '" '
'that has the value "true" or "false". '
'Note that waiting for the agent when it is not present '
'will significantly increase server boot times.'),
cfg.BoolOpt('disable_agent',
default=False,
deprecated_name='xenapi_disable_agent',
deprecated_group='DEFAULT',
help='Disables the use of the XenAPI agent in any image '
'regardless of what image properties are present.'),
cfg.BoolOpt('use_agent_default',
default=False,
deprecated_name='xenapi_use_agent_default',
deprecated_group='DEFAULT',
help='Determines if the xenapi agent should be used when '
'the image used does not contain a hint to declare if '
'the agent is present or not. '
'The hint is a glance property "' + USE_AGENT_KEY + '" '
'that has the value "true" or "false". '
'Note that waiting for the agent when it is not present '
'will significantly increase server boot times.'),
]
CONF = cfg.CONF
CONF.register_opts(xenapi_agent_opts)
CONF.register_opts(xenapi_agent_opts, 'xenserver')
def _call_agent(session, instance, vm_ref, method, addl_args=None,
@ -92,7 +104,7 @@ def _call_agent(session, instance, vm_ref, method, addl_args=None,
if addl_args is None:
addl_args = {}
if timeout is None:
timeout = CONF.agent_timeout
timeout = CONF.xenserver.agent_timeout
if success_codes is None:
success_codes = ['0']
@ -198,7 +210,7 @@ class XenAPIBasedAgent(object):
# it will generally perform a setup process on first boot that can
# take a couple of minutes and then reboot. On Linux, the system can
# also take a while to boot.
expiration = time.time() + CONF.agent_version_timeout
expiration = time.time() + CONF.xenserver.agent_version_timeout
while True:
try:
# NOTE(johngarbutt): we can't use the xapi plugin
@ -334,8 +346,8 @@ class XenAPIBasedAgent(object):
#NOTE(johngarbutt) old FreeBSD and Gentoo agents return 500 on success
return self._call_agent('resetnetwork',
timeout=CONF.agent_resetnetwork_timeout,
success_codes=['0', '500'])
timeout=CONF.xenserver.agent_resetnetwork_timeout,
success_codes=['0', '500'])
def _skip_ssh_key_inject(self):
return self._get_sys_meta_key(SKIP_SSH_SM_KEY)
@ -354,10 +366,10 @@ def find_guest_agent(base_dir):
tries to locate a guest agent at the path
specified by agent_rel_path
"""
if CONF.xenapi_disable_agent:
if CONF.xenserver.disable_agent:
return False
agent_rel_path = CONF.xenapi_agent_path
agent_rel_path = CONF.xenserver.agent_path
agent_path = os.path.join(base_dir, agent_rel_path)
if os.path.isfile(agent_path):
# The presence of the guest agent
@ -385,7 +397,7 @@ def find_guest_agent(base_dir):
def should_use_agent(instance):
sys_meta = utils.instance_sys_meta(instance)
if USE_AGENT_SM_KEY not in sys_meta:
return CONF.xenapi_use_agent_default
return CONF.xenserver.use_agent_default
else:
use_agent_raw = sys_meta[USE_AGENT_SM_KEY]
try:
@ -394,7 +406,7 @@ def should_use_agent(instance):
LOG.warn(_("Invalid 'agent_present' value. "
"Falling back to the default."),
instance=instance)
return CONF.xenapi_use_agent_default
return CONF.xenserver.use_agent_default
class SimpleDH(object):

View File

@ -19,11 +19,11 @@ A driver for XenServer or Xen Cloud Platform.
**Related Flags**
:xenapi_connection_url: URL for connection to XenServer/Xen Cloud Platform.
:xenapi_connection_username: Username for connection to XenServer/Xen Cloud
Platform (default: root).
:xenapi_connection_password: Password for connection to XenServer/Xen Cloud
Platform.
:connection_url: URL for connection to XenServer/Xen Cloud Platform.
:connection_username: Username for connection to XenServer/Xen Cloud
Platform (default: root).
:connection_password: Password for connection to XenServer/Xen Cloud
Platform.
:target_host: the iSCSI Target Host IP address, i.e. the IP
address for the nova-volume host
:target_port: iSCSI Target Port, 3260 Default
@ -67,63 +67,91 @@ from nova.virt.xenapi import volumeops
LOG = logging.getLogger(__name__)
xenapi_opts = [
cfg.StrOpt('xenapi_connection_url',
cfg.StrOpt('connection_url',
deprecated_name='xenapi_connection_url',
deprecated_group='DEFAULT',
help='URL for connection to XenServer/Xen Cloud Platform. '
'A special value of unix://local can be used to connect '
'to the local unix socket. '
'Required if compute_driver=xenapi.XenAPIDriver'),
cfg.StrOpt('xenapi_connection_username',
cfg.StrOpt('connection_username',
default='root',
deprecated_name='xenapi_connection_username',
deprecated_group='DEFAULT',
help='Username for connection to XenServer/Xen Cloud Platform. '
'Used only if compute_driver=xenapi.XenAPIDriver'),
cfg.StrOpt('xenapi_connection_password',
cfg.StrOpt('connection_password',
deprecated_name='xenapi_connection_password',
deprecated_group='DEFAULT',
help='Password for connection to XenServer/Xen Cloud Platform. '
'Used only if compute_driver=xenapi.XenAPIDriver',
secret=True),
cfg.IntOpt('xenapi_connection_concurrent',
cfg.IntOpt('connection_concurrent',
default=5,
deprecated_name='xenapi_connection_concurrent',
deprecated_group='DEFAULT',
help='Maximum number of concurrent XenAPI connections. '
'Used only if compute_driver=xenapi.XenAPIDriver'),
cfg.FloatOpt('xenapi_vhd_coalesce_poll_interval',
cfg.FloatOpt('vhd_coalesce_poll_interval',
default=5.0,
deprecated_name='xenapi_vhd_coalesce_poll_interval',
deprecated_group='DEFAULT',
help='The interval used for polling of coalescing vhds. '
'Used only if compute_driver=xenapi.XenAPIDriver'),
cfg.BoolOpt('xenapi_check_host',
cfg.BoolOpt('check_host',
default=True,
deprecated_name='xenapi_check_host',
deprecated_group='DEFAULT',
help='Ensure compute service is running on host XenAPI '
'connects to.'),
cfg.IntOpt('xenapi_vhd_coalesce_max_attempts',
cfg.IntOpt('vhd_coalesce_max_attempts',
default=5,
deprecated_name='xenapi_vhd_coalesce_max_attempts',
deprecated_group='DEFAULT',
help='Max number of times to poll for VHD to coalesce. '
'Used only if compute_driver=xenapi.XenAPIDriver'),
cfg.StrOpt('xenapi_sr_base_path',
cfg.StrOpt('sr_base_path',
default='/var/run/sr-mount',
deprecated_name='xenapi_sr_base_path',
deprecated_group='DEFAULT',
help='Base path to the storage repository'),
cfg.StrOpt('target_host',
deprecated_name='target_host',
deprecated_group='DEFAULT',
help='iSCSI Target Host'),
cfg.StrOpt('target_port',
default='3260',
deprecated_name='target_port',
deprecated_group='DEFAULT',
help='iSCSI Target Port, 3260 Default'),
cfg.StrOpt('iqn_prefix',
default='iqn.2010-10.org.openstack',
deprecated_name='iqn_prefix',
deprecated_group='DEFAULT',
help='IQN Prefix'),
# NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick,
# when we pull support for it, we should remove this
cfg.BoolOpt('xenapi_remap_vbd_dev',
cfg.BoolOpt('remap_vbd_dev',
default=False,
deprecated_name='xenapi_remap_vbd_dev',
deprecated_group='DEFAULT',
help='Used to enable the remapping of VBD dev '
'(Works around an issue in Ubuntu Maverick)'),
cfg.StrOpt('xenapi_remap_vbd_dev_prefix',
cfg.StrOpt('remap_vbd_dev_prefix',
default='sd',
deprecated_name='xenapi_remap_vbd_dev_prefix',
deprecated_group='DEFAULT',
help='Specify prefix to remap VBD dev to '
'(ex. /dev/xvdb -> /dev/sdb)'),
cfg.IntOpt('xenapi_login_timeout',
cfg.IntOpt('login_timeout',
default=10,
deprecated_name='xenapi_login_timeout',
deprecated_group='DEFAULT',
help='Timeout in seconds for XenAPI login.'),
]
CONF = cfg.CONF
CONF.register_opts(xenapi_opts)
CONF.register_opts(xenapi_opts, 'xenserver')
CONF.import_opt('host', 'nova.netconf')
@ -133,13 +161,13 @@ class XenAPIDriver(driver.ComputeDriver):
def __init__(self, virtapi, read_only=False):
super(XenAPIDriver, self).__init__(virtapi)
url = CONF.xenapi_connection_url
username = CONF.xenapi_connection_username
password = CONF.xenapi_connection_password
url = CONF.xenserver.connection_url
username = CONF.xenserver.connection_username
password = CONF.xenserver.connection_password
if not url or password is None:
raise Exception(_('Must specify xenapi_connection_url, '
'xenapi_connection_username (optionally), and '
'xenapi_connection_password to use '
raise Exception(_('Must specify connection_url, '
'connection_username (optionally), and '
'connection_password to use '
'compute_driver=xenapi.XenAPIDriver'))
self._session = XenAPISession(url, username, password, self.virtapi)
@ -158,7 +186,7 @@ class XenAPIDriver(driver.ComputeDriver):
return self._host_state
def init_host(self, host):
if CONF.xenapi_check_host:
if CONF.xenserver.check_host:
vm_utils.ensure_correct_host(self._session)
try:
@ -399,7 +427,7 @@ class XenAPIDriver(driver.ComputeDriver):
@staticmethod
def get_host_ip_addr():
xs_url = urlparse.urlparse(CONF.xenapi_connection_url)
xs_url = urlparse.urlparse(CONF.xenserver.connection_url)
return xs_url.netloc
def attach_volume(self, context, connection_info, instance, mountpoint,
@ -417,10 +445,10 @@ class XenAPIDriver(driver.ComputeDriver):
mountpoint)
def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(CONF.xenapi_connection_url)
xs_url = urlparse.urlparse(CONF.xenserver.connection_url)
return {'address': xs_url.netloc,
'username': CONF.xenapi_connection_username,
'password': CONF.xenapi_connection_password}
'username': CONF.xenserver.connection_username,
'password': CONF.xenserver.connection_password}
def get_available_resource(self, nodename):
"""Retrieve resource information.
@ -692,7 +720,7 @@ class XenAPISession(object):
def _create_first_session(self, url, user, pw, exception):
try:
session = self._create_session(url)
with timeout.Timeout(CONF.xenapi_login_timeout, exception):
with timeout.Timeout(CONF.xenserver.login_timeout, exception):
session.login_with_password(user, pw)
except self.XenAPI.Failure as e:
# if user and pw of the master are different, we're doomed!
@ -708,9 +736,9 @@ class XenAPISession(object):
return url
def _populate_session_pool(self, url, user, pw, exception):
for i in xrange(CONF.xenapi_connection_concurrent - 1):
for i in xrange(CONF.xenserver.connection_concurrent - 1):
session = self._create_session(url)
with timeout.Timeout(CONF.xenapi_login_timeout, exception):
with timeout.Timeout(CONF.xenserver.login_timeout, exception):
session.login_with_password(user, pw)
self._sessions.put(session)

View File

@ -25,38 +25,54 @@ from nova.virt.xenapi import vm_utils
LOG = logging.getLogger(__name__)
xenapi_torrent_opts = [
cfg.StrOpt('xenapi_torrent_base_url',
cfg.StrOpt('torrent_base_url',
deprecated_name='xenapi_torrent_base_url',
deprecated_group='DEFAULT',
help='Base URL for torrent files.'),
cfg.FloatOpt('xenapi_torrent_seed_chance',
cfg.FloatOpt('torrent_seed_chance',
default=1.0,
deprecated_name='xenapi_torrent_seed_chance',
deprecated_group='DEFAULT',
help='Probability that peer will become a seeder.'
' (1.0 = 100%)'),
cfg.IntOpt('xenapi_torrent_seed_duration',
cfg.IntOpt('torrent_seed_duration',
default=3600,
deprecated_name='xenapi_torrent_seed_duration',
deprecated_group='DEFAULT',
help='Number of seconds after downloading an image via'
' BitTorrent that it should be seeded for other peers.'),
cfg.IntOpt('xenapi_torrent_max_last_accessed',
cfg.IntOpt('torrent_max_last_accessed',
default=86400,
deprecated_name='xenapi_torrent_max_last_accessed',
deprecated_group='DEFAULT',
help='Cached torrent files not accessed within this number of'
' seconds can be reaped'),
cfg.IntOpt('xenapi_torrent_listen_port_start',
cfg.IntOpt('torrent_listen_port_start',
default=6881,
deprecated_name='xenapi_torrent_listen_port_start',
deprecated_group='DEFAULT',
help='Beginning of port range to listen on'),
cfg.IntOpt('xenapi_torrent_listen_port_end',
cfg.IntOpt('torrent_listen_port_end',
default=6891,
deprecated_name='xenapi_torrent_listen_port_end',
deprecated_group='DEFAULT',
help='End of port range to listen on'),
cfg.IntOpt('xenapi_torrent_download_stall_cutoff',
cfg.IntOpt('torrent_download_stall_cutoff',
default=600,
deprecated_name='xenapi_torrent_download_stall_cutoff',
deprecated_group='DEFAULT',
help='Number of seconds a download can remain at the same'
' progress percentage w/o being considered a stall'),
cfg.IntOpt('xenapi_torrent_max_seeder_processes_per_host',
cfg.IntOpt('torrent_max_seeder_processes_per_host',
default=1,
deprecated_name='xenapi_torrent_max_seeder_processes_per_host',
deprecated_group='DEFAULT',
help='Maximum number of seeder processes to run concurrently'
' within a given dom0. (-1 = no limit)')
]
CONF = cfg.CONF
CONF.register_opts(xenapi_torrent_opts)
CONF.register_opts(xenapi_torrent_opts, 'xenserver')
class BittorrentStore(object):
@ -73,12 +89,12 @@ class BittorrentStore(object):
LOG.debug(_("No torrent URL fetcher extension found, using"
" default."))
if not CONF.xenapi_torrent_base_url:
if not CONF.xenserver.torrent_base_url:
raise RuntimeError(_('Cannot create default bittorrent URL'
' without xenapi_torrent_base_url set'))
' without torrent_base_url set'))
def _default_torrent_url_fn(instance, image_id):
return urlparse.urljoin(CONF.xenapi_torrent_base_url,
return urlparse.urljoin(CONF.xenserver.torrent_base_url,
"%s.torrent" % image_id)
fn = _default_torrent_url_fn
@ -98,17 +114,18 @@ class BittorrentStore(object):
params['image_id'] = image_id
params['uuid_stack'] = vm_utils._make_uuid_stack()
params['sr_path'] = vm_utils.get_sr_path(session)
params['torrent_seed_duration'] = CONF.xenapi_torrent_seed_duration
params['torrent_seed_chance'] = CONF.xenapi_torrent_seed_chance
params['torrent_seed_duration'] = CONF.xenserver.torrent_seed_duration
params['torrent_seed_chance'] = CONF.xenserver.torrent_seed_chance
params['torrent_max_last_accessed'] = \
CONF.xenapi_torrent_max_last_accessed
CONF.xenserver.torrent_max_last_accessed
params['torrent_listen_port_start'] = \
CONF.xenapi_torrent_listen_port_start
params['torrent_listen_port_end'] = CONF.xenapi_torrent_listen_port_end
CONF.xenserver.torrent_listen_port_start
params['torrent_listen_port_end'] = \
CONF.xenserver.torrent_listen_port_end
params['torrent_download_stall_cutoff'] = \
CONF.xenapi_torrent_download_stall_cutoff
CONF.xenserver.torrent_download_stall_cutoff
params['torrent_max_seeder_processes_per_host'] = \
CONF.xenapi_torrent_max_seeder_processes_per_host
CONF.xenserver.torrent_max_seeder_processes_per_host
lookup_fn = self._lookup_torrent_url_fn()
params['torrent_url'] = lookup_fn(instance, image_id)

View File

@ -35,12 +35,14 @@ LOG = logging.getLogger(__name__)
xenapi_pool_opts = [
cfg.BoolOpt('use_join_force',
deprecated_name='use_join_force',
deprecated_group='DEFAULT',
default=True,
help='To use for hosts with different CPUs'),
]
CONF = cfg.CONF
CONF.register_opts(xenapi_pool_opts)
CONF.register_opts(xenapi_pool_opts, 'xenserver')
CONF.import_opt('host', 'nova.netconf')
@ -176,10 +178,10 @@ class ResourcePool(object):
'url': url,
'user': user,
'password': passwd,
'force': jsonutils.dumps(CONF.use_join_force),
'force': jsonutils.dumps(CONF.xenserver.use_join_force),
'master_addr': self._host_addr,
'master_user': CONF.xenapi_connection_username,
'master_pass': CONF.xenapi_connection_password, }
'master_user': CONF.xenserver.connection_username,
'master_pass': CONF.xenserver.connection_password, }
self._session.call_plugin('xenhost', 'host_join', args)
except self._session.XenAPI.Failure as e:
LOG.error(_("Pool-Join failed: %s"), e)
@ -235,12 +237,12 @@ class ResourcePool(object):
# because this might be 169.254.0.1, i.e. xenapi
# NOTE: password in clear is not great, but it'll do for now
sender_url = swap_xapi_host(
CONF.xenapi_connection_url, self._host_addr)
CONF.xenserver.connection_url, self._host_addr)
return {
"url": sender_url,
"user": CONF.xenapi_connection_username,
"passwd": CONF.xenapi_connection_password,
"user": CONF.xenserver.connection_username,
"passwd": CONF.xenserver.connection_password,
"compute_uuid": vm_utils.get_this_vm_uuid(None),
"xenhost_uuid": self._host_uuid,
}

View File

@ -26,12 +26,14 @@ from nova.virt.xenapi import network_utils
from nova.virt.xenapi import vm_utils
xenapi_ovs_integration_bridge_opt = cfg.StrOpt('xenapi_ovs_integration_bridge',
default='xapi1',
help='Name of Integration Bridge used by Open vSwitch')
xenapi_ovs_integration_bridge_opt = cfg.StrOpt('ovs_integration_bridge',
default='xapi1',
deprecated_name='xenapi_ovs_integration_bridge',
deprecated_group='DEFAULT',
help='Name of Integration Bridge used by Open vSwitch')
CONF = cfg.CONF
CONF.register_opt(xenapi_ovs_integration_bridge_opt)
CONF.register_opt(xenapi_ovs_integration_bridge_opt, 'xenserver')
class XenVIFDriver(object):
@ -145,7 +147,7 @@ class XenAPIOpenVswitchDriver(XenVIFDriver):
# with OVS model, always plug into an OVS integration bridge
# that is already created
network_ref = network_utils.find_network_with_bridge(
self._session, CONF.xenapi_ovs_integration_bridge)
self._session, CONF.xenserver.ovs_integration_bridge)
vif_rec = {}
vif_rec['device'] = str(device)
vif_rec['network'] = network_ref

View File

@ -62,26 +62,38 @@ LOG = logging.getLogger(__name__)
xenapi_vm_utils_opts = [
cfg.StrOpt('cache_images',
default='all',
help='Cache glance images locally. `all` will cache all'
' images, `some` will only cache images that have the'
' image_property `cache_in_nova=True`, and `none` turns'
' off caching entirely'),
cfg.IntOpt('xenapi_image_compression_level',
default='all',
deprecated_name='cache_images',
deprecated_group='DEFAULT',
help='Cache glance images locally. `all` will cache all'
' images, `some` will only cache images that have the'
' image_property `cache_in_nova=True`, and `none` turns'
' off caching entirely'),
cfg.IntOpt('image_compression_level',
deprecated_name='xenapi_image_compression_level',
deprecated_group='DEFAULT',
help='Compression level for images, e.g., 9 for gzip -9.'
' Range is 1-9, 9 being most compressed but most CPU'
' intensive on dom0.'),
cfg.StrOpt('default_os_type',
default='linux',
deprecated_name='default_os_type',
deprecated_group='DEFAULT',
help='Default OS type'),
cfg.IntOpt('block_device_creation_timeout',
default=10,
deprecated_name='block_device_creation_timeout',
deprecated_group='DEFAULT',
help='Time to wait for a block device to be created'),
cfg.IntOpt('max_kernel_ramdisk_size',
default=16 * unit.Mi,
deprecated_name='max_kernel_ramdisk_size',
deprecated_group='DEFAULT',
help='Maximum size in bytes of kernel or ramdisk images'),
cfg.StrOpt('sr_matching_filter',
default='default-sr:true',
deprecated_name='sr_matching_filter',
deprecated_group='DEFAULT',
help='Filter for finding the SR to be used to install guest '
'instances on. To use the Local Storage in default '
'XenServer/XCP installations set this flag to '
@ -90,31 +102,43 @@ xenapi_vm_utils_opts = [
'other-config:my_favorite_sr=true. On the other hand, to '
'fall back on the Default SR, as displayed by XenCenter, '
'set this flag to: default-sr:true'),
cfg.BoolOpt('xenapi_sparse_copy',
cfg.BoolOpt('sparse_copy',
default=True,
deprecated_name='xenapi_sparse_copy',
deprecated_group='DEFAULT',
help='Whether to use sparse_copy for copying data on a '
'resize down (False will use standard dd). This speeds '
'up resizes down considerably since large runs of zeros '
'won\'t have to be rsynced'),
cfg.IntOpt('xenapi_num_vbd_unplug_retries',
cfg.IntOpt('num_vbd_unplug_retries',
default=10,
deprecated_name='xenapi_num_vbd_unplug_retries',
deprecated_group='DEFAULT',
help='Maximum number of retries to unplug VBD'),
cfg.StrOpt('xenapi_torrent_images',
cfg.StrOpt('torrent_images',
default='none',
deprecated_name='xenapi_torrent_images',
deprecated_group='DEFAULT',
help='Whether or not to download images via Bit Torrent '
'(all|some|none).'),
cfg.StrOpt('xenapi_ipxe_network_name',
cfg.StrOpt('ipxe_network_name',
deprecated_name='xenapi_ipxe_network_name',
deprecated_group='DEFAULT',
help='Name of network to use for booting iPXE ISOs'),
cfg.StrOpt('xenapi_ipxe_boot_menu_url',
cfg.StrOpt('ipxe_boot_menu_url',
deprecated_name='xenapi_ipxe_boot_menu_url',
deprecated_group='DEFAULT',
help='URL to the iPXE boot menu'),
cfg.StrOpt('xenapi_ipxe_mkisofs_cmd',
cfg.StrOpt('ipxe_mkisofs_cmd',
default='mkisofs',
deprecated_name='xenapi_ipxe_mkisofs_cmd',
deprecated_group='DEFAULT',
help='Name and optionally path of the tool used for '
'ISO image creation'),
]
CONF = cfg.CONF
CONF.register_opts(xenapi_vm_utils_opts)
CONF.register_opts(xenapi_vm_utils_opts, 'xenserver')
CONF.import_opt('default_ephemeral_format', 'nova.virt.driver')
CONF.import_opt('use_cow_images', 'nova.virt.driver')
CONF.import_opt('glance_num_retries', 'nova.image.glance')
@ -361,7 +385,7 @@ def _should_retry_unplug_vbd(err):
def unplug_vbd(session, vbd_ref):
max_attempts = CONF.xenapi_num_vbd_unplug_retries + 1
max_attempts = CONF.xenserver.num_vbd_unplug_retries + 1
for num_attempt in xrange(1, max_attempts + 1):
try:
if num_attempt > 1:
@ -769,7 +793,7 @@ def get_sr_path(session, sr_ref=None):
" SR %(uuid)s is of type %(type)s") %
{"uuid": sr_uuid, "type": sr_rec["type"]})
return os.path.join(CONF.xenapi_sr_base_path, sr_uuid)
return os.path.join(CONF.xenserver.sr_base_path, sr_uuid)
def destroy_cached_images(session, sr_ref, all_cached=False, dry_run=False):
@ -1102,7 +1126,7 @@ def _create_kernel_image(context, session, instance, name_label, image_id,
Returns: A list of dictionaries that describe VDIs
"""
filename = ""
if CONF.cache_images:
if CONF.xenserver.cache_images:
args = {}
args['cached-image'] = image_id
args['new-image-uuid'] = str(uuid.uuid4())
@ -1211,7 +1235,7 @@ def _create_image(context, session, instance, name_label, image_id,
Returns: A list of dictionaries that describe VDIs
"""
cache_images = CONF.cache_images.lower()
cache_images = CONF.xenserver.cache_images.lower()
# Determine if the image is cacheable
if image_type == ImageType.DISK_ISO:
@ -1228,7 +1252,7 @@ def _create_image(context, session, instance, name_label, image_id,
cache = False
else:
LOG.warning(_("Unrecognized cache_images value '%s', defaulting to"
" True"), CONF.cache_images)
" True"), CONF.xenserver.cache_images)
cache = True
# Fetch (and cache) the image
@ -1279,22 +1303,22 @@ def _make_uuid_stack():
def _image_uses_bittorrent(context, instance):
bittorrent = False
xenapi_torrent_images = CONF.xenapi_torrent_images.lower()
torrent_images = CONF.xenserver.torrent_images.lower()
if xenapi_torrent_images == 'all':
if torrent_images == 'all':
bittorrent = True
elif xenapi_torrent_images == 'some':
elif torrent_images == 'some':
sys_meta = utils.instance_sys_meta(instance)
try:
bittorrent = strutils.bool_from_string(
sys_meta['image_bittorrent'])
except KeyError:
pass
elif xenapi_torrent_images == 'none':
elif torrent_images == 'none':
pass
else:
LOG.warning(_("Invalid value '%s' for xenapi_torrent_images"),
xenapi_torrent_images)
LOG.warning(_("Invalid value '%s' for torrent_images"),
torrent_images)
return bittorrent
@ -1314,9 +1338,9 @@ def _choose_download_handler(context, instance):
def get_compression_level():
level = CONF.xenapi_image_compression_level
level = CONF.xenserver.image_compression_level
if level is not None and (level < 1 or level > 9):
LOG.warn(_("Invalid value '%d' for xenapi_image_compression_level"),
LOG.warn(_("Invalid value '%d' for image_compression_level"),
level)
return None
return level
@ -1445,8 +1469,8 @@ def _fetch_disk_image(context, session, instance, name_label, image_id,
# Make room for MBR.
vdi_size += MBR_SIZE_BYTES
elif (image_type in (ImageType.KERNEL, ImageType.RAMDISK) and
vdi_size > CONF.max_kernel_ramdisk_size):
max_size = CONF.max_kernel_ramdisk_size
vdi_size > CONF.xenserver.max_kernel_ramdisk_size):
max_size = CONF.xenserver.max_kernel_ramdisk_size
raise exception.NovaException(
_("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, "
"max %(max_size)d bytes") %
@ -1475,7 +1499,7 @@ def _fetch_disk_image(context, session, instance, name_label, image_id,
# Let the plugin copy the correct number of bytes.
args['image-size'] = str(vdi_size)
if CONF.cache_images:
if CONF.xenserver.cache_images:
args['cached-image'] = image_id
filename = session.call_plugin('kernel', 'copy_vdi', args)
@ -1746,13 +1770,14 @@ def _find_sr(session):
"""Return the storage repository to hold VM images."""
host = session.get_xenapi_host()
try:
tokens = CONF.sr_matching_filter.split(':')
tokens = CONF.xenserver.sr_matching_filter.split(':')
filter_criteria = tokens[0]
filter_pattern = tokens[1]
except IndexError:
# oops, flag is invalid
LOG.warning(_("Flag sr_matching_filter '%s' does not respect "
"formatting convention"), CONF.sr_matching_filter)
"formatting convention"),
CONF.xenserver.sr_matching_filter)
return None
if filter_criteria == 'other-config':
@ -1822,7 +1847,7 @@ def _find_iso_sr(session):
def _get_rrd_server():
"""Return server's scheme and address to use for retrieving RRD XMLs."""
xs_url = urlparse.urlparse(CONF.xenapi_connection_url)
xs_url = urlparse.urlparse(CONF.xenserver.connection_url)
return [xs_url.scheme, xs_url.netloc]
@ -1831,8 +1856,8 @@ def _get_rrd(server, vm_uuid):
try:
xml = urllib.urlopen("%s://%s:%s@%s/vm_rrd?uuid=%s" % (
server[0],
CONF.xenapi_connection_username,
CONF.xenapi_connection_password,
CONF.xenserver.connection_username,
CONF.xenserver.connection_password,
server[1],
vm_uuid))
return xml.read()
@ -1952,7 +1977,7 @@ def _wait_for_vhd_coalesce(session, instance, sr_ref, vdi_ref,
base_uuid = _get_vhd_parent_uuid(session, parent_ref)
return parent_uuid, base_uuid
max_attempts = CONF.xenapi_vhd_coalesce_max_attempts
max_attempts = CONF.xenserver.vhd_coalesce_max_attempts
for i in xrange(max_attempts):
# NOTE(sirp): This rescan is necessary to ensure the VM's `sm_config`
# matches the underlying VHDs.
@ -1969,7 +1994,7 @@ def _wait_for_vhd_coalesce(session, instance, sr_ref, vdi_ref,
base_uuid = _get_vhd_parent_uuid(session, parent_ref)
return parent_uuid, base_uuid
greenthread.sleep(CONF.xenapi_vhd_coalesce_poll_interval)
greenthread.sleep(CONF.xenserver.vhd_coalesce_poll_interval)
msg = (_("VHD coalesce attempts exceeded (%d)"
", giving up...") % max_attempts)
@ -1986,12 +2011,12 @@ def _remap_vbd_dev(dev):
For now, we work around it by just doing a string replace.
"""
# NOTE(sirp): This hack can go away when we pull support for Maverick
should_remap = CONF.xenapi_remap_vbd_dev
should_remap = CONF.xenserver.remap_vbd_dev
if not should_remap:
return dev
old_prefix = 'xvd'
new_prefix = CONF.xenapi_remap_vbd_dev_prefix
new_prefix = CONF.xenserver.remap_vbd_dev_prefix
remapped_dev = dev.replace(old_prefix, new_prefix)
return remapped_dev
@ -1999,7 +2024,7 @@ def _remap_vbd_dev(dev):
def _wait_for_device(dev):
"""Wait for device node to appear."""
for i in xrange(0, CONF.block_device_creation_timeout):
for i in xrange(0, CONF.xenserver.block_device_creation_timeout):
dev_path = utils.make_dev_path(dev)
if os.path.exists(dev_path):
return
@ -2274,7 +2299,7 @@ def _copy_partition(session, src_ref, dst_ref, partition, virtual_size):
_write_partition(session, virtual_size, dst)
if CONF.xenapi_sparse_copy:
if CONF.xenserver.sparse_copy:
_sparse_copy(src_path, dst_path, virtual_size)
else:
num_blocks = virtual_size / SECTOR_SIZE
@ -2432,7 +2457,7 @@ def ensure_correct_host(session):
if exc.details[0] != 'UUID_INVALID':
raise
raise Exception(_('This domU must be running on the host '
'specified by xenapi_connection_url'))
'specified by connection_url'))
def import_all_migrated_disks(session, instance):
@ -2524,15 +2549,15 @@ def handle_ipxe_iso(session, instance, cd_vdi, network_info):
provider can either add that package manually to Dom0 or include the
`mkisofs` binary in the image itself.
"""
boot_menu_url = CONF.xenapi_ipxe_boot_menu_url
boot_menu_url = CONF.xenserver.ipxe_boot_menu_url
if not boot_menu_url:
LOG.warn(_('xenapi_ipxe_boot_menu_url not set, user will have to'
LOG.warn(_('ipxe_boot_menu_url not set, user will have to'
' enter URL manually...'), instance=instance)
return
network_name = CONF.xenapi_ipxe_network_name
network_name = CONF.xenserver.ipxe_network_name
if not network_name:
LOG.warn(_('xenapi_ipxe_network_name not set, user will have to'
LOG.warn(_('ipxe_network_name not set, user will have to'
' enter IP manually...'), instance=instance)
return
@ -2563,11 +2588,11 @@ def handle_ipxe_iso(session, instance, cd_vdi, network_info):
try:
session.call_plugin_serialized("ipxe", "inject", sr_path,
cd_vdi['uuid'], boot_menu_url, ip_address, netmask,
gateway, dns, CONF.xenapi_ipxe_mkisofs_cmd)
gateway, dns, CONF.xenserver.ipxe_mkisofs_cmd)
except session.XenAPI.Failure as exc:
_type, _method, error = exc.details[:3]
if error == 'CommandNotFound':
LOG.warn(_("ISO creation tool '%s' does not exist.") %
CONF.xenapi_ipxe_mkisofs_cmd, instance=instance)
CONF.xenserver.ipxe_mkisofs_cmd, instance=instance)
else:
raise

View File

@ -60,20 +60,26 @@ from nova.virt.xenapi import volumeops
LOG = logging.getLogger(__name__)
xenapi_vmops_opts = [
cfg.IntOpt('xenapi_running_timeout',
cfg.IntOpt('running_timeout',
default=60,
deprecated_name='xenapi_running_timeout',
deprecated_group='DEFAULT',
help='number of seconds to wait for instance '
'to go to running state'),
cfg.StrOpt('xenapi_vif_driver',
cfg.StrOpt('vif_driver',
default='nova.virt.xenapi.vif.XenAPIBridgeDriver',
deprecated_name='xenapi_vif_driver',
deprecated_group='DEFAULT',
help='The XenAPI VIF driver using XenServer Network APIs.'),
cfg.StrOpt('xenapi_image_upload_handler',
cfg.StrOpt('image_upload_handler',
default='nova.virt.xenapi.image.glance.GlanceStore',
help='Dom0 plugin driver used to handle image uploads.'),
deprecated_name='xenapi_image_upload_handler',
deprecated_group='DEFAULT',
help='Dom0 plugin driver used to handle image uploads.'),
]
CONF = cfg.CONF
CONF.register_opts(xenapi_vmops_opts)
CONF.register_opts(xenapi_vmops_opts, 'xenserver')
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('vncserver_proxyclient_address', 'nova.vnc')
@ -158,17 +164,17 @@ class VMOps(object):
DEFAULT_FIREWALL_DRIVER,
self._virtapi,
xenapi_session=self._session)
vif_impl = importutils.import_class(CONF.xenapi_vif_driver)
vif_impl = importutils.import_class(CONF.xenserver.vif_driver)
self.vif_driver = vif_impl(xenapi_session=self._session)
self.default_root_dev = '/dev/sda'
LOG.debug(_("Importing image upload handler: %s"),
CONF.xenapi_image_upload_handler)
CONF.xenserver.image_upload_handler)
self.image_upload_handler = importutils.import_object(
CONF.xenapi_image_upload_handler)
CONF.xenserver.image_upload_handler)
def agent_enabled(self, instance):
if CONF.xenapi_disable_agent:
if CONF.xenserver.disable_agent:
return False
return xapi_agent.should_use_agent(instance)
@ -614,7 +620,7 @@ class VMOps(object):
def _wait_for_instance_to_start(self, instance, vm_ref):
LOG.debug(_('Waiting for instance state to become running'),
instance=instance)
expiration = time.time() + CONF.xenapi_running_timeout
expiration = time.time() + CONF.xenserver.running_timeout
while time.time() < expiration:
state = self.get_info(instance, vm_ref)['state']
if state == power_state.RUNNING:
@ -708,7 +714,7 @@ class VMOps(object):
get a stable representation of the data on disk.
3. Push-to-data-store: Once coalesced, we call
'xenapi_image_upload_handler' to upload the images.
'image_upload_handler' to upload the images.
"""
vm_ref = self._get_vm_opaque_ref(instance)