1 # Copyright 2012 OpenStack Foundation
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
18 from oslo_config import cfg
20 from neutron._i18n import _
21 from neutron.common import config
25 cfg.StrOpt('root_helper', default='sudo',
26 help=_("Root helper application. "
27 "Use 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf' "
28 "to use the real root filter facility. Change to 'sudo' "
29 "to skip the filtering and just run the command "
31 cfg.BoolOpt('use_helper_for_ns_read',
33 help=_("Use the root helper when listing the namespaces on a "
34 "system. This may not be required depending on the "
35 "security configuration. If the root helper is "
36 "not required, set this to False for a performance "
38 # We can't just use root_helper=sudo neutron-rootwrap-daemon $cfg because
39 # it isn't appropriate for long-lived processes spawned with create_process
40 # Having a bool use_rootwrap_daemon option precludes specifying the
41 # rootwrap daemon command, which may be necessary for Xen?
42 cfg.StrOpt('root_helper_daemon',
43 help=_('Root helper daemon application to use when possible.')),
47 cfg.FloatOpt('report_interval', default=30,
48 help=_('Seconds between nodes reporting state to server; '
49 'should be less than agent_down_time, best if it '
50 'is half or less than agent_down_time.')),
51 cfg.BoolOpt('log_agent_heartbeats', default=False,
52 help=_('Log agent heartbeats')),
55 INTERFACE_DRIVER_OPTS = [
56 cfg.StrOpt('interface_driver',
57 help=_("The driver used to manage the virtual interface.")),
61 cfg.BoolOpt('comment_iptables_rules', default=True,
62 help=_("Add comments to iptables rules. "
63 "Set to false to disallow the addition of comments to "
64 "generated iptables rules that describe each rule's "
65 "purpose. System must support the iptables comments "
66 "module for addition of comments.")),
69 PROCESS_MONITOR_OPTS = [
70 cfg.StrOpt('check_child_processes_action', default='respawn',
71 choices=['respawn', 'exit'],
72 help=_('Action to be executed when a child process dies')),
73 cfg.IntOpt('check_child_processes_interval', default=60,
74 help=_('Interval between checks of child process liveness '
75 '(seconds), use 0 to disable')),
78 AVAILABILITY_ZONE_OPTS = [
79 # The default AZ name "nova" is selected to match the default
80 # AZ name in Nova and Cinder.
81 cfg.StrOpt('availability_zone', max_length=255, default='nova',
82 help=_("Availability zone of this node")),
85 EXT_NET_BRIDGE_OPTS = [
86 cfg.StrOpt('external_network_bridge', default='br-ex',
87 deprecated_for_removal=True,
88 help=_("Name of bridge used for external network "
89 "traffic. This should be set to an empty value for the "
90 "Linux Bridge. When this parameter is set, each L3 "
91 "agent can be associated with no more than one external "
92 "network. This option is deprecated and will be removed "
93 "in the M release.")),
97 def get_log_args(conf, log_file_name, **kwargs):
100 cmd_args.append('--debug')
102 cmd_args.append('--verbose')
103 if (conf.log_dir or conf.log_file):
104 cmd_args.append('--log-file=%s' % log_file_name)
106 if conf.log_dir and conf.log_file:
107 log_dir = os.path.dirname(
108 os.path.join(conf.log_dir, conf.log_file))
110 log_dir = conf.log_dir
112 log_dir = os.path.dirname(conf.log_file)
114 cmd_args.append('--log-dir=%s' % log_dir)
115 if kwargs.get('metadata_proxy_watch_log') is False:
116 cmd_args.append('--nometadata_proxy_watch_log')
119 cmd_args.append('--use-syslog')
120 if conf.syslog_log_facility:
122 '--syslog-log-facility=%s' % conf.syslog_log_facility)
126 def register_root_helper(conf):
127 conf.register_opts(ROOT_HELPER_OPTS, 'AGENT')
130 def register_agent_state_opts_helper(conf):
131 conf.register_opts(AGENT_STATE_OPTS, 'AGENT')
134 def register_interface_driver_opts_helper(conf):
135 conf.register_opts(INTERFACE_DRIVER_OPTS)
138 def register_iptables_opts(conf):
139 conf.register_opts(IPTABLES_OPTS, 'AGENT')
142 def register_process_monitor_opts(conf):
143 conf.register_opts(PROCESS_MONITOR_OPTS, 'AGENT')
146 def register_availability_zone_opts_helper(conf):
147 conf.register_opts(AVAILABILITY_ZONE_OPTS, 'AGENT')
150 def get_root_helper(conf):
151 return conf.AGENT.root_helper
156 cfg.StrOpt('state_path',
157 default='/var/lib/neutron',
158 help=_("Where to store Neutron state files. "
159 "This directory must be writable by the agent.")),
162 conf = cfg.ConfigOpts()
163 conf.register_opts(bind_opts)
166 # add a logging setup method here for convenience
167 setup_logging = config.setup_logging