skip cpu and mem check for vm creation, verify disk size before attempting to create vm

This commit is contained in:
Jordan Rodgers 2017-12-11 18:58:16 -05:00
parent 05e08fb92d
commit 2b155903fd
4 changed files with 66 additions and 82 deletions

View file

@ -9,12 +9,8 @@
<h3 class="panel-title">Create VM</h3>
</div>
<div class="panel-body">
{% if full_limits %}
<p>You have reached your limit for the following resources:</p>
{% for limit in full_limits %}
<p><strong>{{ limit }}</strong></p>
{% endfor %}
<p>Before you can create any more VMs, you must first either power off (CPU/Memory) or delete (Disk) existing VMs until you have enough resources available.</p>
{% if limits['disk'] - usage['disk'] <= 0 %}
<p>Before you can create any more VMs, you must first delete existing VMs until you have enough disk resources available.</p>
{% else %}
<div class="form-group">
<label for="name">VM Name</label>
@ -23,7 +19,7 @@
<div class="form-group">
<label for="cores">Cores</label>
<select name="cores" id="cores" class="form-control">
{% for i in range(1, limits['cpu'] - usage['cpu'] + 1) %}
{% for i in range(1, limits['cpu'] + 1) %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
@ -31,14 +27,14 @@
<div class="form-group">
<label for="mem">Memory</label>
<select name="mem" id="mem" class="form-control">
{% for i in range(1, limits['mem'] - usage['mem'] + 1) %}
{% for i in range(1, limits['mem'] + 1) %}
<option value="{{ i * 1024 }}">{{ i }}GB</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="disk">Disk</label>
<input type="text" name="disk" id="disk" class="form-control">
<input type="number" name="disk" id="disk" class="form-control" min="1" max="{{ limits['disk'] - usage['disk'] }}">
</div>
<div class="form-group">
<label for="iso">ISO</label>
@ -49,7 +45,7 @@
{% endfor %}
</select>
</div>
<button class="btn btn-success" id="create-vm" name="create">CREATE</button>
<button class="btn btn-success" id="create-vm" name="create" data-max_disk="{{ limits['disk'] - usage['disk'] }}">CREATE</button>
{% endif %}
</div>
</div>