Browse Source

Revert to use of charms.openstack transport_url

Drop charm specific code to build the oslo.messaging
transport_url; this is now provided as part of
charms.openstack.

Change-Id: I1a9bcf7bc57b99326cae618df06930ae3990fab0
Closes-Bug: 1817672
changes/71/639271/6
Corey Bryant 3 months ago
parent
commit
3bedb660d4
2 changed files with 1 additions and 77 deletions
  1. 1
    39
      src/lib/charm/openstack/dragent.py
  2. 0
    38
      unit_tests/test_lib_charm_openstack_dragent.py

+ 1
- 39
src/lib/charm/openstack/dragent.py View File

@@ -142,51 +142,13 @@ def speaker_ip(cls):
142 142
     return ch_ip.get_relation_ip(SPEAKER_BINDING)
143 143
 
144 144
 
145
-class TransportURLAdapter(os_adapters.RabbitMQRelationAdapter):
146
-    """Add Transport URL to RabbitMQRelationAdapter
147
-    TODO: Move to charms.openstack.adapters
148
-    """
149
-
150
-    DEFAULT_PORT = '5672'
151
-
152
-    def __init__(self, relation):
153
-        super(TransportURLAdapter, self).__init__(relation)
154
-
155
-    @property
156
-    def transport_url(self):
157
-        """Return the transport URL for communicating with rabbitmq
158
-
159
-        :returns: string transport URL
160
-        """
161
-        if self.hosts:
162
-            hosts = self.hosts.split(',')
163
-        else:
164
-            hosts = [self.host]
165
-        if hosts:
166
-            transport_url_hosts = ','.join([
167
-                "{}:{}@{}:{}".format(self.username,
168
-                                     self.password,
169
-                                     host_,
170
-                                     self.port)
171
-                for host_ in hosts])
172
-            return "rabbit://{}/{}".format(transport_url_hosts, self.vhost)
173
-
174
-    @property
175
-    def port(self):
176
-        """Return the port for commuicating with rabbitmq
177
-
178
-        :returns: int port number
179
-        """
180
-        return self.ssl_port or self.DEFAULT_PORT
181
-
182
-
183 145
 class DRAgentRelationAdapters(os_adapters.OpenStackRelationAdapters):
184 146
 
185 147
     """
186 148
     Adapters collection to append specific adapters for Neutron Dynamic Routing
187 149
     """
188 150
     relation_adapters = {
189
-        'amqp': TransportURLAdapter,
151
+        'amqp': os_adapters.RabbitMQRelationAdapter,
190 152
     }
191 153
 
192 154
 

+ 0
- 38
unit_tests/test_lib_charm_openstack_dragent.py View File

@@ -15,8 +15,6 @@
15 15
 from __future__ import absolute_import
16 16
 from __future__ import print_function
17 17
 
18
-import mock
19
-
20 18
 import charm.openstack.dragent as dragent
21 19
 
22 20
 import charms_openstack.test_utils as test_utils
@@ -69,42 +67,6 @@ class TestOpenStackDRAgent(Helper):
69 67
         self.get_relation_ip.assert_called_once_with(self.PROVIDER_BINDING)
70 68
 
71 69
 
72
-class TestTransportURLAdapter(Helper):
73
-
74
-    def test_transport_url(self):
75
-        _expected = "rabbit://user:pass@10.0.0.50:5672/vhost"
76
-        amqp = mock.MagicMock()
77
-        amqp.relation_name = "amqp"
78
-        amqp.username.return_value = "user"
79
-        amqp.vhost.return_value = "vhost"
80
-        tua = dragent.TransportURLAdapter(amqp)
81
-        tua.vip = None
82
-        tua.password = "pass"
83
-        tua.ssl_port = None
84
-
85
-        # Single
86
-        tua.private_address = "10.0.0.50"
87
-        self.assertEqual(tua.transport_url, _expected)
88
-
89
-        # Multiple
90
-        _expected = ("rabbit://user:pass@10.200.0.20:5672,"
91
-                     "user:pass@10.200.0.30:5672/vhost")
92
-        amqp.rabbitmq_hosts.return_value = ["10.200.0.20", "10.200.0.30"]
93
-        self.assertEqual(tua.transport_url, _expected)
94
-
95
-    def test_port(self):
96
-        _ssl_port = '2765'
97
-        _port = '5672'
98
-        amqp = mock.MagicMock()
99
-        tua = dragent.TransportURLAdapter(amqp)
100
-        # Default Port
101
-        tua.ssl_port = None
102
-        self.assertEqual(tua.port, _port)
103
-        # SSL port
104
-        tua.ssl_port = _ssl_port
105
-        self.assertEqual(tua.port, _ssl_port)
106
-
107
-
108 70
 class TestDRAgentCharm(Helper):
109 71
 
110 72
     def test_install(self):

Loading…
Cancel
Save