1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-11-01 12:04:15 +00:00

Merge pull request #223 from catborise/master

cosmetic fixes & others
This commit is contained in:
Anatoliy Guskov 2019-02-12 20:09:32 +02:00 committed by GitHub
commit c483925ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 75 additions and 286 deletions

View file

@ -475,11 +475,9 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
<thead> <thead>
<tr>
<th>{% trans "Name" %}</th> <th>{% trans "Name" %}</th>
<th>{% trans "Date" %}</th> <th>{% trans "Date" %}</th>
<th colspan="2">{% trans "Action" %}</th> <th colspan="2">{% trans "Action" %}</th>
</tr>
</thead> </thead>
<tbody> <tbody>
{% for snap in snapshots %} {% for snap in snapshots %}
@ -617,13 +615,13 @@
{% endifequal %} {% endifequal %}
{% else %} {% else %}
{% ifequal bootmenu 0 %} {% ifequal bootmenu 0 %}
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %} <p>{% trans "**** Please shutdown instance to modify boot menu ****" %}</p>
{% endifequal %} {% endifequal %}
{% endifequal %} {% endifequal %}
</p>
</div> </div>
</div> </div>
</form> </form>
</p>
{% ifequal bootmenu 1 %} {% ifequal bootmenu 1 %}
<div class="col-sm-6 col-sm-offset-2"> <div class="col-sm-6 col-sm-offset-2">
<div class="well"> <div class="well">
@ -636,7 +634,7 @@
<input id="bootorder" name="bootorder" hidden> <input id="bootorder" name="bootorder" hidden>
<div class="form-group"> <div class="form-group">
<div class="col-sm-6 col-sm-offset-2"> <div class="col-sm-6 col-sm-offset-2">
<div id="b_order" class="multiselect"> <div id="b_order" class="multipleselect">
{% for disk in disks %} {% for disk in disks %}
<label><input type="checkbox" name="disk:{{ disk.dev }}" value="disk:{{ disk.dev }}" onclick="set_orderlist($('#bootorder'))" />{{ disk.dev }} - {{ disk.image }}</label> <label><input type="checkbox" name="disk:{{ disk.dev }}" value="disk:{{ disk.dev }}" onclick="set_orderlist($('#bootorder'))" />{{ disk.dev }} - {{ disk.image }}</label>
{% endfor %} {% endfor %}
@ -665,16 +663,20 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="disks"> <div role="tabpanel" class="tab-pane tab-pane-bordered" id="disks">
{% if status == 5 %}
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %} <form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
<p style="font-weight:bold;"> <p style="font-weight:bold;">
{% trans "Instance Media" %} {% trans "Instance Media" %}
<button type="submit" name="add_cdrom" type="button" class="btn btn-success pull-right" title="Add CD-Rom"> {% if status == 5 %}
<button type="submit" name="add_cdrom" type="button" class="btn btn-success pull-right" title="Add CD-ROM">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</button> </button>
{% else %}
<button type="submit" type="button" class="btn btn-success disabled pull-right" title="Add CD-ROM" disabled>
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</button>
{% endif %}
</p> </p>
</form> </form>
{% endif %}
{% for cd in media %} {% for cd in media %}
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %} <form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
<div class="form-group"> <div class="form-group">
@ -803,13 +805,16 @@
</div> </div>
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="network"> <div role="tabpanel" class="tab-pane tab-pane-bordered" id="network">
<p> <p>
{% trans "Assign network device to bridge" %} {% trans "Add a network device" %}
{% include 'add_instance_network_block.html' %} {% include 'add_instance_network_block.html' %}
</p> </p>
<p style="font-weight:bold;">{% trans "Network devices" %}</p>
<div class="col-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
<form method="post" role="form">{% csrf_token %} <form method="post" role="form">{% csrf_token %}
{% for network in networks %} {% for network in networks %}
{% if forloop.first %}
<p><strong>{% trans "Network Devices" %}</strong></p>
{% endif %}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<label>eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</label> <label>eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})</label>

View file

