X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=syncplcdb.py;h=6d28e34e9c7994eca0f53b64c7668498d0a06a27;hb=refs%2Fheads%2F1.0;hp=35ac57b454b98e3a65fde2332cc58c0acbdc4b3d;hpb=60a2b331c38f275e1fc3a2f0f6f22ef680754ee0;p=monitor.git diff --git a/syncplcdb.py b/syncplcdb.py index 35ac57b..6d28e34 100755 --- a/syncplcdb.py +++ b/syncplcdb.py @@ -1,12 +1,10 @@ #!/usr/bin/python import plc -from config import config -import soltesz +import config +import database import sys -config = config() - def dsites_from_lsites(l_sites): d_sites = {} id2lb = {} @@ -28,6 +26,9 @@ def dsn_from_dsln(d_sites, id2lb, l_nodes): if node['site_id'] in id2lb.keys(): login_base = id2lb[node['site_id']] else: + print "%s has a foreign site_id %s" % (node['hostname'], + node['site_id']) + continue for i in id2lb: print i, " ", id2lb[i] raise Exception, "Node has missing site id!! %s %d" %(node['hostname'], node['site_id']) @@ -50,10 +51,10 @@ def dsn_from_dsln(d_sites, id2lb, l_nodes): def create_netid2ip(l_nodes, l_nodenetworks): netid2ip = {} for node in l_nodes: - for netid in node['nodenetwork_ids']: + for netid in node['interface_ids']: found = False for nn in l_nodenetworks: - if nn['nodenetwork_id'] == netid: + if nn['interface_id'] == netid: found = True netid2ip[netid] = nn['ip'] if not found: @@ -64,13 +65,15 @@ def create_netid2ip(l_nodes, l_nodenetworks): def create_plcdb(): # get sites, and stats - l_sites = plc.getSites({'peer_id':None}, ['login_base', 'site_id', 'abbreviated_name', 'latitude', 'longitude']) + 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: sys.exit(1) (d_sites,id2lb) = dsites_from_lsites(l_sites) # get nodes at each site, and - l_nodes = plc.getNodes({'peer_id':None}, ['hostname', 'site_id', 'version', 'last_updated', 'date_created', 'last_contact', 'pcu_ids', 'nodenetwork_ids']) + l_nodes = plc.getNodes({'peer_id':None}, ['hostname', 'node_id', 'ports', 'site_id', 'version', + 'last_updated', 'date_created', 'last_contact', 'pcu_ids', 'interface_ids']) l_nodenetworks = plc.getNodeNetworks() (plcdb, hn2lb, lb2hn) = dsn_from_dsln(d_sites, id2lb, l_nodes) @@ -83,12 +86,12 @@ def create_plcdb(): if ('cachenodes' in dir(config) and config.cachenodes) or \ 'cachenodes' not in dir(config): - soltesz.dbDump("plcdb_hn2lb", hn2lb) - soltesz.dbDump("plcdb_lb2hn", lb2hn) - soltesz.dbDump("plcdb_netid2ip", netid2ip) - soltesz.dbDump("l_plcnodenetworks", l_nodenetworks) - soltesz.dbDump("l_plcnodes", l_nodes) - soltesz.dbDump("l_plcsites", l_sites) + database.dbDump("plcdb_hn2lb", hn2lb) + database.dbDump("plcdb_lb2hn", lb2hn) + database.dbDump("plcdb_netid2ip", netid2ip) + database.dbDump("l_plcnodenetworks", l_nodenetworks) + database.dbDump("l_plcnodes", l_nodes) + database.dbDump("l_plcsites", l_sites) return l_nodes