Renew ROC key on expiration
Change-Id: Ie07e8822e8392b61787b4c10f38f6e2970135810
diff --git a/roc.py b/roc.py
index 87ba152..b193a2a 100644
--- a/roc.py
+++ b/roc.py
@@ -106,7 +106,12 @@
log.error("ROC request timeout, error={}".format(e))
sys.exit()
if response.status_code != 200:
- log.error("get_devicegroups() failed, status_code: {}".format(response.status_code))
+ log.info("Renew ROC api key")
+ self.key = self.get_key()
+ response = requests.get(url, headers=self.headers(), timeout=10)
+ if response.status_code != 200:
+ log.error("get_devicegroups() failed, status_code: {}".format(response.status_code))
+ sys.exit()
return None
return json.loads(response.text)['device-group']