Remove asn configuration option

This configuration option is only used for CI testing and
may be confusing for a unsuspecting end user.

Change is coupled with PR on zaza that updates the dragent
test to get information about configured asns by inspecting
relation data on `neutron-dynamic-routing` and `quagga`
units.

Depends-On: I8b1508361fdc7541c0fc231e7e816651626596b7
Change-Id: I41360518ab2e65a207e238d95a39b763897d4fbc
This commit is contained in:
Frode Nordahl 2018-05-14 12:52:09 +02:00
parent dc79712d49
commit 7be2ae2bd8
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
8 changed files with 47 additions and 25 deletions

View File

@ -1,9 +0,0 @@
options:
asn:
default:
type: int
description: |
BGP Autonomous System Number for the OpenStack networks being advertised.
This setting is primarily used for testing. In production use ASNs are
configured post-deployment via the OpenStack client when creating bgp
speakers.

View File

@ -87,6 +87,17 @@ def bgp_speaker_bindings():
return [SPEAKER_BINDING]
def get_os_codename():
"""Return OpenStack Codename for installed application
:returns: OpenStack Codename
:rtype: str
"""
return DRAgentCharm.singleton.get_os_codename_package(
DRAgentCharm.singleton.release_pkg,
DRAgentCharm.singleton.package_codenames)
@os_adapters.config_property
def provider_ip(cls):
"""Return the provider binding network IP

View File

@ -16,7 +16,6 @@
from __future__ import absolute_import
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
import charms_openstack.charm as charm
@ -38,9 +37,13 @@ charm.use_defaults(
def publish_bgp_info(endpoint):
"""Publish BGP information about this unit to interface-bgp peers
"""
endpoint.publish_info(asn=hookenv.config('asn'),
passive=True,
bindings=dragent.bgp_speaker_bindings())
if dragent.get_os_codename() == 'pike':
use_16bit_asn = True
else:
use_16bit_asn = False
endpoint.publish_info(passive=True,
bindings=dragent.bgp_speaker_bindings(),
use_16bit_asn=use_16bit_asn)
dragent.assess_status()

View File

@ -28,7 +28,6 @@ applications:
neutron-dynamic-routing:
charm: ../../../neutron-dynamic-routing
num_units: 1
options: {asn: 12345}
series: bionic
rabbitmq-server:
charm: cs:~openstack-charmers-next/bionic/rabbitmq-server
@ -38,6 +37,5 @@ applications:
quagga:
charm: cs:~openstack-charmers-next/bionic/quagga
num_units: 1
options: {asn: 10000}
series: bionic

View File

@ -30,7 +30,7 @@ applications:
neutron-dynamic-routing:
charm: ../../../neutron-dynamic-routing
num_units: 1
options: {asn: 12345, openstack-origin: 'cloud:xenial-pike/proposed'}
options: {openstack-origin: 'cloud:xenial-pike/proposed'}
series: xenial
rabbitmq-server:
charm: cs:~openstack-charmers-next/xenial/rabbitmq-server
@ -41,6 +41,6 @@ applications:
quagga:
charm: cs:~openstack-charmers-next/xenial/quagga
num_units: 1
options: {asn: 10000}
options: {use-16bit-asn: True}
series: xenial

View File

@ -29,7 +29,7 @@ applications:
neutron-dynamic-routing:
charm: ../../../neutron-dynamic-routing
num_units: 1
options: {asn: 12345, openstack-origin: 'cloud:xenial-queens/proposed'}
options: {openstack-origin: 'cloud:xenial-queens/proposed'}
series: xenial
rabbitmq-server:
charm: cs:~openstack-charmers-next/xenial/rabbitmq-server
@ -40,6 +40,5 @@ applications:
quagga:
charm: cs:~openstack-charmers-next/xenial/quagga
num_units: 1
options: {asn: 10000}
series: xenial

View File

@ -122,16 +122,28 @@ class TestDRAgentHandlers(unittest.TestCase):
"{}: incorrect state registration".format(f))
def test_publish_bgp_info(self):
_asn = 12345
_bindings = ['bgp-speaker']
self.patch(handlers.dragent, 'assess_status')
self.patch(handlers.hookenv, 'config')
self.config.return_value = _asn
self.patch(handlers.dragent, 'get_os_codename')
bgp = mock.MagicMock()
self.get_os_codename.return_value = 'queens'
handlers.publish_bgp_info(bgp)
bgp.publish_info.assert_called_once_with(asn=_asn,
passive=True,
bindings=_bindings)
self.get_os_codename.assert_called()
bgp.publish_info.assert_called_once_with(passive=True,
bindings=_bindings,
use_16bit_asn=False)
def test_publish_bgp_info_pike(self):
_bindings = ['bgp-speaker']
self.patch(handlers.dragent, 'assess_status')
self.patch(handlers.dragent, 'get_os_codename')
bgp = mock.MagicMock()
self.get_os_codename.return_value = 'pike'
handlers.publish_bgp_info(bgp)
self.get_os_codename.assert_called()
bgp.publish_info.assert_called_once_with(passive=True,
bindings=_bindings,
use_16bit_asn=True)
def test_setup_amqp_req(self):
self.patch(handlers.dragent, 'assess_status')

View File

@ -44,6 +44,14 @@ class TestOpenStackDRAgent(Helper):
self.assertEqual(dragent.bgp_speaker_bindings(),
[self.SPEAKER_BINDING])
def get_os_codename(self):
self.patch_object(dragent.DRAgentCharm.singleton,
"get_os_codename_package")
dragent.get_os_codename()
self.get_os_codename_package.assert_called_once_with(
dragent.DRAgentCharm.singleton.release_pkg,
dragent.DRAgentCharm.singleton.package_codenames)
def test_speaker_ip(self):
_ip = "10.0.0.10"
self.patch_object(dragent.ch_ip, "get_relation_ip")