Add new feature group for advanced users
Added new feature group for features that are not experimental, but user need to have special knowledge. All use case of this features should be good documented because user need to be aware of about risk or disadvantages. Implements: blueprint reduced-footprint DocImpact Change-Id: Ia963f43c335d2bdbc305bd74a8fa663242b837b4
This commit is contained in:
parent
d1c2616d4c
commit
f94f8021c9
@ -113,6 +113,8 @@ from nailgun.api.v1.handlers.removed import RemovedIn51RedHatSetupHandler
|
||||
from nailgun.api.v1.handlers.master_node_settings \
|
||||
import MasterNodeSettingsHandler
|
||||
|
||||
from nailgun.settings import settings
|
||||
|
||||
urls = (
|
||||
r'/releases/?$',
|
||||
ReleaseCollectionHandler,
|
||||
@ -189,8 +191,6 @@ urls = (
|
||||
ClusterUpdateHandler,
|
||||
r'/clusters/(?P<obj_id>\d+)/deployment_tasks/?$',
|
||||
ClusterDeploymentTasksHandler,
|
||||
r'/clusters/(?P<cluster_id>\d+)/spawn_vms/?$',
|
||||
SpawnVmsHandler,
|
||||
|
||||
r'/clusters/(?P<cluster_id>\d+)/assignment/?$',
|
||||
NodeAssignmentHandler,
|
||||
@ -223,8 +223,6 @@ urls = (
|
||||
NodeNICsDefaultHandler,
|
||||
r'/nodes/allocation/stats/?$',
|
||||
NodesAllocationStatsHandler,
|
||||
r'/nodes/(?P<node_id>\d+)/vms_conf/?$',
|
||||
NodeVMsHandler,
|
||||
r'/tasks/?$',
|
||||
TaskCollectionHandler,
|
||||
r'/tasks/(?P<obj_id>\d+)/?$',
|
||||
@ -279,6 +277,16 @@ urls = (
|
||||
MasterNodeSettingsHandler,
|
||||
)
|
||||
|
||||
feature_groups_urls = {
|
||||
'advanced': (
|
||||
r'/clusters/(?P<cluster_id>\d+)/spawn_vms/?$',
|
||||
SpawnVmsHandler,
|
||||
r'/nodes/(?P<node_id>\d+)/vms_conf/?$',
|
||||
NodeVMsHandler,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
urls = [i if isinstance(i, str) else i.__name__ for i in urls]
|
||||
|
||||
_locals = locals()
|
||||
@ -315,12 +323,26 @@ def get_extensions_urls():
|
||||
return {'urls': urls, 'handlers': handlers}
|
||||
|
||||
|
||||
def get_feature_groups_urls():
|
||||
"""Method is used to retrieve urls depended on feature groups like
|
||||
'experimental' or 'advanced' which should be enable only for this modes.
|
||||
|
||||
:returns: list of urls
|
||||
"""
|
||||
urls = []
|
||||
for feature in settings.VERSION['feature_groups']:
|
||||
urls.extend([i if isinstance(i, str) else i.__name__ for i in
|
||||
feature_groups_urls.get(feature, [])])
|
||||
return urls
|
||||
|
||||
|
||||
def get_all_urls():
|
||||
"""Merges urls and handlers from core with
|
||||
urls and handlers from extensions
|
||||
"""
|
||||
ext_urls = get_extensions_urls()
|
||||
all_urls = list(urls)
|
||||
all_urls.extend(get_feature_groups_urls())
|
||||
all_urls.extend(ext_urls['urls'])
|
||||
|
||||
for handler in ext_urls['handlers']:
|
||||
|
@ -99,9 +99,10 @@
|
||||
weight: 70
|
||||
virt:
|
||||
name: "Virtual"
|
||||
description: "Make available possibilities to spawn vms on this node that can be assign as a normal nodes."
|
||||
description: "ADVANCED: Make available possibilities to spawn vms on this node that can be assign as a normal nodes."
|
||||
weight: 80
|
||||
public_ip_required: true
|
||||
condition: "'advanced' in version:feature_groups"
|
||||
|
||||
network_roles_metadata:
|
||||
-
|
||||
|
@ -26,6 +26,7 @@ VERSION:
|
||||
ostf_sha: "Unknown build"
|
||||
feature_groups:
|
||||
- experimental
|
||||
- advanced
|
||||
|
||||
FUEL_KEY: "Unknown"
|
||||
|
||||
|
@ -29,13 +29,15 @@ class FakeHandler(object):
|
||||
class TestUrls(BaseTestCase):
|
||||
|
||||
@mock.patch('nailgun.api.v1.urls.get_extensions_urls')
|
||||
def test_get_all_urls(self, mock_get_extensions_urls):
|
||||
@mock.patch('nailgun.api.v1.urls.get_feature_groups_urls')
|
||||
def test_get_all_urls(self, mock_get_feature_groups_urls,
|
||||
mock_get_extensions_urls):
|
||||
mock_get_extensions_urls.return_value = {
|
||||
'urls': (r'/ext/url/', 'FakeHandler'),
|
||||
'handlers': [{
|
||||
'class': FakeHandler,
|
||||
'name': 'FakeHandler'}]}
|
||||
|
||||
mock_get_feature_groups_urls.return_value = ['/advanced/url/']
|
||||
result = get_all_urls()
|
||||
# Urls
|
||||
all_urls = result[0]
|
||||
@ -43,6 +45,7 @@ class TestUrls(BaseTestCase):
|
||||
all_vars = result[1]
|
||||
|
||||
self.assertIn('/ext/url/', all_urls[-2])
|
||||
self.assertIn('/advanced/url/', all_urls)
|
||||
self.assertIn('FakeHandler', all_urls[-1])
|
||||
|
||||
self.assertEqual(all_vars['FakeHandler'], FakeHandler)
|
||||
@ -57,3 +60,14 @@ class TestUrls(BaseTestCase):
|
||||
get_extensions_urls(),
|
||||
{'urls': ['/ext/uri', 'FakeHandler'],
|
||||
'handlers': [{'class': FakeHandler, 'name': 'FakeHandler'}]})
|
||||
|
||||
@mock.patch.dict('nailgun.api.v1.urls.settings.VERSION',
|
||||
{'feature_groups': ['mirantis']})
|
||||
def test_get_feature_urls(self):
|
||||
|
||||
result = get_all_urls()
|
||||
# Urls
|
||||
all_urls = result[0]
|
||||
|
||||
self.assertNotIn('/clusters/(?P<cluster_id>\d+)/spawn_vms/?$',
|
||||
all_urls)
|
||||
|
@ -32,6 +32,7 @@ class TestVersionHandler(BaseIntegrationTest):
|
||||
"astute_sha": "Unknown build",
|
||||
"fuellib_sha": "Unknown build",
|
||||
"ostf_sha": "Unknown build",
|
||||
"feature_groups": [],
|
||||
})
|
||||
def test_version_handler(self):
|
||||
with nested(
|
||||
@ -59,6 +60,7 @@ class TestVersionHandler(BaseIntegrationTest):
|
||||
"fuellib_sha": "Unknown build",
|
||||
"ostf_sha": "Unknown build",
|
||||
"auth_required": True,
|
||||
"feature_groups": [],
|
||||
"release_versions": {
|
||||
"test": "test_data"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user