|
1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
3
|
|
|
# this work for additional information regarding copyright ownership. |
|
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
6
|
|
|
# the License. You may obtain a copy of the License at |
|
7
|
|
|
# |
|
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
9
|
|
|
# |
|
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13
|
|
|
# See the License for the specific language governing permissions and |
|
14
|
|
|
# limitations under the License. |
|
15
|
|
|
|
|
16
|
|
|
from oslo_config import cfg, types |
|
17
|
|
|
|
|
18
|
|
|
from st2common import config as st2cfg |
|
19
|
|
|
from st2common.constants.sensors import DEFAULT_PARTITION_LOADER |
|
20
|
|
|
from st2common.constants.system import VERSION_STRING |
|
21
|
|
|
|
|
22
|
|
|
CONF = cfg.CONF |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
def parse_args(args=None): |
|
26
|
|
|
CONF(args=args, version=VERSION_STRING) |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
def register_opts(ignore_errors=False): |
|
30
|
|
|
_register_common_opts(ignore_errors=ignore_errors) |
|
31
|
|
|
_register_sensor_container_opts(ignore_errors=ignore_errors) |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
def get_logging_config_path(): |
|
35
|
|
|
return cfg.CONF.sensorcontainer.logging |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
def _register_common_opts(ignore_errors=False): |
|
39
|
|
|
st2cfg.register_opts(ignore_errors=ignore_errors) |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
def _register_sensor_container_opts(ignore_errors=False): |
|
43
|
|
|
logging_opts = [ |
|
44
|
|
|
cfg.StrOpt('logging', default='conf/logging.sensorcontainer.conf', |
|
45
|
|
|
help='location of the logging.conf file') |
|
46
|
|
|
] |
|
47
|
|
|
st2cfg.do_register_opts(logging_opts, group='sensorcontainer', ignore_errors=ignore_errors) |
|
48
|
|
|
|
|
49
|
|
|
partition_opts = [ |
|
50
|
|
|
cfg.StrOpt('sensor_node_name', default='sensornode1', |
|
51
|
|
|
help='name of the sensor node.'), |
|
52
|
|
|
cfg.Opt('partition_provider', type=types.Dict(value_type=types.String()), |
|
53
|
|
|
default={'name': DEFAULT_PARTITION_LOADER}, |
|
54
|
|
|
help='Provider of sensor node partition config.') |
|
55
|
|
|
] |
|
56
|
|
|
st2cfg.do_register_opts(partition_opts, group='sensorcontainer', ignore_errors=ignore_errors) |
|
57
|
|
|
|
|
58
|
|
|
sensor_test_opt = cfg.StrOpt('sensor-ref', help='Only run sensor with the provided reference. \ |
|
59
|
|
|
Value is of the form pack.sensor-name.') |
|
60
|
|
|
st2cfg.do_register_cli_opts(sensor_test_opt, ignore_errors=ignore_errors) |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
register_opts(ignore_errors=True) |
|
64
|
|
|
|