Add support for 'availability_zone' parameter.
I've added support for 'availability_zone' parameter. I've added 'dhcp_agent.ini' template and implemented the parameter to be consumed via 'neutron-plugin' relation settings. Change-Id: I015a6dfcf89800043bd7dbf02b07da07d8a7d728 Closes-Bug: 1595937
This commit is contained in:
parent
776d8950ee
commit
297b7eae98
|
@ -114,6 +114,32 @@ class OVSPluginContext(context.NeutronContext):
|
|||
return ovs_ctxt
|
||||
|
||||
|
||||
class DHCPAgentContext(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
"""Return the 'default_availability_zone' from the principal that this
|
||||
ovs unit is attached to (as a subordinate).
|
||||
|
||||
:returns: {} if no relation set, or
|
||||
{'availability_zone': availability_zone from principal relation}
|
||||
"""
|
||||
# as ovs is a subordinate charm, it should only have one relation to
|
||||
# its principal charm. Thus we can take the 1st (only) element in each
|
||||
# list.
|
||||
rids = relation_ids('neutron-plugin')
|
||||
if rids:
|
||||
rid = rids[0]
|
||||
units = related_units(rid)
|
||||
if units:
|
||||
availability_zone = relation_get(
|
||||
'default_availability_zone',
|
||||
rid=rid,
|
||||
unit=units[0])
|
||||
if availability_zone:
|
||||
return {'availability_zone': availability_zone}
|
||||
return {}
|
||||
|
||||
|
||||
class L3AgentContext(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
|
|
|
@ -178,7 +178,7 @@ METADATA_RESOURCE_MAP = OrderedDict([
|
|||
DHCP_RESOURCE_MAP = OrderedDict([
|
||||
(NEUTRON_DHCP_AGENT_CONF, {
|
||||
'services': ['neutron-dhcp-agent'],
|
||||
'contexts': [],
|
||||
'contexts': [neutron_ovs_context.DHCPAgentContext()],
|
||||
}),
|
||||
])
|
||||
DVR_RESOURCE_MAP = OrderedDict([
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# mitaka
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
[DEFAULT]
|
||||
state_path = /var/lib/neutron
|
||||
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
||||
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
|
||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||
|
||||
enable_metadata_network = True
|
||||
enable_isolated_metadata = True
|
||||
|
||||
ovs_use_veth = True
|
||||
|
||||
[AGENT]
|
||||
{% if availability_zone -%}
|
||||
availability_zone = {{ availability_zone }}
|
||||
{% endif -%}
|
|
@ -234,6 +234,44 @@ class OVSPluginContextTest(CharmTestCase):
|
|||
self.assertEquals(expect, napi_ctxt())
|
||||
|
||||
|
||||
class DHCPAgentContextTest(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DHCPAgentContextTest, self).setUp(context, TO_PATCH)
|
||||
self.config.side_effect = self.test_config.get
|
||||
|
||||
def tearDown(self):
|
||||
super(DHCPAgentContextTest, self).tearDown()
|
||||
|
||||
def test_default_availability_zone_not_provided(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = None
|
||||
self.assertEqual(
|
||||
context.DHCPAgentContext()(),
|
||||
{}
|
||||
)
|
||||
self.relation_ids.assert_called_with('neutron-plugin')
|
||||
self.relation_get.assert_called_once_with(
|
||||
'default_availability_zone',
|
||||
rid='rid1',
|
||||
unit='nova-compute/0')
|
||||
|
||||
def test_default_availability_zone_provided(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = 'nova'
|
||||
self.assertEqual(
|
||||
context.DHCPAgentContext()(),
|
||||
{'availability_zone': 'nova'}
|
||||
)
|
||||
self.relation_ids.assert_called_with('neutron-plugin')
|
||||
self.relation_get.assert_called_once_with(
|
||||
'default_availability_zone',
|
||||
rid='rid1',
|
||||
unit='nova-compute/0')
|
||||
|
||||
|
||||
class L3AgentContextTest(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue