mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Python3 & Django 2.2 Migration - Fix & Updates
This commit is contained in:
parent
fc8612c604
commit
4d40de1b55
98 changed files with 1525 additions and 6658 deletions
|
|
@ -1,11 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
# Generated by Django 2.2.10 on 2020-01-28 07:01
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('computes', '0001_initial'),
|
||||
]
|
||||
|
|
@ -14,13 +16,12 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Instance',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=20)),
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=120)),
|
||||
('uuid', models.CharField(max_length=36)),
|
||||
('compute', models.ForeignKey(to='computes.Compute')),
|
||||
('is_template', models.BooleanField(default=False)),
|
||||
('created', models.DateField(auto_now_add=True)),
|
||||
('compute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='computes.Compute')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('instances', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='instance',
|
||||
name='is_template',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import datetime
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('instances', '0002_instance_is_template'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='instance',
|
||||
name='created',
|
||||
field=models.DateField(default=datetime.datetime(2017, 10, 26, 8, 5, 55, 797326), auto_now_add=True),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.13 on 2018-07-24 11:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('instances', '0003_instance_created'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='instance',
|
||||
name='name',
|
||||
field=models.CharField(max_length=120),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
from django.db import models
|
||||
from django.db.models import Model, ForeignKey, CharField, BooleanField, DateField, CASCADE
|
||||
from computes.models import Compute
|
||||
|
||||
|
||||
class Instance(models.Model):
|
||||
compute = models.ForeignKey(Compute, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=120)
|
||||
uuid = models.CharField(max_length=36)
|
||||
is_template = models.BooleanField(default=False)
|
||||
created = models.DateField(auto_now_add=True)
|
||||
class Instance(Model):
|
||||
compute = ForeignKey(Compute, on_delete=CASCADE)
|
||||
name = CharField(max_length=120)
|
||||
uuid = CharField(max_length=36)
|
||||
is_template = BooleanField(default=False)
|
||||
created = DateField(auto_now_add=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans 'Bus' %}</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="vol_bus">
|
||||
<select class="form-control" name="vol_bus" {% if status != 5 %} disabled {% endif %}>
|
||||
{% for bus in bus_host %}
|
||||
<option value="{{ bus }}" {% if bus == disk.bus %}selected{% endif %}>{{ bus }}</option>
|
||||
{% endfor %}
|
||||
|
|
@ -110,6 +110,7 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input class="form-control" name="vol_bus_old" value="{{ disk.bus }}"/>
|
||||
</div><!-- /.tabpane-content -->
|
||||
</div><!-- /.tab-content -->
|
||||
</div> <!-- /.modal-body -->
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@
|
|||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="resizevm_disk">
|
||||
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_change %}
|
||||
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||
<p style="font-weight:bold;">{% trans "Disk allocation (B):" %}</p>
|
||||
<p style="font-weight:bold;">{% trans "Disk allocation (GB):" %}</p>
|
||||
{% for disk in disks %}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Current allocation" %} ({{ disk.dev }})</label>
|
||||
|
|
@ -704,25 +704,25 @@
|
|||
</div>
|
||||
</form>
|
||||
<p style="font-weight:bold;">{% trans 'Boot Order' %}</p>
|
||||
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-sm-offset-2">
|
||||
{% ifequal status 5 %}
|
||||
<p>{% trans "Enable Boot Menu for your instance when it starts up " %}
|
||||
{% ifequal bootmenu 0 %}
|
||||
<input type="submit" class="btn btn-success" name="set_bootmenu" title="Show boot menu" value="{% trans "Enable" %}">
|
||||
{% else %}
|
||||
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-sm-offset-2">
|
||||
{% ifequal status 5 %}
|
||||
<p>{% trans "Enable Boot Menu for your instance when it starts up " %}
|
||||
{% ifequal bootmenu 0 %}
|
||||
<input type="submit" class="btn btn-success" name="set_bootmenu" title="Show boot menu" value="{% trans "Enable" %}">
|
||||
{% else %}
|
||||
{% ifequal bootmenu 0 %}
|
||||
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}</p>
|
||||
{% endifequal %}
|
||||
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}">
|
||||
{% endifequal %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% ifequal bootmenu 0 %}
|
||||
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}</p>
|
||||
{% endifequal %}
|
||||
{% endifequal %}
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% ifequal bootmenu 1 %}
|
||||
<div class="col-sm-6 col-sm-offset-2">
|
||||
<div class="well">
|
||||
|
|
@ -841,12 +841,14 @@
|
|||
<div class="col-xs-12 col-sm-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<th>{% trans "Device" %}</th>
|
||||
<th>{% trans "Used" %}</th>
|
||||
<th>{% trans "Capacity" %}</th>
|
||||
<th>{% trans "Storage" %}</th>
|
||||
<th>{% trans "Source" %}</th>
|
||||
<th>{% trans "Action" %}</th>
|
||||
<tr>
|
||||
<th>{% trans "Device" %}</th>
|
||||
<th>{% trans "Used" %}</th>
|
||||
<th>{% trans "Capacity" %}</th>
|
||||
<th>{% trans "Storage" %}</th>
|
||||
<th>{% trans "Source" %}</th>
|
||||
<th>{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for disk in disks %}
|
||||
|
|
@ -1169,7 +1171,7 @@
|
|||
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Migrate" %}</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
<div class="clearfix"></div></p>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="xmledit">
|
||||
<p>{% trans "If you need to edit xml please Power Off the instance" %}</p>
|
||||
|
|
@ -1354,7 +1356,7 @@
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="col-sm-4">
|
||||
<select id="select_clone_name" class="form-control" name="name" size="1"/>
|
||||
<select id="select_clone_name" class="form-control" name="name" size="1">
|
||||
{% for name in clone_free_names %}
|
||||
<option value="{{ name }}">{{ name }}</option>
|
||||
{% endfor %}
|
||||
|
|
@ -1730,7 +1732,7 @@
|
|||
$.getJSON('{% url 'random_mac_address' %}', function (data) {
|
||||
$('input[name="' + net + '"]').val(data['mac']);
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function show_console() {
|
||||
|
|
@ -1765,13 +1767,13 @@
|
|||
vname = '{{ vname }}';
|
||||
{% for disk in disks %}
|
||||
disk_name = '{{ disk.image }}';
|
||||
disk_dot = disk_name.split('.')
|
||||
disk_dot = disk_name.split('.');
|
||||
disk_dot_suffix = disk_dot[disk_dot.length-1];
|
||||
if (disk_name.startsWith(vname)) {
|
||||
image = disk_name.replace(vname, new_vname);
|
||||
} else if (disk_name.lastIndexOf('.') > -1 && disk_dot_suffix.length <= 7) {
|
||||
disk_dot.pop();
|
||||
disk_name_only = disk_dot.join('-')
|
||||
disk_name_only = disk_dot.join('-');
|
||||
image = new_vname + "-" + disk_name_only + "." + disk_dot_suffix
|
||||
} else if (new_vname != disk_name) {
|
||||
image = new_vname
|
||||
|
|
@ -1811,28 +1813,28 @@
|
|||
});
|
||||
$(document).ready(function () {
|
||||
// set current console keymap or fall back to default
|
||||
var keymap = "{{ console_keymap }}"
|
||||
var keymap = "{{ console_keymap }}";
|
||||
if (keymap != '') {
|
||||
$("#console_select_keymap option[value='" + keymap + "']").prop('selected', true);
|
||||
}
|
||||
});
|
||||
$(document).ready(function () {
|
||||
// set current console type or fall back to default
|
||||
var console_type = "{{ console_type }}"
|
||||
var console_type = "{{ console_type }}";
|
||||
if (console_type != '') {
|
||||
$("#console_select_type option[value='" + console_type + "']").prop('selected', true);
|
||||
}
|
||||
});
|
||||
$(document).ready(function () {
|
||||
// set current console listen address or fall back to default
|
||||
var console_listen_address = "{{ console_listen_address }}"
|
||||
var console_listen_address = "{{ console_listen_address }}";
|
||||
if (console_listen_address != '') {
|
||||
$("#console_select_listen_address option[value='" + console_listen_address + "']").prop('selected', true);
|
||||
}
|
||||
});
|
||||
$(document).ready(function () {
|
||||
// get video model or fall back to default
|
||||
let video_model = "{{ video_model }}"
|
||||
let video_model = "{{ video_model }}";
|
||||
if (video_model != '') {
|
||||
$("#video_model_select option[value='" + video_model + "']").prop('selected', true);
|
||||
}
|
||||
|
|
@ -2103,7 +2105,7 @@
|
|||
var netChart = {};
|
||||
{% for net in networks %}
|
||||
var net_ctx_{{ forloop.counter0 }} = $("#netEth{{ forloop.counter0 }}Chart").get(0).getContext("2d");
|
||||
netChart['{{ forloop.counter0 }}'] = new Chart(net_ctx_{{ forloop.counter0 }}, {
|
||||
netChart[{{ forloop.counter0 }}] = new Chart(net_ctx_{{ forloop.counter0 }}, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets : [
|
||||
|
|
@ -2182,8 +2184,8 @@
|
|||
for (let j = 0; j < data.blkdata.length; j++) {
|
||||
diskChart[data.blkdata[j].dev].data.labels.push(data.timeline);
|
||||
|
||||
diskChart[data.blkdata[j].dev].data.datasets[0].data.push(data.blkdata[0].data[0]);
|
||||
diskChart[data.blkdata[j].dev].data.datasets[1].data.push(data.blkdata[0].data[1]);
|
||||
diskChart[data.blkdata[j].dev].data.datasets[0].data.push(data.blkdata[j].data[0]);
|
||||
diskChart[data.blkdata[j].dev].data.datasets[1].data.push(data.blkdata[j].data[1]);
|
||||
if (diskChart[data.blkdata[j].dev].data.datasets[0].data.length > 10){
|
||||
diskChart[data.blkdata[j].dev].data.labels.shift();
|
||||
diskChart[data.blkdata[j].dev].data.datasets[0].data.shift();
|
||||
|
|
@ -2195,8 +2197,8 @@
|
|||
for (let j = 0; j < data.netdata.length; j++) {
|
||||
netChart[data.netdata[j].dev].data.labels.push(data.timeline);
|
||||
|
||||
netChart[data.netdata[j].dev].data.datasets[0].data.push(data.netdata[0].data[0]);
|
||||
netChart[data.netdata[j].dev].data.datasets[1].data.push(data.netdata[0].data[1]);
|
||||
netChart[data.netdata[j].dev].data.datasets[0].data.push(data.netdata[j].data[0]);
|
||||
netChart[data.netdata[j].dev].data.datasets[1].data.push(data.netdata[j].data[1]);
|
||||
if (netChart[data.netdata[j].dev].data.datasets[0].data.length > 10){
|
||||
netChart[data.netdata[j].dev].data.labels.shift();
|
||||
netChart[data.netdata[j].dev].data.datasets[0].data.shift();
|
||||
|
|
@ -2211,7 +2213,7 @@
|
|||
<script>
|
||||
backgroundJobRunning = false;
|
||||
window.setInterval(function get_status() {
|
||||
var status = {{ status }};
|
||||
var status = {{ status|lower }};
|
||||
$.getJSON('{% url 'inst_status' compute_id vname %}', function (data) {
|
||||
if (data['status'] != status && !backgroundJobRunning) {
|
||||
window.location.reload()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
from django.conf.urls import url
|
||||
from django.urls import path, re_path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.allinstances, name='allinstances'),
|
||||
url(r'^(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.instance, name='instance'),
|
||||
url(r'^statistics/(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.inst_graph, name='inst_graph'),
|
||||
url(r'^status/(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.inst_status, name='inst_status'),
|
||||
url(r'^guess_mac_address/(?P<vname>[\w\-\.]+)/$', views.guess_mac_address, name='guess_mac_address'),
|
||||
url(r'^guess_clone_name/$', views.guess_clone_name, name='guess_clone_name'),
|
||||
url(r'^random_mac_address/$', views.random_mac_address, name='random_mac_address'),
|
||||
url(r'^check_instance/(?P<vname>[\w\-\.]+)/$', views.check_instance, name='check_instance'),
|
||||
url(r'^sshkeys/(?P<vname>[\w\-\.]+)/$', views.sshkeys, name='sshkeys'),
|
||||
path('', views.allinstances, name='allinstances'),
|
||||
re_path(r'^(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.instance, name='instance'),
|
||||
re_path(r'^statistics/(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.inst_graph, name='inst_graph'),
|
||||
re_path(r'^status/(?P<compute_id>[0-9]+)/(?P<vname>[\w\-\.]+)/$', views.inst_status, name='inst_status'),
|
||||
re_path(r'^guess_mac_address/(?P<vname>[\w\-\.]+)/$', views.guess_mac_address, name='guess_mac_address'),
|
||||
re_path(r'^guess_clone_name/$', views.guess_clone_name, name='guess_clone_name'),
|
||||
re_path(r'^random_mac_address/$', views.random_mac_address, name='random_mac_address'),
|
||||
re_path(r'^check_instance/(?P<vname>[\w\-\.]+)/$', views.check_instance, name='check_instance'),
|
||||
re_path(r'^sshkeys/(?P<vname>[\w\-\.]+)/$', views.sshkeys, name='sshkeys'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ def allinstances(request):
|
|||
return instances_actions(request)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
addlogmsg(request.user.username, request.POST.get("name", "instance"), lib_err.message)
|
||||
addlogmsg(request.user.username, request.POST.get("name", "instance"), lib_err)
|
||||
|
||||
view_style = settings.VIEW_INSTANCES_LIST_STYLE
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ def instances(request, compute_id):
|
|||
return instances_actions(request)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
addlogmsg(request.user.username, request.POST.get("name", "instance"), lib_err.message)
|
||||
addlogmsg(request.user.username, request.POST.get("name", "instance"), lib_err)
|
||||
|
||||
return render(request, 'instances.html', locals())
|
||||
|
||||
|
|
@ -131,19 +131,19 @@ def instance(request, compute_id, vname):
|
|||
def filesizefstr(size_str):
|
||||
if size_str == '':
|
||||
return 0
|
||||
size_str = size_str.encode('ascii', 'ignore').upper().translate(None, " B")
|
||||
size_str = size_str.upper().replace("B", "")
|
||||
if 'K' == size_str[-1]:
|
||||
return long(float(size_str[:-1])) << 10
|
||||
return int(float(size_str[:-1])) << 10
|
||||
elif 'M' == size_str[-1]:
|
||||
return long(float(size_str[:-1])) << 20
|
||||
return int(float(size_str[:-1])) << 20
|
||||
elif 'G' == size_str[-1]:
|
||||
return long(float(size_str[:-1])) << 30
|
||||
return int(float(size_str[:-1])) << 30
|
||||
elif 'T' == size_str[-1]:
|
||||
return long(float(size_str[:-1])) << 40
|
||||
return int(float(size_str[:-1])) << 40
|
||||
elif 'P' == size_str[-1]:
|
||||
return long(float(size_str[:-1])) << 50
|
||||
return int(float(size_str[:-1])) << 50
|
||||
else:
|
||||
return long(float(size_str))
|
||||
return int(float(size_str))
|
||||
|
||||
def get_clone_free_names(size=10):
|
||||
prefix = settings.CLONE_INSTANCE_DEFAULT_PREFIX
|
||||
|
|
@ -217,8 +217,8 @@ def instance(request, compute_id, vname):
|
|||
if media:
|
||||
existing_media_devs = [m['dev'] for m in media]
|
||||
|
||||
for l in string.lowercase:
|
||||
dev = dev_base + l
|
||||
for al in string.ascii_lowercase:
|
||||
dev = dev_base + al
|
||||
if dev not in existing_disk_devs and dev not in existing_media_devs:
|
||||
return dev
|
||||
raise Exception(_('None available device name'))
|
||||
|
|
@ -576,7 +576,7 @@ def instance(request, compute_id, vname):
|
|||
target_dev = get_new_disk_dev(media, disks, bus)
|
||||
|
||||
source = conn_create.create_volume(storage, name, size, format, meta_prealloc, default_owner)
|
||||
conn.attach_disk(source, target_dev, target_bus=bus, driver_type=format, cache_mode=cache)
|
||||
conn.attach_disk(target_dev, source, target_bus=bus, driver_type=format, cache_mode=cache)
|
||||
msg = _('Attach new disk {} ({})'.format(name, format))
|
||||
addlogmsg(request.user.username, instance.name, msg)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||
|
|
@ -598,7 +598,7 @@ def instance(request, compute_id, vname):
|
|||
target_dev = get_new_disk_dev(media, disks, bus)
|
||||
source = path + "/" + name
|
||||
|
||||
conn.attach_disk(source, target_dev, target_bus=bus, driver_type=driver_type, cache_mode=cache)
|
||||
conn.attach_disk(target_dev, source, target_bus=bus, driver_type=driver_type, cache_mode=cache)
|
||||
msg = _('Attach Existing disk: ' + target_dev)
|
||||
addlogmsg(request.user.username, instance.name, msg)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||
|
|
@ -609,16 +609,26 @@ def instance(request, compute_id, vname):
|
|||
new_path = request.POST.get('vol_path', '')
|
||||
shareable = bool(request.POST.get('vol_shareable', False))
|
||||
readonly = bool(request.POST.get('vol_readonly', False))
|
||||
bus = request.POST.get('vol_bus', '')
|
||||
disk_type = request.POST.get('vol_type', '')
|
||||
new_bus = request.POST.get('vol_bus', '')
|
||||
bus = request.POST.get('vol_bus_old', '')
|
||||
serial = request.POST.get('vol_serial', '')
|
||||
format = request.POST.get('vol_format', '')
|
||||
cache = request.POST.get('vol_cache', default_cache)
|
||||
io = request.POST.get('vol_io_mode', default_io)
|
||||
discard = request.POST.get('vol_discard_mode', default_discard)
|
||||
zeroes = request.POST.get('vol_detect_zeroes', default_zeroes)
|
||||
new_target_dev = get_new_disk_dev(media, disks, new_bus)
|
||||
|
||||
conn.edit_disk(target_dev, new_path, readonly, shareable, bus, serial, format,
|
||||
cache, io, discard, zeroes)
|
||||
if new_bus != bus:
|
||||
conn.detach_disk(target_dev)
|
||||
conn.attach_disk(new_target_dev, new_path, target_bus=new_bus,
|
||||
driver_type=format, cache_mode=cache,
|
||||
readonly=readonly, shareable=shareable, serial=serial,
|
||||
io_mode=io, discard_mode=discard, detect_zeroes_mode=zeroes)
|
||||
else:
|
||||
conn.edit_disk(target_dev, new_path, readonly, shareable, new_bus, serial, format,
|
||||
cache, io, discard, zeroes)
|
||||
|
||||
if not conn.get_status() == 5:
|
||||
messages.success(request, _("Disk changes changes are applied. " +
|
||||
|
|
@ -646,7 +656,7 @@ def instance(request, compute_id, vname):
|
|||
try:
|
||||
conn_delete.del_volume(name)
|
||||
except libvirtError as err:
|
||||
msg = _('The disk: ' + dev + ' is detached but not deleted. ' + err.message)
|
||||
msg = _('The disk: ' + dev + ' is detached but not deleted. ' + err)
|
||||
messages.warning(request, msg)
|
||||
|
||||
addlogmsg(request.user.username, instance.name, msg)
|
||||
|
|
@ -663,7 +673,7 @@ def instance(request, compute_id, vname):
|
|||
if 'add_cdrom' in request.POST and allow_admin_or_not_template:
|
||||
bus = request.POST.get('bus', 'ide' if machine == 'pc' else 'sata')
|
||||
target = get_new_disk_dev(media, disks, bus)
|
||||
conn.attach_disk("", target, disk_device='cdrom', cache_mode='none', target_bus=bus, readonly=True)
|
||||
conn.attach_disk(target, "", disk_device='cdrom', cache_mode='none', target_bus=bus, readonly=True)
|
||||
msg = _('Add CD-ROM: ' + target)
|
||||
addlogmsg(request.user.username, instance.name, msg)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||
|
|
@ -746,7 +756,7 @@ def instance(request, compute_id, vname):
|
|||
try:
|
||||
conn.set_vcpu_hotplug(eval(status))
|
||||
except libvirtError as lib_err:
|
||||
messages.error(request, lib_err.message)
|
||||
messages.error(request, lib_err)
|
||||
messages.success(request, msg)
|
||||
addlogmsg(request.user.username, instance.name, msg)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#resize')
|
||||
|
|
@ -951,7 +961,7 @@ def instance(request, compute_id, vname):
|
|||
"Stop and start network to activate new config")
|
||||
|
||||
except libvirtError as le:
|
||||
messages.error(request, le.message)
|
||||
messages.error(request, le)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#network')
|
||||
if 'unset_qos' in request.POST:
|
||||
qos_dir = request.POST.get('qos_direction', '')
|
||||
|
|
@ -1028,13 +1038,13 @@ def instance(request, compute_id, vname):
|
|||
error_messages.append(msg)
|
||||
else:
|
||||
new_instance = Instance(compute_id=compute_id, name=clone_data['name'])
|
||||
#new_instance.save()
|
||||
# new_instance.save()
|
||||
try:
|
||||
new_uuid = conn.clone_instance(clone_data)
|
||||
new_instance.uuid = new_uuid
|
||||
new_instance.save()
|
||||
except Exception as e:
|
||||
#new_instance.delete()
|
||||
# new_instance.delete()
|
||||
raise e
|
||||
|
||||
user_instance = UserInstance(instance_id=new_instance.id, user_id=request.user.id, is_delete=True)
|
||||
|
|
@ -1064,8 +1074,8 @@ def instance(request, compute_id, vname):
|
|||
conn.close()
|
||||
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
addlogmsg(request.user.username, vname, lib_err.message)
|
||||
error_messages.append(lib_err)
|
||||
addlogmsg(request.user.username, vname, lib_err)
|
||||
|
||||
return render(request, 'instance.html', locals())
|
||||
|
||||
|
|
@ -1152,7 +1162,7 @@ def get_host_instances(request, comp):
|
|||
status = connection_manager.host_is_up(comp.type, comp.hostname)
|
||||
|
||||
if status is True:
|
||||
conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
|
||||
conn = wvmHostDetails(comp.hostname, comp.login, comp.password, comp.type)
|
||||
comp_node_info = conn.get_node_info()
|
||||
comp_mem = conn.get_memory_usage()
|
||||
comp_instances = conn.get_host_instances(True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue