Exemplo n.º 1
0
 def test_create_node_invalid_driver(self):
     ndict = post_get_test_node()
     self.mock_gtf.side_effect = exception.NoValidHost('Fake Error')
     response = self.post_json('/nodes', ndict, expect_errors=True)
     self.assertEqual(400, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
Exemplo n.º 2
0
    def test_update_fails_bad_driver(self):
        self.mock_gtf.side_effect = exception.NoValidHost('Fake Error')

        response = self.patch_json('/nodes/%s' % self.node['uuid'],
                                   [{'path': '/driver',
                                     'value': 'bad-driver',
                                     'op': 'replace'}],
                                   expect_errors=True)

        self.assertEqual('application/json', response.content_type)
        self.assertEqual(400, response.status_code)
Exemplo n.º 3
0
    def get_topic_for(self, node):
        """Get the RPC topic for the conductor service which the node
        is mapped to.

        :param node: a node object.
        :returns: an RPC topic string.
        :raises: NoValidHost

        """
        try:
            ring = self.ring_manager.get_hash_ring(node.driver)
            dest = ring.get_hosts(node.uuid)
            return self.topic + "." + dest[0]
        except exception.DriverNotFound:
            reason = (_('No conductor service registered which supports '
                        'driver %s.') % node.driver)
            raise exception.NoValidHost(reason=reason)
Exemplo n.º 4
0
    def get_topic_for(self, node):
        """Get the RPC topic for the conductor service the node is mapped to.

        :param node: a node object.
        :returns: an RPC topic string.
        :raises: NoValidHost

        """
        self.ring_manager.reset()

        try:
            ring = self.ring_manager[node.driver]
            dest = ring.get_nodes(node.uuid.encode('utf-8'),
                                  replicas=CONF.hash_distribution_replicas)
            return '%s.%s' % (self.topic, dest.pop())
        except exception.DriverNotFound:
            reason = (_('No conductor service registered which supports '
                        'driver %s.') % node.driver)
            raise exception.NoValidHost(reason=reason)