1
0
Fork 0
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:
catborise 2019-01-28 16:38:15 +03:00
parent 3dc44662a0
commit a7e0e49007
2 changed files with 37 additions and 35 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 %}
@ -605,25 +603,25 @@
</div> </div>
</form> </form>
<p style="font-weight:bold;">{% trans 'Boot Order' %}</p> <p style="font-weight:bold;">{% trans 'Boot Order' %}</p>
<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">
<div class="col-sm-12 col-sm-offset-2"> <div class="col-sm-12 col-sm-offset-2">
{% ifequal status 5 %} {% ifequal status 5 %}
<p>{% trans "Enable Boot Menu for your instance when it starts up " %} <p>{% trans "Enable Boot Menu for your instance when it starts up " %}
{% ifequal bootmenu 0 %} {% ifequal bootmenu 0 %}
<input type="submit" class="btn btn-success" name="set_bootmenu" title="Show boot menu" value="{% trans "Enable" %}"> <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 %}
{% else %} {% else %}
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="Hide boot menu" value="{% trans "Disable" %}"> {% ifequal bootmenu 0 %}
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}</p>
{% endifequal %}
{% endifequal %} {% endifequal %}
{% else %} </div>
{% ifequal bootmenu 0 %}
<p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
{% endifequal %}
{% endifequal %}
</p>
</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" %} {% if status == 5 %}
<button type="submit" name="add_cdrom" type="button" class="btn btn-success pull-right" title="Add CD-Rom"> <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>
</p> {% else %}
</form> <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 %} {% endif %}
</p>
</form>
{% 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">

View file

@ -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')