Make polling interval configurable
Also cleanup in agent code and in config template Change-Id: I5ad6867336421bbb0e2e8d97de865bf42d2ef774
This commit is contained in:
parent
e28c94fea2
commit
bfa290680c
@ -91,9 +91,8 @@
|
||||
# env[SHAKER_SERVER_ENDPOINT]. (string value)
|
||||
#server_endpoint = <None>
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
# How frequently the agent polls server, in seconds (integer value)
|
||||
#polling_interval = 10
|
||||
|
||||
# Authentication URL, defaults to env[OS_AUTH_URL]. (string value)
|
||||
#os_auth_url =
|
||||
@ -123,10 +122,6 @@
|
||||
# value)
|
||||
#flavor_name = shaker-flavor
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
|
||||
# Scenario file name, defaults to env[SHAKER_SCENARIO]. (string value)
|
||||
#scenario = <None>
|
||||
|
||||
@ -134,10 +129,6 @@
|
||||
# value)
|
||||
#output = <None>
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
|
||||
# Report template in Jinja format (string value)
|
||||
#report_template = shaker/resources/report_template.jinja2
|
||||
|
||||
@ -145,23 +136,11 @@
|
||||
# report is printed to stdout. (string value)
|
||||
#report = <None>
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
|
||||
# File to read test results from, defaults to env[SHAKER_INPUT]. (string value)
|
||||
#input = <None>
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
|
||||
# Agent unique id, defaults to env[SHAKER_AGENT_ID]. (string value)
|
||||
#agent_id = <None>
|
||||
|
||||
#
|
||||
# From shaker.engine.config
|
||||
#
|
||||
|
||||
# Heat template for the image builder. (string value)
|
||||
#image_builder_template = shaker/resources/image_builder_template.yaml
|
||||
|
@ -19,9 +19,11 @@ import time
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import sys
|
||||
import zmq
|
||||
|
||||
from shaker.engine import config
|
||||
from shaker.engine import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -54,29 +56,12 @@ def send_reply(socket, agent_id, result):
|
||||
|
||||
|
||||
def main():
|
||||
# init conf and logging
|
||||
conf = cfg.CONF
|
||||
conf.register_cli_opts(config.COMMON_OPTS)
|
||||
conf.register_cli_opts(config.AGENT_OPTS)
|
||||
conf.register_opts(config.COMMON_OPTS)
|
||||
conf.register_opts(config.AGENT_OPTS)
|
||||
logging.register_options(conf)
|
||||
logging.set_defaults()
|
||||
|
||||
try:
|
||||
conf(project='shaker')
|
||||
except cfg.RequiredOptError as e:
|
||||
print('Error: %s' % e)
|
||||
conf.print_usage()
|
||||
exit(1)
|
||||
|
||||
logging.setup(conf, 'shaker')
|
||||
LOG.info('Logging enabled')
|
||||
utils.init_config_and_logging(config.COMMON_OPTS + config.AGENT_OPTS)
|
||||
|
||||
endpoint = cfg.CONF.server_endpoint
|
||||
|
||||
polling_interval = cfg.CONF.polling_interval
|
||||
agent_id = cfg.CONF.agent_id
|
||||
LOG.info('My instance id is: %s', agent_id)
|
||||
LOG.info('My id is: %s', agent_id)
|
||||
|
||||
context = zmq.Context()
|
||||
LOG.info('Connecting to server: %s', endpoint)
|
||||
@ -98,20 +83,23 @@ def main():
|
||||
|
||||
# do something useful
|
||||
command_stdout, command_stderr = processutils.execute(
|
||||
*shlex.split(command))
|
||||
*shlex.split(command), check_exit_code=False)
|
||||
send_reply(socket, agent_id, {
|
||||
'stdout': command_stdout,
|
||||
'stderr': command_stderr,
|
||||
})
|
||||
elif task['operation'] == 'configure':
|
||||
if 'polling_interval' in task:
|
||||
polling_interval = task.get('polling_interval')
|
||||
|
||||
time.sleep(10)
|
||||
time.sleep(polling_interval)
|
||||
|
||||
except BaseException as e:
|
||||
if not isinstance(e, KeyboardInterrupt):
|
||||
if isinstance(e, KeyboardInterrupt):
|
||||
LOG.info('The process is interrupted')
|
||||
sys.exit(3)
|
||||
else:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
LOG.info('Shutting down')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -25,6 +25,9 @@ COMMON_OPTS = [
|
||||
required=True,
|
||||
help='Address for server connections (host:port), '
|
||||
'defaults to env[SHAKER_SERVER_ENDPOINT].'),
|
||||
cfg.IntOpt('polling-interval',
|
||||
default=10,
|
||||
help='How frequently the agent polls server, in seconds')
|
||||
]
|
||||
|
||||
OPENSTACK_OPTS = [
|
||||
@ -119,10 +122,6 @@ IMAGE_BUILDER_OPTS = [
|
||||
|
||||
|
||||
def list_opts():
|
||||
yield (None, copy.deepcopy(COMMON_OPTS))
|
||||
yield (None, copy.deepcopy(OPENSTACK_OPTS))
|
||||
yield (None, copy.deepcopy(SERVER_OPTS))
|
||||
yield (None, copy.deepcopy(REPORT_OPTS))
|
||||
yield (None, copy.deepcopy(INPUT_OPTS))
|
||||
yield (None, copy.deepcopy(AGENT_OPTS))
|
||||
yield (None, copy.deepcopy(IMAGE_BUILDER_OPTS))
|
||||
all_opts = (COMMON_OPTS + OPENSTACK_OPTS + SERVER_OPTS + REPORT_OPTS +
|
||||
INPUT_OPTS + AGENT_OPTS + IMAGE_BUILDER_OPTS)
|
||||
yield (None, copy.deepcopy(all_opts))
|
||||
|
Loading…
x
Reference in New Issue
Block a user