Centralize config option: docker_registry section
Centralize config option of docker_registry section. Replace oslo_conf cfg to magnum.conf. Change-Id: I43d3ce068bb6638f71ea14577f34c1df3d7c9d8c Implements: blueprint centralize-config-magnum
This commit is contained in:
parent
ba11900215
commit
08a48895c4
@ -14,10 +14,10 @@
|
||||
|
||||
import os
|
||||
|
||||
import magnum.conf
|
||||
from magnum.drivers.common import k8s_template_def
|
||||
from oslo_config import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
|
||||
|
@ -2,7 +2,6 @@
|
||||
output_file = etc/magnum/magnum.conf.sample
|
||||
wrap_width = 79
|
||||
|
||||
namespace = magnum
|
||||
namespace = magnum.conf
|
||||
namespace = oslo.concurrency
|
||||
namespace = oslo.db
|
||||
|
@ -25,6 +25,7 @@ from magnum.conf import cluster_templates
|
||||
from magnum.conf import conductor
|
||||
from magnum.conf import database
|
||||
from magnum.conf import docker
|
||||
from magnum.conf import docker_registry
|
||||
from magnum.conf import glance
|
||||
from magnum.conf import heat
|
||||
from magnum.conf import keystone
|
||||
@ -50,6 +51,7 @@ cinder.register_opts(CONF)
|
||||
conductor.register_opts(CONF)
|
||||
database.register_opts(CONF)
|
||||
docker.register_opts(CONF)
|
||||
docker_registry.register_opts(CONF)
|
||||
glance.register_opts(CONF)
|
||||
heat.register_opts(CONF)
|
||||
keystone.register_opts(CONF)
|
||||
|
38
magnum/conf/docker_registry.py
Normal file
38
magnum/conf/docker_registry.py
Normal file
@ -0,0 +1,38 @@
|
||||
# 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 _
|
||||
|
||||
docker_registry_group = cfg.OptGroup(name='docker_registry',
|
||||
title='Options for Docker Registry')
|
||||
|
||||
docker_registry_opts = [
|
||||
cfg.StrOpt('swift_region',
|
||||
help=_('Region name of Swift')),
|
||||
cfg.StrOpt('swift_registry_container',
|
||||
default='docker_registry',
|
||||
help=_('Name of the container in Swift which docker registry '
|
||||
'stores images in'))
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(docker_registry_group)
|
||||
conf.register_opts(docker_registry_opts, group=docker_registry_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
docker_registry_group: docker_registry_opts
|
||||
}
|
@ -14,7 +14,6 @@
|
||||
import abc
|
||||
import ast
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import requests
|
||||
import six
|
||||
@ -22,7 +21,6 @@ import six
|
||||
from magnum.common import clients
|
||||
from magnum.common import exception
|
||||
import magnum.conf
|
||||
from magnum.i18n import _
|
||||
from magnum.i18n import _LW
|
||||
|
||||
from requests import exceptions as req_exceptions
|
||||
@ -32,17 +30,7 @@ LOG = logging.getLogger(__name__)
|
||||
COMMON_TEMPLATES_PATH = "../../common/templates/"
|
||||
COMMON_ENV_PATH = COMMON_TEMPLATES_PATH + "environments/"
|
||||
|
||||
docker_registry_opts = [
|
||||
cfg.StrOpt('swift_region',
|
||||
help=_('Region name of Swift')),
|
||||
cfg.StrOpt('swift_registry_container',
|
||||
default='docker_registry',
|
||||
help=_('Name of the container in Swift which docker registry '
|
||||
'stores images in'))
|
||||
]
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
CONF.register_opts(docker_registry_opts, group='docker_registry')
|
||||
|
||||
|
||||
class ParameterMapping(object):
|
||||
@ -310,7 +298,7 @@ class BaseTemplateDefinition(TemplateDefinition):
|
||||
discovery_url = cluster.discovery_url
|
||||
else:
|
||||
discovery_endpoint = (
|
||||
cfg.CONF.cluster.etcd_discovery_service_endpoint_format %
|
||||
CONF.cluster.etcd_discovery_service_endpoint_format %
|
||||
{'size': cluster.master_count})
|
||||
try:
|
||||
discovery_url = requests.get(discovery_endpoint).text
|
||||
|
@ -13,11 +13,11 @@
|
||||
# under the License.
|
||||
import os
|
||||
|
||||
import magnum.conf
|
||||
from magnum.drivers.common import k8s_template_def
|
||||
from magnum.drivers.common import template_def
|
||||
from oslo_config import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class CoreOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
import os
|
||||
|
||||
import magnum.conf
|
||||
from magnum.drivers.common import k8s_fedora_template_def as kftd
|
||||
from oslo_config import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class AtomicK8sTemplateDefinition(kftd.K8sFedoraTemplateDefinition):
|
||||
|
@ -14,9 +14,6 @@
|
||||
import os
|
||||
|
||||
from magnum.drivers.common import swarm_fedora_template_def as sftd
|
||||
from oslo_config import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class AtomicSwarmTemplateDefinition(sftd.SwarmFedoraTemplateDefinition):
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Copyright 2014
|
||||
# The Cloudscaling Group, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import magnum.drivers.common.template_def
|
||||
|
||||
|
||||
def list_opts():
|
||||
return [
|
||||
('docker_registry',
|
||||
magnum.drivers.common.template_def.docker_registry_opts)
|
||||
]
|
@ -14,16 +14,18 @@
|
||||
|
||||
import mock
|
||||
from mock import patch
|
||||
from oslo_config import cfg
|
||||
from oslo_service import loopingcall
|
||||
|
||||
from magnum.conductor.handlers import cluster_conductor
|
||||
import magnum.conf
|
||||
from magnum.drivers.common import driver
|
||||
from magnum.drivers.swarm_fedora_atomic_v1 import driver as swarm_dr
|
||||
from magnum import objects
|
||||
from magnum.objects.fields import ClusterStatus as cluster_status
|
||||
from magnum.tests import base
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class TestClusterConductorWithSwarm(base.TestCase):
|
||||
def setUp(self):
|
||||
@ -166,9 +168,9 @@ class TestClusterConductorWithSwarm(base.TestCase):
|
||||
mock_driver.return_value = swarm_dr.Driver()
|
||||
cluster = objects.Cluster(self.context, **self.cluster_dict)
|
||||
|
||||
cfg.CONF.set_override('swift_region',
|
||||
'RegionOne',
|
||||
group='docker_registry')
|
||||
CONF.set_override('swift_region',
|
||||
'RegionOne',
|
||||
group='docker_registry')
|
||||
|
||||
(template_path,
|
||||
definition,
|
||||
|
@ -1,28 +0,0 @@
|
||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
import six
|
||||
|
||||
from magnum import opts
|
||||
from magnum.tests import base
|
||||
|
||||
|
||||
class OptsTestCase(base.BaseTestCase):
|
||||
|
||||
def test_list_opts(self):
|
||||
for group_name, opt_list in opts.list_opts():
|
||||
self.assertIsInstance(group_name, six.string_types)
|
||||
for opt in opt_list:
|
||||
self.assertIsInstance(opt, cfg.Opt)
|
Loading…
Reference in New Issue
Block a user