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