software_type now survives to slaprunner reboot.

Also fetch software type when fetching parameters from web.
parent 51605005
...@@ -124,6 +124,18 @@ $(document).ready(function () { ...@@ -124,6 +124,18 @@ $(document).ready(function () {
} }
} }
function loadSoftwareType() {
$.ajax({
type: 'GET',
url: $SCRIPT_ROOT + '/getSoftwareType',
success: function updateSoftwareType(data) {
if (data.code === 1 && data.result) {
$("#software_type").val(data.result);
}
}
});
}
function loadParameter() { function loadParameter() {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
...@@ -267,6 +279,7 @@ $(document).ready(function () { ...@@ -267,6 +279,7 @@ $(document).ready(function () {
}); });
//Load previous instance parameters //Load previous instance parameters
loadParameter(); loadParameter();
loadSoftwareType();
$('a#parameterTab').click(function () { $('a#parameterTab').click(function () {
var i, var i,
size = $('#partitionParameter > tbody > tr').length; size = $('#partitionParameter > tbody > tr').length;
......
...@@ -19,9 +19,6 @@ from flask import jsonify ...@@ -19,9 +19,6 @@ from flask import jsonify
import slapos.slap import slapos.slap
# Global variable
global_software_type = 'default'
# Setup default flask (werkzeug) parser # Setup default flask (werkzeug) parser
logger = logging.getLogger('werkzeug') logger = logging.getLogger('werkzeug')
...@@ -107,9 +104,14 @@ def requestInstance(config, software_type=None): ...@@ -107,9 +104,14 @@ def requestInstance(config, software_type=None):
""" """
Request the main instance of our environment Request the main instance of our environment
""" """
software_type_path = os.path.join(config['etc_dir'], ".software_type.xml")
if software_type: if software_type:
global global_software_type # Write it to conf file for later use
global_software_type = software_type open(software_type_path, 'w').write(software_type)
elif os.path.exists(software_type_path):
software_type = open(software_type_path, 'r').read()
else:
software_type = 'default'
slap = slapos.slap.slap() slap = slapos.slap.slap()
profile = getCurrentSoftwareReleaseProfile(config) profile = getCurrentSoftwareReleaseProfile(config)
...@@ -125,7 +127,7 @@ def requestInstance(config, software_type=None): ...@@ -125,7 +127,7 @@ def requestInstance(config, software_type=None):
profile, profile,
partition_reference=getSoftwareReleaseName(config), partition_reference=getSoftwareReleaseName(config),
partition_parameter_kw=partition_parameter_kw, partition_parameter_kw=partition_parameter_kw,
software_type=global_software_type, software_type=software_type,
filter_kw=None, filter_kw=None,
state=None, state=None,
shared=False) shared=False)
......
...@@ -497,6 +497,13 @@ def saveParameterXml(): ...@@ -497,6 +497,13 @@ def saveParameterXml():
result="An error occurred while applying your settings!<br/>" + str(e)) result="An error occurred while applying your settings!<br/>" + str(e))
return jsonify(code=1, result="") return jsonify(code=1, result="")
@login_required()
def getSoftwareType():
software_type_path = os.path.join(app.config['etc_dir'], ".software_type.xml")
if os.path.exists(software_type_path):
return jsonify(code=1, result=open(software_type_path, 'r').read())
return jsonify(code=1, result="default")
#read instance parameters into the local xml file and return a dict #read instance parameters into the local xml file and return a dict
@login_required() @login_required()
def getParameterXml(request): def getParameterXml(request):
...@@ -656,6 +663,8 @@ app.add_url_rule('/startStopProccess/name/<process>/cmd/<action>', ...@@ -656,6 +663,8 @@ app.add_url_rule('/startStopProccess/name/<process>/cmd/<action>',
'startStopProccess', startStopProccess, methods=['GET']) 'startStopProccess', startStopProccess, methods=['GET'])
app.add_url_rule("/getParameterXml/<request>", 'getParameterXml', app.add_url_rule("/getParameterXml/<request>", 'getParameterXml',
getParameterXml, methods=['GET']) getParameterXml, methods=['GET'])
app.add_url_rule('/getSoftwareType', 'getSoftwareType',
getSoftwareType, methods=['GET'])
app.add_url_rule("/stopSlapgrid", 'stopSlapgrid', stopSlapgrid, methods=['POST']) app.add_url_rule("/stopSlapgrid", 'stopSlapgrid', stopSlapgrid, methods=['POST'])
app.add_url_rule("/slapgridResult", 'slapgridResult', app.add_url_rule("/slapgridResult", 'slapgridResult',
slapgridResult, methods=['POST']) slapgridResult, methods=['POST'])
......
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