Exemplo n.º 1
0
    def __init__(self,
                 url=None,
                 backend=None,
                 username=None,
                 password=None,
                 hosts=None,
                 virt_host=None,
                 exchange=None):
        super(AMQP, self).__init__()

        if exchange:
            oslo_msg.set_transport_defaults(control_exchange=exchange)

        if url:
            self.TRANSPORT = oslo_msg.get_transport(CONF, url=url)
        elif not backend and not hosts:
            raise ValueError("missing AMQP parameters")
        else:
            t_hosts = self._createTransportHosts(username, password, hosts)
            t_url = oslo_msg.TransportURL(CONF,
                                          transport=backend,
                                          virtual_host=virt_host,
                                          hosts=t_hosts,
                                          aliases=None)

            self.TRANSPORT = oslo_msg.get_transport(CONF, url=t_url)
Exemplo n.º 2
0
 def setUp(self):
     super(TestFailover, self).setUp()
     self._brokers = [FakeBroker(), FakeBroker()]
     hosts = []
     for broker in self._brokers:
         hosts.append(oslo_messaging.TransportHost(hostname=broker.host,
                                                   port=broker.port))
     self._broker_url = oslo_messaging.TransportURL(self.conf,
                                                    transport="amqp",
                                                    hosts=hosts)
Exemplo n.º 3
0
    def test_parse_url(self):
        hosts = []
        for host in self.hosts:
            hosts.append(oslo_messaging.TransportHost(host.get('hostname'),
                                                      host.get('port'),
                                                      host.get('username'),
                                                      host.get('password')))

        url = oslo_messaging.TransportURL(self.conf, self.transport,
                                          self.virtual_host, hosts)

        self.assertEqual(self.expected, str(url))
Exemplo n.º 4
0
    def test_parse_url(self):
        url = oslo_messaging.TransportURL.parse(self.conf, self.url)

        hosts = []
        for host in self.expect.get('hosts', []):
            hosts.append(oslo_messaging.TransportHost(host.get('host'),
                                                      host.get('port'),
                                                      host.get('username'),
                                                      host.get('password')))
        expected = oslo_messaging.TransportURL(self.conf,
                                               self.expect.get('transport'),
                                               self.expect.get('virtual_host'),
                                               hosts)

        self.assertEqual(expected, url)