From: Stephen Soltesz Date: Tue, 29 Jun 2010 22:23:14 +0000 (+0000) Subject: add areSlicesEnabled and isSiteEnabled convenience checks X-Git-Tag: monitor-3.1-1~12 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=1021f78d261f1dace74d5af1b464ccc02fbf4182 add areSlicesEnabled and isSiteEnabled convenience checks --- 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: