From 41b2196eccb88e1ed07929a61529f11fb2004164 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 22 Apr 2016 14:49:49 +0200 Subject: [PATCH] feature #4320: Make variable substitution when updating CONTEXT --- src/cli/onevm | 4 ++-- src/vm/VirtualMachine.cc | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index c5c09262b2..1f10b9bb81 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -945,7 +945,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do - Change the DNS for ETH0 device and add PASSWORD: - onevm updateconf myvm --context "ETH0_DNS=\\"8.8.8.8\\", PASSWORD=\\"1234\\"" + onevm updateconf myvm --context 'ETH0_DNS="8.8.8.8", PASSWORD="$USER[PASSWORD]"' This command also accepts a template, the full list of configuration attributes are (not all supported via options): @@ -954,7 +954,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do INPUT = ["TYPE", "BUS"] GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ] RAW = ["DATA", "DATA_VMX", "TYPE"] - CONTEXT (any value, **no variable substitution will be made**) + CONTEXT (any value, **variable substitution will be made**) *NOTE* Update will replace or add attributes, to remove an existing one add an empty value. diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index c4f59a0a28..40e6dce0b4 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -4954,5 +4954,14 @@ int VirtualMachine::updateconf(VirtualMachineTemplate& tmpl, string &err) // ------------------------------------------------------------------------- replace_vector_values(obj_template, &tmpl, "CONTEXT", 0, -1); - return 0; + VectorAttribute * context = obj_template->get("CONTEXT"); + + int rc = 0; + + if ( context != 0 ) + { + rc = parse_context_variables(&context, err); + } + + return rc; }