From 12a86bbd3d5bf875c6e4faa35fd61a4e282306fb Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 7 Feb 2018 19:29:37 +0000 Subject: [PATCH] Interface with quagga Use the interface-bgp to interface with the quagga charm. --- src/config.yaml | 9 ++++++--- src/layer.yaml | 1 + src/lib/charm/openstack/dragent.py | 18 ------------------ src/metadata.yaml | 4 ++++ src/reactive/dragent_handlers.py | 27 +++++++++++++++++++-------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/config.yaml b/src/config.yaml index 3b07f05..285922d 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,9 @@ options: - bgp-peer-ips: + asn: default: - type: string + type: int description: | - Space delimited IPs of BGP peers. + 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. diff --git a/src/layer.yaml b/src/layer.yaml index 93cbb0a..5d0c993 100644 --- a/src/layer.yaml +++ b/src/layer.yaml @@ -1,6 +1,7 @@ includes: - layer:openstack-principle - interface:rabbitmq + - interface:bgp #repo: https://github.com/openstack/charm-neutron-dynamic-routing options: basic: diff --git a/src/lib/charm/openstack/dragent.py b/src/lib/charm/openstack/dragent.py index 4345861..72d2802 100644 --- a/src/lib/charm/openstack/dragent.py +++ b/src/lib/charm/openstack/dragent.py @@ -89,23 +89,6 @@ class TransportURLAdapter(os_adapters.RabbitMQRelationAdapter): return self.ssl_port or 5672 -class BGPPeerRelationAdapter(os_adapters.OpenStackRelationAdapter): - - """ - STub Adapter for the BGPPeerProvides relation interface. - """ - - interface_type = 'bgp' - - @property - def provider_ip(self): - return ch_ip.get_relation_ip('provider') - - @property - def speaker_ip(self): - return ch_ip.get_relation_ip('speaker') - - class DRAgentCharm(charms_openstack.charm.OpenStackCharm): """DRAgentCharm provides the specialisation of the OpenStackCharm functionality to manage a dragent unit. @@ -123,7 +106,6 @@ class DRAgentCharm(charms_openstack.charm.OpenStackCharm): adapters_class = os_adapters.OpenStackRelationAdapters adapters_class.relation_adapters = { 'amqp': TransportURLAdapter, - 'bgp': BGPPeerRelationAdapter, } restart_map = { diff --git a/src/metadata.yaml b/src/metadata.yaml index e1cfe86..0d0f94d 100644 --- a/src/metadata.yaml +++ b/src/metadata.yaml @@ -15,3 +15,7 @@ extra-bindings: requires: amqp: interface: rabbitmq +provides: + bgp-speaker: + interface: bgp + optional: true diff --git a/src/reactive/dragent_handlers.py b/src/reactive/dragent_handlers.py index 395d1ab..f5db38d 100644 --- a/src/reactive/dragent_handlers.py +++ b/src/reactive/dragent_handlers.py @@ -33,6 +33,21 @@ charm.use_defaults( 'update-status') +@reactive.when('charm.installed') +def debug(): + if not hookenv.config('debug'): + return + for key, value in reactive.get_states().items(): + print(key, value) + + +# Use for testing with the quagga charm +@reactive.when('endpoint.bgp-speaker.joined') +def publish_bgp_info(endpoint): + endpoint.publish_info(asn=hookenv.config('asn'), + passive=True) + + @reactive.when('amqp.connected') def setup_amqp_req(amqp): """Use the amqp interface to request access to the amqp broker using our @@ -43,15 +58,11 @@ def setup_amqp_req(amqp): dragent.assess_status() -# Note that because of the way reactive.when works, (which is to 'find' the -# __code__ segment of the decorated function, it's very, very difficult to add -# other kinds of decorators here. This rules out adding other things into the -# charm args list. It is also CPython dependent. @reactive.when('amqp.available') -def render_stuff(amqp): - """Render the configuration for Barbican when all the interfaces are +def render_stuff(*args): + """Render the configuration for dyanmic routing when all the interfaces are available. """ - hookenv.log("about to call the render_configs with {}".format(amqp)) - dragent.render_configs(amqp) + hookenv.log("about to call the render_configs with {}".format(args)) + dragent.render_configs(args) dragent.assess_status()