Exemple #1
0
    def test_cast_to_host_network_topic(self):
        host = "fake_host1"
        method = "fake_method"
        fake_kwargs = {"extra_arg": "meow"}

        self.mox.StubOutWithMock(driver, "cast_to_network_host")
        driver.cast_to_network_host(self.context, host, method, **fake_kwargs)

        self.mox.ReplayAll()
        driver.cast_to_host(self.context, "network", host, method, **fake_kwargs)
Exemple #2
0
    def test_cast_to_host_network_topic(self):
        host = 'fake_host1'
        method = 'fake_method'
        fake_kwargs = {'extra_arg': 'meow'}

        self.mox.StubOutWithMock(driver, 'cast_to_network_host')
        driver.cast_to_network_host(self.context, host, method, **fake_kwargs)

        self.mox.ReplayAll()
        driver.cast_to_host(self.context, 'network', host, method,
                            **fake_kwargs)
Exemple #3
0
    def test_cast_to_host_network_topic(self):
        host = 'fake_host1'
        method = 'fake_method'
        fake_kwargs = {'extra_arg': 'meow'}

        self.mox.StubOutWithMock(driver, 'cast_to_network_host')
        driver.cast_to_network_host(self.context, host, method,
                update_db=False, **fake_kwargs)

        self.mox.ReplayAll()
        driver.cast_to_host(self.context, 'network', host, method,
                update_db=False, **fake_kwargs)
Exemple #4
0
    def test_cast_to_network_host(self):
        host = 'fake_host1'
        method = 'fake_method'
        fake_kwargs = {'extra_arg': 'meow'}
        queue = 'fake_queue'

        self.mox.StubOutWithMock(rpc, 'queue_get_for')
        self.mox.StubOutWithMock(rpc, 'cast')

        rpc.queue_get_for(self.context, 'network', host).AndReturn(queue)
        rpc.cast(self.context, queue, {'method': method, 'args': fake_kwargs})

        self.mox.ReplayAll()
        driver.cast_to_network_host(self.context, host, method, **fake_kwargs)
Exemple #5
0
    def schedule_set_network_host(self, context, *_args, **_kwargs):
        """Picks a host that is up and has the fewest networks."""

        results = db.service_get_all_network_sorted(context)
        for result in results:
            (service, instance_count) = result
            if instance_count >= FLAGS.max_networks:
                raise driver.NoValidHost(_("All hosts have too many networks"))
            if self.service_is_up(service):
                driver.cast_to_network_host(context, service["host"], "set_network_host", **_kwargs)
                return None
        raise driver.NoValidHost(
            _("Scheduler was unable to locate a host" " for this request. Is the appropriate" " service running?")
        )
Exemple #6
0
    def test_cast_to_network_host(self):
        host = "fake_host1"
        method = "fake_method"
        fake_kwargs = {"extra_arg": "meow"}
        queue = "fake_queue"

        self.mox.StubOutWithMock(rpc, "queue_get_for")
        self.mox.StubOutWithMock(rpc, "cast")

        rpc.queue_get_for(self.context, "network", host).AndReturn(queue)
        rpc.cast(self.context, queue, {"method": method, "args": fake_kwargs})

        self.mox.ReplayAll()
        driver.cast_to_network_host(self.context, host, method, **fake_kwargs)
Exemple #7
0
    def schedule_set_network_host(self, context, *_args, **_kwargs):
        """Picks a host that is up and has the fewest networks."""
        elevated = context.elevated()

        results = db.service_get_all_network_sorted(elevated)
        for result in results:
            (service, instance_count) = result
            if instance_count >= FLAGS.max_networks:
                msg = _("Not enough allocatable networks remaining")
                raise exception.NoValidHost(reason=msg)
            if self.service_is_up(service):
                driver.cast_to_network_host(context, service['host'],
                        'set_network_host', **_kwargs)
                return None
        msg = _("Is the appropriate service running?")
        raise exception.NoValidHost(reason=msg)
Exemple #8
0
    def schedule_set_network_host(self, context, *_args, **_kwargs):
        """Picks a host that is up and has the fewest networks."""
        elevated = context.elevated()

        results = db.service_get_all_network_sorted(elevated)
        for result in results:
            (service, instance_count) = result
            if instance_count >= FLAGS.max_networks:
                msg = _("Not enough allocatable networks remaining")
                raise exception.NoValidHost(reason=msg)
            if self.service_is_up(service):
                driver.cast_to_network_host(context, service['host'],
                                            'set_network_host', **_kwargs)
                return None
        msg = _("Is the appropriate service running?")
        raise exception.NoValidHost(reason=msg)
Exemple #9
0
    def test_cast_to_network_host(self):
        host = 'fake_host1'
        method = 'fake_method'
        fake_kwargs = {'extra_arg': 'meow'}
        queue = 'fake_queue'

        self.mox.StubOutWithMock(db, 'queue_get_for')
        self.mox.StubOutWithMock(rpc, 'cast')

        db.queue_get_for(self.context, 'network', host).AndReturn(queue)
        rpc.cast(self.context, queue,
                {'method': method,
                 'args': fake_kwargs})

        self.mox.ReplayAll()
        driver.cast_to_network_host(self.context, host, method,
                update_db=True, **fake_kwargs)