Merge commit 'origin/master'
authorroot <root@blitz.inria.fr>
Mon, 28 Mar 2011 21:04:44 +0000 (23:04 +0200)
committerroot <root@blitz.inria.fr>
Mon, 28 Mar 2011 21:04:44 +0000 (23:04 +0200)
Makefile
sfa/client/Makefile
sfa/client/sfascan.py
sfa/init.d/sfa
sfa/managers/registry_manager_pl.py
sfa/plc/api.py
sfa/plc/network.py
sfa/util/rspecHelper.py

index dfd3a8c..502c415 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -119,10 +119,13 @@ RSYNC_EXCLUDES            := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $
 RSYNC_COND_DRY_RUN     := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
 RSYNC                  := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
 
+CLIENTS = sfi.py getNodes.py getRecord.py setRecord.py \
+sfiAddAttribute.py sfiAddSliver.py sfiDeleteAttribute.py sfiDeleteSliver.py sfiListNodes.py \
+sfiListSlivers.py sfadump.py
+
 BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
        ./sfa/plc/sfa-import-plc.py ./sfa/plc/sfa-nuke-plc.py ./sfa/server/sfa-server.py \
-       ./sfa/client/sfi.py ./sfa/client/getNodes.py ./sfa/client/getRecord.py \
-       ./sfa/client/setRecord.py ./sfa/client/sfadump.py
+       $(foreach client,$(CLIENTS),./sfa/client/$(client))
 
 sync:
 ifeq (,$(SSHURL))
index 0572230..8f334b5 100644 (file)
@@ -1,5 +1,6 @@
 # recompute the SFA graphs from different locations
 
+# AMs, at least MyPLC AMs, are boring
 #BUNDLES += http://planet-lab.eu:12346/@auto-ple-am
 BUNDLES += http://planet-lab.eu:12345/@auto-ple-reg 
 BUNDLES += http://planet-lab.eu:12347/@auto-ple-sa
@@ -7,7 +8,6 @@ BUNDLES += http://planet-lab.org:12345/@auto-plc-reg
 BUNDLES += http://planet-lab.org:12347/@auto-plc-sa
 BUNDLES += http://planet-lab.kr:12345/@auto-ppk-reg 
 BUNDLES += http://planet-lab.kr:12347/@auto-ppk-sa
-BUNDLES += http://www.emulab.net:443/protogeni/xmlrpc/am/@auto-emulab-am
 BUNDLES += http://geni-myvini.umkc.gpeni.net:12345/@auto-gpeni-reg
 BUNDLES += http://geni-myvini.umkc.gpeni.net:12347/@auto-gpeni-sa
 BUNDLES += http://198.248.241.100:12345/@auto-glc-reg
@@ -19,25 +19,59 @@ BUNDLES += http://www.planet-lab.jp:12347/@auto-plj-sa
 BUNDLES += http://www.emanicslab.org:12345/@auto-elc-reg 
 BUNDLES += http://www.emanicslab.org:12347/@auto-elc-sa
 
-# dont output svg yet
-#EXTENSIONS := png svg
-EXTENSIONS := png 
+# left to right
+BUNDLES-LR += http://www.emulab.net:443/protogeni/xmlrpc/am/@auto-emulab-am
+BUNDLES-LR += http://planet-lab.eu:12345/@auto-ple-reg 
+BUNDLES-LR += http://planet-lab.eu:12347/@auto-ple-sa
+BUNDLES-LR += http://planet-lab.org:12345/@auto-plc-reg 
+BUNDLES-LR += http://planet-lab.org:12347/@auto-plc-sa
+BUNDLES-LR += http://planet-lab.kr:12345/@auto-ppk-reg 
+#BUNDLES-LR += http://planet-lab.kr:12347/@auto-ppk-sa
+BUNDLES-LR += http://geni-myvini.umkc.gpeni.net:12345/@auto-gpeni-reg
+BUNDLES-LR += http://geni-myvini.umkc.gpeni.net:12347/@auto-gpeni-sa
+BUNDLES-LR += http://198.248.241.100:12345/@auto-glc-reg
+BUNDLES-LR += http://198.248.241.100:12347/@auto-glc-sa
+BUNDLES-LR += http://vini-veritas.net:12345/@auto-vini-reg
+BUNDLES-LR += http://vini-veritas.net:12347/@auto-vini-sa
+BUNDLES-LR += http://www.planet-lab.jp:12345/@auto-plj-reg 
+BUNDLES-LR += http://www.planet-lab.jp:12347/@auto-plj-sa
+BUNDLES-LR += http://www.emanicslab.org:12345/@auto-elc-reg 
+BUNDLES-LR += http://www.emanicslab.org:12347/@auto-elc-sa
 
