mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Make visible add cdrom/media space/button even if instance is running. Check media and disk for cdrom target dev
This commit is contained in:
parent
3dc44662a0
commit
a7e0e49007
2 changed files with 37 additions and 35 deletions
|
@ -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">
|
||||||
|
@ -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">
|
||||||
|
|
|
@ -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')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue