git://git.onelab.eu
/
myplc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
httpd takes care of /var/log/plcapi.log and permissions
[myplc.git]
/
bin
/
check-hrns.py
diff --git
a/bin/check-hrns.py
b/bin/check-hrns.py
index
7c8bdef
..
e5ac4dc
100755
(executable)
--- a/
bin/check-hrns.py
+++ b/
bin/check-hrns.py
@@
-5,11
+5,7
@@
from optparse import OptionParser
from PLC.Namespace import hostname_to_hrn, email_to_hrn, slicename_to_hrn
# (auth_hrn, email):
from PLC.Namespace import hostname_to_hrn, email_to_hrn, slicename_to_hrn
# (auth_hrn, email):
-try:
- from sfa.util.config import Config
- toplevel=Config().SFA_INTERFACE_HRN
-except:
- toplevel=api.config.PLC_HRN_ROOT
+toplevel=api.config.PLC_HRN_ROOT
def handle_nodes (sites,sites_by_id, dry_run, verbose):
nodes=GetNodes ({'peer_id':None},['node_id','hostname','hrn'])
def handle_nodes (sites,sites_by_id, dry_run, verbose):
nodes=GetNodes ({'peer_id':None},['node_id','hostname','hrn'])
@@
-21,7
+17,8
@@
def handle_nodes (sites,sites_by_id, dry_run, verbose):
except: print 'cannot find node %s'%node_id; continue
hrn=hostname_to_hrn (toplevel, login_base, node['hostname'])
if node['hrn'] != hrn:
except: print 'cannot find node %s'%node_id; continue
hrn=hostname_to_hrn (toplevel, login_base, node['hostname'])
if node['hrn'] != hrn:
- print "Node %s - current hrn %s, should be %s"%(node['hostname'], node['hrn'], hrn)
+ if verbose:
+ print "Node %s - current hrn %s, should be %s"%(node['hostname'], node['hrn'], hrn)
if dry_run: continue
SetNodeHrn (node['node_id'],hrn)
else:
if dry_run: continue
SetNodeHrn (node['node_id'],hrn)
else:
@@
-42,7
+39,8
@@
def handle_persons (sites,sites_by_id, dry_run,verbose):
hrn=email_to_hrn ("%s.%s"%(toplevel,login_base),person['email'])
if person['hrn'] != hrn:
hrn=email_to_hrn ("%s.%s"%(toplevel,login_base),person['email'])
if person['hrn'] != hrn:
- print "Person %s - current hrn %s, should be %s"%(person['email'], person['hrn'], hrn)
+ if verbose:
+ print "Person %s - current hrn %s, should be %s"%(person['email'], person['hrn'], hrn)
if dry_run: continue
SetPersonHrn (person['person_id'],hrn)
else:
if dry_run: continue
SetPersonHrn (person['person_id'],hrn)
else:
@@
-59,7
+57,8
@@
def handle_slices (sites,sites_by_id, dry_run,verbose):
except: print 'cannot find slice %s'%slice_id; continue
hrn=slicename_to_hrn (toplevel, slice['name'])
if slice['hrn'] != hrn:
except: print 'cannot find slice %s'%slice_id; continue
hrn=slicename_to_hrn (toplevel, slice['name'])
if slice['hrn'] != hrn:
- print "Slice %s - current hrn %s, should be %s"%(slice['name'], slice['hrn'], hrn)
+ if verbose:
+ print "Slice %s - current hrn %s, should be %s"%(slice['name'], slice['hrn'], hrn)
if dry_run: continue
SetSliceHrn (slice['slice_id'],hrn)
else:
if dry_run: continue
SetSliceHrn (slice['slice_id'],hrn)
else:
@@
-70,7
+69,8
@@
def handle_sites (sites,sites_by_id, dry_run,verbose):
for site in sites:
hrn='.'.join([toplevel, site['login_base']])
if site['hrn'] != hrn:
for site in sites:
hrn='.'.join([toplevel, site['login_base']])
if site['hrn'] != hrn:
- print "Site %s - current hrn %s, should be %s"%(site['name'], site['hrn'], hrn)
+ if verbose:
+ print "Site %s - current hrn %s, should be %s"%(site['name'].encode('ascii', 'ignore'), site['hrn'], hrn)
if dry_run: continue
SetSiteHrn (site['site_id'],hrn)
else:
if dry_run: continue
SetSiteHrn (site['site_id'],hrn)
else:
@@
-112,9
+112,9
@@
Example:
dry_run=options.show
verbose=options.verbose
# optimizing : we compute the set of sites only once
dry_run=options.show
verbose=options.verbose
# optimizing : we compute the set of sites only once
- sites = GetSites({'peer_id':None},['site_id','login_base','node_ids','person_ids','name','hrn'])
+ sites = GetSites({'peer_id':None},['site_id','login_base','node_ids','person_ids','name','hrn'
,'slice_ids', 'sfa_created'
])
# remove external sites created through SFA
# remove external sites created through SFA
- sites = [site for site in sites if
not site['name'].startswith('sfa:')
]
+ sites = [site for site in sites if
site['sfa_created'] != 'True'
]
sites_by_id = dict ( [ (site['site_id'], site) for site in sites ] )
if options.nodes: handle_nodes(sites,sites_by_id,dry_run,verbose)
sites_by_id = dict ( [ (site['site_id'], site) for site in sites ] )
if options.nodes: handle_nodes(sites,sites_by_id,dry_run,verbose)