+EXTENSIONS := png svg
+
+####################
+ALL += $(foreach bundle,$(BUNDLES),$(word 2,$(subst @, ,$(bundle))))
+ALL += $(foreach bundle,$(BUNDLES-LR),$(word 2,$(subst @, ,$(bundle)))-lr)
+
+all: $(ALL)
+
+####################
 define bundle_scan_target
 $(word 2,$(subst @, ,$(1))):
        ./sfascan.py $(foreach extension,$(EXTENSIONS),-o $(word 2,$(subst @, ,$(1))).$(extension)) $(word 1,$(subst @, ,$(1))) >& $(word 2,$(subst @, ,$(1))).out
 .PHONY: $(word 2,$(subst @, ,$(1)))
 endef
 
-ALL := $(foreach bundle,$(BUNDLES),$(word 2,$(subst @, ,$(bundle))))
+# the actual targets
+$(foreach bundle,$(BUNDLES),$(eval $(call bundle_scan_target,$(bundle))))
 
-all: $(ALL)
+#################### same but left-to-right
+define bundle_scan_target_lr
+$(word 2,$(subst @, ,$(1)))-lr:
+       ./sfascan.py -l $(foreach extension,$(EXTENSIONS),-o $(word 2,$(subst @, ,$(1)))-lr.$(extension)) $(word 1,$(subst @, ,$(1))) >& $(word 2,$(subst @, ,$(1)))-lr.out
+.PHONY: $(word 2,$(subst @, ,$(1)))-lr
+endef
 
 # the actual targets
-$(foreach bundle,$(BUNDLES),$(eval $(call bundle_scan_target,$(bundle))))
+$(foreach bundle,$(BUNDLES-LR),$(eval $(call bundle_scan_target_lr,$(bundle))))
 
 ####################
+versions: $(VERSIONS)
+clean-versions: 
+       rm -f $(VERSIONS)
 
+#################### make name.version
 define bundle_version_target
 $(word 2,$(subst @, ,$(1))).version:
        -./sfi.py -s $(word 1,$(subst @, ,$(1))) version >& $$@
@@ -45,17 +79,18 @@ endef
 
 VERSIONS := $(foreach bundle,$(BUNDLES),$(word 2,$(subst @, ,$(bundle))).version)
 
-versions: $(VERSIONS)
-clean-versions: 
-       rm -f $(VERSIONS)
-
 # the actual targets
 $(foreach bundle,$(BUNDLES),$(eval $(call bundle_version_target,$(bundle))))
 
+####################
 clean:
        rm -f auto-*.{out,version}
        $(foreach extension,$(EXTENSIONS),rm -rf auto-*.$(extension);)
 
+PUBEXTENSIONS=png
+publish:
+       $(foreach extension,$(PUBEXTENSIONS),rsync -av auto-*.$(extension) tparment@srv-planete.inria.fr:/proj/planete/www/Thierry.Parmentelat/sfascan/ ;)
+
 #################### convenience, for debugging only
 # make +foo : prints the value of $(foo)
 # make ++foo : idem but verbose, i.e. foo=$(foo)
index 14e20ef..97457e3 100755 (executable)
@@ -16,11 +16,15 @@ import sfa.util.xmlrpcprotocol as xmlrpcprotocol
 def url_hostname_port (url):
     if url.find("://")<0:
         url="http://"+url
+    parsed_url=urlparse(url)
+    # 0(scheme) returns protocol
+    default_port='80'
+    if parsed_url[0]=='https': default_port='443'
     # 1(netloc) returns the hostname+port part
-    parts=urlparse(url)[1].split(":")
+    parts=parsed_url[1].split(":")
     # just a hostname
     if len(parts)==1:
-        return (url,parts[0],'80')
+        return (url,parts[0],default_port)
     else:
         return (url,parts[0],parts[1])
 
@@ -123,11 +127,14 @@ class Interface:
 class SfaScan:
 
     # provide the entry points (a list of interfaces)
-    def __init__ (self):
-        pass
+    def __init__ (self, left_to_right=False, verbose=False):
+        self.verbose=verbose
+        self.left_to_right=left_to_right
 
     def graph (self,entry_points):
         graph=pygraphviz.AGraph(directed=True)
+        if self.left_to_right: 
+            graph.graph_attr['rankdir']='LR'
         self.scan(entry_points,graph)
         return graph
     
@@ -150,9 +157,21 @@ class SfaScan:
             for interface in to_scan:
                 # performing xmlrpc call
                 version=interface.get_version()
-                # 'sfa' is expected if the call succeeded at all
+                if self.verbose:
+                    sfa_logger().info("GetVersion at interface %s"%interface.url())
+                    if not version:
+                        sfa_logger().info("<EMPTY GetVersion(); offline or cannot authenticate>")
+                    else: 
+                        for (k,v) in version.iteritems(): 
+                            if not isinstance(v,dict):
+                                sfa_logger().info("\r\t%s:%s"%(k,v))
+                            else:
+                                sfa_logger().info(k)
+                                for (k1,v1) in v.iteritems():
+                                    sfa_logger().info("\r\t\t%s:%s"%(k1,v1))
+                # 'geni_api' is expected if the call succeeded at all
                 # 'peers' is needed as well as AMs typically don't have peers
