Commit a58553e2 authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: let user delete unused software releases

parent 9a2cae4e
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<li><a href="#tab2">Connection Information</a></li> <li><a href="#tab2">Connection Information</a></li>
<li><a href="#tab3" id="parameterTab">Parameters</a></li> <li><a href="#tab3" id="parameterTab">Parameters</a></li>
<li><a href="#tab4" id="instancetabfiles">Partitions Content</a></li> <li><a href="#tab4" id="instancetabfiles">Partitions Content</a></li>
<li><a href="#tab5">Monitoring</a></li> <li><a href="#tab5">Software Releases</a></li>
</ul><!-- //Tab buttons --> </ul><!-- //Tab buttons -->
<div class="tabDetails"> <div class="tabDetails">
<div id="tab1" class="tabContents"> <div id="tab1" class="tabContents">
...@@ -143,14 +143,30 @@ ...@@ -143,14 +143,30 @@
{%endif%} {%endif%}
</div><!-- end tab4 --> </div><!-- end tab4 -->
<div id="tab5" class="tabContents"> <div id="tab5" class="tabContents">
<h2>Monitoring interface</h2>
<div class="clear"></div> <div class="clear"></div>
<p>By clicking on the next link, you can access to the monitoring interface of the instance running inside the webrunner.</p> <h2>List of unused Software Releases</h2>
<div class="clear"></div> <p></p>
<p><b>Notice</b> that you have to extend the stack monitor in your software release (as explained <a href="http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/stack/monitor/README.txt?js=1">here</a>) for this weblink to work. <p>Request here the deletion of Software Releases.</p>
<div class="clear"></div> <p>A Software Release won't be deleted from disk until Build&amp;Run is executed. If you requested a Software Release removal by mistake, and Build&amp;Run didn't run yet, it is still possible to request it again.</p>
<p><b><a href="{{ g.instance_monitoring_url }}" target="_blank">{{ g.instance_monitoring_url }}</a></b></p>
<div class="clear"></div> <div class="clear"></div>
<table width="100%">
<tr>
<th>Software Release URI</th><th>Ask Deletion</th>
</tr>
{% for software_release_uri in software_release_uri_list %}
<tr>
<td>
{{ software_release_uri }}
</td>
<td>
<form action="/destroySoftwareRelease" method="POST">
<input type="hidden" name="uri" value="{{ software_release_uri }}" />
<input type="submit" class="button" title="Remove this software" value="Remove" />
</form>
</td>
</tr>
{% endfor %}
</table>
</div><!-- end tab5 --> </div><!-- end tab5 -->
</div> </div>
</div> </div>
......
...@@ -218,6 +218,30 @@ def supplySoftwareRelease(config, sr_path): ...@@ -218,6 +218,30 @@ def supplySoftwareRelease(config, sr_path):
if not getCurrentUsedSoftwareReleaseProfile(config): if not getCurrentUsedSoftwareReleaseProfile(config):
setCurrentSoftwareRelease(config, sr_path) setCurrentSoftwareRelease(config, sr_path)
def destroySoftwareRelease(config, uri):
available_sr_list = getAvailableSoftwareReleaseURIList(config)
for available_sr in available_sr_list:
if os.path.realpath(available_sr) == os.path.realpath(uri):
real_uri = available_sr
break
else:
return False
slap = slapos.slap.slap()
slap.initializeConnection(config['master_url'])
try:
software_release, = [
x for x in slap.registerComputer(config['computer_id']).getSoftwareReleaseList()
if x.getURI() == real_uri
]
except ValueError:
return False
slap.registerSupply().supply(
real_uri,
computer_guid=config['computer_id'],
state='destroyed',
)
return True
def updateProxy(config): def updateProxy(config):
""" """
...@@ -867,7 +891,7 @@ def relativepath(config, path): ...@@ -867,7 +891,7 @@ def relativepath(config, path):
'runner_workdir', 'runner_workdir',
) )
for virtual_path in virtual_path_list: for virtual_path in virtual_path_list:
if path.startswith(config[virtual_path]): if os.path.realpath(path).startswith(os.path.realpath(config[virtual_path])):
return path.replace(os.path.realpath(config[virtual_path]), virtual_path) return path.replace(os.path.realpath(config[virtual_path]), virtual_path)
return '' return ''
......
...@@ -831,6 +831,15 @@ def getMiniShellHistory(): ...@@ -831,6 +831,15 @@ def getMiniShellHistory():
return json.dumps(history) return json.dumps(history)
def destroySoftwareRelease():
software_release_uri = request.form['uri']
if utils.destroySoftwareRelease(app.config, realpath(app.config, software_release_uri)):
flash('Software Release deleted.')
else:
flash('Error: Software Release not found')
return redirect(url_for('inspectInstance'))
#Setup List of URLs #Setup List of URLs
app.add_url_rule('/', 'home', home) app.add_url_rule('/', 'home', home)
app.add_url_rule('/browseWorkspace', 'browseWorkspace', browseWorkspace) app.add_url_rule('/browseWorkspace', 'browseWorkspace', browseWorkspace)
...@@ -920,3 +929,4 @@ app.add_url_rule('/addUser', 'addUser', addUser, methods=['POST']) ...@@ -920,3 +929,4 @@ app.add_url_rule('/addUser', 'addUser', addUser, methods=['POST'])
app.add_url_rule('/getSlapgridParameters', 'getSlapgridParameters', getSlapgridParameters, methods=['GET']) app.add_url_rule('/getSlapgridParameters', 'getSlapgridParameters', getSlapgridParameters, methods=['GET'])
app.add_url_rule('/runCommand', 'runCommand', runCommand, methods=['POST']) app.add_url_rule('/runCommand', 'runCommand', runCommand, methods=['POST'])
app.add_url_rule("/getMiniShellHistory", 'getMiniShellHistory', getMiniShellHistory, methods=['GET']) app.add_url_rule("/getMiniShellHistory", 'getMiniShellHistory', getMiniShellHistory, methods=['GET'])
app.add_url_rule("/destroySoftwareRelease", "destroySoftwareRelease", destroySoftwareRelease, 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