# Copyright (c) 2013 Rackspace, 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 ConfigParser import os import uuid class Config(object): def __init__(self, config_path=None): if config_path is None: if os.path.exists('/etc/marconi/functional-tests.conf'): config_path = '/etc/marconi/functional-tests.conf' else: config_path = os.path.expanduser('~/.marconi' '/functional-tests.conf') self.parser = ConfigParser.SafeConfigParser() self.parser.read(config_path) @property def auth_enabled(self): return self.parser.getboolean('auth', 'auth_on') @property def username(self): return self.parser.get('auth', 'username') @property def password(self): return self.parser.get('auth', 'password') @property def auth_url(self): return self.parser.get('auth', 'url') @property def base_server(self): return self.parser.get('marconi_env', 'marconi_url') @property def marconi_version(self): return self.parser.get('marconi_env', 'marconi_version') @property def base_url(self): return (self.base_server + '/' + self.marconi_version) @property def uuid(self): return str(uuid.uuid1()) @property def user_agent(self): return self.parser.get('header_values', 'useragent') @property def host(self): return self.parser.get('header_values', 'host') @property def project_id(self): return self.parser.get('header_values', 'project_id') @property def queue_paging_uplimit(self): return int(self.parser.get('marconi_config', 'queue_paging_uplimit')) @property def message_paging_uplimit(self): return int(self.parser.get('marconi_config', 'message_paging_uplimit')) @property def message_ttl_max(self): return int(self.parser.get('marconi_config', 'message_ttl_max')) @property def claim_ttl_max(self): return int(self.parser.get('marconi_config', 'claim_ttl_max')) @property def claim_grace_max(self): return int(self.parser.get('marconi_config', 'claim_grace_max')) @property def metadata_size_uplimit(self): return self.parser.get('marconi_config', 'metadata_size_uplimit') @property def message_size_uplimit(self): return self.parser.get('marconi_config', 'message_size_uplimit')