fix shaker-spot execution

A previous commit introduced a feature to specify the directory the
agent uses for shell class execution via a cfg entry, agent_dir.

However this addition introduced an error when using shaker-spot:
  oslo_config.cfg.NoSuchOptError: no such option agent_dir in group
  [DEFAULT]

This commit fixes shaker-spot while still supporting the agent_dir
feature

Change-Id: I7cfb87ba406e177121e7914225857937a19502e4
This commit is contained in:
Le'Sage, Oded (ol7435) 2021-03-04 15:31:18 -06:00
parent 159bd35d2f
commit a2adff395f

View File

@ -61,10 +61,6 @@ def send_reply(socket, agent_id, result):
def run_command(command):
command_stdout, command_stderr = None, None
start = time.time()
agent_dir = cfg.CONF.agent_dir
if agent_dir:
utils.mkdir_tree(agent_dir)
if command['type'] == 'program':
command_stdout, command_stderr = processutils.execute(
@ -72,7 +68,8 @@ def run_command(command):
elif command['type'] == 'script':
if 'agent_dir' in cfg.CONF:
file_name = tempfile.mktemp(dir="%s" % agent_dir)
utils.mkdir_tree(cfg.CONF.agent_dir)
file_name = tempfile.mktemp(dir="%s" % cfg.CONF.agent_dir)
else:
file_name = tempfile.mktemp()