Rename charm to neutron-gateway including code

This commit is contained in:
james.page@ubuntu.com 2015-05-07 10:27:07 +01:00
parent cc75012ac5
commit 0c3387dc3c
40 changed files with 217 additions and 227 deletions

View File

@ -3,4 +3,4 @@
exclude_lines =
if __name__ == .__main__.:
include=
hooks/quantum_*
hooks/neutron_*

View File

@ -26,5 +26,5 @@ test:
@juju test -v -p AMULET_HTTP_PROXY,AMULET_OS_VIP --timeout 2700
publish: lint unit_test
bzr push lp:charms/quantum-gateway
bzr push lp:charms/trusty/quantum-gateway
bzr push lp:charms/neutron-gateway
bzr push lp:charms/trusty/neutron-gateway

View File

@ -14,13 +14,9 @@ be suitable for all.
Neutron supports a rich plugin/extension framework for propriety networking
solutions and supports (in core) Nicira NVP, NEC, Cisco and others...
The Openstack charms currently only support the fully free OpenvSwitch plugin
and implements the 'Provider Router with Private Networks' use case.
See the upstream [Neutron documentation](http://docs.openstack.org/trunk/openstack-network/admin/content/use_cases_single_router.html)
for more details.
Usage
-----
@ -40,10 +36,10 @@ Neutron is deployed baked into these charms from install onwards:
The Neutron Gateway can then be added to the deploying:
juju deploy quantum-gateway
juju add-relation quantum-gateway mysql
juju add-relation quantum-gateway rabbitmq-server
juju add-relation quantum-gateway nova-cloud-controller
juju deploy neutron-gateway
juju add-relation neutron-gateway mysql
juju add-relation neutron-gateway rabbitmq-server
juju add-relation neutron-gateway nova-cloud-controller
The gateway provides two key services; L3 network routing and DHCP services.
@ -60,13 +56,13 @@ External Port Configuration
If the port to be used for external traffic is consistent accross all physical
servers then is can be specified by simply setting ext-port to the nic id:
quantum-gateway:
neutron-gateway:
ext-port: eth2
However, if it varies between hosts then the mac addresses of the external
nics for each host can be passed as a space seperated list:
quantum-gateway:
neutron-gateway:
ext-port: <MAC ext port host 1> <MAC ext port host 2> <MAC ext port host 3>
@ -74,25 +70,25 @@ Multiple Floating Pools
=======================
If multiple floating pools are needed then an L3 agent (which corresponds to
a quantum-gateway for the sake of this charm) is needed for each one. Each
a neutron-gateway for the sake of this charm) is needed for each one. Each
gateway needs to be deployed as a seperate service so that the external
network id can be set differently for each gateway e.g.
juju deploy quantum-gateway quantum-gateway-extnet1
juju add-relation quantum-gateway-extnet1 mysql
juju add-relation quantum-gateway-extnet1 rabbitmq-server
juju add-relation quantum-gateway-extnet1 nova-cloud-controller
juju deploy quantum-gateway quantum-gateway-extnet2
juju add-relation quantum-gateway-extnet2 mysql
juju add-relation quantum-gateway-extnet2 rabbitmq-server
juju add-relation quantum-gateway-extnet2 nova-cloud-controller
juju deploy neutron-gateway neutron-gateway-extnet1
juju add-relation neutron-gateway-extnet1 mysql
juju add-relation neutron-gateway-extnet1 rabbitmq-server
juju add-relation neutron-gateway-extnet1 nova-cloud-controller
juju deploy neutron-gateway neutron-gateway-extnet2
juju add-relation neutron-gateway-extnet2 mysql
juju add-relation neutron-gateway-extnet2 rabbitmq-server
juju add-relation neutron-gateway-extnet2 nova-cloud-controller
Create extnet1 and extnet2 via neutron client and take a note of their ids
juju set quantum-gateway-extnet1 "run-internal-router=leader"
juju set quantum-gateway-extnet2 "run-internal-router=none"
juju set quantum-gateway-extnet1 "external-network-id=<extnet1 id>"
juju set quantum-gateway-extnet2 "external-network-id=<extnet2 id>"
juju set neutron-gateway-extnet1 "run-internal-router=leader"
juju set neutron-gateway-extnet2 "run-internal-router=none"
juju set neutron-gateway-extnet1 "external-network-id=<extnet1 id>"
juju set neutron-gateway-extnet2 "external-network-id=<extnet2 id>"
Instance MTU
============
@ -102,7 +98,7 @@ packet fragmentation due to GRE overhead. One solution is to increase the MTU on
physical hosts and network equipment. When this is not possible or practical the
charm's instance-mtu option can be used to reduce instance MTU via DHCP.
juju set quantum-gateway instance-mtu=1400
juju set neutron-gateway instance-mtu=1400
OpenStack upstream documentation recomments a MTU value of 1400:
[Openstack documentation](http://docs.openstack.org/admin-guide-cloud/content/openvswitch_plugin.html)
@ -202,9 +198,3 @@ The following is a full list of current tip repos (may not be up-to-date):
- {name: neutron,
repository: 'git://github.com/openstack/neutron',
branch: master}
TODO
----
* Provide more network configuration use cases.
* Support VLAN in addition to GRE+OpenFlow for L2 separation.

View File

@ -14,11 +14,11 @@ from charmhelpers.core.hookenv import (
config,
)
from quantum_utils import (
from neutron_utils import (
git_install,
)
from quantum_hooks import (
from neutron_hooks import (
config_changed,
)

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -41,7 +41,7 @@ from charmhelpers.core.sysctl import create as create_sysctl
from charmhelpers.contrib.charmsupport import nrpe
import sys
from quantum_utils import (
from neutron_utils import (
L3HA_PACKAGES,
register_configs,
restart_map,

View File

@ -60,7 +60,7 @@ from charmhelpers.contrib.openstack.context import (
)
import charmhelpers.contrib.openstack.templating as templating
from charmhelpers.contrib.openstack.neutron import headers_package
from quantum_contexts import (
from neutron_contexts import (
CORE_PLUGIN, OVS, NVP, NSX, N1KV,
NEUTRON, QUANTUM,
networking_name,

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1 +1 @@
quantum_hooks.py
neutron_hooks.py

View File

@ -1,4 +1,4 @@
name: quantum-gateway
name: neutron-gateway
summary: Virtual Networking for OpenStack - Neutron Gateway
maintainer: James Page <james.page@ubuntu.com>
description: |

View File

@ -2,7 +2,7 @@ from mock import patch, MagicMock
with patch('charmhelpers.core.hookenv.config') as config:
config.return_value = 'neutron'
import quantum_utils as utils # noqa
import neutron_utils as utils # noqa
# Need to do some early patching to get the module loaded.
_register_configs = utils.register_configs

View File

@ -3,7 +3,7 @@ from mock import (
MagicMock,
patch
)
import quantum_contexts
import neutron_contexts
import sys
from contextlib import contextmanager
@ -50,60 +50,60 @@ class DummyNeutronAPIContext():
class TestL3AgentContext(CharmTestCase):
def setUp(self):
super(TestL3AgentContext, self).setUp(quantum_contexts,
super(TestL3AgentContext, self).setUp(neutron_contexts,
TO_PATCH)
self.config.side_effect = self.test_config.get
@patch('quantum_contexts.NeutronAPIContext')
@patch('neutron_contexts.NeutronAPIContext')
def test_no_ext_netid(self, _NeutronAPIContext):
_NeutronAPIContext.return_value = \
DummyNeutronAPIContext(return_value={'enable_dvr': False})
self.test_config.set('run-internal-router', 'none')
self.test_config.set('external-network-id', '')
self.eligible_leader.return_value = False
self.assertEquals(quantum_contexts.L3AgentContext()(),
self.assertEquals(neutron_contexts.L3AgentContext()(),
{'agent_mode': 'legacy',
'handle_internal_only_router': False,
'plugin': 'ovs'})
@patch('quantum_contexts.NeutronAPIContext')
@patch('neutron_contexts.NeutronAPIContext')
def test_hior_leader(self, _NeutronAPIContext):
_NeutronAPIContext.return_value = \
DummyNeutronAPIContext(return_value={'enable_dvr': False})
self.test_config.set('run-internal-router', 'leader')
self.test_config.set('external-network-id', 'netid')
self.eligible_leader.return_value = True
self.assertEquals(quantum_contexts.L3AgentContext()(),
self.assertEquals(neutron_contexts.L3AgentContext()(),
{'agent_mode': 'legacy',
'handle_internal_only_router': True,
'ext_net_id': 'netid',
'plugin': 'ovs'})
@patch('quantum_contexts.NeutronAPIContext')
@patch('neutron_contexts.NeutronAPIContext')
def test_hior_all(self, _NeutronAPIContext):
_NeutronAPIContext.return_value = \
DummyNeutronAPIContext(return_value={'enable_dvr': False})
self.test_config.set('run-internal-router', 'all')
self.test_config.set('external-network-id', 'netid')
self.eligible_leader.return_value = True
self.assertEquals(quantum_contexts.L3AgentContext()(),
self.assertEquals(neutron_contexts.L3AgentContext()(),
{'agent_mode': 'legacy',
'handle_internal_only_router': True,
'ext_net_id': 'netid',
'plugin': 'ovs'})
@patch('quantum_contexts.NeutronAPIContext')
@patch('neutron_contexts.NeutronAPIContext')
def test_dvr(self, _NeutronAPIContext):
_NeutronAPIContext.return_value = \
DummyNeutronAPIContext(return_value={'enable_dvr': True})
self.assertEquals(quantum_contexts.L3AgentContext()()['agent_mode'],
self.assertEquals(neutron_contexts.L3AgentContext()()['agent_mode'],
'dvr_snat')
class TestQuantumGatewayContext(CharmTestCase):
def setUp(self):
super(TestQuantumGatewayContext, self).setUp(quantum_contexts,
super(TestQuantumGatewayContext, self).setUp(neutron_contexts,
TO_PATCH)
self.config.side_effect = self.test_config.get
self.maxDiff = None
@ -111,8 +111,8 @@ class TestQuantumGatewayContext(CharmTestCase):
@patch('charmhelpers.contrib.openstack.context.relation_get')
@patch('charmhelpers.contrib.openstack.context.related_units')
@patch('charmhelpers.contrib.openstack.context.relation_ids')
@patch.object(quantum_contexts, 'get_shared_secret')
@patch.object(quantum_contexts, 'get_host_ip')
@patch.object(neutron_contexts, 'get_shared_secret')
@patch.object(neutron_contexts, 'get_host_ip')
def test_all(self, _host_ip, _secret, _rids, _runits, _rget):
rdata = {'l2-population': 'True',
'enable-dvr': 'True',
@ -133,7 +133,7 @@ class TestQuantumGatewayContext(CharmTestCase):
self.get_os_codename_install_source.return_value = 'folsom'
_host_ip.return_value = '10.5.0.1'
_secret.return_value = 'testsecret'
ctxt = quantum_contexts.QuantumGatewayContext()()
ctxt = neutron_contexts.QuantumGatewayContext()()
self.assertEquals(ctxt, {
'shared_secret': 'testsecret',
'enable_dvr': True,
@ -158,7 +158,7 @@ class TestQuantumGatewayContext(CharmTestCase):
class TestSharedSecret(CharmTestCase):
def setUp(self):
super(TestSharedSecret, self).setUp(quantum_contexts,
super(TestSharedSecret, self).setUp(neutron_contexts,
TO_PATCH)
self.config.side_effect = self.test_config.get
@ -168,10 +168,10 @@ class TestSharedSecret(CharmTestCase):
_path.exists.return_value = False
_uuid4.return_value = 'secret_thing'
with patch_open() as (_open, _file):
self.assertEquals(quantum_contexts.get_shared_secret(),
self.assertEquals(neutron_contexts.get_shared_secret(),
'secret_thing')
_open.assert_called_with(
quantum_contexts.SHARED_SECRET.format('quantum'), 'w')
neutron_contexts.SHARED_SECRET.format('quantum'), 'w')
_file.write.assert_called_with('secret_thing')
@patch('os.path')
@ -179,16 +179,16 @@ class TestSharedSecret(CharmTestCase):
_path.exists.return_value = True
with patch_open() as (_open, _file):
_file.read.return_value = 'secret_thing\n'
self.assertEquals(quantum_contexts.get_shared_secret(),
self.assertEquals(neutron_contexts.get_shared_secret(),
'secret_thing')
_open.assert_called_with(
quantum_contexts.SHARED_SECRET.format('quantum'), 'r')
neutron_contexts.SHARED_SECRET.format('quantum'), 'r')
class TestHostIP(CharmTestCase):
def setUp(self):
super(TestHostIP, self).setUp(quantum_contexts,
super(TestHostIP, self).setUp(neutron_contexts,
TO_PATCH)
self.config.side_effect = self.test_config.get
# Save and inject
@ -206,12 +206,12 @@ class TestHostIP(CharmTestCase):
del sys.modules[mod]
def test_get_host_ip_already_ip(self):
self.assertEquals(quantum_contexts.get_host_ip('10.5.0.1'),
self.assertEquals(neutron_contexts.get_host_ip('10.5.0.1'),
'10.5.0.1')
def test_get_host_ip_noarg(self):
self.unit_get.return_value = "10.5.0.1"
self.assertEquals(quantum_contexts.get_host_ip(),
self.assertEquals(neutron_contexts.get_host_ip(),
'10.5.0.1')
@patch('dns.resolver.query')
@ -219,7 +219,7 @@ class TestHostIP(CharmTestCase):
class NXDOMAIN(Exception):
pass
_query.side_effect = NXDOMAIN()
self.assertRaises(NXDOMAIN, quantum_contexts.get_host_ip,
self.assertRaises(NXDOMAIN, neutron_contexts.get_host_ip,
'missing.example.com')
@patch('dns.resolver.query')
@ -227,7 +227,7 @@ class TestHostIP(CharmTestCase):
data = MagicMock()
data.address = '10.5.0.1'
_query.return_value = [data]
self.assertEquals(quantum_contexts.get_host_ip('myhost.example.com'),
self.assertEquals(neutron_contexts.get_host_ip('myhost.example.com'),
'10.5.0.1')
_query.assert_called_with('myhost.example.com', 'A')
@ -236,39 +236,39 @@ class TestMisc(CharmTestCase):
def setUp(self):
super(TestMisc,
self).setUp(quantum_contexts,
self).setUp(neutron_contexts,
TO_PATCH)
def test_lt_havana(self):
self.get_os_codename_install_source.return_value = 'folsom'
self.assertEquals(quantum_contexts.networking_name(), 'quantum')
self.assertEquals(neutron_contexts.networking_name(), 'quantum')
def test_ge_havana(self):
self.get_os_codename_install_source.return_value = 'havana'
self.assertEquals(quantum_contexts.networking_name(), 'neutron')
self.assertEquals(neutron_contexts.networking_name(), 'neutron')
def test_remap_plugin(self):
self.get_os_codename_install_source.return_value = 'havana'
self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nvp')
self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nvp')
self.assertEquals(neutron_contexts.remap_plugin('nvp'), 'nvp')
self.assertEquals(neutron_contexts.remap_plugin('nsx'), 'nvp')
def test_remap_plugin_icehouse(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nsx')
self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nsx')
self.assertEquals(neutron_contexts.remap_plugin('nvp'), 'nsx')
self.assertEquals(neutron_contexts.remap_plugin('nsx'), 'nsx')
def test_remap_plugin_noop(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertEquals(quantum_contexts.remap_plugin('ovs'), 'ovs')
self.assertEquals(neutron_contexts.remap_plugin('ovs'), 'ovs')
def test_core_plugin(self):
self.get_os_codename_install_source.return_value = 'havana'
self.config.return_value = 'ovs'
self.assertEquals(quantum_contexts.core_plugin(),
quantum_contexts.NEUTRON_OVS_PLUGIN)
self.assertEquals(neutron_contexts.core_plugin(),
neutron_contexts.NEUTRON_OVS_PLUGIN)
def test_core_plugin_ml2(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.config.return_value = 'ovs'
self.assertEquals(quantum_contexts.core_plugin(),
quantum_contexts.NEUTRON_ML2_PLUGIN)
self.assertEquals(neutron_contexts.core_plugin(),
neutron_contexts.NEUTRON_ML2_PLUGIN)

View File

@ -2,12 +2,12 @@ from mock import MagicMock, patch, call
import yaml
import charmhelpers.core.hookenv as hookenv
hookenv.config = MagicMock()
import quantum_utils as utils
import neutron_utils as utils
_register_configs = utils.register_configs
_restart_map = utils.restart_map
utils.register_configs = MagicMock()
utils.restart_map = MagicMock()
import quantum_hooks as hooks
import neutron_hooks as hooks
utils.register_configs = _register_configs
utils.restart_map = _restart_map

View File

@ -4,7 +4,7 @@ import charmhelpers.contrib.openstack.templating as templating
templating.OSConfigRenderer = MagicMock()
import quantum_utils
import neutron_utils
try:
@ -72,7 +72,7 @@ class TestQuantumUtils(CharmTestCase):
self.assertEqual(v1, v2, msg)
def setUp(self):
super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH)
super(TestQuantumUtils, self).setUp(neutron_utils, TO_PATCH)
self.networking_name.return_value = 'neutron'
self.headers_package.return_value = 'linux-headers-2.6.18'
self._set_distrib_codename('trusty')
@ -90,92 +90,92 @@ class TestQuantumUtils(CharmTestCase):
def test_valid_plugin(self):
self.config.return_value = 'ovs'
self.assertTrue(quantum_utils.valid_plugin())
self.assertTrue(neutron_utils.valid_plugin())
self.config.return_value = 'nvp'
self.assertTrue(quantum_utils.valid_plugin())
self.assertTrue(neutron_utils.valid_plugin())
self.config.return_value = 'nsx'
self.assertTrue(quantum_utils.valid_plugin())
self.assertTrue(neutron_utils.valid_plugin())
def test_invalid_plugin(self):
self.config.return_value = 'invalid'
self.assertFalse(quantum_utils.valid_plugin())
self.assertFalse(neutron_utils.valid_plugin())
def test_get_early_packages_ovs(self):
self.config.return_value = 'ovs'
self.determine_dkms_package.return_value = [
'openvswitch-datapath-dkms']
self.assertEquals(
quantum_utils.get_early_packages(),
neutron_utils.get_early_packages(),
['openvswitch-datapath-dkms', 'linux-headers-2.6.18'])
def test_get_early_packages_nvp(self):
self.config.return_value = 'nvp'
self.assertEquals(
quantum_utils.get_early_packages(),
neutron_utils.get_early_packages(),
[])
def test_get_early_packages_empty(self):
self.config.return_value = 'noop'
self.assertEquals(quantum_utils.get_early_packages(),
self.assertEquals(neutron_utils.get_early_packages(),
[])
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'havana'
self.assertNotEqual(quantum_utils.get_packages(), [])
self.assertNotEqual(neutron_utils.get_packages(), [])
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs_icehouse(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages())
self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages())
self.assertTrue('neutron-vpn-agent' in neutron_utils.get_packages())
self.assertFalse('neutron-l3-agent' in neutron_utils.get_packages())
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs_juno_utopic(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'juno'
self._set_distrib_codename('utopic')
self.assertFalse('neutron-vpn-agent' in quantum_utils.get_packages())
self.assertTrue('neutron-l3-agent' in quantum_utils.get_packages())
self.assertFalse('neutron-vpn-agent' in neutron_utils.get_packages())
self.assertTrue('neutron-l3-agent' in neutron_utils.get_packages())
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs_juno_trusty(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'juno'
self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages())
self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages())
self.assertTrue('neutron-vpn-agent' in neutron_utils.get_packages())
self.assertFalse('neutron-l3-agent' in neutron_utils.get_packages())
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs_kilo(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'kilo'
self.assertTrue('python-neutron-fwaas' in quantum_utils.get_packages())
self.assertTrue('python-neutron-fwaas' in neutron_utils.get_packages())
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_l3ha(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'juno'
self.assertTrue('keepalived' in quantum_utils.get_packages())
self.assertTrue('keepalived' in neutron_utils.get_packages())
@patch('charmhelpers.contrib.openstack.context.config')
def test_configure_ovs_starts_service_if_required(self, mock_config):
mock_config.side_effect = self.test_config.get
self.config.return_value = 'ovs'
self.service_running.return_value = False
quantum_utils.configure_ovs()
neutron_utils.configure_ovs()
self.assertTrue(self.full_restart.called)
def test_configure_ovs_doesnt_restart_service(self):
self.service_running.return_value = True
quantum_utils.configure_ovs()
neutron_utils.configure_ovs()
self.assertFalse(self.full_restart.called)
@patch('charmhelpers.contrib.openstack.context.config')
@ -186,7 +186,7 @@ class TestQuantumUtils(CharmTestCase):
self.test_config.set('ext-port', 'eth0')
self.ExternalPortContext.return_value = \
DummyExternalPortContext(return_value={'ext_port': 'eth0'})
quantum_utils.configure_ovs()
neutron_utils.configure_ovs()
self.add_bridge.assert_has_calls([
call('br-int'),
call('br-ex'),
@ -204,7 +204,7 @@ class TestQuantumUtils(CharmTestCase):
# Test back-compatibility i.e. port but no bridge (so br-data is
# assumed)
self.test_config.set('data-port', 'eth0')
quantum_utils.configure_ovs()
neutron_utils.configure_ovs()
self.add_bridge.assert_has_calls([
call('br-int'),
call('br-ex'),
@ -216,7 +216,7 @@ class TestQuantumUtils(CharmTestCase):
self.test_config.set('data-port', 'br-foo:eth0')
self.add_bridge.reset_mock()
self.add_bridge_port.reset_mock()
quantum_utils.configure_ovs()
neutron_utils.configure_ovs()
self.add_bridge.assert_has_calls([
call('br-int'),
call('br-ex'),
@ -225,7 +225,7 @@ class TestQuantumUtils(CharmTestCase):
# Not called since we have a bogus bridge in data-ports
self.assertFalse(self.add_bridge_port.called)
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_install_requested')
def test_do_openstack_upgrade(self, git_requested):
git_requested.return_value = False
self.config.side_effect = self.test_config.get
@ -233,7 +233,7 @@ class TestQuantumUtils(CharmTestCase):
self.test_config.set('openstack-origin', 'cloud:precise-havana')
self.test_config.set('plugin', 'ovs')
self.get_os_codename_install_source.return_value = 'havana'
quantum_utils.do_openstack_upgrade()
neutron_utils.do_openstack_upgrade()
self.assertTrue(self.log.called)
self.apt_update.assert_called_with(fatal=True)
dpkg_opts = [
@ -250,36 +250,36 @@ class TestQuantumUtils(CharmTestCase):
def test_register_configs_ovs(self):
self.config.return_value = 'ovs'
self.is_relation_made.return_value = False
configs = quantum_utils.register_configs()
confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF,
quantum_utils.NEUTRON_METADATA_AGENT_CONF,
quantum_utils.NOVA_CONF,
quantum_utils.NEUTRON_CONF,
quantum_utils.NEUTRON_L3_AGENT_CONF,
quantum_utils.NEUTRON_OVS_PLUGIN_CONF,
quantum_utils.EXT_PORT_CONF]
configs = neutron_utils.register_configs()
confs = [neutron_utils.NEUTRON_DHCP_AGENT_CONF,
neutron_utils.NEUTRON_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF,
neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
quantum_utils.CONFIG_FILES['neutron'][quantum_utils.OVS][conf]
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
['hook_contexts']
)
def test_register_configs_amqp_nova(self):
self.config.return_value = 'ovs'
self.is_relation_made.return_value = True
configs = quantum_utils.register_configs()
confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF,
quantum_utils.NEUTRON_METADATA_AGENT_CONF,
quantum_utils.NOVA_CONF,
quantum_utils.NEUTRON_CONF,
quantum_utils.NEUTRON_L3_AGENT_CONF,
quantum_utils.NEUTRON_OVS_PLUGIN_CONF,
quantum_utils.EXT_PORT_CONF]
configs = neutron_utils.register_configs()
confs = [neutron_utils.NEUTRON_DHCP_AGENT_CONF,
neutron_utils.NEUTRON_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF,
neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
quantum_utils.CONFIG_FILES['neutron'][quantum_utils.OVS][conf]
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
['hook_contexts']
)
@ -287,7 +287,7 @@ class TestQuantumUtils(CharmTestCase):
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'havana'
ex_map = {
quantum_utils.NEUTRON_CONF: ['neutron-l3-agent',
neutron_utils.NEUTRON_CONF: ['neutron-l3-agent',
'neutron-dhcp-agent',
'neutron-metadata-agent',
'neutron-plugin-openvswitch-agent',
@ -296,62 +296,62 @@ class TestQuantumUtils(CharmTestCase):
'neutron-lbaas-agent',
'neutron-plugin-vpn-agent',
'neutron-vpn-agent'],
quantum_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
quantum_utils.NEUTRON_LBAAS_AGENT_CONF:
neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_LBAAS_AGENT_CONF:
['neutron-lbaas-agent'],
quantum_utils.NEUTRON_OVS_PLUGIN_CONF:
neutron_utils.NEUTRON_OVS_PLUGIN_CONF:
['neutron-plugin-openvswitch-agent'],
quantum_utils.NEUTRON_METADATA_AGENT_CONF:
neutron_utils.NEUTRON_METADATA_AGENT_CONF:
['neutron-metadata-agent'],
quantum_utils.NEUTRON_VPNAAS_AGENT_CONF: [
neutron_utils.NEUTRON_VPNAAS_AGENT_CONF: [
'neutron-plugin-vpn-agent',
'neutron-vpn-agent'],
quantum_utils.NEUTRON_L3_AGENT_CONF: ['neutron-l3-agent',
neutron_utils.NEUTRON_L3_AGENT_CONF: ['neutron-l3-agent',
'neutron-vpn-agent'],
quantum_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
quantum_utils.NEUTRON_FWAAS_CONF: ['neutron-l3-agent',
neutron_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_FWAAS_CONF: ['neutron-l3-agent',
'neutron-vpn-agent'],
quantum_utils.NEUTRON_METERING_AGENT_CONF:
neutron_utils.NEUTRON_METERING_AGENT_CONF:
['neutron-metering-agent', 'neutron-plugin-metering-agent'],
quantum_utils.NOVA_CONF: ['nova-api-metadata'],
quantum_utils.EXT_PORT_CONF: ['ext-port'],
quantum_utils.PHY_NIC_MTU_CONF: ['os-charm-phy-nic-mtu'],
neutron_utils.NOVA_CONF: ['nova-api-metadata'],
neutron_utils.EXT_PORT_CONF: ['ext-port'],
neutron_utils.PHY_NIC_MTU_CONF: ['os-charm-phy-nic-mtu'],
}
self.assertDictEqual(quantum_utils.restart_map(), ex_map)
self.assertDictEqual(neutron_utils.restart_map(), ex_map)
def test_register_configs_nvp(self):
self.config.return_value = 'nvp'
self.is_relation_made.return_value = False
configs = quantum_utils.register_configs()
confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF,
quantum_utils.NEUTRON_METADATA_AGENT_CONF,
quantum_utils.NOVA_CONF,
quantum_utils.NEUTRON_CONF]
configs = neutron_utils.register_configs()
confs = [neutron_utils.NEUTRON_DHCP_AGENT_CONF,
neutron_utils.NEUTRON_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
quantum_utils.CONFIG_FILES['neutron'][quantum_utils.NVP][conf]
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NVP][conf]
['hook_contexts']
)
def test_register_configs_nsx(self):
self.config.return_value = 'nsx'
configs = quantum_utils.register_configs()
confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF,
quantum_utils.NEUTRON_METADATA_AGENT_CONF,
quantum_utils.NOVA_CONF,
quantum_utils.NEUTRON_CONF]
configs = neutron_utils.register_configs()
confs = [neutron_utils.NEUTRON_DHCP_AGENT_CONF,
neutron_utils.NEUTRON_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
quantum_utils.CONFIG_FILES['neutron'][quantum_utils.NSX][conf]
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NSX][conf]
['hook_contexts']
)
def test_stop_services_nvp(self):
self.config.return_value = 'nvp'
quantum_utils.stop_services()
neutron_utils.stop_services()
calls = [
call('neutron-dhcp-agent'),
call('nova-api-metadata'),
@ -364,7 +364,7 @@ class TestQuantumUtils(CharmTestCase):
def test_stop_services_ovs(self):
self.config.return_value = 'ovs'
quantum_utils.stop_services()
neutron_utils.stop_services()
calls = [call('neutron-dhcp-agent'),
call('neutron-plugin-openvswitch-agent'),
call('nova-api-metadata'),
@ -378,75 +378,75 @@ class TestQuantumUtils(CharmTestCase):
def test_restart_map_nvp(self):
self.config.return_value = 'nvp'
ex_map = {
quantum_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
quantum_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
quantum_utils.NOVA_CONF: ['nova-api-metadata'],
quantum_utils.NEUTRON_CONF: ['neutron-dhcp-agent',
neutron_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
neutron_utils.NOVA_CONF: ['nova-api-metadata'],
neutron_utils.NEUTRON_CONF: ['neutron-dhcp-agent',
'neutron-metadata-agent'],
quantum_utils.NEUTRON_METADATA_AGENT_CONF:
neutron_utils.NEUTRON_METADATA_AGENT_CONF:
['neutron-metadata-agent'],
}
self.assertEquals(quantum_utils.restart_map(), ex_map)
self.assertEquals(neutron_utils.restart_map(), ex_map)
def test_register_configs_pre_install(self):
self.config.return_value = 'ovs'
self.is_relation_made.return_value = False
self.networking_name.return_value = 'quantum'
configs = quantum_utils.register_configs()
confs = [quantum_utils.QUANTUM_DHCP_AGENT_CONF,
quantum_utils.QUANTUM_METADATA_AGENT_CONF,
quantum_utils.NOVA_CONF,
quantum_utils.QUANTUM_CONF,
quantum_utils.QUANTUM_L3_AGENT_CONF,
quantum_utils.QUANTUM_OVS_PLUGIN_CONF,
quantum_utils.EXT_PORT_CONF]
configs = neutron_utils.register_configs()
confs = [neutron_utils.QUANTUM_DHCP_AGENT_CONF,
neutron_utils.QUANTUM_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.QUANTUM_CONF,
neutron_utils.QUANTUM_L3_AGENT_CONF,
neutron_utils.QUANTUM_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF]
print configs.register.mock_calls
for conf in confs:
configs.register.assert_any_call(
conf,
quantum_utils.CONFIG_FILES['quantum'][quantum_utils.OVS][conf]
neutron_utils.CONFIG_FILES['quantum'][neutron_utils.OVS][conf]
['hook_contexts']
)
def test_get_common_package_quantum(self):
self.get_os_codename_package.return_value = 'folsom'
self.assertEquals(quantum_utils.get_common_package(), 'quantum-common')
self.assertEquals(neutron_utils.get_common_package(), 'quantum-common')
def test_get_common_package_neutron(self):
self.get_os_codename_package.return_value = None
self.assertEquals(quantum_utils.get_common_package(), 'neutron-common')
self.assertEquals(neutron_utils.get_common_package(), 'neutron-common')
def test_copy_file_without_update(self):
src = 'dummy_source_dir/dummy_file'
dst = 'dummy_des_dir'
quantum_utils.copy_file(src, dst)
neutron_utils.copy_file(src, dst)
self.assertTrue(self.mkdir.called)
self.assertTrue(self.copy2.called)
@patch('quantum_utils.os.path.isfile')
@patch('neutron_utils.os.path.isfile')
def test_copy_file_with_update(self, _isfile):
src = 'dummy_source_dir/dummy_file'
dst = 'dummy_des_dir'
_isfile.return_value = False
quantum_utils.copy_file(src, dst, force=True)
neutron_utils.copy_file(src, dst, force=True)
self.assertTrue(self.mkdir.called)
self.assertTrue(self.copy2.called)
@patch('quantum_utils.os.remove')
@patch('quantum_utils.os.path.isfile')
@patch('neutron_utils.os.remove')
@patch('neutron_utils.os.path.isfile')
def test_remove_file_exists(self, _isfile, _remove):
path = 'dummy_des_dir/dummy_file'
_isfile.return_value = True
quantum_utils.remove_file(path)
neutron_utils.remove_file(path)
self.assertTrue(_remove.called)
self.assertFalse(self.log.called)
@patch('quantum_utils.os.remove')
@patch('quantum_utils.os.path.isfile')
@patch('neutron_utils.os.remove')
@patch('neutron_utils.os.path.isfile')
def test_remove_file_non_exists(self, _isfile, _remove):
path = 'dummy_des_dir/dummy_file'
_isfile.return_value = False
quantum_utils.remove_file(path)
neutron_utils.remove_file(path)
self.assertFalse(_remove.called)
self.assertTrue(self.log.called)
@ -608,7 +608,7 @@ class TestQuantumAgentReallocation(CharmTestCase):
def setUp(self):
if not neutronclient:
raise self.skipTest('Skipping, no neutronclient installed')
super(TestQuantumAgentReallocation, self).setUp(quantum_utils,
super(TestQuantumAgentReallocation, self).setUp(neutron_utils,
TO_PATCH)
def tearDown(self):
@ -618,7 +618,7 @@ class TestQuantumAgentReallocation(CharmTestCase):
def test_no_network_context(self):
self.NetworkServiceContext.return_value = \
DummyNetworkServiceContext(return_value=None)
quantum_utils.reassign_agent_resources()
neutron_utils.reassign_agent_resources()
self.assertTrue(self.log.called)
@patch('neutronclient.v2_0.client.Client')
@ -628,7 +628,7 @@ class TestQuantumAgentReallocation(CharmTestCase):
dummy_client = MagicMock()
dummy_client.list_agents.side_effect = agents_all_alive.itervalues()
_client.return_value = dummy_client
quantum_utils.reassign_agent_resources()
neutron_utils.reassign_agent_resources()
dummy_client.add_router_to_l3_agent.assert_not_called()
dummy_client.remove_router_from_l3_agent.assert_not_called()
dummy_client.add_network_to_dhcp_agent.assert_not_called()
@ -649,7 +649,7 @@ class TestQuantumAgentReallocation(CharmTestCase):
self.unit_private_ip.return_value = 'cluster2-machine1.internal'
self.relations_of_type.return_value = \
[{'private-address': 'cluster2-machine3.internal'}]
quantum_utils.reassign_agent_resources()
neutron_utils.reassign_agent_resources()
# Ensure routers removed from dead l3 agent
dummy_client.remove_router_from_l3_agent.assert_has_calls(
@ -690,33 +690,33 @@ class TestQuantumAgentReallocation(CharmTestCase):
_client.return_value = dummy_client
self.unit_private_ip.return_value = 'cluster1-machine1.internal'
self.relations_of_type.return_value = []
quantum_utils.reassign_agent_resources()
neutron_utils.reassign_agent_resources()
self.assertTrue(self.log.called)
assert not dummy_client.remove_router_from_l3_agent.called
assert not dummy_client.remove_network_from_dhcp_agent.called
@patch.object(quantum_utils, 'git_install_requested')
@patch.object(quantum_utils, 'git_clone_and_install')
@patch.object(quantum_utils, 'git_post_install')
@patch.object(quantum_utils, 'git_pre_install')
@patch.object(neutron_utils, 'git_install_requested')
@patch.object(neutron_utils, 'git_clone_and_install')
@patch.object(neutron_utils, 'git_post_install')
@patch.object(neutron_utils, 'git_pre_install')
def test_git_install(self, git_pre, git_post, git_clone_and_install,
git_requested):
projects_yaml = openstack_origin_git
git_requested.return_value = True
quantum_utils.git_install(projects_yaml)
neutron_utils.git_install(projects_yaml)
self.assertTrue(git_pre.called)
git_clone_and_install.assert_called_with(openstack_origin_git,
core_project='neutron')
self.assertTrue(git_post.called)
@patch.object(quantum_utils, 'mkdir')
@patch.object(quantum_utils, 'write_file')
@patch.object(quantum_utils, 'add_user_to_group')
@patch.object(quantum_utils, 'add_group')
@patch.object(quantum_utils, 'adduser')
@patch.object(neutron_utils, 'mkdir')
@patch.object(neutron_utils, 'write_file')
@patch.object(neutron_utils, 'add_user_to_group')
@patch.object(neutron_utils, 'add_group')
@patch.object(neutron_utils, 'adduser')
def test_git_pre_install(self, adduser, add_group, add_user_to_group,
write_file, mkdir):
quantum_utils.git_pre_install()
neutron_utils.git_pre_install()
adduser.assert_called_with('neutron', shell='/bin/bash',
system_user=True)
add_group.assert_called_with('neutron', system_group=True)
@ -779,8 +779,8 @@ class TestQuantumAgentReallocation(CharmTestCase):
self.assertEquals(write_file.call_args_list, expected)
@patch('os.remove')
@patch.object(quantum_utils, 'git_src_dir')
@patch.object(quantum_utils, 'render')
@patch.object(neutron_utils, 'git_src_dir')
@patch.object(neutron_utils, 'render')
@patch('os.path.join')
@patch('os.path.exists')
@patch('os.symlink')
@ -791,7 +791,7 @@ class TestQuantumAgentReallocation(CharmTestCase):
exists, join, render, git_src_dir, remove):
projects_yaml = openstack_origin_git
join.return_value = 'joined-string'
quantum_utils.git_post_install(projects_yaml)
neutron_utils.git_post_install(projects_yaml)
expected = [
call('joined-string', '/etc/neutron'),
call('joined-string', '/etc/neutron/plugins'),