Basic ping test
Change-Id: Ib61ebd3963db46118a0d8f5c4cea0e002f48aa9a
diff --git a/roc.py b/roc.py
index 9d9478f..ede71f7 100644
--- a/roc.py
+++ b/roc.py
@@ -5,10 +5,13 @@
import requests
import json
+# noinspection PyUnresolvedReferences
from requests.structures import CaseInsensitiveDict
import logging as log
import pyaml
+from device import Device
+
URL = "https://roc.menlo.aetherproject.org/aether-roc-api/aether/v4.0.0/connectivity-service-v4/"
@@ -51,6 +54,7 @@
if response.status_code != 201:
log.error("Failed to set mbr, device_group:{}, mbr:{}, status_code: {}".format(device_group, mbr,
response.status_code))
+ # noinspection PyUnresolvedReferences
sys.exit()
def get_key(self):
@@ -92,11 +96,11 @@
return None
return json.loads(response.text)
- def get_devicegroup(self):
+ def get_devicegroups(self):
url = URL + "device-group"
response = requests.get(url, headers=self.headers())
if response.status_code != 200:
- log.error("get_devicegroup() failed, status_code: {}".format(response.status_code))
+ log.error("get_devicegroups() failed, status_code: {}".format(response.status_code))
return None
return json.loads(response.text)['device-group']
@@ -108,14 +112,20 @@
return None
return json.loads(response.text)['ip-domain']
- def get_imsi(self):
- imsis = {} # imsi-id:imsi
- devicegroups = self.get_devicegroup()
+ def get_devices(self):
+ imsis = {}
+ devicegroups = self.get_devicegroups()
for devicegroup in devicegroups:
- for imsi in devicegroup['imsis']:
- imsis[imsi['imsi-id']] = imsi['imsi-range-from']
+ for device in devicegroup['imsis']:
+ imsis[device['imsi-id']] = device['imsi-range-from']
return imsis
+ def update_devices(self, devices):
+ dgs = self.get_devicegroups()
+ for dg in dgs:
+ for d in dg['imsis']:
+ devices[str(d['imsi-range-from'])] = Device(str(d['imsi-id']), d['imsi-range-from'])
+
def get_subnet(self):
subnets = {}
ip_domains = self.get_ipdomain()
@@ -128,7 +138,7 @@
print(pyaml.dump(self.get_enterprise()))
print(pyaml.dump(self.get_site()))
print(pyaml.dump(self.get_upf()))
- print(pyaml.dump(self.get_devicegroup()))
+ print(pyaml.dump(self.get_devicegroups()))
print(pyaml.dump(self.get_ipdomain()))
@@ -140,7 +150,7 @@
print(pyaml.dump(roc.get_enterprise()))
print(pyaml.dump(roc.get_site()))
print(pyaml.dump(roc.get_upf()))
- print(pyaml.dump(roc.get_devicegroup()))
+ print(pyaml.dump(roc.get_devicegroups()))
print(pyaml.dump(roc.get_ipdomain()))
cameras = "menlo-4g-cameras"