return (self.ceph_git_url or
self.ceph_git_base_url + 'ceph.git')
+
class JobConfig(YamlConfig):
pass
class FakeNamespace(YamlConfig):
"""
- This class is meant to behave like a argparse Namespace. It mimics the old
- way of doing things with argparse and teuthology.misc.read_config.
+ This class is meant to behave like a argparse Namespace
We'll use this as a stop-gap as we refactor commands but allow the tasks
to still be passed a single namespace object for the time being.
"""
- def __init__(self, config_dict=None, yaml_path=None):
- if not yaml_path:
- yaml_path = _get_config_path()
+ def __init__(self, config_dict=None):
if not config_dict:
config_dict = dict()
self._conf = self._clean_config(config_dict)
- # avoiding circular imports
- from .misc import read_config
- # teuthology.misc.read_config attaches the teuthology config
- # to a teuthology_config key.
- read_config(self)
+ set_config_attr(self)
def _clean_config(self, config_dict):
"""
return self._defaults[name]
raise AttributeError(name)
+ def __setattr__(self, name, value):
+ if name == 'teuthology_config':
+ object.__setattr__(self, name, value)
+ else:
+ super(FakeNamespace, self).__setattr__(name, value)
+
def __repr__(self):
return repr(self._conf)
return str(self._conf)
+def set_config_attr(obj):
+ """
+ Set obj.teuthology_config, mimicking the old behavior of misc.read_config
+ """
+ obj.teuthology_config = config
+
+
def _get_config_path():
system_config_path = '/etc/teuthology.yaml'
if not os.path.exists(TeuthologyConfig.yaml_path) and \
from . import misc
from . import provision
from .config import config
+from .config import set_config_attr
from .contextutil import safe_while
from .lockstatus import get_status
if ctx.verbose:
teuthology.log.setLevel(logging.DEBUG)
- misc.read_config(ctx)
+ set_config_attr(ctx)
ret = 0
user = ctx.owner
return getpass.getuser() + '@' + socket.gethostname()
-def read_config(ctx):
- """
- read the default teuthology yaml configuration file.
- """
- ctx.teuthology_config = {}
- filename = os.path.join(os.environ['HOME'], '.teuthology.yaml')
-
- if not os.path.exists(filename):
- log.debug("%s not found", filename)
- return
-
- with file(filename) as f:
- g = yaml.safe_load_all(f)
- for new in g:
- ctx.teuthology_config.update(new)
-
-
def get_mon_names(ctx):
"""
:returns: a list of monitor names
from teuthology.contextutil import safe_while
from teuthology.config import config as teuth_config
+from teuthology.config import set_config_attr
from teuthology.orchestra import connection
from teuthology import misc
Entry point implementing the teuthology-openstack command.
"""
self.setup_logs()
- misc.read_config(self.args)
+ set_config_attr(self.args)
self.key_filename = self.args.key_filename
self.verify_openstack()
ip = self.setup()
import scripts.lock
import scripts.suite
from teuthology.config import config as teuth_config
+from teuthology.config import set_config_attr
+
class Integration(object):
@classmethod
def setup_class(self):
teuthology.log.setLevel(logging.DEBUG)
- teuthology.misc.read_config(argparse.Namespace())
+ set_config_attr(argparse.Namespace())
self.teardown_class()
@classmethod
import teuthology
from teuthology import misc
+from teuthology.config import set_config_attr
from teuthology.openstack import TeuthologyOpenStack, OpenStack, OpenStackInstance
import scripts.openstack
pytest.skip('no OS_AUTH_URL environment variable')
teuthology.log.setLevel(logging.DEBUG)
- teuthology.misc.read_config(argparse.Namespace())
+ set_config_attr(argparse.Namespace())
ip = TeuthologyOpenStack.create_floating_ip()
if ip:
self.can_create_floating_ips = True
else:
self.can_create_floating_ips = False
-
+
def setup(self):
self.key_filename = tempfile.mktemp()
self.key_name = 'teuthology-test'
def test_config(self):
"""
Tests that a teuthology_config property is automatically added
- by misc.read_config.
+ to the conf_obj
"""
conf_obj = self.test_class(dict(foo="bar"))
assert conf_obj["foo"] == "bar"
assert conf_obj.foo == "bar"
- # teuthology_config needs to be a dict because all
- # of the tasks expect it to be
- assert isinstance(conf_obj.teuthology_config, dict)
+ assert conf_obj.teuthology_config.get("fake key") is None
def test_getattr(self):
conf_obj = self.test_class.from_dict({"foo": "bar"})
in_str = "foo: bar"
conf_obj = self.test_class.from_str(in_str)
assert conf_obj.to_str() == "{'foo': 'bar'}"
+
+ def test_multiple_access(self):
+ """
+ Test that config.config and FakeNamespace.teuthology_config reflect
+ each others' modifications
+ """
+ in_str = "foo: bar"
+ conf_obj = self.test_class.from_str(in_str)
+ assert config.config.get('test_key_1') is None
+ assert conf_obj.teuthology_config.get('test_key_1') is None
+ config.config.test_key_1 = 'test value'
+ assert conf_obj.teuthology_config['test_key_1'] == 'test value'
+
+ assert config.config.get('test_key_2') is None
+ assert conf_obj.teuthology_config.get('test_key_2') is None
+ conf_obj.teuthology_config['test_key_2'] = 'test value'
+ assert config.config['test_key_2'] == 'test value'
from . import report
from . import safepath
from .config import config as teuth_config
+from .config import set_config_attr
from .exceptions import BranchNotFoundError
from .kill import kill_job
-from .misc import read_config
from .repo_utils import fetch_qa_suite, fetch_teuthology
log = logging.getLogger(__name__)
else:
teuth_config.archive_base = ctx.archive_dir
- read_config(ctx)
+ set_config_attr(ctx)
connection = beanstalk.connect()
beanstalk.watch_tube(connection, ctx.tube)