Commit e57e0ead authored by Vincent Pelletier's avatar Vincent Pelletier

Expect the whole configuration file to be provided as one parameter.

Move out of configuration file and into command line parameters options
which are auto-generated or not possible to provide as string (python's
_ssl module insists on getting key & cert as file, and we inherit from that
limitation).
Helps making "agent" software release more independent from agent parameter
needs.
parent 7f64359e
...@@ -48,47 +48,37 @@ class Recipe(BaseSlapRecipe, GenericSlapRecipe): ...@@ -48,47 +48,37 @@ class Recipe(BaseSlapRecipe, GenericSlapRecipe):
self.computer_partition_id, self.computer_partition_id,
).getInstanceParameterDict() ).getInstanceParameterDict()
# XXX: should probably expect one more (SR-originating) parameter instead
# of using self.work_directory .
configuration_path = os.path.join(self.work_directory, "agent.cfg") configuration_path = os.path.join(self.work_directory, "agent.cfg")
configuration = ConfigParser.SafeConfigParser() with open(configuration_path, "w") as configuration:
configuration.add_section("agent") configuration.write(parameter_dict["configuration"])
configuration.set("agent", "portal_url", parameter_dict["portal_url"]) if "key" in parameter_dict:
configuration.set("agent", "master_url", parameter_dict["master_url"]) key_filepath = os.path.join(self.work_directory, "key")
configuration.set("agent", "report_url", parameter_dict["report_url"]) cert_filepath = os.path.join(self.work_directory, "cert")
key_filepath = os.path.join(self.work_directory, "key") with open(key_filepath, "w") as key_file:
key_file = open(key_filepath, "w") key_file.write(parameter_dict['key'])
key_file.write(parameter_dict["key"]) with open(cert_filepath, "w") as cert_file:
key_file.close() cert_file.write(parameter_dict["cert"])
configuration.set("agent", "key_file", key_filepath) extra_arguments = "--key_file=%s --cert_file=%s " % (key_filepath,
cert_filepath = os.path.join(self.work_directory, "cert") cert_filepath)
cert_file = open(cert_filepath, "w") else:
cert_file.write(parameter_dict["cert"]) extra_arguments = ""
cert_file.close()
configuration.set("agent", "cert_file", cert_filepath)
configuration.set("agent", "maximum_software_installation_duration",
parameter_dict["maximum_software_installation_duration"])
configuration.set("agent", "software_live_duration",
parameter_dict["software_live_duration"])
configuration.set("agent", "computer_list",
parameter_dict["computer_list"])
configuration.set("agent", "software_list",
parameter_dict["software_list"])
configuration.set("agent", "log_directory", self.options["log_directory"])
state_file = self.options["state_file"] state_file = self.options["state_file"]
configuration.set("agent", "state_file", state_file)
open(state_file, "a").close() open(state_file, "a").close()
configuration.set("agent", "path_file", self.options["path_file"])
configuration.add_section("software_uri")
software_list = json.loads(parameter_dict["software_list"])
for software in software_list:
configuration.set("software_uri", software, parameter_dict[software])
configuration.write(open(configuration_path, "w"))
agent_crond_path = os.path.join(crond, "agent") agent_crond_path = os.path.join(crond, "agent")
with open(agent_crond_path, "w") as agent_crond: with open(agent_crond_path, "w") as agent_crond:
agent_crond.write("*/5 * * * * %s -S %s --pidfile=%s %s\n" % ( agent_crond.write("*/5 * * * * %s -S %s --pidfile=%s --log_directory=%s "
"--state_file=%s --path_file=%s %s%s\n" % (
self.options["python_binary"], self.options["python_binary"],
self.options["agent_binary"], self.options["agent_binary"],
self.options["pidfile"], self.options["pidfile"],
self.options["log_directory"],
state_file,
self.options["path_file"],
extra_arguments,
configuration_path, configuration_path,
)) ))
agent_crond.write("1 0 * * * %s -S %s %s\n" % ( agent_crond.write("1 0 * * * %s -S %s %s\n" % (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment