Merge commit 'origin/master'
authorroot <root@blitz.inria.fr>
Sat, 26 Mar 2011 13:55:30 +0000 (14:55 +0100)
committerroot <root@blitz.inria.fr>
Sat, 26 Mar 2011 13:55:30 +0000 (14:55 +0100)
Makefile
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 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 d8f0c1d..5834f4f 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")