@ -74,7 +74,7 @@ def instances(request, compute_id):
:param request: :param request:
:return: :return:
""" """
all_host_vms = {}
error_messages = [] error_messages = []
compute = get_object_or_404(Compute, pk=compute_id) compute = get_object_or_404(Compute, pk=compute_id)
@ -194,7 +194,7 @@ def instance(request, compute_id, vname):
msg += " (%s > %s)" % (disk_size, ua.max_disk_size) msg += " (%s > %s)" % (disk_size, ua.max_disk_size)
return msg return msg
def get_new_disk_dev(disks, bus): def get_new_disk_dev(media, disks, bus):
if bus == "virtio": if bus == "virtio":
dev_base = "vd" dev_base = "vd"
elif bus == "ide": elif bus == "ide":
@ -465,7 +465,7 @@ def instance(request, compute_id, vname):
meta_prealloc = request.POST.get('meta_prealloc', False) meta_prealloc = request.POST.get('meta_prealloc', False)
bus = request.POST.get('bus', default_bus) bus = request.POST.get('bus', default_bus)
cache = request.POST.get('cache', default_cache) cache = request.POST.get('cache', default_cache)
target = get_new_disk_dev(disks, bus) target = get_new_disk_dev(None, disks, bus)
path = connCreate.create_volume(storage, name, size, format, meta_prealloc, default_owner) path = connCreate.create_volume(storage, name, size, format, meta_prealloc, default_owner)
conn.attach_disk(path, target, subdriver=format, cache=cache, targetbus=bus) conn.attach_disk(path, target, subdriver=format, cache=cache, targetbus=bus)
@ -487,7 +487,7 @@ def instance(request, compute_id, vname):
format = connCreate.get_volume_type(name) format = connCreate.get_volume_type(name)
path = connCreate.get_target_path() path = connCreate.get_target_path()
target = get_new_disk_dev(disks, bus) target = get_new_disk_dev(None, disks, bus)
source = path + "/" + name; source = path + "/" + name;
conn.attach_disk(source, target, subdriver=format, cache=cache, targetbus=bus) conn.attach_disk(source, target, subdriver=format, cache=cache, targetbus=bus)
@ -523,9 +523,9 @@ def instance(request, compute_id, vname):
if 'add_cdrom' in request.POST and allow_admin_or_not_template: if 'add_cdrom' in request.POST and allow_admin_or_not_template:
bus = request.POST.get('bus', 'ide') bus = request.POST.get('bus', 'ide')
target = get_new_disk_dev(media, bus) target = get_new_disk_dev(media, disks, bus)
conn.attach_disk("", target, device='cdrom', cache='none', targetbus=bus) conn.attach_disk("", target, device='cdrom', cache='none', targetbus=bus)
msg = _('Add CD-Rom: ' + target) msg = _('Add CD-ROM: ' + target)
addlogmsg(request.user.username, instance.name, msg) addlogmsg(request.user.username, instance.name, msg)
return HttpResponseRedirect(request.get_full_path() + '#disks') return HttpResponseRedirect(request.get_full_path() + '#disks')
@ -880,12 +880,21 @@ def get_host_instances(request, comp):
info['first_user'] = None info['first_user'] = None
return info return info
# Multiple Instance Name Check
instances = Instance.objects.filter(name=inst_name) instances = Instance.objects.filter(name=inst_name)
if instances.count() > 1: if instances.count() > 1:
for i in instances: for i in instances:
user_instances_count = UserInstance.objects.filter(instance=i).count() user_instances_count = UserInstance.objects.filter(instance=i).count()
if user_instances_count == 0: if user_instances_count == 0:
addlogmsg(request.user.username, i.name, _("Deleting due to multiple records.")) addlogmsg(request.user.username, i.name, _("Deleting due to multiple(Instance Name) records."))
i.delete()
# Multiple UUID Check
instances = Instance.objects.filter(uuid=info['uuid'])
if instances.count() > 1:
for i in instances:
if i.name != inst_name:
addlogmsg(request.user.username, i.name, _("Deleting due to multiple(UUID) records."))
i.delete() i.delete()
try: try:

File diff suppressed because one or more lines are too long

View file

