diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 3eb87ae195..a100c16437 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -402,16 +402,29 @@ var create_vm_tmpl =
\
\
\
-
Add context
\
+
Add context variables
\
\
\
-
\
+ \
+
\
+
\
+
Name for the context variable
\
+
\
+ \
+
\
+
\
+
Value of the context variable
\
+
\
+ \
+
\
+
\
+
\
+
\
+
\
+
\
+ \
+ \
\
\
\
@@ -1521,9 +1534,29 @@ function setupCreateVMDialog(){
$('fieldset',section_context).hide();
$('#add_context',section_context).click(function(){
- $('fieldset',section_context).toggle();
+ $('fieldset',section_context).toggle();
return false;
});
+
+ $('#add_context_button', section_context).click(function(){
+ var name = $('#var_name',section_context).val();
+ var value = $('#var_value',section_context).val();
+ if (!name.length || !value.length) {
+ notifyError("Context variable name and value must be filled in");
+ return false;
+ }
+ option= '';
+ $('select#context_box',section_context).append(option);
+ return false;
+ });
+
+ $('#remove_context_button', section_context).click(function(){
+ box_remove_element(section_context,'#context_box');
+ return false;
+ });
+
};
@@ -1675,11 +1708,15 @@ function setupCreateVMDialog(){
vm_json["GRAPHICS"] = {};
addSectionJSON(vm_json["GRAPHICS"],scope);
- //context -> include
- scope = section_context;
+ //context
+ scope = section_context;
var context = $('#CONTEXT',scope).val();
- if (context)
- vm_json["CONTEXT"] = context;
+ vm_json["CONTEXT"] = {};
+ $('#context_box option',scope).each(function(){
+ name = $(this).attr("name");
+ value = $(this).val();
+ vm_json["CONTEXT"][name]=value;
+ });
//placement -> fetch with value
scope = section_placement;