X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=syncplcdb.py;h=73a6e57779ef82c924f04a2d5edeb28030403c37;hb=6f2351e4b44590221425fa9b4bfa77c92db49b6a;hp=de6a474f954bfbb585a1fc66d3a6369db186a828;hpb=c3f2afdc81c6711c3825c82e2cd4970671575438;p=monitor.git diff --git a/syncplcdb.py b/syncplcdb.py index de6a474..73a6e57 100755 --- a/syncplcdb.py +++ b/syncplcdb.py @@ -1,9 +1,9 @@ #!/usr/bin/python -import plc -import config -import database import sys +from monitor.wrapper import plc +from monitor import database +from monitor import config def dsites_from_lsites(l_sites): d_sites = {} @@ -62,6 +62,44 @@ def create_netid2ip(l_nodes, l_nodenetworks): return netid2ip +l_sites = None +l_nodes = None +l_pcus = None +l_nodenetworks = None + +plcdb_hn2lb = None +plcdb_lb2hn = None +plcdb_netid2ip = None + +def init(): + global l_sites + global l_nodes + global l_pcus + global l_nodenetworks + global plcdb_hn2lb + global plcdb_lb2hn + global plcdb_netid2ip + + api = plc.getCachedAuthAPI() + l_sites = api.GetSites({'peer_id':None}, + ['login_base', 'site_id', 'abbreviated_name', 'latitude', + 'longitude', 'max_slices', 'slice_ids', 'node_ids' ]) + l_nodes = api.GetNodes({'peer_id':None}, + ['hostname', 'node_id', 'ports', 'site_id', 'version', 'last_updated', + 'date_created', 'last_contact', 'pcu_ids', 'nodenetwork_ids']) + l_pcus = api.GetPCUs() + l_nodenetworks = api.GetNodeNetworks() + + (d_sites,id2lb) = dsites_from_lsites(l_sites) + (plcdb, hn2lb, lb2hn) = dsn_from_dsln(d_sites, id2lb, l_nodes) + netid2ip = create_netid2ip(l_nodes, l_nodenetworks) + + plcdb_hn2lb = hn2lb + plcdb_lb2hn = lb2hn + plcdb_netid2ip = netid2ip + + return l_nodes + def create_plcdb(): # get sites, and stats