From a3c44eb0891f3e90caa978e1832365300d31ee61 Mon Sep 17 00:00:00 2001 From: gong yong sheng Date: Fri, 29 Jan 2016 14:36:43 +0800 Subject: [PATCH] Unify the driver config opts mgmt_driver, monitor_driver and infra_driver are configuration items. Some of them are multistropt, some are listopt. This patch uses the listopt for all of them. In addition, rename drivers dir into infra_drivers. Change-Id: I5bbc7b6a52d97dae8bbca7dd2e804b7c50c8f7a4 Closes-bug: 1524255 --- etc/tacker/tacker.conf | 11 +++-------- setup.cfg | 6 +++--- .../tests/unit/vm/drivers/heat/test_heat.py | 19 +++++++++++-------- .../vm/{drivers => infra_drivers}/__init__.py | 0 .../abstract_driver.py | 0 .../heat/__init__.py | 0 .../{drivers => infra_drivers}/heat/heat.py | 2 +- tacker/vm/{drivers => infra_drivers}/noop.py | 2 +- .../nova/__init__.py | 0 .../{drivers => infra_drivers}/nova/nova.py | 2 +- tacker/vm/monitor.py | 6 +++--- tacker/vm/plugin.py | 6 +++--- 12 files changed, 26 insertions(+), 28 deletions(-) rename tacker/vm/{drivers => infra_drivers}/__init__.py (100%) rename tacker/vm/{drivers => infra_drivers}/abstract_driver.py (100%) rename tacker/vm/{drivers => infra_drivers}/heat/__init__.py (100%) rename tacker/vm/{drivers => infra_drivers}/heat/heat.py (99%) rename tacker/vm/{drivers => infra_drivers}/noop.py (97%) rename tacker/vm/{drivers => infra_drivers}/nova/__init__.py (100%) rename tacker/vm/{drivers => infra_drivers}/nova/nova.py (99%) diff --git a/etc/tacker/tacker.conf b/etc/tacker/tacker.conf index 819029ff2..f5765ac1e 100644 --- a/etc/tacker/tacker.conf +++ b/etc/tacker/tacker.conf @@ -387,18 +387,13 @@ auth_uri = http://127.0.0.1:5000 [tacker] # Specify drivers for hosting device -# exmpale: infra_driver = noop -# exmpale: infra_driver = nova -# exmpale: infra_driver = heat -infra_driver = heat +# infra_driver = heat,nova,noop # Specify drivers for mgmt -mgmt_driver = noop -mgmt_driver = openwrt +# mgmt_driver = noop,openwrt # Specify drivers for monitoring -monitor_driver = ping -monitor_driver = http_ping +# monitor_driver = ping, http_ping [tacker_nova] # parameters for novaclient to talk to nova diff --git a/setup.cfg b/setup.cfg index ed63f21f4..67d9564da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,9 +46,9 @@ tacker.service_plugins = tacker.openstack.common.cache.backends = memory = tacker.openstack.common.cache._backends.memory:MemoryBackend tacker.tacker.device.drivers = - noop = tacker.vm.drivers.noop:DeviceNoop - nova = tacker.vm.drivers.nova.nova:DeviceNova - heat = tacker.vm.drivers.heat.heat:DeviceHeat + noop = tacker.vm.infra_drivers.noop:DeviceNoop + nova = tacker.vm.infra_drivers.nova.nova:DeviceNova + heat = tacker.vm.infra_drivers.heat.heat:DeviceHeat tacker.tacker.mgmt.drivers = noop = tacker.vm.mgmt_drivers.noop:DeviceMgmtNoop openwrt = tacker.vm.mgmt_drivers.openwrt.openwrt:DeviceMgmtOpenWRT diff --git a/tacker/tests/unit/vm/drivers/heat/test_heat.py b/tacker/tests/unit/vm/drivers/heat/test_heat.py index 14905c5e9..a0509942f 100644 --- a/tacker/tests/unit/vm/drivers/heat/test_heat.py +++ b/tacker/tests/unit/vm/drivers/heat/test_heat.py @@ -18,7 +18,7 @@ import testtools from tacker import context from tacker.tests.unit.db import utils -from tacker.vm.drivers.heat import heat +from tacker.vm.infra_drivers.heat import heat class FakeHeatClient(mock.Mock): @@ -48,15 +48,16 @@ class TestDeviceHeat(testtools.TestCase): fake_heat_client = mock.Mock() fake_heat_client.return_value = self.heat_client self._mock( - 'tacker.vm.drivers.heat.heat.HeatClient', fake_heat_client) + 'tacker.vm.infra_drivers.heat.heat.HeatClient', fake_heat_client) def _mock(self, target, new=mock.DEFAULT): patcher = mock.patch(target, new) return patcher.start() def _get_expected_fields(self): - return {'stack_name': 'tacker.vm.drivers.heat.heat_DeviceHeat-eb84260e' - '-5ff7-4332-b032-50a14d6c1123', 'template': + return {'stack_name': + 'tacker.vm.infra_drivers.heat.heat_DeviceHeat-eb84260e' + '-5ff7-4332-b032-50a14d6c1123', 'template': 'description: OpenWRT with services\nheat_template_version: ' '2013-05-23\noutputs:\n mgmt_ip-vdu1:\n description: ' 'management ip address\n value:\n get_attr: [vdu1-net_mgmt' @@ -71,8 +72,9 @@ class TestDeviceHeat(testtools.TestCase): ' type: OS::Neutron::Port\n'} def _get_expected_fields_user_data(self): - return {'stack_name': 'tacker.vm.drivers.heat.heat_DeviceHeat-18685f68' - '-2b2a-4185-8566-74f54e548811', 'template': + return {'stack_name': + 'tacker.vm.infra_drivers.heat.heat_DeviceHeat-18685f68' + '-2b2a-4185-8566-74f54e548811', 'template': 'description: Parameterized VNF descriptor\nheat_template_version:' ' 2013-05-23\noutputs:\n mgmt_ip-vdu1:\n description: ' 'management ip address\n value:\n get_attr: ' @@ -91,8 +93,9 @@ class TestDeviceHeat(testtools.TestCase): 'type: OS::Neutron::Port\n'} def _get_expected_fields_ipaddr_data(self): - return {'stack_name': 'tacker.vm.drivers.heat.heat_DeviceHeat-d1337add' - '-d5a1-4fd4-9447-bb9243c8460b', 'template': + return {'stack_name': + 'tacker.vm.infra_drivers.heat.heat_DeviceHeat-d1337add' + '-d5a1-4fd4-9447-bb9243c8460b', 'template': 'description: Parameterized VNF descriptor for IP addresses\n' 'heat_template_version: 2013-05-23\noutputs:\n mgmt_ip-vdu1:\n ' ' description: management ip address\n value:\n ' diff --git a/tacker/vm/drivers/__init__.py b/tacker/vm/infra_drivers/__init__.py similarity index 100% rename from tacker/vm/drivers/__init__.py rename to tacker/vm/infra_drivers/__init__.py diff --git a/tacker/vm/drivers/abstract_driver.py b/tacker/vm/infra_drivers/abstract_driver.py similarity index 100% rename from tacker/vm/drivers/abstract_driver.py rename to tacker/vm/infra_drivers/abstract_driver.py diff --git a/tacker/vm/drivers/heat/__init__.py b/tacker/vm/infra_drivers/heat/__init__.py similarity index 100% rename from tacker/vm/drivers/heat/__init__.py rename to tacker/vm/infra_drivers/heat/__init__.py diff --git a/tacker/vm/drivers/heat/heat.py b/tacker/vm/infra_drivers/heat/heat.py similarity index 99% rename from tacker/vm/drivers/heat/heat.py rename to tacker/vm/infra_drivers/heat/heat.py index a560f85a1..a0a35e2ea 100644 --- a/tacker/vm/drivers/heat/heat.py +++ b/tacker/vm/infra_drivers/heat/heat.py @@ -29,7 +29,7 @@ from tacker.common import log from tacker.extensions import vnfm from tacker.openstack.common import jsonutils from tacker.openstack.common import log as logging -from tacker.vm.drivers import abstract_driver +from tacker.vm.infra_drivers import abstract_driver LOG = logging.getLogger(__name__) diff --git a/tacker/vm/drivers/noop.py b/tacker/vm/infra_drivers/noop.py similarity index 97% rename from tacker/vm/drivers/noop.py rename to tacker/vm/infra_drivers/noop.py index b0326b542..094f6ca31 100644 --- a/tacker/vm/drivers/noop.py +++ b/tacker/vm/infra_drivers/noop.py @@ -23,7 +23,7 @@ import uuid from tacker.common import log from tacker.openstack.common import log as logging -from tacker.vm.drivers import abstract_driver +from tacker.vm.infra_drivers import abstract_driver LOG = logging.getLogger(__name__) diff --git a/tacker/vm/drivers/nova/__init__.py b/tacker/vm/infra_drivers/nova/__init__.py similarity index 100% rename from tacker/vm/drivers/nova/__init__.py rename to tacker/vm/infra_drivers/nova/__init__.py diff --git a/tacker/vm/drivers/nova/nova.py b/tacker/vm/infra_drivers/nova/nova.py similarity index 99% rename from tacker/vm/drivers/nova/nova.py rename to tacker/vm/infra_drivers/nova/nova.py index cf0b3c1a3..7536aaff4 100644 --- a/tacker/vm/drivers/nova/nova.py +++ b/tacker/vm/infra_drivers/nova/nova.py @@ -28,7 +28,7 @@ from oslo_config import cfg from tacker.api.v1 import attributes from tacker.i18n import _LE, _LW from tacker.openstack.common import log as logging -from tacker.vm.drivers import abstract_driver +from tacker.vm.infra_drivers import abstract_driver LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/tacker/vm/monitor.py b/tacker/vm/monitor.py index 9edd916ce..601969ced 100644 --- a/tacker/vm/monitor.py +++ b/tacker/vm/monitor.py @@ -30,7 +30,7 @@ from tacker.common import driver_manager from tacker import context as t_context from tacker.openstack.common import jsonutils from tacker.openstack.common import log as logging -from tacker.vm.drivers.heat import heat +from tacker.vm.infra_drivers.heat import heat LOG = logging.getLogger(__name__) @@ -52,8 +52,8 @@ class VNFMonitor(object): _lock = threading.RLock() OPTS = [ - cfg.MultiStrOpt( - 'monitor_driver', default=[], + cfg.ListOpt( + 'monitor_driver', default=['ping', 'http_ping'], help=_('Monitor driver to communicate with ' 'Hosting VNF/logical service ' 'instance tacker plugin will use')), diff --git a/tacker/vm/plugin.py b/tacker/vm/plugin.py index 3b99c8968..59f8626d6 100644 --- a/tacker/vm/plugin.py +++ b/tacker/vm/plugin.py @@ -41,8 +41,8 @@ LOG = logging.getLogger(__name__) class VNFMMgmtMixin(object): OPTS = [ - cfg.MultiStrOpt( - 'mgmt_driver', default=[], + cfg.ListOpt( + 'mgmt_driver', default=['noop', 'openwrt'], help=_('MGMT driver to communicate with ' 'Hosting Device/logical service ' 'instance tacker plugin will use')), @@ -106,7 +106,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin): """ OPTS = [ cfg.ListOpt( - 'infra_driver', default=['heat'], + 'infra_driver', default=['nova', 'heat', 'noop'], help=_('Hosting device drivers tacker plugin will use')), ] cfg.CONF.register_opts(OPTS, 'tacker')