-                if 'sfa' in version and 'peers' in version: 
+                if 'geni_api' in version and 'peers' in version: 
                     # proceed with neighbours
                     for (next_name,next_url) in version['peers'].items():
                         next_interface=Interface(next_url)
@@ -187,13 +206,17 @@ def main():
     parser=OptionParser(usage=usage)
     parser.add_option("-o","--output",action='append',dest='outfiles',default=[],
                       help="output filenames (cumulative) - defaults are %r"%default_outfiles)
+    parser.add_option("-l","--left-to-right",action="store_true",dest="left_to_right",default=False,
+                      help="instead of top-to-bottom")
+    parser.add_option("-v","--verbose",action='store_true',dest='verbose',default=False,
+                      help="verbose")
     (options,args)=parser.parse_args()
     if not args:
         parser.print_help()
         sys.exit(1)
     if not options.outfiles:
         options.outfiles=default_outfiles
-    scanner=SfaScan()
+    scanner=SfaScan(left_to_right=options.left_to_right, verbose=options.verbose)
     entries = [ Interface(entry) for entry in args ]
     g=scanner.graph(entries)
     sfa_logger().info("creating layout")
index 73b228e..b039c24 100755 (executable)
@@ -2,13 +2,11 @@
 #
 # sfa   Wraps PLCAPI into the SFA compliant API
 #
-# chkconfig: 2345 5 99
+# hopefully right after plc
+# chkconfig: 2345 61 39
 #
 # description:   Wraps PLCAPI into the SFA compliant API
 #
-# $Id$
-# $URL$
-#
 
 # Source config
 [ -f /etc/sfa/sfa_config ] && . /etc/sfa/sfa_config
index 135fd8d..8df0891 100644 (file)
@@ -87,14 +87,14 @@ def get_credential(api, xrn, type, is_self=False):
 
 def resolve(api, xrns, type=None, full=True):
 
-    # load all know registry names into a prefix tree and attempt to find
+    # load all known registry names into a prefix tree and attempt to find
     # the longest matching prefix
     if not isinstance(xrns, types.ListType):
         if not type:
             type = Xrn(xrns).get_type()
         xrns = [xrns]
     hrns = [urn_to_hrn(xrn)[0] for xrn in xrns] 
-    # create a dict whre key is an registry hrn and its value is a
+    # create a dict where key is a registry hrn and its value is a
     # hrns at that registry (determined by the known prefix tree).  
     xrn_dict = {}
     registries = api.registries
index 2ad969f..d4781f3 100644 (file)
@@ -338,8 +338,11 @@ class SfaAPI(BaseAPI):
                         break
             # fill in key info
             if record['type'] == 'user':
-                pubkeys = [keys[key_id]['key'] for key_id in record['key_ids'] if key_id in keys] 
-                record['keys'] = pubkeys
+                if 'key_ids' not in record:
+                    self.logger.info("user record has no 'key_ids' - need to import from myplc ?")
+                else:
+                    pubkeys = [keys[key_id]['key'] for key_id in record['key_ids'] if key_id in keys] 
+                    record['keys'] = pubkeys
 
         # fill in record hrns
         records = self.fill_record_hrns(records)   
index 71f0bd1..c84ffa5 100644 (file)
@@ -1,13 +1,15 @@
 from __future__ import with_statement
+import sys
 import re
 import socket
+from StringIO import StringIO
+from lxml import etree
+from xmlbuilder import XMLBuilder
+
+from sfa.util.faults import *
+#from sfa.util.sfalogging import sfa_logger
 from sfa.util.xrn import get_authority
 from sfa.util.plxrn import hrn_to_pl_slicename, hostname_to_urn
-from sfa.util.faults import *
-from xmlbuilder import XMLBuilder
-from lxml import etree
-import sys
-from StringIO import StringIO
 
 class Sliver:
     def __init__(self, node):
index 6cac3b3..f6c860b 100755 (executable)
@@ -79,20 +79,27 @@ class RSpec:
         if len(networks) == 1:
             self.network = networks[0]
 
+    # Thierry : need this to locate hostname even if several networks
     def get_node_element(self, hostname, network=None):
-        if network == None:
+        if network == None and self.network:
             network = self.network
-        names = self.rspec.iterfind("./network[@name='%s']/site/node/hostname" % network)
+        if network != None:
+            names = self.rspec.iterfind("./network[@name='%s']/site/node/hostname" % network)
+        else:
+            names = self.rspec.iterfind("./network/site/node/hostname")
         for name in names:
             if name.text == hostname:
                 return name.getparent()
         return None
         
+    # Thierry : need this to return all nodes in all networks
     def get_node_list(self, network=None):
-        if network == None:
+        if network == None and self.network:
             network = self.network
-        result = self.rspec.xpath("./network[@name='%s']/site/node/hostname/text()" % network)
-        return result
+        if network != None:
+            return self.rspec.xpath("./network[@name='%s']/site/node/hostname/text()" % network)
+        else:
+            return self.rspec.xpath("./network/site/node/hostname/text()")
 
     def get_network_list(self):
         return self.rspec.xpath("./network[@name]/@name")