Make host as second arg in compute api calls
It's better to have similar signature for consistency and availability to apply decorator (for feature about applying cell context). Changes modify signature for methods in compute rpcapi. Change-Id: Iaf404ee17944ca4d0de901d5cd7109cbcab68bb4
This commit is contained in:
		@@ -377,7 +377,7 @@ class ComputeAPI(object):
 | 
			
		||||
    def get_cell_client(self, context):
 | 
			
		||||
        return rpc.get_cell_client(context, self.client)
 | 
			
		||||
 | 
			
		||||
    def add_aggregate_host(self, ctxt, aggregate, host_param, host,
 | 
			
		||||
    def add_aggregate_host(self, ctxt, host, aggregate, host_param,
 | 
			
		||||
                           slave_info=None):
 | 
			
		||||
        '''Add aggregate host.
 | 
			
		||||
 | 
			
		||||
@@ -534,7 +534,7 @@ class ComputeAPI(object):
 | 
			
		||||
        return cctxt.call(ctxt, 'get_console_output',
 | 
			
		||||
                          instance=instance, tail_length=tail_length)
 | 
			
		||||
 | 
			
		||||
    def get_console_pool_info(self, ctxt, console_type, host):
 | 
			
		||||
    def get_console_pool_info(self, ctxt, host, console_type):
 | 
			
		||||
        version = '4.0'
 | 
			
		||||
        cctxt = self.get_cell_client(ctxt).prepare(
 | 
			
		||||
                server=host, version=version)
 | 
			
		||||
@@ -605,7 +605,7 @@ class ComputeAPI(object):
 | 
			
		||||
                          instance=instance, port=port,
 | 
			
		||||
                          console_type=console_type)
 | 
			
		||||
 | 
			
		||||
    def host_maintenance_mode(self, ctxt, host_param, mode, host):
 | 
			
		||||
    def host_maintenance_mode(self, ctxt, host, host_param, mode):
 | 
			
		||||
        '''Set host maintenance mode
 | 
			
		||||
 | 
			
		||||
        :param ctxt: request context
 | 
			
		||||
@@ -620,7 +620,7 @@ class ComputeAPI(object):
 | 
			
		||||
        return cctxt.call(ctxt, 'host_maintenance_mode',
 | 
			
		||||
                          host=host_param, mode=mode)
 | 
			
		||||
 | 
			
		||||
    def host_power_action(self, ctxt, action, host):
 | 
			
		||||
    def host_power_action(self, ctxt, host, action):
 | 
			
		||||
        version = '4.0'
 | 
			
		||||
        cctxt = self.get_cell_client(ctxt).prepare(
 | 
			
		||||
                server=host, version=version)
 | 
			
		||||
@@ -765,7 +765,7 @@ class ComputeAPI(object):
 | 
			
		||||
                   recreate=recreate, on_shared_storage=on_shared_storage,
 | 
			
		||||
                   **extra)
 | 
			
		||||
 | 
			
		||||
    def remove_aggregate_host(self, ctxt, aggregate, host_param, host,
 | 
			
		||||
    def remove_aggregate_host(self, ctxt, host, aggregate, host_param,
 | 
			
		||||
                              slave_info=None):
 | 
			
		||||
        '''Remove aggregate host.
 | 
			
		||||
 | 
			
		||||
@@ -869,7 +869,7 @@ class ComputeAPI(object):
 | 
			
		||||
        return cctxt.call(ctxt, 'set_admin_password',
 | 
			
		||||
                          instance=instance, new_pass=new_pass)
 | 
			
		||||
 | 
			
		||||
    def set_host_enabled(self, ctxt, enabled, host):
 | 
			
		||||
    def set_host_enabled(self, ctxt, host, enabled):
 | 
			
		||||
        version = '4.0'
 | 
			
		||||
        cctxt = self.get_cell_client(ctxt).prepare(
 | 
			
		||||
                server=host, version=version)
 | 
			
		||||
 
 | 
			
		||||
@@ -105,7 +105,7 @@ class ConsoleProxyManager(manager.Manager):
 | 
			
		||||
            #                compute worker's flagfile, at least for
 | 
			
		||||
            #                xenserver. Thus we ned to ask.
 | 
			
		||||
            pool_info = self.compute_rpcapi.get_console_pool_info(context,
 | 
			
		||||
                        console_type, instance_host)
 | 
			
		||||
                        instance_host, console_type)
 | 
			
		||||
            pool_info['password'] = self.driver.fix_pool_password(
 | 
			
		||||
                                                    pool_info['password'])
 | 
			
		||||
            pool_info['host'] = self.host
 | 
			
		||||
 
 | 
			
		||||
@@ -3224,11 +3224,11 @@ class MockComputeAPI(object):
 | 
			
		||||
            self.add_aggregate_host, ctxt, aggregate,
 | 
			
		||||
            host_param, host, slave_info))
 | 
			
		||||
 | 
			
		||||
    def remove_aggregate_host(self, ctxt, aggregate_id, host_param,
 | 
			
		||||
                              host, slave_info):
 | 
			
		||||
    def remove_aggregate_host(self, ctxt, host, aggregate_id, host_param,
 | 
			
		||||
                              slave_info):
 | 
			
		||||
        self._mock_calls.append((
 | 
			
		||||
            self.remove_aggregate_host, ctxt, aggregate_id,
 | 
			
		||||
            host_param, host, slave_info))
 | 
			
		||||
            self.remove_aggregate_host, ctxt, host, aggregate_id,
 | 
			
		||||
            host_param, slave_info))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class StubDependencies(object):
 | 
			
		||||
@@ -3274,8 +3274,8 @@ class HypervisorPoolTestCase(test.NoDBTestCase):
 | 
			
		||||
 | 
			
		||||
        self.assertIn(
 | 
			
		||||
            (slave.compute_rpcapi.add_aggregate_host,
 | 
			
		||||
            "CONTEXT", jsonutils.to_primitive(self.fake_aggregate),
 | 
			
		||||
            "slave", "master", "SLAVE_INFO"),
 | 
			
		||||
            "CONTEXT", "slave", jsonutils.to_primitive(self.fake_aggregate),
 | 
			
		||||
            "master", "SLAVE_INFO"),
 | 
			
		||||
            slave.compute_rpcapi._mock_calls)
 | 
			
		||||
 | 
			
		||||
    def test_slave_asks_master_to_remove_slave_from_pool(self):
 | 
			
		||||
@@ -3285,7 +3285,7 @@ class HypervisorPoolTestCase(test.NoDBTestCase):
 | 
			
		||||
 | 
			
		||||
        self.assertIn(
 | 
			
		||||
            (slave.compute_rpcapi.remove_aggregate_host,
 | 
			
		||||
            "CONTEXT", 98, "slave", "master", "SLAVE_INFO"),
 | 
			
		||||
             "CONTEXT", "slave", 98, "master", "SLAVE_INFO"),
 | 
			
		||||
            slave.compute_rpcapi._mock_calls)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,7 @@ class ResourcePool(object):
 | 
			
		||||
                slave_info = self._create_slave_info()
 | 
			
		||||
 | 
			
		||||
                self.compute_rpcapi.add_aggregate_host(
 | 
			
		||||
                    context, aggregate, host, master_compute, slave_info)
 | 
			
		||||
                    context, host, aggregate, master_compute, slave_info)
 | 
			
		||||
 | 
			
		||||
    def remove_from_aggregate(self, context, aggregate, host, slave_info=None):
 | 
			
		||||
        """Remove a compute host from an aggregate."""
 | 
			
		||||
@@ -144,7 +144,7 @@ class ResourcePool(object):
 | 
			
		||||
            slave_info = self._create_slave_info()
 | 
			
		||||
 | 
			
		||||
            self.compute_rpcapi.remove_aggregate_host(
 | 
			
		||||
                context, aggregate.id, host, master_compute, slave_info)
 | 
			
		||||
                context, host, aggregate.id, master_compute, slave_info)
 | 
			
		||||
        else:
 | 
			
		||||
            # this shouldn't have happened
 | 
			
		||||
            raise exception.AggregateError(aggregate_id=aggregate.id,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user