From c5c58cb20def79401a374f863983a343139b53f3 Mon Sep 17 00:00:00 2001 From: "NTT PF Lab." Date: Fri, 24 Dec 2010 20:38:49 +0900 Subject: Support IPv6 --- nova/db/api.py | 9 +++++++++ nova/db/sqlalchemy/api.py | 23 +++++++++++++++++++++++ nova/db/sqlalchemy/models.py | 4 ++++ 3 files changed, 36 insertions(+) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index 8f9dc2443..caee0b7b8 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -240,6 +240,9 @@ def fixed_ip_get_instance(context, address): """Get an instance for a fixed ip by address.""" return IMPL.fixed_ip_get_instance(context, address) +def fixed_ip_get_instance_v6(context, address): + return IMPL.fixed_ip_get_instance_v6(context, address) + def fixed_ip_get_network(context, address): """Get a network for a fixed ip by address.""" @@ -298,6 +301,9 @@ def instance_get_fixed_address(context, instance_id): """Get the fixed ip address of an instance.""" return IMPL.instance_get_fixed_address(context, instance_id) +def instance_get_fixed_address_v6(context, instance_id): + return IMPL.instance_get_fixed_address_v6(context, instance_id) + def instance_get_floating_address(context, instance_id): """Get the first floating ip address of an instance.""" @@ -476,6 +482,9 @@ def project_get_network(context, project_id): """ return IMPL.project_get_network(context, project_id) +def project_get_network_v6(context, project_id): + return IMPL.project_get_network_v6(context, project_id) + ################### diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 55036d1d1..29f3cdee1 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -504,6 +504,16 @@ def fixed_ip_get_instance(context, address): fixed_ip_ref = fixed_ip_get_by_address(context, address) return fixed_ip_ref.instance +@require_context +def fixed_ip_get_instance_v6(context, address): + session = get_session() + mac = utils.to_mac(address) + + result = session.query(models.Instance + ).filter_by(mac_address=mac + ).first() + return result + @require_admin_context def fixed_ip_get_network(context, address): @@ -692,6 +702,15 @@ def instance_get_fixed_address(context, instance_id): return None return instance_ref.fixed_ip['address'] +@require_context +def instance_get_fixed_address_v6(context, instance_id): + session = get_session() + with session.begin(): + instance_ref = instance_get(context, instance_id, session=session) + network_ref = project_get_network(context, context.project_id) + prefix = network_ref.cidr_v6 + mac = instance_ref.mac_address + return utils.to_global_ipv6(prefix, mac) @require_context def instance_get_floating_address(context, instance_id): @@ -1004,6 +1023,10 @@ def project_get_network(context, project_id): first() return rv +@require_context +def project_get_network_v6(context, project_id): + return project_get_network(context, project_id) + ################### diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index fe0a9a921..c81ef68f1 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -389,6 +389,10 @@ class Network(BASE, NovaBase): injected = Column(Boolean, default=False) cidr = Column(String(255), unique=True) + cidr_v6 = Column(String(255), unique=True) + + ra_server = Column(String(255)) + netmask = Column(String(255)) bridge = Column(String(255)) gateway = Column(String(255)) -- cgit From 1629dcf935a29c01d4e4ad509e33356daa93b051 Mon Sep 17 00:00:00 2001 From: Hisaharu Ishii Date: Wed, 12 Jan 2011 11:26:22 +0900 Subject: Fixed for pep8 Remove temporary debugging --- nova/db/api.py | 3 +++ nova/db/sqlalchemy/api.py | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index 8684a3aef..03e800466 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -284,6 +284,7 @@ def fixed_ip_get_instance(context, address): """Get an instance for a fixed ip by address.""" return IMPL.fixed_ip_get_instance(context, address) + def fixed_ip_get_instance_v6(context, address): return IMPL.fixed_ip_get_instance_v6(context, address) @@ -345,6 +346,7 @@ def instance_get_fixed_address(context, instance_id): """Get the fixed ip address of an instance.""" return IMPL.instance_get_fixed_address(context, instance_id) + def instance_get_fixed_address_v6(context, instance_id): return IMPL.instance_get_fixed_address_v6(context, instance_id) @@ -543,6 +545,7 @@ def project_get_network(context, project_id, associate=True): return IMPL.project_get_network(context, project_id) + def project_get_network_v6(context, project_id): return IMPL.project_get_network_v6(context, project_id) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index ffc0ec221..7c3afa4ad 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -585,6 +585,7 @@ def fixed_ip_get_instance(context, address): fixed_ip_ref = fixed_ip_get_by_address(context, address) return fixed_ip_ref.instance + @require_context def fixed_ip_get_instance_v6(context, address): session = get_session() @@ -801,6 +802,7 @@ def instance_get_fixed_address(context, instance_id): return None return instance_ref.fixed_ip['address'] + @require_context def instance_get_fixed_address_v6(context, instance_id): session = get_session() @@ -811,6 +813,7 @@ def instance_get_fixed_address_v6(context, instance_id): mac = instance_ref.mac_address return utils.to_global_ipv6(prefix, mac) + @require_context def instance_get_floating_address(context, instance_id): session = get_session() @@ -1150,6 +1153,7 @@ def project_get_network(context, project_id, associate=True): first() return result + @require_context def project_get_network_v6(context, project_id): return project_get_network(context, project_id) -- cgit From b945fed7779bddf799aa4a180d44745052d2da8c Mon Sep 17 00:00:00 2001 From: Hisaharu Ishii Date: Wed, 12 Jan 2011 21:55:36 +0900 Subject: Support IPv6 firewall with IptablesFirewallDriver --- nova/db/sqlalchemy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 3b3a88170..2ca16283f 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -798,7 +798,7 @@ def instance_get_fixed_address_v6(context, instance_id): session = get_session() with session.begin(): instance_ref = instance_get(context, instance_id, session=session) - network_ref = project_get_network(context, context.project_id) + network_ref = network_get_by_instance(context, instance_id) prefix = network_ref.cidr_v6 mac = instance_ref.mac_address return utils.to_global_ipv6(prefix, mac) -- cgit From 5fbc74784918abb509aba88400e6ed9a1d01deb9 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 12 Jan 2011 15:03:08 -0800 Subject: standardize on hex for ids, allow configurable instance names --- nova/db/api.py | 4 ++++ nova/db/sqlalchemy/models.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index 1f81ef145..e57766b5c 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -42,6 +42,10 @@ flags.DEFINE_string('db_backend', 'sqlalchemy', 'The backend to use for db') flags.DEFINE_boolean('enable_new_services', True, 'Services to be added to the available pool on create') +flags.DEFINE_string('instance_name_template', 'instance-%08x', + 'Template string to be used to generate instance names') +flags.DEFINE_string('volume_name_template', 'volume-%08x', + 'Template string to be used to generate instance names') IMPL = utils.LazyPluggable(FLAGS['db_backend'], diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 1dc46fe78..bbc89e573 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -169,7 +169,7 @@ class Instance(BASE, NovaBase): @property def name(self): - return "instance-%08x" % self.id + return FLAGS.instance_name_template % self.id admin_pass = Column(String(255)) user_id = Column(String(255)) @@ -256,7 +256,7 @@ class Volume(BASE, NovaBase): @property def name(self): - return "volume-%08x" % self.id + return FLAGS.volume_name_template % self.id user_id = Column(String(255)) project_id = Column(String(255)) -- cgit