mirror of
				https://github.com/retspen/webvirtcloud
				synced 2025-07-31 12:41:08 +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">
 | 
			
		||||
                                                            <table class="table">
 | 
			
		||||
                                                                <thead>
 | 
			
		||||
                                                                    <tr>
 | 
			
		||||
                                                                        <th>{% trans "Name" %}</th>
 | 
			
		||||
                                                                        <th>{% trans "Date" %}</th>
 | 
			
		||||
                                                                        <th colspan="2">{% trans "Action" %}</th>
 | 
			
		||||
                                                                    </tr>
 | 
			
		||||
                                                                    <th>{% trans "Name" %}</th>
 | 
			
		||||
                                                                    <th>{% trans "Date" %}</th>
 | 
			
		||||
                                                                    <th colspan="2">{% trans "Action" %}</th>
 | 
			
		||||
                                                                </thead>
 | 
			
		||||
                                                                <tbody>
 | 
			
		||||
                                                                {% for snap in snapshots %}
 | 
			
		||||
| 
						 | 
				
			
			@ -605,25 +603,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" %}">
 | 
			
		||||
                                                        <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 %}
 | 
			
		||||
                                                                {% 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 %}
 | 
			
		||||
                                                            {% else %}
 | 
			
		||||
                                                                {% ifequal bootmenu 0  %}
 | 
			
		||||
                                                                    <p>{% trans "**** Please shutdown instance to modify boot menu ****" %}
 | 
			
		||||
                                                                {% endifequal %}
 | 
			
		||||
                                                            {% endifequal %}
 | 
			
		||||
                                                            </p>
 | 
			
		||||
                                                                </div>
 | 
			
		||||
                                                            </div>
 | 
			
		||||
                                                        </div>
 | 
			
		||||
                                                    </form>
 | 
			
		||||
                                                        </form>
 | 
			
		||||
                                                    </p>
 | 
			
		||||
                                                    {% ifequal bootmenu 1  %}
 | 
			
		||||
                                                        <div class="col-sm-6 col-sm-offset-2">
 | 
			
		||||
                                                        <div class="well">
 | 
			
		||||
| 
						 | 
				
			
			@ -665,16 +663,20 @@
 | 
			
		|||
                                                    <div class="clearfix"></div>
 | 
			
		||||
                                                </div>
 | 
			
		||||
                                                <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 %}
 | 
			
		||||
                                                            <p style="font-weight:bold;">
 | 
			
		||||
                                                                {% trans "Instance Media" %}
 | 
			
		||||
                                                                <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>
 | 
			
		||||
                                                                </button>
 | 
			
		||||
                                                            </p>
 | 
			
		||||
                                                        </form>
 | 
			
		||||
                                                <form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
 | 
			
		||||
                                                    <p style="font-weight:bold;">
 | 
			
		||||
                                                        {% trans "Instance Media" %}
 | 
			
		||||
                                                        {% 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>
 | 
			
		||||
                                                            </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>
 | 
			
		||||
                                                </form>
 | 
			
		||||
                                                    {% for cd in media %}
 | 
			
		||||
                                                        <form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
 | 
			
		||||
                                                            <div class="form-group">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ def instance(request, compute_id, vname):
 | 
			
		|||
                msg += " (%s > %s)" % (disk_size, ua.max_disk_size)
 | 
			
		||||
        return msg
 | 
			
		||||
 | 
			
		||||
    def get_new_disk_dev(disks, bus):
 | 
			
		||||
    def get_new_disk_dev(media, disks, bus):
 | 
			
		||||
        if bus == "virtio":
 | 
			
		||||
            dev_base = "vd"
 | 
			
		||||
        elif bus == "ide":
 | 
			
		||||
| 
						 | 
				
			
			@ -465,7 +465,7 @@ def instance(request, compute_id, vname):
 | 
			
		|||
                meta_prealloc = request.POST.get('meta_prealloc', False)
 | 
			
		||||
                bus = request.POST.get('bus', default_bus)
 | 
			
		||||
                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)
 | 
			
		||||
                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)
 | 
			
		||||
                path = connCreate.get_target_path()
 | 
			
		||||
                target = get_new_disk_dev(disks, bus)
 | 
			
		||||
                target = get_new_disk_dev(None, disks, bus)
 | 
			
		||||
                source = path + "/" + name;
 | 
			
		||||
 | 
			
		||||
                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:
 | 
			
		||||
                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)
 | 
			
		||||
                msg = _('Add CD-Rom: ' + target)
 | 
			
		||||
                msg = _('Add CD-ROM: ' + target)
 | 
			
		||||
                addlogmsg(request.user.username, instance.name, msg)
 | 
			
		||||
                return HttpResponseRedirect(request.get_full_path() + '#disks')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue