From 97b2d1b83c4bc44b2ef03119e6f3b24350686e33 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami <tagami.keisuke@lab.ntt.co.jp> Date: Mon, 5 Sep 2011 14:45:41 +0900 Subject: [PATCH 1/7] Fix bug #835919 that output a option file for dnsmasq not to offer a default gateway on second vif. --- nova/db/sqlalchemy/api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) mode change 100644 => 100755 nova/db/sqlalchemy/api.py diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py old mode 100644 new mode 100755 index b99667afc..aee1c2a55 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1415,6 +1415,21 @@ def instance_get_all_by_reservation(context, reservation_id): filter_by(project_id=context.project_id).\ filter_by(deleted=False).\ all() + +@require_admin_context +def instance_get_all_by_network(context, network_id): + session = get_session() + return session.query(models.Instance).\ + options(joinedload_all('fixed_ips.floating_ips')).\ + options(joinedload('virtual_interfaces')).\ + options(joinedload('security_groups')).\ + options(joinedload_all('fixed_ips.network')).\ + options(joinedload('metadata')).\ + options(joinedload('instance_type')).\ + filter_by(deleted=can_read_deleted(context)).\ + filter_by(network_id=network_id).\ + all() + @require_context From 272fcf91454afda37aa54898d9b9493327b530d6 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami <tagami.keisuke@lab.ntt.co.jp> Date: Mon, 5 Sep 2011 20:23:28 +0900 Subject: [PATCH 2/7] implement unit test for linux_net --- nova/db/api.py | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 nova/db/api.py diff --git a/nova/db/api.py b/nova/db/api.py old mode 100644 new mode 100755 index 148887635..85e9c7669 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -532,6 +532,11 @@ def instance_get_all_by_reservation(context, reservation_id): return IMPL.instance_get_all_by_reservation(context, reservation_id) +def instance_get_all_by_network(context, network_id): + """Get all instances belonging to a network.""" + return IMPL.instance_get_all_by_network(context, network_id) + + def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) From d193081258f2a3c0cedcc220c49355acc600c7a2 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami <tagami.keisuke@lab.ntt.co.jp> Date: Mon, 5 Sep 2011 21:13:00 +0900 Subject: [PATCH 3/7] format for pep8 --- nova/db/api.py | 4 ++-- nova/db/sqlalchemy/api.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/nova/db/api.py b/nova/db/api.py index 85e9c7669..faac13966 100755 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -535,8 +535,8 @@ def instance_get_all_by_reservation(context, reservation_id): def instance_get_all_by_network(context, network_id): """Get all instances belonging to a network.""" return IMPL.instance_get_all_by_network(context, network_id) - - + + def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index aee1c2a55..3194a5231 100755 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1415,8 +1415,8 @@ def instance_get_all_by_reservation(context, reservation_id): filter_by(project_id=context.project_id).\ filter_by(deleted=False).\ all() - -@require_admin_context + + def instance_get_all_by_network(context, network_id): session = get_session() return session.query(models.Instance).\ @@ -1431,7 +1431,6 @@ def instance_get_all_by_network(context, network_id): all() - @require_context def instance_get_by_fixed_ip(context, address): """Return instance ref by exact match of FixedIP""" From e6ab1718de8eaba5ca6282ec291631765fe9c084 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami <tagami.keisuke@lab.ntt.co.jp> Date: Tue, 6 Sep 2011 10:14:27 +0900 Subject: [PATCH 4/7] correct a method to collect instances from db add interface data to test --- nova/db/api.py | 5 ----- nova/db/sqlalchemy/api.py | 14 -------------- 2 files changed, 19 deletions(-) diff --git a/nova/db/api.py b/nova/db/api.py index faac13966..148887635 100755 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -532,11 +532,6 @@ def instance_get_all_by_reservation(context, reservation_id): return IMPL.instance_get_all_by_reservation(context, reservation_id) -def instance_get_all_by_network(context, network_id): - """Get all instances belonging to a network.""" - return IMPL.instance_get_all_by_network(context, network_id) - - def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 3194a5231..b99667afc 100755 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1417,20 +1417,6 @@ def instance_get_all_by_reservation(context, reservation_id): all() -def instance_get_all_by_network(context, network_id): - session = get_session() - return session.query(models.Instance).\ - options(joinedload_all('fixed_ips.floating_ips')).\ - options(joinedload('virtual_interfaces')).\ - options(joinedload('security_groups')).\ - options(joinedload_all('fixed_ips.network')).\ - options(joinedload('metadata')).\ - options(joinedload('instance_type')).\ - filter_by(deleted=can_read_deleted(context)).\ - filter_by(network_id=network_id).\ - all() - - @require_context def instance_get_by_fixed_ip(context, address): """Return instance ref by exact match of FixedIP""" From 23f90a9edd5033a187ca5a971d96d1fc03cd5e6e Mon Sep 17 00:00:00 2001 From: Keisuke Tagami <tagami.keisuke@lab.ntt.co.jp> Date: Tue, 6 Sep 2011 10:20:28 +0900 Subject: [PATCH 5/7] revert codes for db --- nova/db/api.py | 0 nova/db/sqlalchemy/api.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 nova/db/api.py mode change 100755 => 100644 nova/db/sqlalchemy/api.py diff --git a/nova/db/api.py b/nova/db/api.py old mode 100755 new mode 100644 diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py old mode 100755 new mode 100644 From f9431a1f884bc6f93a1a0afee3eee4d7dc2d391b Mon Sep 17 00:00:00 2001 From: Brian Waldon <brian.waldon@rackspace.com> Date: Thu, 8 Sep 2011 11:32:11 -0400 Subject: [PATCH 6/7] adding can_read_deleted back to db api --- nova/db/sqlalchemy/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 523258841..1730b4ddb 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1277,6 +1277,10 @@ def instance_get_all_by_filters(context, filters): changes_since = filters['changes-since'] query_prefix = query_prefix.\ filter(models.Instance.updated_at > changes_since) + else: + # filter out deleted instances if no changes-since filter provided + query_prefix = query_prefix.\ + filter_by(deleted=can_read_deleted(context)) if not context.is_admin: # If we're not admin context, add appropriate filter.. From 0873840079e6af51f8c6c43b8d4adea711667c5c Mon Sep 17 00:00:00 2001 From: Brian Waldon <brian.waldon@rackspace.com> Date: Thu, 8 Sep 2011 15:26:44 -0400 Subject: [PATCH 7/7] converting fix to just address ec2; updating test --- nova/db/sqlalchemy/api.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 1730b4ddb..523258841 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1277,10 +1277,6 @@ def instance_get_all_by_filters(context, filters): changes_since = filters['changes-since'] query_prefix = query_prefix.\ filter(models.Instance.updated_at > changes_since) - else: - # filter out deleted instances if no changes-since filter provided - query_prefix = query_prefix.\ - filter_by(deleted=can_read_deleted(context)) if not context.is_admin: # If we're not admin context, add appropriate filter..