本文整理汇总了Python中monasca_common.simport.simport.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_good_load_local
def test_good_load_local(self):
method = simport.load(PWD + "|localmodule:Foo.method_a")
import localmodule
self.assertEqual(method, localmodule.Foo.method_a)
self.assertEqual(localmodule.function_a,
simport.load("localmodule:function_a"))
开发者ID:openstack,项目名称:monasca-common,代码行数:7,代码来源:test_simport.py
示例2: __init__
def __init__(self):
super(Alarming, self).__init__()
self.events_message_queue = simport.load(
cfg.CONF.messaging.driver)('events')
self.alarm_state_transitions_message_queue = simport.load(
cfg.CONF.messaging.driver)('alarm-state-transitions')
开发者ID:artur-ba,项目名称:monasca-api,代码行数:9,代码来源:alarming.py
示例3: __init__
def __init__(self):
super(Alarming, self).__init__()
self.events_message_queue = simport.load(
cfg.CONF.messaging.driver)(cfg.CONF.kafka.events_topic)
self.alarm_state_transitions_message_queue = simport.load(
cfg.CONF.messaging.driver)(cfg.CONF.kafka.alarm_state_transitions_topic)
开发者ID:jgrassler,项目名称:monasca-api,代码行数:9,代码来源:alarming.py
示例4: __init__
def __init__(self):
super(Notifications, self).__init__()
self._region = cfg.CONF.region
self._notifications_repo = simport.load(
cfg.CONF.repositories.notifications_driver)()
self._notification_method_type_repo = simport.load(
cfg.CONF.repositories.notification_method_type_driver)()
self.valid_periods = cfg.CONF.valid_notification_periods
开发者ID:openstack,项目名称:monasca-api,代码行数:10,代码来源:notifications.py
示例5: main
def main():
log.register_options(cfg.CONF)
log.set_defaults()
cfg.CONF(sys.argv[1:], project='monasca', prog='persister')
log.setup(cfg.CONF, "monasca-persister")
"""Start persister."""
metric_repository = simport.load(cfg.CONF.repositories.metrics_driver)
alarm_state_history_repository = simport.load(cfg.CONF.repositories.alarm_state_history_driver)
# Add processors for metrics topic
for proc in range(0, cfg.CONF.kafka_metrics.num_processors):
processors.append(multiprocessing.Process(
target=start_process, args=(metric_repository, cfg.CONF.kafka_metrics)))
# Add processors for alarm history topic
for proc in range(0, cfg.CONF.kafka_alarm_history.num_processors):
processors.append(multiprocessing.Process(
target=start_process, args=(alarm_state_history_repository, cfg.CONF.kafka_alarm_history)))
# Start
try:
LOG.info('''
_____
/ \ ____ ____ _____ ______ ____ _____
/ \ / \ / _ \ / \\\__ \ / ___// ___\\\__ \\
/ Y ( <_> ) | \/ __ \_\___ \\ \___ / __ \\_
\____|__ /\____/|___| (____ /____ >\___ >____ /
\/ \/ \/ \/ \/ \/
__________ .__ __
\______ \ ___________ _____|__| _______/ |_ ___________
| ___// __ \_ __ \/ ___/ |/ ___/\ __\/ __ \_ __ \\
| | \ ___/| | \/\___ \| |\___ \ | | \ ___/| | \/
|____| \___ >__| /____ >__/____ > |__| \___ >__|
\/ \/ \/ \/
''')
for process in processors:
process.start()
# The signal handlers must be added after the processes start otherwise
# they run on all processes
signal.signal(signal.SIGCHLD, clean_exit)
signal.signal(signal.SIGINT, clean_exit)
signal.signal(signal.SIGTERM, clean_exit)
while True:
time.sleep(10)
except Exception:
LOG.exception('Error! Exiting.')
clean_exit(signal.SIGKILL)
开发者ID:sapcc,项目名称:monasca-persister,代码行数:54,代码来源:persister.py
示例6: __init__
def __init__(self):
super(Notifications, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = cfg.CONF.security.default_authorized_roles
self._get_notifications_authorized_roles = (
cfg.CONF.security.default_authorized_roles + cfg.CONF.security.read_only_authorized_roles
)
self._notifications_repo = simport.load(cfg.CONF.repositories.notifications_driver)()
self._notification_method_type_repo = simport.load(cfg.CONF.repositories.notification_method_type_driver)()
self.valid_periods = cfg.CONF.valid_notification_periods
开发者ID:sapcc,项目名称:monasca-api,代码行数:12,代码来源:notifications.py
示例7: __init__
def __init__(self):
try:
super(AlarmsStateHistory, self).__init__()
self._region = cfg.CONF.region
self._alarms_repo = simport.load(
cfg.CONF.repositories.alarms_driver)()
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
开发者ID:openstack,项目名称:monasca-api,代码行数:12,代码来源:alarms.py
示例8: __init__
def __init__(self):
try:
super(AlarmsStateHistory, self).__init__()
self._region = cfg.CONF.region
self._get_alarms_authorized_roles = (
cfg.CONF.security.default_authorized_roles + cfg.CONF.security.read_only_authorized_roles
)
self._alarms_repo = simport.load(cfg.CONF.repositories.alarms_driver)()
self._metrics_repo = simport.load(cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
开发者ID:sapcc,项目名称:monasca-api,代码行数:13,代码来源:alarms.py
示例9: __init__
def __init__(self):
try:
self._metrics_repo = simport.load(
CONF.repositories.metrics_driver)
except Exception as ex:
LOG.exception(ex)
raise
开发者ID:jgrassler,项目名称:monasca-api,代码行数:8,代码来源:metrics_db_check.py
示例10: prepare_processes
def prepare_processes(conf, repo_driver):
if conf.num_processors > 0:
repository = simport.load(repo_driver)
for proc in range(0, conf.num_processors):
processors.append(multiprocessing.Process(
target=start_process, args=(repository, conf)))
else:
LOG.warning("Number of processors (num_processors) is {}".format(
conf.num_processors))
开发者ID:openstack,项目名称:monasca-persister,代码行数:9,代码来源:persister.py
示例11: __init__
def __init__(self):
try:
super(AlarmDefinitions, self).__init__()
self._region = cfg.CONF.region
self._alarm_definitions_repo = simport.load(
cfg.CONF.repositories.alarm_definitions_driver)()
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
开发者ID:openstack,项目名称:monasca-api,代码行数:10,代码来源:alarm_definitions.py
示例12: test_good_load_external
def test_good_load_external(self):
method = simport.load("tests/external|" "external.externalmodule:Blah.method_b")
self.assertTrue("external.externalmodule" in sys.modules)
old = sys.modules["external.externalmodule"]
import external.externalmodule
self.assertEqual(external.externalmodule, sys.modules["external.externalmodule"])
self.assertEqual(old, external.externalmodule)
self.assertEqual(method, external.externalmodule.Blah.method_b)
开发者ID:sapcc,项目名称:monasca-common,代码行数:10,代码来源:test_simport.py
示例13: __init__
def __init__(self):
try:
super(Metrics, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._delegate_authorized_roles = (
cfg.CONF.security.delegate_authorized_roles)
self._post_metrics_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.agent_authorized_roles)
self._message_queue = simport.load(cfg.CONF.messaging.driver)(
'metrics')
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise falcon.HTTPInternalServerError('Service unavailable',
ex.message)
开发者ID:bigluster,项目名称:monasca-api,代码行数:20,代码来源:metrics.py
示例14: test_good_load_external
def test_good_load_external(self):
method = simport.load(PWD + "/external|external.externalmodule:Blah.method_b")
self.assertTrue('external.externalmodule' in sys.modules)
old = sys.modules['external.externalmodule']
import external.externalmodule
self.assertEqual(external.externalmodule,
sys.modules['external.externalmodule'])
self.assertEqual(old, external.externalmodule)
self.assertEqual(method, external.externalmodule.Blah.method_b)
开发者ID:openstack,项目名称:monasca-common,代码行数:12,代码来源:test_simport.py
示例15: __init__
def __init__(self):
try:
super(AlarmsCount, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._alarms_repo = simport.load(
cfg.CONF.repositories.alarms_driver)()
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
开发者ID:bigluster,项目名称:monasca-api,代码行数:12,代码来源:alarms.py
示例16: __init__
def __init__(self):
try:
super(DimensionNames, self).__init__()
self._region = cfg.CONF.region
self._get_metrics_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.read_only_authorized_roles)
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise falcon.HTTPInternalServerError('Service unavailable',
ex.message)
开发者ID:sapcc,项目名称:monasca-api,代码行数:14,代码来源:metrics.py
示例17: get_kafka_stream
def get_kafka_stream(topic, streaming_context):
offset_specifications = simport.load(cfg.CONF.repositories.offsets)()
app_name = streaming_context.sparkContext.appName
saved_offset_spec = offset_specifications.get_kafka_offsets(app_name)
if len(saved_offset_spec) < 1:
MonMetricsKafkaProcessor.log_debug(
"No saved offsets available..."
"connecting to kafka without specifying offsets")
kvs = KafkaUtils.createDirectStream(
streaming_context, [topic],
{"metadata.broker.list": cfg.CONF.messaging.brokers})
return kvs
else:
from_offsets = {}
for key, value in saved_offset_spec.items():
if key.startswith("%s_%s" % (app_name, topic)):
# spec_app_name = value.get_app_name()
spec_topic = value.get_topic()
spec_partition = int(value.get_partition())
# spec_from_offset = value.get_from_offset()
spec_until_offset = value.get_until_offset()
# composite_key = "%s_%s_%s" % (spec_app_name,
# spec_topic,
# spec_partition)
# partition = saved_offset_spec[composite_key]
from_offsets[
TopicAndPartition(spec_topic, spec_partition)
] = int(spec_until_offset)
MonMetricsKafkaProcessor.log_debug(
"get_kafka_stream: calling createDirectStream :"
" topic:{%s} : start " % topic)
for key, value in from_offsets.items():
MonMetricsKafkaProcessor.log_debug(
"get_kafka_stream: calling createDirectStream : "
"offsets : TopicAndPartition:{%s,%s}, value:{%s}" %
(str(key._topic), str(key._partition), str(value)))
MonMetricsKafkaProcessor.log_debug(
"get_kafka_stream: calling createDirectStream : "
"topic:{%s} : done" % topic)
kvs = KafkaUtils.createDirectStream(
streaming_context, [topic],
{"metadata.broker.list": cfg.CONF.messaging.brokers},
from_offsets)
return kvs
开发者ID:openstack,项目名称:monasca-transform,代码行数:49,代码来源:mon_metrics_kafka.py
示例18: save_kafka_offsets
def save_kafka_offsets(current_offsets, app_name,
batch_time_info):
"""save current offsets to offset specification."""
offset_specs = simport.load(cfg.CONF.repositories.offsets)()
for o in current_offsets:
MonMetricsKafkaProcessor.log_debug(
"saving: OffSetRanges: %s %s %s %s, "
"batch_time_info: %s" % (
o.topic, o.partition, o.fromOffset, o.untilOffset,
str(batch_time_info)))
# add new offsets, update revision
offset_specs.add_all_offsets(app_name,
current_offsets,
batch_time_info)
开发者ID:openstack,项目名称:monasca-transform,代码行数:16,代码来源:mon_metrics_kafka.py
示例19: __init__
def __init__(self):
try:
super(MetricsMeasurements, self).__init__()
self._region = cfg.CONF.region
self._delegate_authorized_roles = (
cfg.CONF.security.delegate_authorized_roles)
self._get_metrics_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.read_only_authorized_roles)
self._post_metrics_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.agent_authorized_roles)
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise falcon.HTTPInternalServerError('Service unavailable',
str(ex))
开发者ID:jgrassler,项目名称:monasca-api,代码行数:19,代码来源:metrics.py
示例20: get_data_provider
def get_data_provider():
if not PreHourlyProcessorUtil.data_provider:
PreHourlyProcessorUtil.data_provider = simport.load(
cfg.CONF.pre_hourly_processor.data_provider)()
return PreHourlyProcessorUtil.data_provider
开发者ID:openstack,项目名称:monasca-transform,代码行数:5,代码来源:processor_util.py
注:本文中的monasca_common.simport.simport.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论