Skip to content

Commit

Permalink
Merge pull request #137 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Apr 26, 2021
2 parents 5b332de + e52a550 commit 917fd35
Show file tree
Hide file tree
Showing 4 changed files with 471 additions and 3 deletions.
36 changes: 34 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def showvminfo():
flash("Error retrieving VM info: \n" + response.text, 'error')
else:
app.logger.debug("VM Info: %s" % response.text)
vminfo = utils.format_json_radl(response.json()["radl"])
radl_json = response.json()["radl"]
outports = utils.get_out_ports(radl_json)
vminfo = utils.format_json_radl(radl_json)
if "cpu.arch" in vminfo:
del vminfo["cpu.arch"]
if "state" in vminfo:
Expand Down Expand Up @@ -280,7 +282,21 @@ def showvminfo():

cont += 1

return render_template('vminfo.html', infid=infid, vmid=vmid, vminfo=vminfo,
str_outports = ""
for port in outports:
str_outports += Markup('<i class="fas fa-project-diagram"></i> <span class="badge '
'badge-secondary">%s</span>' % port.get_remote_port())
if not port.is_range():
if port.get_remote_port() != port.get_local_port():
str_outports += Markup(' <i class="fas fa-long-arrow-alt-right">'
'</i> <span class="badge badge-secondary">%s</span>' %
port.get_local_port())
else:
str_outports += Markup(' : </i> <span class="badge badge-secondary">%s</span>' %
port.get_local_port())
str_outports += Markup('<br/>')

return render_template('vminfo.html', infid=infid, vmid=vmid, vminfo=vminfo, outports=str_outports,
state=state, nets=nets, deployment=deployment, disks=disks)

@app.route('/managevm/<op>/<infid>/<vmid>', methods=['POST'])
Expand Down Expand Up @@ -529,6 +545,15 @@ def add_auth_to_template(template, auth_data):

return template

def add_record_name_to_template(template):
# Add a random name in the DNS record name

for node in list(template['topology_template']['node_templates'].values()):
if node["type"] == "tosca.nodes.ec3.DNSRegistry":
node["properties"]["record_name"] = utils.generate_random_name()

return template

def set_inputs_to_template(template, inputs):
# Add the image to all compute nodes

Expand Down Expand Up @@ -600,6 +625,9 @@ def createdep():

template = add_auth_to_template(template, auth_data)

# Specially added for OSCAR clusters
template = add_record_name_to_template(template)

inputs = {k: v for (k, v) in form_data.items() if not k.startswith("extra_opts.")}

app.logger.debug("Parameters: " + json.dumps(inputs))
Expand Down Expand Up @@ -787,6 +815,10 @@ def manage_inf(infid=None, op=None):
force = False
if 'force' in form_data and form_data['force'] != "0":
force = True
# Specially added for OSCAR clusters
success, msg = utils.delete_dns_record(infid, im, auth_data)
if not success:
app.logger.error('Error deleting DNS record: %s', (msg))
response = im.delete_inf(infid, force, auth_data)
if not response.ok:
raise Exception(response.text)
Expand Down
10 changes: 10 additions & 0 deletions app/templates/vminfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ <h4 class="font-weight-bold text-primary">VM ID {{ vmid }}:</h4>
{{ nets }}
</td>
</tr>
{% if outports %}
<tr>
<th>
Ports:
</th>
<td>
{{ outports }}
</td>
</tr>
{% endif %}
<tr>
<th>
HW Features:
Expand Down
Loading

0 comments on commit 917fd35

Please sign in to comment.