Skip to content

Commit

Permalink
Merge pull request #589 from grycap/egi_brand_v2
Browse files Browse the repository at this point in the history
Egi brand v2
  • Loading branch information
micafer authored Oct 28, 2024
2 parents 07eeb5b + f7098ad commit fd32d6a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
16 changes: 14 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ def managevm(op=None, infid=None, vmid=None):
elif op == "resize":
form_data = request.form.to_dict()
cpu = int(form_data['cpu'])
memory = int(form_data['memory'])
memory = float(form_data['memory'])
gpu = int(form_data.get('gpu', 0))
disk_size = float(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 Expand Up @@ -512,7 +523,8 @@ def showinfrastructures():
infrastructures[inf_id]['cloud_type'] = infra_data["site"]["type"]
infrastructures[inf_id]['site'] = Markup(site_info)

return render_template('infrastructures.html', infrastructures=infrastructures, reload=reload_infid)
return render_template('infrastructures.html', infrastructures=infrastructures,
reload=reload_infid, inf_list=inf_list)

@app.route('/infrastructures/state')
@authorized_with_valid_token
Expand Down
3 changes: 2 additions & 1 deletion app/templates/infrastructures.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ <h4 class="font-weight-bold text-primary">My Infrastructures</h4>
<!--Table head-->
<!--Table body-->
<tbody>
{% for infId, infInfo in infrastructures.items() %}
{% for infId in inf_list %}
<tr>
{% set infInfo=infrastructures[infId] %}
<th scope="row">
{% if infInfo["name"] != "" %}
{{infInfo["name"]}}
Expand Down
22 changes: 17 additions & 5 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 @@ -326,11 +328,21 @@ <h5 class="modal-title" id="managevm_resize_label">VM resize</h5>

<div class="row form-group">
<div class="col">
CPU Number: <input name="cpu" class="col-sm-12" type="number" value="{{ cpu }}" required/>
CPU Number: <input name="cpu" class="col-sm-12" type="number" min="0" step="1" value="{{ cpu }}" required/>
</div>
<div class="col">
{% set memory_parts = memory.split() %}
Memory (GB): <input name="memory" class="col-sm-12" type="number" value="{{ memory_parts[0] | int }}" required/>
Memory (GB): <input name="memory" class="col-sm-12" type="number" min="0" value="{{ memory_parts[0] | float }}" required/>
</div>
</div>

<div class="row form-group">
<div class="col">
GPU Number: <input name="gcpu" class="col-sm-12" type="number" min="0" step="1" 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" min="0" value="{{ disk_size_parts[0] | float }}"/>
</div>
</div>

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 fd32d6a

Please sign in to comment.