Commit 70397b80 by tarokkk

Merger conflicts.

Merge branch 'master' of ssh://giccero.cloud.ik.bme.hu/cloud

Conflicts:
	miscellaneous/store-server/CloudStore.py
parents c6533997 39de8802
......@@ -16,6 +16,10 @@ urlpatterns = patterns('',
url(r'^vm/new/(?P<template>\d+)/$', 'one.views.vm_new', name='vm_new'),
url(r'^vm/show/(?P<iid>\d+)/$', 'one.views.vm_show', name='vm_show'),
url(r'^vm/delete/(?P<iid>\d+)/$', 'one.views.vm_delete', name='vm_delete'),
url(r'^vm/stop/(?P<iid>\d+)/$', 'one.views.vm_stop', name='vm_stop'),
url(r'^vm/resume/(?P<iid>\d+)/$', 'one.views.vm_resume', name='vm_resume'),
url(r'^vm/power_off/(?P<iid>\d+)/$', 'one.views.vm_power_off', name='vm_power_off'),
url(r'^vm/restart/(?P<iid>\d+)/$', 'one.views.vm_restart', name='vm_restart'),
url(r'^vm/port_add/(?P<iid>\d+)/$', 'one.views.vm_port_add', name='vm_port_add'),
url(r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$', 'one.views.vm_port_del', name='vm_port_del'),
url(r'^reload/$', 'firewall.views.reload_firewall', name='reload_firewall'),
......
cd /opt/webadmin/
if [ -d cloud ]
then
:
else
echo Run init.sh? [N/y]
read
if [ "$REPLY" = y ]
then
passwd
/home/cloud/init.sh
fi
fi
cd cloud
......@@ -413,6 +413,40 @@ class Instance(models.Model):
self.firewall_host.delete()
reload_firewall_lock()
"""
Change host state in OpenNebula.
"""
def _change_state(self, new_state):
from django.template.defaultfilters import escape
out = ""
with tempfile.NamedTemporaryFile(delete=False) as f:
os.chmod(f.name, stat.S_IRUSR|stat.S_IWUSR|stat.S_IRGRP|stat.S_IROTH)
tpl = u"""
<COMPUTE>
<ID>%(id)d</ID>
<STATE>%(state)s</STATE>
</COMPUTE>""" % {"id": self.one_id,
"state": new_state}
f.write(tpl)
f.close()
import subprocess
proc = subprocess.Popen(["/opt/occi.sh",
"compute", "update",
f.name], stdout=subprocess.PIPE)
(out, err) = proc.communicate()
os.unlink(f.name)
print "out: " + out
def stop(self):
self._change_state("STOPPED")
def resume(self):
self._change_state("RESUME")
def poweroff(self):
self._change_state("POWEROFF")
def restart(self):
self._change_state("RESTART")
class Meta:
verbose_name = _('instance')
verbose_name_plural = _('instances')
......@@ -23,6 +23,9 @@ a:link,a:visited{
margin:0;
padding:5px;
}
.contentblock ul{
list-style: none;
}
.contentblock h2
{
......@@ -107,14 +110,16 @@ a:link,a:visited{
.wm .details .value{
float: right;
}
.wm:hover{
.wm .summary:hover{
background-color: #b1b1b1;
}
.wm .name{
float: left;
}
.wm .status{
text-align: right;
float: right;
width: 60px;
}
.wm .id{
float: right;
......@@ -129,11 +134,15 @@ a:link,a:visited{
.file-list .info{
float: right;
width: 60px;
text-align: right;
}
.wm .actions{
float: right;
width: 60px;
margin-left: 5px;
display: none;
}
.wm:hover .actions{
display: block;
}
.wm .actions a{
height: 16px;
......@@ -154,9 +163,15 @@ a:link,a:visited{
.filetype-c {
background-image: url(icons/document-visual-studio.png);
}
.filetype-text {
background-image: url(icons/document.png);
}
.filetype-image {
background-image: url(icons/document-image.png);
}
.filetype-zip {
background-image: url(icons/folder-zipper.png);
}
.filetype-folder {
background-image: url(icons/folder-horizontal.png);
}
......@@ -260,6 +275,7 @@ body
background-position:80px 0;
margin:0;
padding:0;
overflow: scroll;
}
#header
......
......@@ -8,26 +8,42 @@
<link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="icon" type="image/png" href="one/static/favicon.png">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="/static/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.wm').click(function(){
if($(this).children('.details').is(':hidden')){
$(this).children('.details')
$('.wm .summary').click(function(){
if($(this).next('.details').is(':hidden')){
$(this).next('.details')
.css('height',0)
.css('padding','0px 5px')
.show()
.animate({height:160,paddingTop:15,paddingBottom:15},700);
} else {
var that=this;
$(this).children('.details')
$(this).next('.details')
.css('height',130)
.css('padding','15px 5px')
.animate({height:0,paddingTop:0,paddingBottom:0},700,function(){
$(that).children('.details').hide();
$(that).next('.details').hide();
});
}
})
$('#load-more-files').click(function(){
$('.actions', this).show();
var that=this;
setTimeout(function(){
$(that).prev('li').slideDown(500,function(){
$('.actions', that).hide();
});
},2000);
})
$('#new-wm-button').click(function(){
$('#modal').show();
$('#modal-container').html($('#new-wm').html());
});
$('#shadow').click(function(){
$('#modal').hide();
})
})
</script>
......@@ -77,5 +93,10 @@ $(function(){
<div id="content">
{% block content %}{% endblock %}
</div>
<div id="modal" style="display: none">
<div id="shadow"></div>
<div id="modal-container">
</div>
</div>
</body>
</html>
<div class="contentblock" id="state">
<h2>Saját gépek</h2>
<div class="content">
{% if instances %}
<table style="width:388px">
<!--<tr><th>#</th><th>Megnevezés</th><th>Állapot</th><th style="width: 96px">Műveletek</th></tr>-->
{% for i in instances %}
<tr style="line-height: 22px;">
<td>{{i.id}}</td>
<td><a href="/vm/show/{{i.id}}/" title="{{i.name}}">{{i.name|truncatechars:20}}</td>
<td>{{i.state}}</td>
<td>
{% if i.state == 'ACTIVE' %}
<a href="{{i.get_connect_uri}}" title="Csatlakozás"><img src="/static/icons/Video-display.png" alt="⌨" /></a><a href="/vm/suspend/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="Felfüggesztés"><img src="/static/icons/Media-playback-pause.png" alt="||" /></a><a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="Törlés"><img src="/static/icons/Edit-delete-2.png" alt="⌫" /></a><a href="/vm/reset/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="Újraindítás"><img src="/static/icons/View-refresh.png" alt="↺" /></a>
{% endif %}
{% if i.state == 'PENDING' %}
<img src="/static/load-2.gif" /> indítás...
{% endif %}
{% if i.state == 'SUSPENDED' %}
<a href="/vm/continue/{{i.id}}/" title="Folytatás"><img src="/static/icons/Media-playback-start.png" alt=">" /></a>
<a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="Törlés"><img src="/static/icons/Edit-delete-2.png" alt="⌫" /></a>
{% endif %}
{% if i.state == 'FAILED' %}
<a href="/vm/delete/{{i.id}}/" title="Törlés"><img src="/static/icons/Edit-delete-2.png" alt="⌫" /></a>
{% endif %}
</td>
</tr>
<li class="wm">
<div class="summary">
<!--<div class="id">161</div>-->
<div class="name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}">
<a href="/vm/show/{{i.id}}/" title="{{i.name}}">{{i.name|truncatechars:20}}</a>
</div>
<div class="status">
{{i.state}}
</div>
<div class="actions">
{% if i.state == 'ACTIVE' %}
<a href="{{i.get_connect_uri}}" title="Csatlakozás"><img src="static/icons/plug.png" alt="connect" /></a>
<a href="/vm/suspend/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="Felfüggesztés"><img src="/static/icons/control-pause.png" alt="pause" /></a>
<a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
<a href="/vm/reset/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="Újraindítás"><img src="/static/icons/arrow-circle-double.png" alt="↺" /></a>
{% endif %}
{% if i.state == 'PENDING' %}
<img src="/static/load-2.gif" /> indítás...
{% endif %}
{% if i.state == 'SUSPENDED' %}
<a href="/vm/continue/{{i.id}}/" title="Folytatás"><img src="/static/icons/control.png" alt="resume" /></a>
<a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
{% endif %}
{% if i.state == 'FAILED' %}
<a href="/vm/delete/{{i.id}}/" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
{% endif %}
</div>
<div class="clear"></div>
</div>
<div class="details" style="display: none">
<h3>Részletek</h3>
<ul>
<li class="name">Gép neve: <span class="value">{{i.name}}</span></li>
<li class="os-linux">Operációs rendszer: <span class="value">{{i.template.disk.name}}</span></li>
<li class="type">Instance típus: <span class="value">{{i.template.instance_type.name}}</span></li>
<li class="date">Létrehozás dátuma: <span class="value">{{i.created_at}}</span></li>
</ul>
</div>
</li>
{% endfor %}
</table>
{% else %}
<p>Nem fut egy gép sem.</p>
{% endif %}
</div>
</div>
<div id="new-wm-tooltip">
<div id="new-wm-tooltip-container">
<p>
Még nem indított egy gépet sem.
</p>
<p>
Válasszon sablont, és iziben használhatja a kiválasztott rendszert.
</p>
</div>
</div>
{% endif %}
\ No newline at end of file
......@@ -162,6 +162,45 @@ class VmDeleteView(View):
vm_delete = login_required(VmDeleteView.as_view())
@login_required
@require_POST
def vm_stop(request, iid, *args, **kwargs):
try:
get_object_or_404(Instance, id=iid, owner=request.user).stop()
messages.success(request, _('Virtual machine is successfully stopped.'))
except:
messages.error(request, _('Failed to stop virtual machine.'))
return redirect('/')
@login_required
@require_POST
def vm_resume(request, iid, *args, **kwargs):
try:
get_object_or_404(Instance, id=iid, owner=request.user).resume()
messages.success(request, _('Virtual machine is successfully resumed.'))
except:
messages.error(request, _('Failed to resume virtual machine.'))
return redirect('/')
@login_required
@require_POST
def vm_power_off(request, iid, *args, **kwargs):
try:
get_object_or_404(Instance, id=iid, owner=request.user).poweroff()
messages.success(request, _('Virtual machine is successfully powered off.'))
except:
messages.error(request, _('Failed to power off virtual machine.'))
return redirect('/')
@login_required
@require_POST
def vm_restart(request, iid, *args, **kwargs):
try:
get_object_or_404(Instance, id=iid, owner=request.user).restart()
messages.success(request, _('Virtual machine is successfully restarted.'))
except:
messages.error(request, _('Failed to restart virtual machine.'))
return redirect('/')
def vm_active(request, token):
id = signing.loads(token, salt='activate', max_age=300)
......
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 sign in to comment