Centralize config option: cluster_template section
Centralize config option of Cluster Template section. Replace oslo_conf cfg to magnum.conf. Change-Id: Ia120c8cb43c71977f69ac520cbd76563f4a8b655 Implements: blueprint centralize-config-magnum
This commit is contained in:
parent
4f8b26f822
commit
e891d0a20b
@ -14,56 +14,17 @@
|
||||
# limitations under the License.
|
||||
|
||||
import decorator
|
||||
from oslo_config import cfg
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import pecan
|
||||
|
||||
from magnum.api import utils as api_utils
|
||||
from magnum.common import exception
|
||||
import magnum.conf
|
||||
from magnum.i18n import _
|
||||
from magnum import objects
|
||||
|
||||
|
||||
cluster_template_opts = [
|
||||
cfg.ListOpt('kubernetes_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for kubernetes "
|
||||
"cluster-templates. Use 'all' keyword to allow all "
|
||||
"drivers supported for kubernetes cluster-templates. "
|
||||
"Supported network drivers include flannel."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('kubernetes_default_network_driver',
|
||||
default='flannel',
|
||||
help=_("Default network driver for kubernetes "
|
||||
"cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.ListOpt('swarm_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for docker swarm "
|
||||
"cluster-templates. Use 'all' keyword to allow all "
|
||||
"drivers supported for swarm cluster-templates. "
|
||||
"Supported network drivers include docker and flannel."
|
||||
),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('swarm_default_network_driver',
|
||||
default='docker',
|
||||
help=_("Default network driver for docker swarm "
|
||||
"cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.ListOpt('mesos_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for mesos cluster-templates. "
|
||||
"Use 'all' keyword to allow all drivers supported "
|
||||
"for mesos cluster-templates. Supported network "
|
||||
"drivers include docker."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('mesos_default_network_driver',
|
||||
default='docker',
|
||||
help=_("Default network driver for mesos cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
]
|
||||
cfg.CONF.register_opts(cluster_template_opts, group='cluster_template')
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
cluster_update_allowed_properties = set(['node_count'])
|
||||
|
||||
@ -297,9 +258,9 @@ class K8sValidator(Validator):
|
||||
supported_network_drivers = ['flannel']
|
||||
supported_server_types = ['vm', 'bm']
|
||||
allowed_network_drivers = (
|
||||
cfg.CONF.cluster_template.kubernetes_allowed_network_drivers)
|
||||
CONF.cluster_template.kubernetes_allowed_network_drivers)
|
||||
default_network_driver = (
|
||||
cfg.CONF.cluster_template.kubernetes_default_network_driver)
|
||||
CONF.cluster_template.kubernetes_default_network_driver)
|
||||
|
||||
supported_volume_driver = ['cinder']
|
||||
|
||||
@ -308,9 +269,9 @@ class SwarmValidator(Validator):
|
||||
|
||||
supported_network_drivers = ['docker', 'flannel']
|
||||
supported_server_types = ['vm', 'bm']
|
||||
allowed_network_drivers = (cfg.CONF.cluster_template.
|
||||
allowed_network_drivers = (CONF.cluster_template.
|
||||
swarm_allowed_network_drivers)
|
||||
default_network_driver = (cfg.CONF.cluster_template.
|
||||
default_network_driver = (CONF.cluster_template.
|
||||
swarm_default_network_driver)
|
||||
|
||||
supported_volume_driver = ['rexray']
|
||||
@ -320,9 +281,9 @@ class MesosValidator(Validator):
|
||||
|
||||
supported_network_drivers = ['docker']
|
||||
supported_server_types = ['vm', 'bm']
|
||||
allowed_network_drivers = (cfg.CONF.cluster_template.
|
||||
allowed_network_drivers = (CONF.cluster_template.
|
||||
mesos_allowed_network_drivers)
|
||||
default_network_driver = (cfg.CONF.cluster_template.
|
||||
default_network_driver = (CONF.cluster_template.
|
||||
mesos_default_network_driver)
|
||||
|
||||
supported_volume_driver = ['rexray']
|
||||
|
@ -20,7 +20,7 @@ from magnum.conf import barbican
|
||||
# from magnum.conf import certificates
|
||||
from magnum.conf import cinder
|
||||
from magnum.conf import cluster
|
||||
# from magnum.conf import cluster_templates
|
||||
from magnum.conf import cluster_templates
|
||||
from magnum.conf import conductor
|
||||
# from magnum.conf import database
|
||||
# from magnum.conf import docker
|
||||
@ -37,7 +37,7 @@ CONF = cfg.CONF
|
||||
api.register_opts(CONF)
|
||||
barbican.register_opts(CONF)
|
||||
cluster.register_opts(CONF)
|
||||
# cluster_templates.register_opts(CONF)
|
||||
cluster_templates.register_opts(CONF)
|
||||
# certificates.register_opts(CONF)
|
||||
cinder.register_opts(CONF)
|
||||
conductor.register_opts(CONF)
|
||||
|
68
magnum/conf/cluster_templates.py
Normal file
68
magnum/conf/cluster_templates.py
Normal file
@ -0,0 +1,68 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
# use this file except in compliance with the License. You may obtain a copy
|
||||
# of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from magnum.i18n import _
|
||||
|
||||
cluster_template_group = cfg.OptGroup(name='cluster_template',
|
||||
title='Options for cluster_template')
|
||||
|
||||
cluster_template_opts = [
|
||||
cfg.ListOpt('kubernetes_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for kubernetes "
|
||||
"cluster-templates. Use 'all' keyword to allow all "
|
||||
"drivers supported for kubernetes cluster-templates. "
|
||||
"Supported network drivers include flannel."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('kubernetes_default_network_driver',
|
||||
default='flannel',
|
||||
help=_("Default network driver for kubernetes "
|
||||
"cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.ListOpt('swarm_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for docker swarm "
|
||||
"cluster-templates. Use 'all' keyword to allow all "
|
||||
"drivers supported for swarm cluster-templates. "
|
||||
"Supported network drivers include docker and flannel."
|
||||
),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('swarm_default_network_driver',
|
||||
default='docker',
|
||||
help=_("Default network driver for docker swarm "
|
||||
"cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.ListOpt('mesos_allowed_network_drivers',
|
||||
default=['all'],
|
||||
help=_("Allowed network drivers for mesos cluster-templates. "
|
||||
"Use 'all' keyword to allow all drivers supported "
|
||||
"for mesos cluster-templates. Supported network "
|
||||
"drivers include docker."),
|
||||
deprecated_group='baymodel'),
|
||||
cfg.StrOpt('mesos_default_network_driver',
|
||||
default='docker',
|
||||
help=_("Default network driver for mesos cluster-templates."),
|
||||
deprecated_group='baymodel'),
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(cluster_template_group)
|
||||
conf.register_opts(cluster_template_opts, group=cluster_template_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
cluster_template_group: cluster_template_opts
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
|
||||
import itertools
|
||||
|
||||
import magnum.api.validation
|
||||
import magnum.common.cert_manager
|
||||
from magnum.common.cert_manager import local_cert_manager
|
||||
import magnum.common.exception
|
||||
@ -44,7 +43,6 @@ def list_opts():
|
||||
itertools.chain(magnum.common.cert_manager.cert_manager_opts,
|
||||
local_cert_manager.local_cert_manager_opts,
|
||||
)),
|
||||
('cluster_template', magnum.api.validation.cluster_template_opts),
|
||||
('keystone_auth', magnum.common.keystone.keystone_auth_opts),
|
||||
('docker_registry',
|
||||
magnum.drivers.common.template_def.docker_registry_opts)
|
||||
|
@ -13,7 +13,6 @@
|
||||
import datetime
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
@ -24,11 +23,14 @@ from magnum.api import attr_validator
|
||||
from magnum.api.controllers.v1 import baymodel as api_baymodel
|
||||
from magnum.common import exception
|
||||
from magnum.common import policy as magnum_policy
|
||||
import magnum.conf
|
||||
from magnum.tests import base
|
||||
from magnum.tests.unit.api import base as api_base
|
||||
from magnum.tests.unit.api import utils as apiutils
|
||||
from magnum.tests.unit.objects import utils as obj_utils
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class TestBayModelObject(base.TestCase):
|
||||
|
||||
@ -171,7 +173,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
||||
self.assertIn(next_marker, response['next'])
|
||||
|
||||
def test_collection_links_default_limit(self):
|
||||
cfg.CONF.set_override('max_limit', 3, 'api')
|
||||
CONF.set_override('max_limit', 3, 'api')
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_cluster_template(
|
||||
self.context, id=id_, uuid=uuidutils.generate_uuid())
|
||||
@ -625,11 +627,10 @@ class TestPost(api_base.FunctionalTest):
|
||||
mock_image_data.return_value = {'name': 'mock_name',
|
||||
'os_distro': 'fedora-atomic'}
|
||||
for k, v in baymodel_config_dict.items():
|
||||
cfg.CONF.set_override(k, v, 'cluster_template')
|
||||
CONF.set_override(k, v, 'cluster_template')
|
||||
with mock.patch.object(
|
||||
self.dbapi, 'create_cluster_template',
|
||||
wraps=self.dbapi.create_cluster_template) as cc_mock:
|
||||
|
||||
bdict = apiutils.baymodel_post_data(**baymodel_dict)
|
||||
response = self.post_json('/baymodels', bdict,
|
||||
expect_errors=expect_errors)
|
||||
@ -639,7 +640,7 @@ class TestPost(api_base.FunctionalTest):
|
||||
expected_driver = bdict.get('network_driver')
|
||||
if not expected_driver:
|
||||
expected_driver = (
|
||||
cfg.CONF.cluster_template.swarm_default_network_driver)
|
||||
CONF.cluster_template.swarm_default_network_driver)
|
||||
self.assertEqual(expected_driver,
|
||||
response.json['network_driver'])
|
||||
self.assertEqual(bdict['image_id'],
|
||||
|
@ -14,15 +14,17 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from six.moves import reload_module
|
||||
|
||||
from magnum.api import validation as v
|
||||
from magnum.common import exception
|
||||
import magnum.conf
|
||||
from magnum import objects
|
||||
from magnum.tests import base
|
||||
from magnum.tests.unit.objects import utils as obj_utils
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class TestValidation(base.BaseTestCase):
|
||||
|
||||
@ -181,7 +183,7 @@ class TestValidation(base.BaseTestCase):
|
||||
pass
|
||||
|
||||
for key, val in network_driver_config_dict.items():
|
||||
cfg.CONF.set_override(key, val, 'cluster_template')
|
||||
CONF.set_override(key, val, 'cluster_template')
|
||||
|
||||
cluster_template = mock.MagicMock()
|
||||
cluster_template.name = 'test_cluster_template'
|
||||
@ -269,7 +271,7 @@ class TestValidation(base.BaseTestCase):
|
||||
pass
|
||||
|
||||
for key, val in network_driver_config_dict.items():
|
||||
cfg.CONF.set_override(key, val, 'cluster_template')
|
||||
CONF.set_override(key, val, 'cluster_template')
|
||||
|
||||
cluster_template_ident = 'test_uuid_or_name'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user