Add option to hide/show consistency groups tab

Cinder by default does not enable Consistency Groups, but Horizon always
show its tabs and there is not an option to hide them. This patch adds a
config option to change the policy file to hide or show those tabs.

Change-Id: Ia2fb52650201524acbb8d6aafe37e7c0ea26e99e
Closes-bug: #1684113
This commit is contained in:
tpsilva 2019-03-18 17:10:47 -03:00
parent f80b94b9a3
commit ca21ac8116
6 changed files with 61 additions and 1 deletions

View File

@ -362,3 +362,11 @@ options:
external network before allowing FIPs to be attached to a VM. Some use 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 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. different project. Setting this to False removes this check from Horizon.
enable-consistency-groups:
type: boolean
default: false
description: |
By default Cinder does not enable the Consistency Groups feature. To
avoid having the Consistency Groups tabs on Horizon without the feature
enabled on Cinder, this also defaults to False. Setting this to True
will make the Consistency Groups tabs appear on the dashboard.

View File

@ -203,7 +203,8 @@ class HorizonContext(OSContextGenerator):
'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'), 'enable_fip_topology_check': config('enable-fip-topology-check'),
'session_timeout': config('session-timeout'), 'session_timeout': config('session-timeout'),
'dropdown_max_items': config('dropdown-max-items') 'dropdown_max_items': config('dropdown-max-items'),
'enable_consistency_groups': config('enable-consistency-groups'),
} }
return ctxt return ctxt

View File

@ -106,6 +106,9 @@ ROUTER_SETTING = ('/usr/share/openstack-dashboard/openstack_dashboard/enabled/'
'_40_router.py') '_40_router.py')
KEYSTONEV3_POLICY = ('/usr/share/openstack-dashboard/openstack_dashboard/conf/' KEYSTONEV3_POLICY = ('/usr/share/openstack-dashboard/openstack_dashboard/conf/'
'keystonev3_policy.json') 'keystonev3_policy.json')
CONSISTENCY_GROUP_POLICY = ('/usr/share/openstack-dashboard/'
'openstack_dashboard/conf/cinder_policy.d/'
'consistencygroup.yaml')
TEMPLATES = 'templates' TEMPLATES = 'templates'
CUSTOM_THEME_DIR = ("/usr/share/openstack-dashboard/openstack_dashboard/" CUSTOM_THEME_DIR = ("/usr/share/openstack-dashboard/openstack_dashboard/"
"themes/custom") "themes/custom")
@ -171,6 +174,10 @@ CONFIG_FILES = OrderedDict([
'hook_contexts': [horizon_contexts.IdentityServiceContext()], 'hook_contexts': [horizon_contexts.IdentityServiceContext()],
'services': ['apache2', 'memcached'], 'services': ['apache2', 'memcached'],
}), }),
(CONSISTENCY_GROUP_POLICY, {
'hook_contexts': [horizon_contexts.HorizonContext()],
'services': ['apache2', 'memcached'],
}),
]) ])
@ -184,6 +191,11 @@ def register_configs():
HAPROXY_CONF, HAPROXY_CONF,
PORTS_CONF] PORTS_CONF]
if CompareOpenStackReleases(release) >= 'queens':
configs.register(
CONSISTENCY_GROUP_POLICY,
CONFIG_FILES[CONSISTENCY_GROUP_POLICY]['hook_contexts'])
if CompareOpenStackReleases(release) >= 'mitaka': if CompareOpenStackReleases(release) >= 'mitaka':
configs.register(KEYSTONEV3_POLICY, configs.register(KEYSTONEV3_POLICY,
CONFIG_FILES[KEYSTONEV3_POLICY]['hook_contexts']) CONFIG_FILES[KEYSTONEV3_POLICY]['hook_contexts'])

View File

@ -0,0 +1,21 @@
{% if enable_consistency_groups -%}
"consistencygroup:create" : ""
"consistencygroup:create_cgsnapshot" : ""
"consistencygroup:delete": ""
"consistencygroup:delete_cgsnapshot": ""
"consistencygroup:get": ""
"consistencygroup:get_all": ""
"consistencygroup:get_all_cgsnapshots": ""
"consistencygroup:get_cgsnapshot": ""
"consistencygroup:update": ""
{% else -%}
"consistencygroup:create" : "group:nobody"
"consistencygroup:create_cgsnapshot" : "group:nobody"
"consistencygroup:delete": "group:nobody"
"consistencygroup:delete_cgsnapshot": "group:nobody"
"consistencygroup:get": "group:nobody"
"consistencygroup:get_all": "group:nobody"
"consistencygroup:get_all_cgsnapshots": "group:nobody"
"consistencygroup:get_cgsnapshot": "group:nobody"
"consistencygroup:update": "group:nobody"
{% endif -%}

View File

@ -122,6 +122,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -152,6 +153,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -182,6 +184,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -212,6 +215,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -243,6 +247,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -277,6 +282,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -307,6 +313,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -337,6 +344,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -372,6 +380,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -402,6 +411,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -432,6 +442,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -463,6 +474,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -494,6 +506,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -525,6 +538,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": True, "enable_fip_topology_check": True,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )
@ -556,6 +570,7 @@ class TestHorizonContexts(CharmTestCase):
"enable_fip_topology_check": False, "enable_fip_topology_check": False,
"session_timeout": 3600, "session_timeout": 3600,
"dropdown_max_items": 30, "dropdown_max_items": 30,
"enable_consistency_groups": False,
} }
) )

View File

@ -133,6 +133,9 @@ class TestHorizonUtils(CharmTestCase):
('/usr/share/openstack-dashboard/openstack_dashboard/conf/' ('/usr/share/openstack-dashboard/openstack_dashboard/conf/'
'keystonev3_policy.json', 'keystonev3_policy.json',
['apache2', 'memcached']), ['apache2', 'memcached']),
('/usr/share/openstack-dashboard/openstack_dashboard/conf/'
'cinder_policy.d/consistencygroup.yaml',
['apache2', 'memcached']),
]) ])
self.assertEqual(horizon_utils.restart_map(), ex_map) self.assertEqual(horizon_utils.restart_map(), ex_map)