use javascript for vm creation, show warnings if fields arent filled, display IP instead of MAC for interfaces

This commit is contained in:
Jordan Rodgers 2017-12-10 02:14:00 -05:00
parent 5198780746
commit 6d589f7bf8
7 changed files with 173 additions and 66 deletions

View file

@ -16,42 +16,40 @@
{% 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>
{% else %}
<form action="create" method="post">
<div class="form-group">
<label for="name">VM Name</label>
<input type="text" name="name" class="form-control">
</div>
<div class="form-group">
<label for="cores">Cores</label>
<select name="cores" class="form-control">
{% for i in range(1, 4 - usage['cpu'] + 1) %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="memory">Memory</label>
<select name="memory" class="form-control">
{% for i in range(1, 4 - usage['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" class="form-control">
</div>
<div class="form-group">
<label for="iso">ISO</label>
<select name="iso" class="form-control">
<option value="none"></option>
{% for iso in isos %}
<option value="{{ iso }}">{{ iso }}</option>
{% endfor %}
</select>
</div>
<button class="btn btn-success" type="submit" value="Create">Create</button>
</form>
<div class="form-group">
<label for="name">VM Name</label>
<input type="text" name="name" id="name" class="form-control">
</div>
<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) %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
</div>
<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) %}
<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">
</div>
<div class="form-group">
<label for="iso">ISO</label>
<select name="iso" id="iso" class="form-control">
<option value="none"></option>
{% for iso in isos %}
<option value="{{ iso }}">{{ iso }}</option>
{% endfor %}
</select>
</div>
<button class="btn btn-success" id="create-vm" name="create">CREATE</button>
{% endif %}
</div>
</div>

View file

@ -40,7 +40,7 @@
{% endfor %}
<li class="nav-header">Disks</li>
{% for disk in vm['disks'] %}
<li>{{ disk[0] }}: {{ disk[1] }}</li>
<li>{{ disk[0] }}: {{ disk[1] }} GB</li>
{% endfor %}
<li class="nav-header">ISO</li>
<li>
@ -74,7 +74,7 @@
<dt>Cores</dt>
<dd>{{ vm['config']['cores'] * vm['config'].get('sockets', 1) }}</dd>
<dt>Memory</dt>
<dd>{{ vm['config']['memory'] }} MB</dd>
<dd>{{ vm['config']['memory'] // 1024}} GB</dd>
<dt>Expiration</dt>
<dd>
{{ vm['expire'] }}