1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-23 21:55:20 +00:00

Added 404 and fixed urls

This commit is contained in:
Retspen 2015-04-02 15:39:40 +03:00
parent acd91931ec
commit 35da9ad193
8 changed files with 34 additions and 34 deletions

View file

@ -2,7 +2,7 @@ import time
import json
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from computes.models import Compute
from instances.models import Instance
from accounts.models import UserInstance
@ -143,7 +143,7 @@ def overview(request, compute_id):
return HttpResponseRedirect(reverse('index'))
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmHostDetails(compute.hostname,
@ -172,7 +172,7 @@ def compute_graph(request, compute_id):
points = 5
datasets = {}
cookies = {}
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
curent_time = time.strftime("%H:%M:%S")
try:

View file

@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
@ -29,7 +29,7 @@ def create_instance(request, compute_id):
networks = []
meta_prealloc = False
computes = Compute.objects.all()
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
flavors = Flavor.objects.filter().order_by('id')
try:

View file

@ -5,7 +5,7 @@ from random import choice
from bisect import insort
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext_lazy as _
from computes.models import Compute
from instances.models import Instance
@ -134,7 +134,7 @@ def instance(request, compute_id, vname):
error_messages = []
messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
computes = Compute.objects.all()
computes_count = len(computes)
keymaps = QEMU_KEYMAPS
@ -161,7 +161,8 @@ def instance(request, compute_id, vname):
else:
image = disk['image'] + "-clone"
clone_disk.append(
{'dev': disk['dev'], 'storage': disk['storage'], 'image': image, 'format': disk['format']})
{'dev': disk['dev'], 'storage': disk['storage'],
'image': image, 'format': disk['format']})
return clone_disk
try:
@ -424,7 +425,7 @@ def instance(request, compute_id, vname):
return render(request, 'instances/instance.html', locals())
def inst_status(request, host_id, vname):
def inst_status(request, compute_id, vname):
"""
:param request:
:return:
@ -433,7 +434,7 @@ def inst_status(request, host_id, vname):
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('login'))
compute = Compute.objects.get(id=host_id)
compute = get_object_or_404(Compute, pk=compute_id)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
@ -468,7 +469,7 @@ def inst_graph(request, compute_id, vname):
cookies = {}
points = 5
curent_time = time.strftime("%H:%M:%S")
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
@ -547,7 +548,8 @@ def inst_graph(request, compute_id, vname):
json_net.append({'dev': net['dev'], 'data': [datasets_rx, datasets_tx]})
datasets_net[net['dev']] = [datasets_rx, datasets_tx]
data = json.dumps({'cpudata': datasets['cpu'], 'blkdata': json_blk, 'netdata': json_net, 'timeline': datasets['timer']})
data = json.dumps({'cpudata': datasets['cpu'], 'blkdata': json_blk,
'netdata': json_net, 'timeline': datasets['timer']})
response.cookies['cpu'] = datasets['cpu']
response.cookies['timer'] = datasets['timer']

View file

@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from computes.models import Compute
@ -21,7 +21,7 @@ def interfaces(request, compute_id):
ifaces_all = []
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmInterfaces(compute.hostname,
@ -71,7 +71,7 @@ def interface(request, compute_id, iface):
ifaces_all = []
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmInterface(compute.hostname,

View file

@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
@ -22,7 +22,7 @@ def networks(request, compute_id):
return HttpResponseRedirect(reverse('index'))
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmNetworks(compute.hostname,
@ -73,7 +73,7 @@ def network(request, compute_id, pool):
return HttpResponseRedirect(reverse('index'))
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmNetwork(compute.hostname,

View file

@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from computes.models import Compute
@ -21,7 +21,7 @@ def secrets(request, compute_id):
secrets_all = []
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmSecrets(compute.hostname,

View file

@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
@ -21,7 +21,7 @@ def storages(request, compute_id):
return HttpResponseRedirect(reverse('index'))
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
try:
conn = wvmStorages(compute.hostname,
@ -85,7 +85,7 @@ def storage(request, compute_id, pool):
destination.close()
error_messages = []
compute = Compute.objects.get(id=compute_id)
compute = get_object_or_404(Compute, pk=compute_id)
meta_prealloc = False
try:

View file

@ -4,23 +4,21 @@ from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^$', 'instances.views.index', name='index'),
url(r'^instances/$', 'instances.views.instances', name='instances'),
url(r'^instance/', include('instances.urls')),
url(r'^accounts/', include('accounts.urls')),
url(r'^computes/', include('computes.urls')),
url(r'^compute/stgs/(?P<compute_id>[0-9]+)/$', 'storages.views.storages', name='storages'),
url(r'^compute/stg/(?P<compute_id>[0-9]+)/(?P<pool>[\w\-\.]+)/$', 'storages.views.storage', name='storage'),
url(r'^compute/nets/(?P<compute_id>[0-9]+)/$', 'networks.views.networks', name='networks'),
url(r'^compute/net/(?P<compute_id>[0-9]+)/(?P<pool>[\w\-\.]+)/$', 'networks.views.network', name='network'),
url(r'^compute/ifaces/(?P<compute_id>[0-9]+)/$', 'interfaces.views.interfaces', name='interfaces'),
url(r'^compute/iface/(?P<compute_id>[0-9]+)/(?P<iface>[\w\-\.\:]+)/$', 'interfaces.views.interface', name='interface'),
url(r'^compute/secret/(?P<compute_id>[0-9]+)/$', 'secrets.views.secrets', name='secrets'),
url(r'^compute/(?P<compute_id>[0-9]+)/storages/$', 'storages.views.storages', name='storages'),
url(r'^compute/(?P<compute_id>[0-9]+)/storage/(?P<pool>[\w\-\.]+)/$', 'storages.views.storage', name='storage'),
url(r'^compute/(?P<compute_id>[0-9]+)/networks/$', 'networks.views.networks', name='networks'),
url(r'^compute/(?P<compute_id>[0-9]+)/network/(?P<pool>[\w\-\.]+)/$', 'networks.views.network', name='network'),
url(r'^compute/(?P<compute_id>[0-9]+)/interfaces/$', 'interfaces.views.interfaces', name='interfaces'),
url(r'^compute/(?P<compute_id>[0-9]+)/interface/(?P<iface>[\w\-\.\:]+)/$', 'interfaces.views.interface', name='interface'),
url(r'^compute/(?P<compute_id>[0-9]+)/secrets/$', 'secrets.views.secrets', name='secrets'),
url(r'^compute/(?P<compute_id>[0-9]+)/create/$', 'create.views.create_instance', name='create_instance'),
url(r'^console/$', 'console.views.console', name='console'),
url(r'^create/(?P<compute_id>[0-9]+)/$', 'create.views.create_instance', name='create_instance'),
url(r'^logs/$', 'logs.views.showlogs', name='showlogs'),
# (r'^admin/', include(admin.site.urls)),
)