diff --git a/config.yaml b/config.yaml index 358ce65a..cffe1292 100644 --- a/config.yaml +++ b/config.yaml @@ -362,3 +362,11 @@ options: 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. + 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. diff --git a/hooks/horizon_contexts.py b/hooks/horizon_contexts.py index 3e8a4ec7..ff4731f4 100644 --- a/hooks/horizon_contexts.py +++ b/hooks/horizon_contexts.py @@ -203,7 +203,8 @@ class HorizonContext(OSContextGenerator): 'api_result_limit': config('api-result-limit') or 1000, 'enable_fip_topology_check': config('enable-fip-topology-check'), '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 diff --git a/hooks/horizon_utils.py b/hooks/horizon_utils.py index a329511e..1ef5ec5d 100644 --- a/hooks/horizon_utils.py +++ b/hooks/horizon_utils.py @@ -106,6 +106,9 @@ ROUTER_SETTING = ('/usr/share/openstack-dashboard/openstack_dashboard/enabled/' '_40_router.py') KEYSTONEV3_POLICY = ('/usr/share/openstack-dashboard/openstack_dashboard/conf/' 'keystonev3_policy.json') +CONSISTENCY_GROUP_POLICY = ('/usr/share/openstack-dashboard/' + 'openstack_dashboard/conf/cinder_policy.d/' + 'consistencygroup.yaml') TEMPLATES = 'templates' CUSTOM_THEME_DIR = ("/usr/share/openstack-dashboard/openstack_dashboard/" "themes/custom") @@ -171,6 +174,10 @@ CONFIG_FILES = OrderedDict([ 'hook_contexts': [horizon_contexts.IdentityServiceContext()], 'services': ['apache2', 'memcached'], }), + (CONSISTENCY_GROUP_POLICY, { + 'hook_contexts': [horizon_contexts.HorizonContext()], + 'services': ['apache2', 'memcached'], + }), ]) @@ -184,6 +191,11 @@ def register_configs(): HAPROXY_CONF, PORTS_CONF] + if CompareOpenStackReleases(release) >= 'queens': + configs.register( + CONSISTENCY_GROUP_POLICY, + CONFIG_FILES[CONSISTENCY_GROUP_POLICY]['hook_contexts']) + if CompareOpenStackReleases(release) >= 'mitaka': configs.register(KEYSTONEV3_POLICY, CONFIG_FILES[KEYSTONEV3_POLICY]['hook_contexts']) diff --git a/templates/queens/consistencygroup.yaml b/templates/queens/consistencygroup.yaml new file mode 100644 index 00000000..0cadfd9f --- /dev/null +++ b/templates/queens/consistencygroup.yaml @@ -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 -%} \ No newline at end of file diff --git a/unit_tests/test_horizon_contexts.py b/unit_tests/test_horizon_contexts.py index f859986a..7d7418c8 100644 --- a/unit_tests/test_horizon_contexts.py +++ b/unit_tests/test_horizon_contexts.py @@ -122,6 +122,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -152,6 +153,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -182,6 +184,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -212,6 +215,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -243,6 +247,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -277,6 +282,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -307,6 +313,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -337,6 +344,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -372,6 +380,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -402,6 +411,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -432,6 +442,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -463,6 +474,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -494,6 +506,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -525,6 +538,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": True, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) @@ -556,6 +570,7 @@ class TestHorizonContexts(CharmTestCase): "enable_fip_topology_check": False, "session_timeout": 3600, "dropdown_max_items": 30, + "enable_consistency_groups": False, } ) diff --git a/unit_tests/test_horizon_utils.py b/unit_tests/test_horizon_utils.py index 90715e5a..51530df1 100644 --- a/unit_tests/test_horizon_utils.py +++ b/unit_tests/test_horizon_utils.py @@ -133,6 +133,9 @@ class TestHorizonUtils(CharmTestCase): ('/usr/share/openstack-dashboard/openstack_dashboard/conf/' 'keystonev3_policy.json', ['apache2', 'memcached']), + ('/usr/share/openstack-dashboard/openstack_dashboard/conf/' + 'cinder_policy.d/consistencygroup.yaml', + ['apache2', 'memcached']), ]) self.assertEqual(horizon_utils.restart_map(), ex_map)