46245fc43e433a59e3f6bcbb5434bbf4dfc1adab
[openstack-build/neutron-build.git] / neutron / agent / dhcp_agent.py
1 # Copyright 2015 OpenStack Foundation
2 #
3 # All Rights Reserved.
4 #
5 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
6 #    not use this file except in compliance with the License. You may obtain
7 #    a copy of the License at
8 #
9 #         http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #    Unless required by applicable law or agreed to in writing, software
12 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 #    License for the specific language governing permissions and limitations
15 #    under the License.
16
17 import sys
18
19 from oslo_config import cfg
20 from oslo_service import service
21
22 from neutron.agent.common import config
23 from neutron.agent.dhcp import config as dhcp_config
24 from neutron.agent.linux import interface
25 from neutron.agent.metadata import config as metadata_config
26 from neutron.common import config as common_config
27 from neutron.common import topics
28 from neutron import service as neutron_service
29
30
31 def register_options(conf):
32     config.register_interface_driver_opts_helper(conf)
33     config.register_agent_state_opts_helper(conf)
34     config.register_availability_zone_opts_helper(conf)
35     conf.register_opts(dhcp_config.DHCP_AGENT_OPTS)
36     conf.register_opts(dhcp_config.DHCP_OPTS)
37     conf.register_opts(dhcp_config.DNSMASQ_OPTS)
38     conf.register_opts(metadata_config.DRIVER_OPTS)
39     conf.register_opts(metadata_config.SHARED_OPTS)
40     conf.register_opts(interface.OPTS)
41
42
43 def main():
44     register_options(cfg.CONF)
45     common_config.init(sys.argv[1:])
46     config.setup_logging()
47     server = neutron_service.Service.create(
48         binary='neutron-dhcp-agent',
49         topic=topics.DHCP_AGENT,
50         report_interval=cfg.CONF.AGENT.report_interval,
51         manager='neutron.agent.dhcp.agent.DhcpAgentWithStateReport')
52     service.launch(cfg.CONF, server).wait()