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('', ...@@ -16,6 +16,10 @@ urlpatterns = patterns('',
url(r'^vm/new/(?P<template>\d+)/$', 'one.views.vm_new', name='vm_new'), 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/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/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_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'^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'), 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): ...@@ -413,6 +413,40 @@ class Instance(models.Model):
self.firewall_host.delete() self.firewall_host.delete()
reload_firewall_lock() 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: class Meta:
verbose_name = _('instance') verbose_name = _('instance')
verbose_name_plural = _('instances') verbose_name_plural = _('instances')
...@@ -23,6 +23,9 @@ a:link,a:visited{ ...@@ -23,6 +23,9 @@ a:link,a:visited{
margin:0; margin:0;
padding:5px; padding:5px;
} }
.contentblock ul{
list-style: none;
}
.contentblock h2 .contentblock h2
{ {
...@@ -107,14 +110,16 @@ a:link,a:visited{ ...@@ -107,14 +110,16 @@ a:link,a:visited{
.wm .details .value{ .wm .details .value{
float: right; float: right;
} }
.wm:hover{ .wm .summary:hover{
background-color: #b1b1b1; background-color: #b1b1b1;
} }
.wm .name{ .wm .name{
float: left; float: left;
} }
.wm .status{ .wm .status{
text-align: right;
float: right; float: right;
width: 60px;
} }
.wm .id{ .wm .id{
float: right; float: right;
...@@ -129,11 +134,15 @@ a:link,a:visited{ ...@@ -129,11 +134,15 @@ a:link,a:visited{
.file-list .info{ .file-list .info{
float: right; float: right;
width: 60px; width: 60px;
text-align: right;
} }
.wm .actions{ .wm .actions{
float: right; float: right;
width: 60px;
margin-left: 5px; margin-left: 5px;
display: none;
}
.wm:hover .actions{
display: block;
} }
.wm .actions a{ .wm .actions a{
height: 16px; height: 16px;
...@@ -154,9 +163,15 @@ a:link,a:visited{ ...@@ -154,9 +163,15 @@ a:link,a:visited{
.filetype-c { .filetype-c {
background-image: url(icons/document-visual-studio.png); background-image: url(icons/document-visual-studio.png);
} }
.filetype-text {
background-image: url(icons/document.png);
}
.filetype-image { .filetype-image {
background-image: url(icons/document-image.png); background-image: url(icons/document-image.png);
} }
.filetype-zip {
background-image: url(icons/folder-zipper.png);
}
.filetype-folder { .filetype-folder {
background-image: url(icons/folder-horizontal.png); background-image: url(icons/folder-horizontal.png);
} }
...@@ -260,6 +275,7 @@ body ...@@ -260,6 +275,7 @@ body
background-position:80px 0; background-position:80px 0;
margin:0; margin:0;
padding:0; padding:0;
overflow: scroll;
} }
#header #header
......
...@@ -8,26 +8,42 @@ ...@@ -8,26 +8,42 @@
<link rel="icon" type="image/png" href="/static/favicon.png" /> <link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="icon" type="image/png" href="one/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" /> <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"> <script type="text/javascript">
$(function(){ $(function(){
$('.wm').click(function(){ $('.wm .summary').click(function(){
if($(this).children('.details').is(':hidden')){ if($(this).next('.details').is(':hidden')){
$(this).children('.details') $(this).next('.details')
.css('height',0) .css('height',0)
.css('padding','0px 5px') .css('padding','0px 5px')
.show() .show()
.animate({height:160,paddingTop:15,paddingBottom:15},700); .animate({height:160,paddingTop:15,paddingBottom:15},700);
} else { } else {
var that=this; var that=this;
$(this).children('.details') $(this).next('.details')
.css('height',130) .css('height',130)
.css('padding','15px 5px') .css('padding','15px 5px')
.animate({height:0,paddingTop:0,paddingBottom:0},700,function(){ .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> </script>
...@@ -77,5 +93,10 @@ $(function(){ ...@@ -77,5 +93,10 @@ $(function(){
<div id="content"> <div id="content">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<div id="modal" style="display: none">
<div id="shadow"></div>
<div id="modal-container">
</div>
</div>
</body> </body>
</html> </html>
<div class="contentblock" id="state">
<h2>Saját gépek</h2>
<div class="content">
{% if instances %} {% 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 %} {% for i in instances %}
<tr style="line-height: 22px;"> <li class="wm">
<td>{{i.id}}</td> <div class="summary">
<td><a href="/vm/show/{{i.id}}/" title="{{i.name}}">{{i.name|truncatechars:20}}</td> <!--<div class="id">161</div>-->
<td>{{i.state}}</td> <div class="name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}">
<td> <a href="/vm/show/{{i.id}}/" title="{{i.name}}">{{i.name|truncatechars:20}}</a>
{% if i.state == 'ACTIVE' %} </div>
<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> <div class="status">
{% endif %} {{i.state}}
{% if i.state == 'PENDING' %} </div>
<img src="/static/load-2.gif" /> indítás... <div class="actions">
{% endif %} {% if i.state == 'ACTIVE' %}
{% if i.state == 'SUSPENDED' %} <a href="{{i.get_connect_uri}}" title="Csatlakozás"><img src="static/icons/plug.png" alt="connect" /></a>
<a href="/vm/continue/{{i.id}}/" title="Folytatás"><img src="/static/icons/Media-playback-start.png" alt=">" /></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/Edit-delete-2.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/minus-circle.png" alt="delete" /></a>
{% endif %} <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>
{% if i.state == 'FAILED' %} {% endif %}
<a href="/vm/delete/{{i.id}}/" title="Törlés"><img src="/static/icons/Edit-delete-2.png" alt="⌫" /></a> {% if i.state == 'PENDING' %}
{% endif %} <img src="/static/load-2.gif" /> indítás...
{% endif %}
</td> {% if i.state == 'SUSPENDED' %}
</tr> <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 %} {% endfor %}
</table>
{% else %} {% else %}
<p>Nem fut egy gép sem.</p> <div id="new-wm-tooltip">
{% endif %} <div id="new-wm-tooltip-container">
</div> <p>
</div> 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): ...@@ -162,6 +162,45 @@ class VmDeleteView(View):
vm_delete = login_required(VmDeleteView.as_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): def vm_active(request, token):
id = signing.loads(token, salt='activate', max_age=300) 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