Path bug fixes for harness
There was some inconsistency between different components' semantics for one of the path config variables. One thought it was pointing to congress/congress and the other thought it was pointing to congress. This change eliminates that inconsistency. Change-Id: Ib06843d9d17be83bc7cde88e57453a4e8dd78b70
This commit is contained in:
parent
a084ec3996
commit
e701b9d382
@ -40,6 +40,8 @@ core_opts = [
|
|||||||
help="The path to the latest policy dump"),
|
help="The path to the latest policy dump"),
|
||||||
cfg.StrOpt('datasource_file', default=None,
|
cfg.StrOpt('datasource_file', default=None,
|
||||||
help="The file containing datasource configuration"),
|
help="The file containing datasource configuration"),
|
||||||
|
cfg.StrOpt('root_path', default=None,
|
||||||
|
help="The absolute path to the congress repo"),
|
||||||
cfg.IntOpt('api_workers', default=1,
|
cfg.IntOpt('api_workers', default=1,
|
||||||
help='The number of worker processes to serve the congress '
|
help='The number of worker processes to serve the congress '
|
||||||
'API application.'),
|
'API application.'),
|
||||||
|
@ -48,15 +48,18 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
# read in datasource configurations
|
# read in datasource configurations
|
||||||
cage.config = initialize_config(config_file, config_override)
|
cage.config = initialize_config(config_file, config_override)
|
||||||
|
|
||||||
|
# path to congress source dir
|
||||||
|
src_path = os.path.join(rootdir, "congress")
|
||||||
|
|
||||||
# add policy engine
|
# add policy engine
|
||||||
engine_path = os.path.join(rootdir, "policy/dsepolicy.py")
|
engine_path = os.path.join(src_path, "policy/dsepolicy.py")
|
||||||
LOG.info("main::start() engine_path: " + str(engine_path))
|
LOG.info("main::start() engine_path: " + str(engine_path))
|
||||||
cage.loadModule("PolicyEngine", engine_path)
|
cage.loadModule("PolicyEngine", engine_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
name="engine",
|
name="engine",
|
||||||
moduleName="PolicyEngine",
|
moduleName="PolicyEngine",
|
||||||
description="Policy Engine (DseRuntime instance)",
|
description="Policy Engine (DseRuntime instance)",
|
||||||
args={'d6cage': cage, 'rootdir': rootdir})
|
args={'d6cage': cage, 'rootdir': src_path})
|
||||||
engine = cage.service_object('engine')
|
engine = cage.service_object('engine')
|
||||||
if statedir is not None:
|
if statedir is not None:
|
||||||
engine.load_dir(statedir)
|
engine.load_dir(statedir)
|
||||||
@ -66,7 +69,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
|
|
||||||
# add policy api
|
# add policy api
|
||||||
# TODO(thinrichs): change to real API path.
|
# TODO(thinrichs): change to real API path.
|
||||||
api_path = os.path.join(rootdir, "api/policy_model.py")
|
api_path = os.path.join(src_path, "api/policy_model.py")
|
||||||
LOG.info("main::start() api_path: " + str(api_path))
|
LOG.info("main::start() api_path: " + str(api_path))
|
||||||
cage.loadModule("API-policy", api_path)
|
cage.loadModule("API-policy", api_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
@ -77,7 +80,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
cage.system_service_names.add('api-policy')
|
cage.system_service_names.add('api-policy')
|
||||||
|
|
||||||
# add rule api
|
# add rule api
|
||||||
api_path = os.path.join(rootdir, "api/rule_model.py")
|
api_path = os.path.join(src_path, "api/rule_model.py")
|
||||||
LOG.info("main::start() api_path: " + str(api_path))
|
LOG.info("main::start() api_path: " + str(api_path))
|
||||||
cage.loadModule("API-rule", api_path)
|
cage.loadModule("API-rule", api_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
@ -88,7 +91,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
cage.system_service_names.add('api-rule')
|
cage.system_service_names.add('api-rule')
|
||||||
|
|
||||||
# add table api
|
# add table api
|
||||||
api_path = os.path.join(rootdir, "api/table_model.py")
|
api_path = os.path.join(src_path, "api/table_model.py")
|
||||||
LOG.info("main::start() api_path: " + str(api_path))
|
LOG.info("main::start() api_path: " + str(api_path))
|
||||||
cage.loadModule("API-table", api_path)
|
cage.loadModule("API-table", api_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
@ -99,7 +102,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
cage.system_service_names.add('api-table')
|
cage.system_service_names.add('api-table')
|
||||||
|
|
||||||
# add row api
|
# add row api
|
||||||
api_path = os.path.join(rootdir, "api/row_model.py")
|
api_path = os.path.join(src_path, "api/row_model.py")
|
||||||
LOG.info("main::start() api_path: " + str(api_path))
|
LOG.info("main::start() api_path: " + str(api_path))
|
||||||
cage.loadModule("API-row", api_path)
|
cage.loadModule("API-row", api_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
@ -110,7 +113,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
cage.system_service_names.add('api-row')
|
cage.system_service_names.add('api-row')
|
||||||
|
|
||||||
# add datasource api
|
# add datasource api
|
||||||
api_path = os.path.join(rootdir, "api/datasource_model.py")
|
api_path = os.path.join(src_path, "api/datasource_model.py")
|
||||||
LOG.info("main::start() api_path: " + str(api_path))
|
LOG.info("main::start() api_path: " + str(api_path))
|
||||||
cage.loadModule("API-datasource", api_path)
|
cage.loadModule("API-datasource", api_path)
|
||||||
cage.createservice(
|
cage.createservice(
|
||||||
@ -133,7 +136,7 @@ def create(rootdir, statedir, config_file, config_override=None):
|
|||||||
if cage.config:
|
if cage.config:
|
||||||
for name in cage.config:
|
for name in cage.config:
|
||||||
if 'module' in cage.config[name]:
|
if 'module' in cage.config[name]:
|
||||||
load_data_service(name, cage.config[name], cage, rootdir)
|
load_data_service(name, cage.config[name], cage, src_path)
|
||||||
return cage
|
return cage
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,18 +42,18 @@ def fail_gracefully(f):
|
|||||||
|
|
||||||
@fail_gracefully
|
@fail_gracefully
|
||||||
def congress_app_factory(global_conf, **local_conf):
|
def congress_app_factory(global_conf, **local_conf):
|
||||||
fpath = os.path.dirname(__file__) # drop filename
|
root_path = cfg.CONF.root_path
|
||||||
src_path = os.path.dirname(fpath) # drop to congress src dir
|
if root_path is None:
|
||||||
|
root_path = os.path.dirname(__file__) # drop filename
|
||||||
|
root_path = os.path.dirname(root_path) # drop to congress src dir
|
||||||
policy_path = cfg.CONF.policy_path
|
policy_path = cfg.CONF.policy_path
|
||||||
if policy_path is None:
|
if policy_path is None:
|
||||||
policy_path = os.path.dirname(src_path)
|
policy_path = os.path.join(root_path, 'etc', 'snapshot')
|
||||||
policy_path = os.path.join(policy_path, 'etc', 'snapshot')
|
|
||||||
data_path = cfg.CONF.datasource_file
|
data_path = cfg.CONF.datasource_file
|
||||||
if data_path is None:
|
if data_path is None:
|
||||||
data_path = os.path.dirname(src_path)
|
data_path = os.path.join(root_path, 'etc', 'datasources.conf')
|
||||||
data_path = os.path.join(data_path, 'etc', 'datasources.conf')
|
|
||||||
|
|
||||||
cage = harness.create(src_path, policy_path, data_path)
|
cage = harness.create(root_path, policy_path, data_path)
|
||||||
|
|
||||||
api_resource_mgr = application.ResourceManager()
|
api_resource_mgr = application.ResourceManager()
|
||||||
congress_server.initialize_resources(api_resource_mgr, cage)
|
congress_server.initialize_resources(api_resource_mgr, cage)
|
||||||
|
@ -25,6 +25,15 @@ from congress.policy import runtime
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def root_path():
|
||||||
|
"""Return path to root of source code."""
|
||||||
|
x = os.path.realpath(__file__)
|
||||||
|
x, y = os.path.split(x) # drop "helper.py"
|
||||||
|
x, y = os.path.split(x) # drop "tests"
|
||||||
|
x, y = os.path.split(x) # drop "congress"
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
def source_path():
|
def source_path():
|
||||||
"""Return path to root of source code."""
|
"""Return path to root of source code."""
|
||||||
x = os.path.realpath(__file__)
|
x = os.path.realpath(__file__)
|
||||||
|
@ -107,7 +107,7 @@ class TestCongress(base.TestCase):
|
|||||||
override['neutron2'] = {'client': neutron_mock2, 'poll_time': 0}
|
override['neutron2'] = {'client': neutron_mock2, 'poll_time': 0}
|
||||||
override['nova'] = {'poll_time': 0}
|
override['nova'] = {'poll_time': 0}
|
||||||
|
|
||||||
cage = harness.create(helper.source_path(), self.state_path(),
|
cage = harness.create(helper.root_path(), self.state_path(),
|
||||||
helper.datasource_config_path(), override)
|
helper.datasource_config_path(), override)
|
||||||
engine = cage.service_object('engine')
|
engine = cage.service_object('engine')
|
||||||
api = {'policy': cage.service_object('api-policy'),
|
api = {'policy': cage.service_object('api-policy'),
|
||||||
|
@ -6,3 +6,11 @@ password: password
|
|||||||
auth_url: http://127.0.0.1:5000/v2.0
|
auth_url: http://127.0.0.1:5000/v2.0
|
||||||
tenant_name: demo
|
tenant_name: demo
|
||||||
|
|
||||||
|
[nova]
|
||||||
|
module: datasources/nova_driver.py
|
||||||
|
username: demo
|
||||||
|
password: password
|
||||||
|
auth_url: http://127.0.0.1:5000/v2.0
|
||||||
|
tenant_name: demo
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user