Skip to content

Commit

Permalink
Added more fields and missing API file
Browse files Browse the repository at this point in the history
  • Loading branch information
Soufiane Jounaid committed Mar 29, 2024
1 parent 18483eb commit e351c0a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
18 changes: 18 additions & 0 deletions chameleon/edge_hw_discovery_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import requests
import json
from django.conf import settings
import logging

logger = logging.getLogger("default")


class EDGE_HW_API:
def get_devices(self):
url = self.make_url("devices")
logger.info("Requesting %s from Edge HW API ...", url)
resp = requests.get(url)
logger.info("Response received. Parsing to json ...")
return resp.json()

def make_url(self, endpoint):
return "{0}/{1}".format(settings.EDGE_HW_ROOT, endpoint)
2 changes: 1 addition & 1 deletion chameleon/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@
# Edge HW Discovery API
#
#####
EDGE_HW_ROOT = "http://host.docker.internal:5000"
EDGE_HW_ROOT = "http://edgehwdiscovery:5000"

#####
#
Expand Down
10 changes: 10 additions & 0 deletions chameleon/templates/edge-hw-discovery/resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ <h1>CHI@Edge Hardware Discovery</h1>
<table width=100%>
<tr>
<th>Name</th>
<th>UUID</th>
<th>Type</th>
<th>Owning project</th>
<th>Device profiles</th>
<th>Authorized projects</th>
</tr>
{% for device in devices %}
<tr>
<td>{{ device.device_name }}</td>
<td>{{ device.uuid }}</td>
<td>{{ device.device_type }}</td>
<td>{{ device.owning_project }}</td>
<td>
Expand All @@ -24,6 +27,13 @@ <h1>CHI@Edge Hardware Discovery</h1>
{% endfor %}
</ul>
</td>
<td>
<ul>
{% for project in device.authorized_projects %}
<li>{{ project }}</li>
{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</table>
Expand Down
2 changes: 1 addition & 1 deletion chameleon/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def __init__(self, *args, **kwargs):
super(OIDCRegisterView, self).__init__(*args, **kwargs)
self.OIDC_OP_AUTH_ENDPOINT = self.get_settings("OIDC_OP_REGISTRATION_ENDPOINT")


def edge_hardware_discovery(request):
"""Hardware resource discovery page for CHI@Edge."""
# devices = {device['device_name']: device for device in edge_api.get_devices()}
devices = {'devices': edge_api.get_devices()}
return render(request, "edge-hw-discovery/resources.html", devices)

Expand Down

0 comments on commit e351c0a

Please sign in to comment.