Commit 0682f043 by Szabolcs Gelencser Committed by Szabolcs Gelencsér

Fix external network connectivity

parent 6c9a7148
...@@ -595,7 +595,7 @@ DEFAULT_SUBNETPOOL_PREFIXES = ( ...@@ -595,7 +595,7 @@ DEFAULT_SUBNETPOOL_PREFIXES = (
) )
DEFAULT_SUBNETPOOL_PREFIX_LEN = 20 DEFAULT_SUBNETPOOL_PREFIX_LEN = 20
DEFAULT_PUBLIC_NETWORK_NAME = "public" DEFAULT_EXTERNAL_NETWORK_NAME = "Smart1"
DEFAULT_PUBLIC_ROUTER_NAME_FOR_USER = "default_public" DEFAULT_PUBLIC_ROUTER_NAME_FOR_USER = "default_public"
DEFAULT_PUBLIC_ROUTED_NET_NAME_FOR_USER = "default_public_routed" DEFAULT_PUBLIC_ROUTED_NET_NAME_FOR_USER = "default_public_routed"
......
...@@ -102,9 +102,9 @@ class SubnetPool(object): ...@@ -102,9 +102,9 @@ class SubnetPool(object):
class DefaultPublicRouter(object): class DefaultPublicRouter(object):
@classmethod @classmethod
def __get_default_public_network(cls, request): def __get_external_network(cls, request):
nets = openstack_api.neutron.network_list(request) nets = openstack_api.neutron.network_list(request)
nets = [n for n in nets if n.name == settings.DEFAULT_PUBLIC_NETWORK_NAME] nets = [n for n in nets if n.name == settings.DEFAULT_EXTERNAL_NETWORK_NAME]
return nets[0] if len(nets) > 0 else None return nets[0] if len(nets) > 0 else None
@classmethod @classmethod
...@@ -114,30 +114,26 @@ class DefaultPublicRouter(object): ...@@ -114,30 +114,26 @@ class DefaultPublicRouter(object):
return routers[0] if len(routers) > 0 else None return routers[0] if len(routers) > 0 else None
@classmethod @classmethod
def create_if_not_exists(cls, request, subnet_id): def create_if_not_exists(cls, request, network):
default_public_router = DefaultPublicRouter.__get(request) default_public_router = DefaultPublicRouter.__get(request)
if default_public_router is None: if default_public_router is None:
default_public_router = openstack_api.neutron.router_create( default_public_router = openstack_api.neutron.router_create(
request, request,
name=settings.DEFAULT_PUBLIC_ROUTER_NAME_FOR_USER, name=settings.DEFAULT_PUBLIC_ROUTER_NAME_FOR_USER,
external_gateway_info={ external_gateway_info={
"network_id": DefaultPublicRouter.__get_default_public_network(request).id "network_id": DefaultPublicRouter.__get_external_network(request).id
} }
) )
openstack_api.neutron.router_add_interface( openstack_api.neutron.router_add_interface(
request, request,
default_public_router.id, default_public_router.id,
subnet_id=subnet_id subnet_id=network.subnets[0].id
) )
return default_public_router return default_public_router
class DefaultPublicRoutedNet(object): class DefaultPublicRoutedNet(object):
@classmethod @classmethod
def __connect_router(cls, request, default_routed_net):
DefaultPublicRouter.create_if_not_exists(request, default_routed_net.subnets[0].id)
@classmethod
def __create_network(cls, request): def __create_network(cls, request):
network_created = openstack_api.neutron.network_create( network_created = openstack_api.neutron.network_create(
request, request,
...@@ -169,7 +165,7 @@ class DefaultPublicRoutedNet(object): ...@@ -169,7 +165,7 @@ class DefaultPublicRoutedNet(object):
default_routed_net = DefaultPublicRoutedNet.__get(request) default_routed_net = DefaultPublicRoutedNet.__get(request)
if default_routed_net is None: if default_routed_net is None:
default_routed_net = DefaultPublicRoutedNet.__create_network(request) default_routed_net = DefaultPublicRoutedNet.__create_network(request)
DefaultPublicRoutedNet.__connect_router(request, default_routed_net) DefaultPublicRouter.create_if_not_exists(request, default_routed_net)
return default_routed_net return default_routed_net
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment