mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
Merge branch 'master' of https://github.com/catborise/webvirtcloud
This commit is contained in:
commit
6a992b03c0
2 changed files with 22 additions and 7 deletions
|
@ -7,13 +7,15 @@ from libvirt import libvirtError
|
||||||
import json
|
import json
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
OS_VERSIONS = [ 'latest', '' ]
|
OS_VERSIONS = ['latest', '']
|
||||||
OS_UUID = "iid-dswebvirtcloud"
|
OS_UUID = "iid-dswebvirtcloud"
|
||||||
|
|
||||||
|
|
||||||
def os_index(request):
|
def os_index(request):
|
||||||
response = '\n'.join(OS_VERSIONS)
|
response = '\n'.join(OS_VERSIONS)
|
||||||
return HttpResponse(response)
|
return HttpResponse(response)
|
||||||
|
|
||||||
|
|
||||||
def os_metadata_json(request, version):
|
def os_metadata_json(request, version):
|
||||||
"""
|
"""
|
||||||
:param request:
|
:param request:
|
||||||
|
@ -27,9 +29,10 @@ def os_metadata_json(request, version):
|
||||||
response = { 'uuid': OS_UUID, 'hostname': hostname }
|
response = { 'uuid': OS_UUID, 'hostname': hostname }
|
||||||
return HttpResponse(json.dumps(response))
|
return HttpResponse(json.dumps(response))
|
||||||
else:
|
else:
|
||||||
err = 'Invalid version: %s' % version
|
err = 'Invalid version: {}'.format(version)
|
||||||
raise Http404(err)
|
raise Http404(err)
|
||||||
|
|
||||||
|
|
||||||
def os_userdata(request, version):
|
def os_userdata(request, version):
|
||||||
"""
|
"""
|
||||||
:param request:
|
:param request:
|
||||||
|
@ -51,9 +54,10 @@ def os_userdata(request, version):
|
||||||
|
|
||||||
return render(request, 'user_data', locals())
|
return render(request, 'user_data', locals())
|
||||||
else:
|
else:
|
||||||
err = 'Invalid version: %s' % version
|
err = 'Invalid version: {}'.format(version)
|
||||||
raise Http404(err)
|
raise Http404(err)
|
||||||
|
|
||||||
|
|
||||||
def get_client_ip(request):
|
def get_client_ip(request):
|
||||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||||
if x_forwarded_for:
|
if x_forwarded_for:
|
||||||
|
@ -62,10 +66,15 @@ def get_client_ip(request):
|
||||||
ip = request.META.get('REMOTE_ADDR')
|
ip = request.META.get('REMOTE_ADDR')
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
|
|
||||||
def get_hostname_by_ip(ip):
|
def get_hostname_by_ip(ip):
|
||||||
addrs = socket.gethostbyaddr(ip)
|
try:
|
||||||
|
addrs = socket.gethostbyaddr(ip)
|
||||||
|
except Exception:
|
||||||
|
addrs = [ip,]
|
||||||
return addrs[0]
|
return addrs[0]
|
||||||
|
|
||||||
|
|
||||||
def get_vdi_url(request, vname):
|
def get_vdi_url(request, vname):
|
||||||
instance = Instance.objects.get(name=vname)
|
instance = Instance.objects.get(name=vname)
|
||||||
compute = instance.compute
|
compute = instance.compute
|
||||||
|
|
|
@ -321,7 +321,12 @@
|
||||||
{% ifequal status 1 %}
|
{% ifequal status 1 %}
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vdiconsole">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vdiconsole">
|
||||||
<p>{% trans "This action opens a remote viewer with a connection to the console of the instance." %}</p>
|
<p>{% trans "This action opens a remote viewer with a connection to the console of the instance." %}</p>
|
||||||
<a href="#" class="btn btn-lg btn-success pull-right" id="vdi_url" >{% trans "VDI" %}</a>
|
<div class="input-group">
|
||||||
|
<input type="text" class="input-lg disabled form-control" disabled id="vdi_url_input"/>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<a href="#" class="btn btn-lg btn-success" id="vdi_url" >{% trans "VDI" %}</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
|
@ -560,7 +565,7 @@
|
||||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="name" value="{{ snap.name }}">
|
<input type="hidden" name="name" value="{{ snap.name }}">
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
<button type="submit" class="btn btn-sm btn-default" name="revert_snapshot" onclick="return confirm('Are you sure?')">
|
<button type="submit" class="btn btn-sm btn-default" name="revert_snapshot" title="Revert to this Snapshot" onclick="return confirm('Are you sure?')">
|
||||||
<span class="glyphicon glyphicon-save"></span>
|
<span class="glyphicon glyphicon-save"></span>
|
||||||
</button>
|
</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -573,7 +578,7 @@
|
||||||
<td style="width:30px;">
|
<td style="width:30px;">
|
||||||
<form action="" method="post" role="form">{% csrf_token %}
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="name" value="{{ snap.name }}">
|
<input type="hidden" name="name" value="{{ snap.name }}">
|
||||||
<button type="submit" class="btn btn-sm btn-default" name="delete_snapshot" onclick="return confirm('{% trans "Are you sure?" %}')">
|
<button type="submit" class="btn btn-sm btn-default" name="delete_snapshot" title="Delete Snapshot" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||||
<span class="glyphicon glyphicon-trash"></span>
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -1337,6 +1342,7 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// set vdi url
|
// set vdi url
|
||||||
$.get("/datasource/vdi/{{ vname }}/", function(data) {
|
$.get("/datasource/vdi/{{ vname }}/", function(data) {
|
||||||
|
$("#vdi_url_input").attr("value", data);
|
||||||
$("#vdi_url").attr("href", data);
|
$("#vdi_url").attr("href", data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue