Commit 51ab20f4 authored by Alain Takoudjou's avatar Alain Takoudjou

clean slapproxy database when destroying all instances

parent ff93f75e
......@@ -108,8 +108,7 @@ def updateProxy(config):
'address': config['ipv4_address'],
'instance_root': config['instance_root'],
'netmask': '255.255.255.255',
'partition_list': [
],
'partition_list': [],
'reference': config['computer_id'],
'software_root': config['software_root']}
for i in xrange(0, int(config['partition_amount'])):
......@@ -170,8 +169,6 @@ def updateInstanceParameter(config, software_type=None):
xml_result = readParameters(param_path)
partition_parameter_kw = None
if type(xml_result) != type('') and xml_result.has_key('instance'):
#for item in xml_result['instance'].keys():
# xml_result['instance'][item] = xml_result['instance'][item].decode('utf-8')
partition_parameter_kw = xml_result['instance']
slap.registerOpenOrder().request(profile, partition_reference=getSoftwareReleaseName(config),
partition_parameter_kw=partition_parameter_kw, software_type=software_type,
......@@ -542,10 +539,10 @@ def writeSoftwareData(runner_dir, data):
def removeSoftwareByName(config, folderName):
if isSoftwareRunning(config) or isInstanceRunning(config):
return jsonify(code=0, result="Software installation or instantiation in progress, cannot remove")
raise Exception("Software installation or instantiation in progress, cannot remove")
path = os.path.join(config['software_root'], folderName)
if not os.path.exists(path):
return jsonify(code=0, result="Can not remove software: No such file or directory")
raise Exception("Cannot remove software Release: No such file or directory")
svcStopAll(config)
shutil.rmtree(path)
#update compiled software list
......@@ -557,7 +554,7 @@ def removeSoftwareByName(config, folderName):
writeSoftwareData(config['runner_workdir'], data)
break
i = i+1
return jsonify(code=1, result=data)
return data
def tail(f, lines=20):
"""
......
......@@ -11,6 +11,7 @@ from gittools import cloneRepo, gitStatus, switchBranch, addBranch, getDiff, \
app = Flask(__name__)
#Access Control: Only static files and login pages are allowed to guest
@app.before_request
def before_request():
if (not session.has_key('account') or not session['account']) \
......@@ -146,6 +147,9 @@ def removeInstance():
if isInstanceRunning(app.config):
flash('Instantiation in progress, cannot remove')
else:
stopProxy(app.config)
removeProxyDb(app.config)
startProxy(app.config)
removeInstanceRoot(app.config)
flash('Instance removed')
return redirect(url_for('inspectInstance'))
......@@ -286,7 +290,11 @@ def removeFile():
@app.route("/removeSoftwareDir", methods=['POST'])
def removeSoftwareDir():
return removeSoftwareByName(app.config, request.form['name'])
try:
data = removeSoftwareByName(app.config, request.form['name'])
return jsonify(code=1, result=data)
except Exception, e:
return jsonify(code=0, result=str(e))
@app.route("/getFileContent", methods=['POST'])
def getFileContent():
......
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