@ -134,7 +134,7 @@ p {
min-width: 250px; min-width: 250px;
} }
.multiselect { .multipleselect {
width:27em; width:27em;
height:10em; height:10em;
border:solid 2px #c0c0c0; border:solid 2px #c0c0c0;
@ -143,11 +143,11 @@ p {
margin: 0.9em; margin: 0.9em;
} }
.multiselect label { .multipleselect label {
display:block; display:block;
} }
.multiselect-on { .multipleselect-on {
color:#ffffff; color:#ffffff;
background-color:#000099; background-color:#000099;
} }

File diff suppressed because one or more lines are too long

9
static/js/jquery.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,227 +0,0 @@
// Morris.js Charts sample data for SB Admin template
$(function() {
// Area Chart
Morris.Area({
element: 'morris-area-chart',
data: [{
period: '2010 Q1',
iphone: 2666,
ipad: null,
itouch: 2647
}, {
period: '2010 Q2',
iphone: 2778,
ipad: 2294,
itouch: 2441
}, {
period: '2010 Q3',
iphone: 4912,
ipad: 1969,
itouch: 2501
}, {
period: '2010 Q4',
iphone: 3767,
ipad: 3597,
itouch: 5689
}, {
period: '2011 Q1',
iphone: 6810,
ipad: 1914,
itouch: 2293
}, {
period: '2011 Q2',
iphone: 5670,
ipad: 4293,
itouch: 1881
}, {
period: '2011 Q3',
iphone: 4820,
ipad: 3795,
itouch: 1588
}, {
period: '2011 Q4',
iphone: 15073,
ipad: 5967,
itouch: 5175
}, {
period: '2012 Q1',
iphone: 10687,
ipad: 4460,
itouch: 2028
}, {
period: '2012 Q2',
iphone: 8432,
ipad: 5713,
itouch: 1791
}],
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 2,
hideHover: 'auto',
resize: true
});
// Donut Chart
Morris.Donut({
element: 'morris-donut-chart',
data: [{
label: "Download Sales",
value: 12
}, {
label: "In-Store Sales",
value: 30
}, {
label: "Mail-Order Sales",
value: 20
}],
resize: true
});
// Line Chart
Morris.Line({
// ID of the element in which to draw the chart.
element: 'morris-line-chart',
// Chart data records -- each entry in this array corresponds to a point on
// the chart.
data: [{
d: '2012-10-01',
visits: 802
}, {
d: '2012-10-02',
visits: 783
}, {
d: '2012-10-03',
visits: 820
}, {
d: '2012-10-04',
visits: 839
}, {
d: '2012-10-05',
visits: 792
}, {
d: '2012-10-06',
visits: 859
}, {
d: '2012-10-07',
visits: 790
}, {
d: '2012-10-08',
visits: 1680
}, {
d: '2012-10-09',
visits: 1592
}, {
d: '2012-10-10',
visits: 1420
}, {
d: '2012-10-11',
visits: 882
}, {
d: '2012-10-12',
visits: 889
}, {
d: '2012-10-13',
visits: 819
}, {
d: '2012-10-14',
visits: 849
}, {
d: '2012-10-15',
visits: 870
}, {
d: '2012-10-16',
visits: 1063
}, {
d: '2012-10-17',
visits: 1192
}, {
d: '2012-10-18',
visits: 1224
}, {
d: '2012-10-19',
visits: 1329
}, {
d: '2012-10-20',
visits: 1329
}, {
d: '2012-10-21',
visits: 1239
}, {
d: '2012-10-22',
visits: 1190
}, {
d: '2012-10-23',
visits: 1312
}, {
d: '2012-10-24',
visits: 1293
}, {
d: '2012-10-25',
visits: 1283
}, {
d: '2012-10-26',
visits: 1248
}, {
d: '2012-10-27',
visits: 1323
}, {
d: '2012-10-28',
visits: 1390
}, {
d: '2012-10-29',
visits: 1420
}, {
d: '2012-10-30',
visits: 1529
}, {
d: '2012-10-31',
visits: 1892
}, ],
// The name of the data record attribute that contains x-visitss.
xkey: 'd',
// A list of names of data record attributes that contain y-visitss.
ykeys: ['visits'],
// Labels for the ykeys -- will be displayed when you hover over the
// chart.
labels: ['Visits'],
// Disables line smoothing
smooth: false,
resize: true
});
// Bar Chart
Morris.Bar({
element: 'morris-bar-chart',
data: [{
device: 'iPhone',
geekbench: 136
}, {
device: 'iPhone 3G',
geekbench: 137
}, {
device: 'iPhone 3GS',
geekbench: 275
}, {
device: 'iPhone 4',
geekbench: 380
}, {
device: 'iPhone 4S',
geekbench: 655
}, {
device: 'iPhone 5',
geekbench: 1571
}],
xkey: 'device',
ykeys: ['geekbench'],
labels: ['Geekbench'],
barRatio: 0.4,
xLabelAngle: 35,
hideHover: 'auto',
resize: true
});
});

View file

@ -479,13 +479,15 @@ class wvmInstance(wvmConnect):
def attach_disk(self, source, target, sourcetype='file', device='disk', driver='qemu', subdriver='raw', cache='none', targetbus='ide'): def attach_disk(self, source, target, sourcetype='file', device='disk', driver='qemu', subdriver='raw', cache='none', targetbus='ide'):
tree = ElementTree.fromstring(self._XMLDesc(0)) tree = ElementTree.fromstring(self._XMLDesc(0))
xml_disk = """ xml_disk = "<disk type='%s' device='%s'>" % (sourcetype, device)
<disk type='%s' device='%s'> if device == 'cdrom':
<driver name='%s' type='%s' cache='%s'/> xml_disk += "<driver name='%s' type='%s'/>" % (driver, subdriver)
<source file='%s'/> elif device == 'disk':
xml_disk += "<driver name='%s' type='%s' cache='%s'/>" % (driver, subdriver, cache)
xml_disk += """<source file='%s'/>
<target dev='%s' bus='%s'/> <target dev='%s' bus='%s'/>
</disk> </disk>
""" % (sourcetype, device, driver, subdriver, cache, source, target, targetbus) """ % (source, target, targetbus)
if self.get_status() == 5: if self.get_status() == 5:
devices = tree.find('devices') devices = tree.find('devices')
elm_disk = ElementTree.fromstring(xml_disk) elm_disk = ElementTree.fromstring(xml_disk)