2014-04-09 14:31:31 -07:00
|
|
|
# Copyright 2013 Rackspace, Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2013-09-23 23:29:55 -07:00
|
|
|
|
2015-08-20 10:54:55 -07:00
|
|
|
import sys
|
|
|
|
|
2015-02-07 14:08:23 +08:00
|
|
|
from oslo_config import cfg
|
2015-03-09 23:48:47 +01:00
|
|
|
from oslo_log import log
|
2014-01-06 12:56:27 -08:00
|
|
|
|
2014-03-19 16:19:52 -07:00
|
|
|
from ironic_python_agent import agent
|
2015-07-24 17:23:33 +02:00
|
|
|
from ironic_python_agent import inspector
|
2014-08-19 11:29:59 +05:30
|
|
|
from ironic_python_agent import utils
|
2014-03-31 15:02:13 -07:00
|
|
|
|
2014-05-28 23:11:47 -07:00
|
|
|
CONF = cfg.CONF
|
2014-03-31 15:02:13 -07:00
|
|
|
|
|
|
|
|
2015-03-09 12:23:12 +00:00
|
|
|
APARAMS = utils.get_agent_params()
|
2014-05-28 23:11:47 -07:00
|
|
|
|
|
|
|
cli_opts = [
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.StrOpt('api_url',
|
2015-10-02 10:01:00 -07:00
|
|
|
default=APARAMS.get('ipa-api-url', 'http://127.0.0.1:6385'),
|
|
|
|
deprecated_name='api-url',
|
|
|
|
help='URL of the Ironic API'),
|
2014-05-28 23:11:47 -07:00
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.StrOpt('listen_host',
|
2015-10-02 10:01:00 -07:00
|
|
|
default=APARAMS.get('ipa-listen-host', '0.0.0.0'),
|
|
|
|
deprecated_name='listen-host',
|
|
|
|
help='The IP address to listen on.'),
|
2014-05-28 23:11:47 -07:00
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('listen_port',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-listen-port', 9999)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='listen-port',
|
2014-05-28 23:11:47 -07:00
|
|
|
help='The port to listen on'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.StrOpt('advertise_host',
|
2015-10-02 10:01:00 -07:00
|
|
|
default=APARAMS.get('ipa-advertise-host', None),
|
|
|
|
deprecated_name='advertise_host',
|
|
|
|
help='The host to tell Ironic to reply and send '
|
|
|
|
'commands to.'),
|
2014-05-28 23:11:47 -07:00
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('advertise_port',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-advertise-port', 9999)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='advertise-port',
|
2014-05-28 23:11:47 -07:00
|
|
|
help='The port to tell Ironic to reply and send '
|
|
|
|
'commands to.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('ip_lookup_attempts',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-ip-lookup-attempts', 3)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='ip-lookup-attempts',
|
2014-05-30 23:55:34 +00:00
|
|
|
help='The number of times to try and automatically'
|
|
|
|
'determine the agent IPv4 address.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('ip_lookup_sleep',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-ip-lookup-timeout', 10)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='ip-lookup-sleep',
|
2014-05-30 23:55:34 +00:00
|
|
|
help='The amaount of time to sleep between attempts'
|
|
|
|
'to determine IP address.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.StrOpt('network_interface',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=APARAMS.get('ipa-network-interface', None),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='network-interface',
|
2014-05-30 23:55:34 +00:00
|
|
|
help='The interface to use when looking for an IP'
|
|
|
|
'address.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('lookup_timeout',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-lookup-timeout', 300)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='lookup-timeout',
|
2014-05-28 23:11:47 -07:00
|
|
|
help='The amount of time to retry the initial lookup '
|
|
|
|
'call to Ironic. After the timeout, the agent '
|
|
|
|
'will exit with a non-zero exit code.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.IntOpt('lookup_interval',
|
2014-12-04 23:38:06 +00:00
|
|
|
default=int(APARAMS.get('ipa-lookup-timeout', 1)),
|
2014-10-29 12:28:59 +08:00
|
|
|
deprecated_name='lookup-interval',
|
2014-05-28 23:11:47 -07:00
|
|
|
help='The initial interval for retries on the initial '
|
|
|
|
'lookup call to Ironic. The interval will be '
|
|
|
|
'doubled after each failure until timeout is '
|
|
|
|
'exceeded.'),
|
|
|
|
|
2014-10-29 12:28:59 +08:00
|
|
|
cfg.StrOpt('driver_name',
|
2015-10-02 10:01:00 -07:00
|
|
|
default=APARAMS.get('ipa-driver-name', 'agent_ipmitool'),
|
|
|
|
deprecated_name='driver-name',
|
|
|
|
help='The Ironic driver in use for this node'),
|
2014-05-07 09:28:19 -07:00
|
|
|
|
|
|
|
cfg.FloatOpt('lldp_timeout',
|
|
|
|
default=APARAMS.get('lldp-timeout', 30.0),
|
2014-12-15 17:29:14 -08:00
|
|
|
help='The amount of seconds to wait for LLDP packets.'),
|
|
|
|
|
|
|
|
cfg.BoolOpt('standalone',
|
2015-02-27 14:25:13 -06:00
|
|
|
default=APARAMS.get('ipa-standalone', False),
|
2014-12-15 17:29:14 -08:00
|
|
|
help='Note: for debugging only. Start the Agent but suppress '
|
|
|
|
'any calls to Ironic API.'),
|
2015-07-24 17:23:33 +02:00
|
|
|
|
|
|
|
cfg.StrOpt('inspection_callback_url',
|
|
|
|
default=APARAMS.get('ipa-inspection-callback-url'),
|
|
|
|
help='Endpoint of ironic-inspector. If set, hardware inventory '
|
|
|
|
'will be collected and sent to ironic-inspector '
|
|
|
|
'on start up.'),
|
|
|
|
|
|
|
|
cfg.StrOpt('inspection_collectors',
|
|
|
|
default=APARAMS.get('ipa-inspection-collectors',
|
|
|
|
inspector.DEFAULT_COLLECTOR),
|
|
|
|
help='Comma-separated list of plugins providing additional '
|
|
|
|
'hardware data for inspection, empty value gives '
|
|
|
|
'a minimum required set of plugins.'),
|
2014-05-28 23:11:47 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
CONF.register_cli_opts(cli_opts)
|
|
|
|
|
2013-09-23 23:29:55 -07:00
|
|
|
|
2013-12-16 15:38:02 -08:00
|
|
|
def run():
|
2015-09-03 16:15:54 -07:00
|
|
|
"""Entrypoint for IronicPythonAgent."""
|
2015-03-09 23:48:47 +01:00
|
|
|
log.register_options(CONF)
|
2015-08-20 10:54:55 -07:00
|
|
|
CONF(args=sys.argv[1:])
|
2015-03-09 23:48:47 +01:00
|
|
|
log.setup(CONF, 'ironic-python-agent')
|
2014-05-28 23:11:47 -07:00
|
|
|
agent.IronicPythonAgent(CONF.api_url,
|
|
|
|
(CONF.advertise_host, CONF.advertise_port),
|
|
|
|
(CONF.listen_host, CONF.listen_port),
|
2014-05-30 23:55:34 +00:00
|
|
|
CONF.ip_lookup_attempts,
|
|
|
|
CONF.ip_lookup_sleep,
|
|
|
|
CONF.network_interface,
|
2014-05-28 23:11:47 -07:00
|
|
|
CONF.lookup_timeout,
|
|
|
|
CONF.lookup_interval,
|
2014-12-15 17:29:14 -08:00
|
|
|
CONF.driver_name,
|
|
|
|
CONF.standalone).run()
|