config options: Centralize xenapi torrent options

The config options of
"nova/virt/xenapi/image/bittorrent.py" got moved
to the new central location
"nova/conf/xenserver.py”

Change-Id: I25e0d57021fc797878379aa8b13dc15536d16771
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Allen Gao 2016-03-29 07:38:57 +00:00
parent fbee8e418b
commit e76c0cea98
4 changed files with 44 additions and 53 deletions

View File

@ -195,9 +195,47 @@ xenapi_session_opts = [
]
xenapi_torrent_opts = [
cfg.StrOpt('torrent_base_url',
help='Base URL for torrent files; must contain a slash'
' character (see RFC 1808, step 6)'),
cfg.FloatOpt('torrent_seed_chance',
default=1.0,
help='Probability that peer will become a seeder.'
' (1.0 = 100%)'),
cfg.IntOpt('torrent_seed_duration',
default=3600,
help='Number of seconds after downloading an image via'
' BitTorrent that it should be seeded for other peers.'),
cfg.IntOpt('torrent_max_last_accessed',
default=86400,
help='Cached torrent files not accessed within this number of'
' seconds can be reaped'),
cfg.IntOpt('torrent_listen_port_start',
default=6881,
min=1,
max=65535,
help='Beginning of port range to listen on'),
cfg.IntOpt('torrent_listen_port_end',
default=6891,
min=1,
max=65535,
help='End of port range to listen on'),
cfg.IntOpt('torrent_download_stall_cutoff',
default=600,
help='Number of seconds a download can remain at the same'
' progress percentage w/o being considered a stall'),
cfg.IntOpt('torrent_max_seeder_processes_per_host',
default=1,
help='Maximum number of seeder processes to run concurrently'
' within a given dom0. (-1 = no limit)')
]
ALL_XENSERVER_OPTS = itertools.chain(
xenapi_agent_opts,
xenapi_session_opts)
xenapi_session_opts,
xenapi_torrent_opts)
def register_opts(conf):
@ -206,4 +244,4 @@ def register_opts(conf):
def list_opts():
return {xenserver_group.name: ALL_XENSERVER_OPTS}
return {xenserver_group: ALL_XENSERVER_OPTS}

View File

@ -22,7 +22,6 @@ import mock
from mox3 import mox
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_config import fixture as config_fixture
from oslo_utils import fixture as utils_fixture
from oslo_utils import timeutils
@ -33,6 +32,7 @@ import six
from nova.compute import flavors
from nova.compute import power_state
from nova.compute import vm_mode
import nova.conf
from nova import context
from nova import exception
from nova import objects
@ -49,7 +49,7 @@ from nova.virt.xenapi import driver as xenapi_conn
from nova.virt.xenapi import fake
from nova.virt.xenapi import vm_utils
CONF = cfg.CONF
CONF = nova.conf.CONF
XENSM_TYPE = 'xensm'
ISCSI_TYPE = 'iscsi'
@ -347,9 +347,6 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_fetch_vhd_image_works_with_bittorrent(self):
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')
@ -409,9 +406,6 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_fallback_to_default_handler(self):
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')
@ -443,9 +437,6 @@ class FetchVhdImageTestCase(VMUtilsTestBase):
self.mox.VerifyAll()
def test_default_handler_does_not_fallback_to_itself(self):
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')

View File

@ -41,7 +41,6 @@ import nova.virt.vmwareapi.vmops
import nova.virt.xenapi.agent
import nova.virt.xenapi.client.session
import nova.virt.xenapi.driver
import nova.virt.xenapi.image.bittorrent
import nova.virt.xenapi.pool
import nova.virt.xenapi.vif
import nova.virt.xenapi.vm_utils
@ -89,7 +88,6 @@ def list_opts():
itertools.chain(
[nova.virt.xenapi.vif.xenapi_ovs_integration_bridge_opt],
nova.virt.xenapi.driver.xenapi_opts,
nova.virt.xenapi.image.bittorrent.xenapi_torrent_opts,
nova.virt.xenapi.pool.xenapi_pool_opts,
nova.virt.xenapi.vm_utils.xenapi_vm_utils_opts,
nova.virt.xenapi.vmops.xenapi_vmops_opts,

View File

@ -13,53 +13,17 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
import six.moves.urllib.parse as urlparse
import nova.conf
from nova.i18n import _, _LW
from nova.virt.xenapi import vm_utils
LOG = logging.getLogger(__name__)
xenapi_torrent_opts = [
cfg.StrOpt('torrent_base_url',
help='Base URL for torrent files; must contain a slash'
' character (see RFC 1808, step 6)'),
cfg.FloatOpt('torrent_seed_chance',
default=1.0,
help='Probability that peer will become a seeder.'
' (1.0 = 100%)'),
cfg.IntOpt('torrent_seed_duration',
default=3600,
help='Number of seconds after downloading an image via'
' BitTorrent that it should be seeded for other peers.'),
cfg.IntOpt('torrent_max_last_accessed',
default=86400,
help='Cached torrent files not accessed within this number of'
' seconds can be reaped'),
cfg.IntOpt('torrent_listen_port_start',
default=6881,
min=1,
max=65535,
help='Beginning of port range to listen on'),
cfg.IntOpt('torrent_listen_port_end',
default=6891,
min=1,
max=65535,
help='End of port range to listen on'),
cfg.IntOpt('torrent_download_stall_cutoff',
default=600,
help='Number of seconds a download can remain at the same'
' progress percentage w/o being considered a stall'),
cfg.IntOpt('torrent_max_seeder_processes_per_host',
default=1,
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, 'xenserver')
CONF = nova.conf.CONF
class BittorrentStore(object):