Commit ed0b7b17 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Extend export OS to override environment

Extend export OS RPC and backend to allow the environment file that
goes in the OS archive to be overridden.  This will be necessary to
introduce new OS environment variables, as well as, override the disk
Signed-off-by: default avatarJose A. Lopes <>
Reviewed-by: default avatarHrvoje Ribicic <>
parent 808cb0ee
......@@ -3876,7 +3876,7 @@ def ValidateOS(required, osname, checks, osparams, force_variant):
return True
def ExportOS(instance):
def ExportOS(instance, override_env):
"""Creates a GZIPed tarball with an OS definition and environment.
The archive contains a file with the environment variables needed by
......@@ -3885,6 +3885,10 @@ def ExportOS(instance):
@type instance: L{objects.Instance}
@param instance: instance for which the OS definition is exported
@type override_env: dict of string to string
@param override_env: if supplied, it overrides the environment on a
key-by-key basis that is part of the archive
@rtype: string
@return: filepath of the archive
......@@ -3902,6 +3906,8 @@ def ExportOS(instance):
inst_os, temp_dir, result.fail_reason, result.output)
env = OSEnvironment(instance, inst_os)
with open(utils.PathJoin(temp_dir, "environment"), "w") as f:
for var in env:
f.write(var + "=" + env[var] + "\n")
......@@ -468,6 +468,7 @@ _OS_CALLS = [
], None, None, "Run a validation routine for a given OS"),
("os_export", SINGLE, None, constants.RPC_TMO_FAST, [
("instance", ED_INST_DICT, None),
("override_env", None, None),
], None, None, "Export an OS for a given instance"),
......@@ -1000,7 +1000,8 @@ class NodeRequestHandler(http.server.HttpServerHandler):
instance = objects.Instance.FromDict(params[0])
return backend.ExportOS(instance)
override_env = params[1]
return backend.ExportOS(instance, override_env)
# extstorage -----------------------
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