diff service/powerEagle/reader.py @ 1748:d012c53c5ae8

powereagle now registers a hostname with dhcp so we don't have to hunt for it
author drewp@bigasterisk.com
date Sat, 23 Mar 2024 14:57:59 -0700
parents bacb13c10c7a
children
line wrap: on
line diff
--- a/service/powerEagle/reader.py	Sat Dec 30 18:46:42 2023 -0800
+++ b/service/powerEagle/reader.py	Sat Mar 23 14:57:59 2024 -0700
@@ -14,7 +14,7 @@
 from starlette.routing import Route
 from starlette_exporter import PrometheusMiddleware, handle_metrics
 
-from private_config import cloudId, deviceMac, installId, macId, periodSec
+from private_config import cloudId, deviceIp, deviceMac, installId, macId, periodSec
 
 ROOM = Namespace("http://projects.bigasterisk.com/room/")
 
@@ -25,32 +25,6 @@
 auth = binascii.b2a_base64(authPlain.encode('ascii')).strip(b'=\n')
 
 
-async def getOneSseEvent(url):
-    async with aiohttp.ClientSession() as session:
-        async with session.get(url) as response:
-            line1 = None
-            async for line_in_bytes in response.content:
-                if line1 is None:
-                    line1 = line_in_bytes
-                else:
-                    return line1, line_in_bytes
-    raise ValueError
-
-
-def getJsonldValue(g, k):
-    return g[k][0]['@value']
-
-
-def ipLookup(collectorJsonLd, mac):
-    for add in collectorJsonLd['patch']['adds']:
-        for g in add['@graph']:
-            try:
-                if getJsonldValue(g, 'http://projects.bigasterisk.com/room/macAddress') == mac:
-                    return getJsonldValue(g, 'http://projects.bigasterisk.com/room/assignedIp')
-            except (KeyError, ValueError):
-                pass
-    raise ValueError
-
 
 class Poller(object):
 
@@ -59,11 +33,6 @@
         self.graph = graph
 
     async def poll(self, first_run: bool):
-        line1, line2 = await getOneSseEvent('http://collector.default.svc.cluster.local/collector/graph/lanscape')
-        p = json.loads(line2.split(b'data: ', 1)[1])
-
-        deviceIp = ipLookup(p, deviceMac)
-
         url = (f'http://{deviceIp}/cgi-bin/cgi_manager')
 
         async with aiohttp.ClientSession() as session: