X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fwrapper%2Fplccache.py;h=96b56465454e009f65e2a171f32895f8bfeeb384;hb=d8c4f261680cbc9cb2708cf12d97202716120dc7;hp=f872d7af6c07ab63f319253f34b49db33162aa58;hpb=90b2e8e7cb145cb1f6b3780867617084441b6ca9;p=monitor.git diff --git a/monitor/wrapper/plccache.py b/monitor/wrapper/plccache.py index f872d7a..96b5646 100755 --- a/monitor/wrapper/plccache.py +++ b/monitor/wrapper/plccache.py @@ -14,13 +14,18 @@ def dsites_from_lsites(l_sites): id2lb[site['site_id']] = site['login_base'] else: #print "Two sites have the same login_base value %s!" % site['login_base'] - sys.exit(1) + #sys.exit(1) + continue return (d_sites, id2lb) def dsn_from_dsln(d_sites, id2lb, l_nodes): lb2hn = {} dsn = {} hn2lb = {} + for id in id2lb: + if id2lb[id] not in lb2hn: + lb2hn[id2lb[id]] = [] + for node in l_nodes: # this won't reach sites without nodes, which I guess isn't a problem. if node['site_id'] in id2lb.keys(): @@ -70,6 +75,7 @@ l_nodenetworks = None plcdb_hn2lb = None plcdb_lb2hn = None plcdb_netid2ip = None +plcdb_id2lb = None def init(): global l_sites @@ -79,11 +85,12 @@ def init(): global plcdb_hn2lb global plcdb_lb2hn global plcdb_netid2ip + global plcdb_id2lb api = plc.getCachedAuthAPI() l_sites = api.GetSites({'peer_id':None}, ['login_base', 'site_id', 'abbreviated_name', 'latitude', - 'longitude', 'max_slices', 'slice_ids', 'node_ids' ]) + 'longitude', 'max_slices', 'slice_ids', 'node_ids', 'enabled' ]) l_nodes = api.GetNodes({'peer_id':None}, ['hostname', 'node_id', 'ports', 'site_id', 'version', 'last_updated', 'date_created', 'last_contact', 'pcu_ids', 'nodenetwork_ids']) @@ -97,6 +104,7 @@ def init(): plcdb_hn2lb = hn2lb plcdb_lb2hn = lb2hn plcdb_netid2ip = netid2ip + plcdb_id2lb = id2lb return l_nodes @@ -107,6 +115,7 @@ def create_plcdb(): l_sites = plc.getSites({'peer_id':None}, ['login_base', 'site_id', 'abbreviated_name', 'latitude', 'longitude', 'max_slices', 'slice_ids', 'node_ids' ]) if len(l_sites) == 0: + print "no sites! exiting..." sys.exit(1) (d_sites,id2lb) = dsites_from_lsites(l_sites)