Make fip topology check configurable

Horizon will by default check that a project has
a router with a port on an external network prior
to allowing floating ips to be attached to
instances. Since it is valid to use a shared
router from a different project we make this
configurable to allow disabling this check.

Closes-Bug: #1815032
Change-Id: I5c3e44e5daa683e14ac39979d6e9a7c2238dd120
This commit is contained in:
Edward Hope-Morley 2019-02-07 11:42:38 +00:00
parent 1534accb10
commit ac7793ffee
7 changed files with 57 additions and 5 deletions

View File

@ -341,3 +341,11 @@ options:
The maximum number of objects (e.g. Swift objects or Glance images) to
display on a single page before providing a paging element (a "more" link)
to paginate results.
enable-fip-topology-check:
type: boolean
default: true
description:
By default Horizon checks that a project has a router attached to an
external network before allowing FIPs to be attached to a VM. Some use
cases will not meet this constraint, e.g. if the router is owned by a
different project. Setting this to False removes this check from Horizon.

View File

@ -203,7 +203,8 @@ class HorizonContext(OSContextGenerator):
'multi_domain': False if config('default-domain') else True,
"default_create_volume": config("default-create-volume"),
'image_formats': config('image-formats'),
'api_result_limit': config('api-result-limit') or 1000
'api_result_limit': config('api-result-limit') or 1000,
'enable_fip_topology_check': config('enable-fip-topology-check'),
}
return ctxt

View File

@ -247,7 +247,7 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': {{ neutron_network_lb }},
'enable_firewall': {{ neutron_network_firewall }},
'enable_vpn': {{ neutron_network_vpn }},
'enable_fip_topology_check': True,
'enable_fip_topology_check': {{ enable_fip_topology_check }},
# Neutron can be configured with a default Subnet Pool to be used for IPv4
# subnet-allocation. Specify the label you wish to display in the Address

View File

@ -318,7 +318,7 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': {{ neutron_network_lb }},
'enable_firewall': {{ neutron_network_firewall }},
'enable_vpn': {{ neutron_network_vpn }},
'enable_fip_topology_check': True,
'enable_fip_topology_check': {{ enable_fip_topology_check }},
# Neutron can be configured with a default Subnet Pool to be used for IPv4
# subnet-allocation. Specify the label you wish to display in the Address

View File

@ -324,7 +324,7 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': {{ neutron_network_lb }},
'enable_firewall': {{ neutron_network_firewall }},
'enable_vpn': {{ neutron_network_vpn }},
'enable_fip_topology_check': True,
'enable_fip_topology_check': {{ enable_fip_topology_check }},
# Default dns servers you would like to use when a subnet is
# created. This is only a default, users can still choose a different

View File

@ -328,7 +328,7 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': {{ neutron_network_lb }},
'enable_firewall': {{ neutron_network_firewall }},
'enable_vpn': {{ neutron_network_vpn }},
'enable_fip_topology_check': True,
'enable_fip_topology_check': {{ enable_fip_topology_check }},
# Default dns servers you would like to use when a subnet is
# created. This is only a default, users can still choose a different

View File

@ -163,6 +163,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -190,6 +191,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -217,6 +219,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -244,6 +247,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -272,6 +276,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -303,6 +308,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -330,6 +336,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -357,6 +364,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -389,6 +397,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -416,6 +425,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -443,6 +453,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -471,6 +482,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -499,6 +511,7 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": False,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
@ -527,6 +540,36 @@ class TestHorizonContexts(CharmTestCase):
"default_create_volume": True,
"image_formats": 'iso qcow2 raw',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
}
)
def test_HorizonContext_fip_topology_check_disabled(self):
self.maxDiff = 900
self.test_config.set('enable-fip-topology-check', False)
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
'customization_module': '',
'default_role': 'Member', 'webroot': '/horizon',
'ubuntu_theme': True,
'default_theme': None,
'custom_theme': False,
'secret': 'secret',
'support_profile': None,
"neutron_network_dvr": False,
"neutron_network_l3ha": False,
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": False,
}
)