diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2013-02-05 18:12:02 -0800 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2013-02-08 12:15:46 -0800 |
| commit | 6ff32210772a67a1b526d9d784030afc90f3ce99 (patch) | |
| tree | 19532173de03e64507b64c289c2e680b81bb5e26 | |
| parent | daddc54befea4414776368b0ae8f689872b21e27 (diff) | |
| download | nova-6ff32210772a67a1b526d9d784030afc90f3ce99.tar.gz nova-6ff32210772a67a1b526d9d784030afc90f3ce99.tar.xz nova-6ff32210772a67a1b526d9d784030afc90f3ce99.zip | |
Use joined version of db.api calls
Replace db.instance_get_active_by_window with
db.instance_get_active_by_window_joined
Remove db.instance_get_active_by_window as it is now unused
When moving over to nova.db.api not returning sqlalchemy
objects non-joined db calls (lazy loaded) won't work.
Partially implements bp db-api-cleanup
Change-Id: Iec647792a049d53862a45f95accd7f46e483aa17
| -rw-r--r-- | nova/compute/api.py | 4 | ||||
| -rw-r--r-- | nova/conductor/api.py | 10 | ||||
| -rw-r--r-- | nova/conductor/manager.py | 1 | ||||
| -rw-r--r-- | nova/conductor/rpcapi.py | 8 | ||||
| -rw-r--r-- | nova/db/api.py | 11 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 19 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py | 5 | ||||
| -rw-r--r-- | nova/tests/conductor/test_conductor.py | 10 |
8 files changed, 7 insertions, 61 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 394f09e11..47d122eaa 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1250,8 +1250,8 @@ class API(base.Base): # search_opts in get_all def get_active_by_window(self, context, begin, end=None, project_id=None): """Get instances that were continuously active over a window.""" - return self.db.instance_get_active_by_window(context, begin, end, - project_id) + return self.db.instance_get_active_by_window_joined(context, begin, + end, project_id) #NOTE(bcwaldon): this doesn't really belong in this class def get_instance_type(self, context, instance_type_id): diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 9f526646c..490b605ba 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -113,11 +113,6 @@ class LocalAPI(object): return self._manager.instance_get_all_hung_in_rebooting(context, timeout) - def instance_get_active_by_window(self, context, begin, end=None, - project_id=None, host=None): - return self._manager.instance_get_active_by_window( - context, begin, end, project_id, host) - def instance_get_active_by_window_joined(self, context, begin, end=None, project_id=None, host=None): return self._manager.instance_get_active_by_window_joined( @@ -404,11 +399,6 @@ class API(object): return self.conductor_rpcapi.instance_get_all_hung_in_rebooting( context, timeout) - def instance_get_active_by_window(self, context, begin, end=None, - project_id=None, host=None): - return self.conductor_rpcapi.instance_get_active_by_window( - context, begin, end, project_id, host) - def instance_get_active_by_window_joined(self, context, begin, end=None, project_id=None, host=None): return self.conductor_rpcapi.instance_get_active_by_window_joined( diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index b53ab8fcc..0d2031a4a 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -239,6 +239,7 @@ class ConductorManager(manager.SchedulerDependentManager): def instance_get_active_by_window(self, context, begin, end=None, project_id=None, host=None): + # Unused, but cannot remove until major RPC version bump result = self.db.instance_get_active_by_window(context, begin, end, project_id, host) return jsonutils.to_primitive(result) diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 169da4ed7..f5ce0b4cb 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -74,6 +74,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): 1.39 - Added notify_usage_exists 1.40 - Added security_groups_trigger_handler and security_groups_trigger_members_refresh + Remove instance_get_active_by_window """ BASE_RPC_API_VERSION = '1.0' @@ -244,13 +245,6 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): timeout=timeout) return self.call(context, msg, version='1.15') - def instance_get_active_by_window(self, context, begin, end=None, - project_id=None, host=None): - msg = self.make_msg('instance_get_active_by_window', - begin=begin, end=end, project_id=project_id, - host=host) - return self.call(context, msg, version='1.15') - def instance_get_active_by_window_joined(self, context, begin, end=None, project_id=None, host=None): msg = self.make_msg('instance_get_active_by_window_joined', diff --git a/nova/db/api.py b/nova/db/api.py index 8d3f0fa4d..ffd153a46 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -606,17 +606,6 @@ def instance_get_all_by_filters(context, filters, sort_key='created_at', marker=marker) -def instance_get_active_by_window(context, begin, end=None, project_id=None, - host=None): - """Get instances active during a certain time window. - - Specifying a project_id will filter for a certain project. - Specifying a host will filter for instances on a given compute host. - """ - return IMPL.instance_get_active_by_window(context, begin, end, - project_id, host) - - def instance_get_active_by_window_joined(context, begin, end=None, project_id=None, host=None): """Get instances and joins active during a certain time window. diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index fb39600c4..74ee6c9e7 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1656,25 +1656,6 @@ def regex_filter(query, model, filters): return query -@require_context -def instance_get_active_by_window(context, begin, end=None, - project_id=None, host=None): - """Return instances that were active during window.""" - session = get_session() - query = session.query(models.Instance) - - query = query.filter(or_(models.Instance.terminated_at == None, - models.Instance.terminated_at > begin)) - if end: - query = query.filter(models.Instance.launched_at < end) - if project_id: - query = query.filter_by(project_id=project_id) - if host: - query = query.filter_by(host=host) - - return query.all() - - @require_admin_context def instance_get_active_by_window_joined(context, begin, end=None, project_id=None, host=None): diff --git a/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py b/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py index 13a4e9d61..440c97fbd 100644 --- a/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py +++ b/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py @@ -65,7 +65,8 @@ def get_fake_db_instance(start, end, instance_id, tenant_id): 'terminated_at': end} -def fake_instance_get_active_by_window(self, context, begin, end, project_id): +def fake_instance_get_active_by_window_joined(self, context, begin, end, + project_id): return [get_fake_db_instance(START, STOP, x, @@ -79,7 +80,7 @@ class SimpleTenantUsageTest(test.TestCase): self.stubs.Set(api.API, "get_instance_type", fake_instance_type_get) self.stubs.Set(api.API, "get_active_by_window", - fake_instance_get_active_by_window) + fake_instance_get_active_by_window_joined) self.admin_context = context.RequestContext('fakeadmin_0', 'faketenant_0', is_admin=True) diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 773b65d43..d4d0fc3bb 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -335,16 +335,6 @@ class _BaseTestCase(object): self.mox.ReplayAll() self.conductor.instance_get_all_hung_in_rebooting(self.context, 123) - def test_instance_get_active_by_window(self): - self.mox.StubOutWithMock(db, 'instance_get_active_by_window_joined') - db.instance_get_active_by_window(self.context, 'fake-begin', - 'fake-end', 'fake-proj', - 'fake-host') - self.mox.ReplayAll() - self.conductor.instance_get_active_by_window(self.context, - 'fake-begin', 'fake-end', - 'fake-proj', 'fake-host') - def test_instance_get_active_by_window_joined(self): self.mox.StubOutWithMock(db, 'instance_get_active_by_window_joined') db.instance_get_active_by_window_joined(self.context, 'fake-begin', |
