From 1021f78d261f1dace74d5af1b464ccc02fbf4182 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 29 Jun 2010 22:23:14 +0000 Subject: [PATCH] add areSlicesEnabled and isSiteEnabled convenience checks --- monitor/wrapper/plc.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/monitor/wrapper/plc.py b/monitor/wrapper/plc.py index 8113c57..97200d9 100644 --- a/monitor/wrapper/plc.py +++ b/monitor/wrapper/plc.py @@ -436,6 +436,35 @@ def enableSliceCreation(nodename): loginbase = siteId(nodename) enableSiteSliceCreation(loginbase) +def areSlicesEnabled(site): + + try: + slice_list = api.GetSlices(slices(site)) + if len(slice_list) == 0: + return None + for slice in slice_list: + slice_id = slice['slice_id'] + l_attr = api.GetSliceAttributes({'slice_id': slice_id}) + for attr in l_attr: + if "enabled" == attr['name'] and attr['value'] == "0": + return False + + except Exception, exc: + pass + + return True + + +def isSiteEnabled(site): + try: + site = api.GetSites(site)[0] + return site['enabled'] + except: + pass + + return True + + def isTagCurrent(tags): if len(tags) > 0: for tag in tags: -- 2.43.0