Skip to content

Commit

Permalink
Merge pull request #587 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Oct 28, 2024
2 parents 191e7a7 + 7ff63c6 commit 1529465
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ def managevm(op=None, infid=None, vmid=None):
form_data = request.form.to_dict()
cpu = int(form_data['cpu'])
memory = int(form_data['memory'])
gpu = int(form_data.get('gpu', 0))
disk_size = int(form_data.get('disk_size', 0))

vminforesp = im.get_vm_info(infid, vmid, auth_data, "text/plain")
if vminforesp.ok:
Expand All @@ -407,6 +409,15 @@ def managevm(op=None, infid=None, vmid=None):
vminfo.systems[0].delValue("memory.size")
vminfo.systems[0].addFeature(Feature("memory.size", ">=", memory, "GB"),
conflict="other", missing="other")
if gpu > 0:
vminfo.systems[0].delValue("gpu.count")
vminfo.systems[0].addFeature(Feature("gpu.count", ">=", gpu),
conflict="other", missing="other")
if disk_size > 0:
vminfo.systems[0].delValue("disks.free_size")
vminfo.systems[0].delValue("disks.0.free_size")
vminfo.systems[0].addFeature(Feature("disks.free_size", ">=", disk_size, "GB"),
conflict="other", missing="other")
response = im.resize_vm(infid, vmid, str(vminfo), auth_data)
else:
raise Exception("Error getting VM info: %s" % vminforesp.text)
Expand Down
18 changes: 15 additions & 3 deletions app/templates/vminfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ <h4 class="font-weight-bold text-primary">VM ID {{ vmid }}:</h4>
HW Features:
</th>
<td>
{% set disk_size="0.0 GB" %}
{% set gpu="0" %}
{% if 'instance_type' in vminfo %}
{% if vminfo['instance_type'] %}
{{ vminfo['instance_type'] }}<br/>
Expand All @@ -124,14 +126,14 @@ <h4 class="font-weight-bold text-primary">VM ID {{ vmid }}:</h4>
{% endif %}
{% if 'disks.free_size' in vminfo %}
, {{ vminfo['disks.free_size'] }} of HD
{% set _dummy=vminfo.pop('disks.free_size') %}
{% set disk_size=vminfo.pop('disks.free_size') %}
{% elif 'disk.0.free_size' in vminfo %}
, {{ vminfo['disk.0.free_size'] }} of HD
{% set _dummy=vminfo.pop('disk.0.free_size') %}
{% set disk_size=vminfo.pop('disk.0.free_size') %}
{% endif %}
{% if 'gpu.count' in vminfo and vminfo['gpu.count'] > 0 %}
, {{ vminfo['gpu.count'] }} GPUs
{% set _dummy=vminfo.pop('gpu.count') %}
{% set gpu=vminfo.pop('gpu.count') %}
{% if 'gpu.vendor' in vminfo or 'gpu.model' in vminfo %}
(
{% if 'gpu.model' in vminfo %}
Expand Down Expand Up @@ -334,6 +336,16 @@ <h5 class="modal-title" id="managevm_resize_label">VM resize</h5>
</div>
</div>

<div class="row form-group">
<div class="col">
GPU Number: <input name="gcpu" class="col-sm-12" type="number" value="{{ gpu }}"/>
</div>
<div class="col">
{% set disk_size_parts = disk_size.split() %}
Disk Size (GB): <input name="disk_size" class="col-sm-12" type="number" value="{{ disk_size_parts[0] | int }}"/>
</div>
</div>

</div>
<div class="modal-footer">
<a class="btn btn-secondary cancelResizeBtn" role="button" data-bs-dismiss="modal">Cancel</a>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Flask_Dance==7.1.0
Werkzeug==3.0.4
Werkzeug==3.0.6
Flask==3.0.3
requests==2.32.2
PyYAML==6.0.2
Expand Down

0 comments on commit 1529465

Please sign in to comment.