Commit 8d66b2e4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_web: Implement support for Slave Instances with parameter editor

Indroduce the possibility to request Slaves by respecting software definition ("shared").
parent 5f6fb6b3
......@@ -42,6 +42,7 @@
<fieldset id="parameter-optional"> </fieldset>
<fieldset id="parameter-xml">
<input type=hidden name="parameter_hash" class="parameter_hash_output"></input>
<input type=hidden name="shared" class="parameter_shared"></input>
</fieldset>
</div>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.50545.7614.60620</string> </value>
<value> <string>950.53351.55207.18824</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1461685732.02</float>
<float>1461854038.17</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -536,12 +536,18 @@
}
var g = this,
to_hide = g.props.element.querySelector("button.slapos-show-form"),
to_show = g.props.element.querySelector("button.slapos-show-raw-parameter"),
softwaretype;
if (to_hide !== null) {
$(to_hide).addClass("hidden-button");
}
if (to_show !== null) {
$(to_show).removeClass("hidden-button");
}
this.options = options;
return g.loadSoftwareJSON(g.options.json_url).push(function (json) {
......@@ -550,6 +556,7 @@
option_selected = options.parameter.softwaretypeindex,
restricted_softwaretype = options.parameter.restricted_softwaretype,
input = g.props.element.querySelector('select.slapos-software-type'),
parameter_shared = g.props.element.querySelector('input.parameter_shared'),
s_input = g.props.element.querySelector('input.slapos-serialisation-type');
if (options.parameter.softwaretypeindex === undefined) {
......@@ -569,21 +576,45 @@
option.textContent = json['software-type'][option_index].title;
// option.index = json['software-type'][option_index].index;
if (options.parameter.shared === undefined) {
options.parameter.shared = false;
}
if (option_selected === undefined) {
option_selected = option_index;
if (json['software-type'][option_index].shared === true) {
parameter_shared.value = true;
} else {
parameter_shared.value = false;
}
}
if (softwaretype === undefined) {
softwaretype = option_selected;
}
if (option_index === option_selected) {
if (json['software-type'][option_index].shared === undefined) {
json['software-type'][option_index].shared = false;
}
option['data-shared'] = json['software-type'][option_index].shared;
if ((option_index === option_selected) &&
(options.parameter.shared === json['software-type'][option_index].shared)) {
option.selected = "selected";
if (json['software-type'][option_index].shared === true) {
parameter_shared.value = true;
} else {
parameter_shared.value = false;
}
}
if (restricted_softwaretype === true) {
if (option.value === options.parameter.softwaretype) {
if (options.parameter.shared === json['software-type'][option_index].shared) {
input.appendChild(option);
}
}
} else {
input.appendChild(option);
}
......@@ -591,6 +622,8 @@
}
}
if (softwaretype === undefined) {
softwaretype = option_selected;
}
......@@ -680,7 +713,8 @@
}
function updateParameterForm(evt) {
var e = g.props.element.getElementsByTagName('select')[0];
var e = g.props.element.getElementsByTagName('select')[0],
parameter_shared = g.props.element.querySelector('input.parameter_shared');
if (e === undefined) {
throw new Error("Select not found.");
......@@ -688,6 +722,7 @@
g.options.parameter.softwaretype = e.value;
g.options.parameter.softwaretypeindex = e.selectedOptions[0]["data-id"];
parameter_shared.value = e.selectedOptions[0]["data-shared"];
return g.render(g.options)
.push(function () {
return loadEventList(g);
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.52652.28107.49237</string> </value>
<value> <string>950.53504.63330.8328</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1461814951.2</float>
<float>1461863673.55</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -22,5 +22,9 @@ if context.getPortalType() == "Hosting Subscription":
if context.getTextContent() is not None:
option_dict['parameter']['parameter_hash'] = base64.b64encode(context.getTextContent())
option_dict['parameter']['restricted_softwaretype'] = True
option_dict['parameter']['shared'] = False
predecessor = context.getPredecessorValue(portal_type=["Software Instance", "Slave Instance"])
if predecessor is not None and predecessor.getPortalType() == "Slave Instance":
option_dict['parameter']['shared'] = True
return json.dumps(option_dict)
portal = context.getPortalObject()
if shared == "true":
shared = True
if shared == "false":
shared = False
if not service_title:
raise ValueError("Service Title is mandatory!")
......@@ -47,7 +53,7 @@ request_kw.update(
software_type=software_type,
instance_xml=instance_xml,
sla_xml="",
shared=False,
shared=shared,
state="started",
)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>dialog_id, service_title, instance_xml, parameter_hash=None, software_type=None, computer_guid=\'\', cpu_core=\'\', cpu_frequency=\'\', cpu_type=\'\', local_area_network_type=\'\', memory_size=\'\', memory_type=\'\', storage_capacity=\'\', storage_interface=\'\', storage_redundancy=\'\', group=\'\', region=\'\', **kw</string> </value>
<value> <string>dialog_id, service_title, instance_xml, parameter_hash=None, software_type=None, shared=False, computer_guid=\'\', cpu_core=\'\', cpu_frequency=\'\', cpu_type=\'\', local_area_network_type=\'\', memory_size=\'\', memory_type=\'\', storage_capacity=\'\', storage_interface=\'\', storage_redundancy=\'\', group=\'\', region=\'\', **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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