merges master (so, no sfa-cm anymore)
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 17 Jan 2013 18:36:21 +0000 (19:36 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 17 Jan 2013 18:36:21 +0000 (19:36 +0100)
debian/control
setup.py
sfa.spec
sfa/dummy/dummy_testbed_api.py
sfa/dummy/dummyaggregate.py
sfa/dummy/dummydriver.py
sfa/dummy/dummyslices.py
sfa/dummy/dummyxrn.py
sfa/managers/registry_manager.py
sfa/planetlab/pldriver.py

index 64c00c1..0b7e461 100644 (file)
@@ -32,11 +32,6 @@ Architecture: any
 Depends: sfa-common
 Description: the SFA layer around MyPLC
 
-Package: sfa-cm
-Architecture: any
-Depends: sfa-common
-Description: the SFA layer around MyPLC NodeManager
-
 Package: sfa-federica
 Architecture: any
 Depends: sfa-common
index 55a7b47..61757df 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -15,9 +15,9 @@ scripts = glob("clientbin/*.py") + \
     [ 
     'config/sfa-config-tty',
     'config/sfa-config',
-    'config/gen-sfa-cm-config.py',
+#    'config/gen-sfa-cm-config.py',
     'sfa/server/sfa-start.py', 
-    'sfa/server/sfa_component_setup.py', 
+#    'sfa/server/sfa_component_setup.py', 
     'sfatables/sfatables',
     'keyconvert/keyconvert.py',
     'flashpolicy/sfa_flashpolicy.py',
@@ -48,8 +48,9 @@ packages = [
     'sfatables/processors',
     ]
 
-# need to do something about functions
-initscripts = [ 'sfa', 'sfa-cm', 'functions.sfa' ]
+initscripts = [ 'sfa', 
+                'functions.sfa',
+                ]
 
 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
                               'config/registries.xml',
index f901231..fc1aff5 100644 (file)
--- a/sfa.spec
+++ b/sfa.spec
@@ -77,11 +77,11 @@ Summary: the SFA layer around MyPLC
 Group: Applications/System
 Requires: sfa
 
-%package cm
-Summary: the SFA layer around MyPLC NodeManager
-Group: Applications/System
-Requires: sfa
-Requires: pyOpenSSL >= 0.6
+#%package cm
+#Summary: the SFA layer around MyPLC NodeManager
+#Group: Applications/System
+#Requires: sfa
+#Requires: pyOpenSSL >= 0.6
 
 %package federica
 Summary: the SFA layer around Federica
@@ -127,9 +127,9 @@ sfi.py, together with other utilities.
 This package implements the SFA interface which serves as a layer
 between the existing PlanetLab interfaces and the SFA API.
 
-%description cm
-This package implements the SFA interface which serves as a layer
-between the existing PlanetLab NodeManager interfaces and the SFA API.
+#%description cm
+#This package implements the SFA interface which serves as a layer
+#between the existing PlanetLab NodeManager interfaces and the SFA API.
 
 %description federica
 The SFA driver for FEDERICA.
@@ -216,12 +216,12 @@ rm -rf $RPM_BUILD_ROOT
 /etc/sfa/xml.xsd
 /etc/sfa/protogeni-rspec-common.xsd
 /etc/sfa/topology
-%{_bindir}/gen-sfa-cm-config.py*
+#%{_bindir}/gen-sfa-cm-config.py*
 
-%files cm
-/etc/init.d/sfa-cm
-%{_bindir}/sfa_component_setup.py*
-# cron jobs here 
+#%files cm
+#/etc/init.d/sfa-cm
+#%{_bindir}/sfa_component_setup.py*
+## cron jobs here 
 
 %files federica
 %{python_sitelib}/sfa/federica
@@ -256,18 +256,18 @@ fi
 %postun
 [ "$1" -ge "1" ] && { service sfa dbdump ; service sfa restart ; }
 
-### sfa-cm installs the 'sfa-cm' service
-%post cm
-chkconfig --add sfa-cm
-
-%preun cm
-if [ "$1" = 0 ] ; then
-   /sbin/service sfa-cm stop || :
-   /sbin/chkconfig --del sfa-cm || :
-fi
-
-%postun cm
-[ "$1" -ge "1" ] && service sfa-cm restart || :
+#### sfa-cm installs the 'sfa-cm' service
+#%post cm
+#chkconfig --add sfa-cm
+#
+#%preun cm
+#if [ "$1" = 0 ] ; then
+#   /sbin/service sfa-cm stop || :
+#   /sbin/chkconfig --del sfa-cm || :
+#fi
+#
+#%postun cm
+#[ "$1" -ge "1" ] && service sfa-cm restart || :
 
 %changelog
 * Sun Dec 16 2012 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - sfa-2.1-22
index f40a853..f37e52c 100644 (file)
@@ -29,9 +29,12 @@ def FilterList(myfilter, mylist):
     result.extend(mylist)
     for item in mylist:
          for key in myfilter.keys():
-             if myfilter[key] != item[key]:
-                result.remove(item)
-                break
+             if 'ids' in key:
+                 pass
+             else:
+                 if myfilter[key] != item[key]:
+                     result.remove(item)
+                     break
     return result
 
 
@@ -132,7 +135,10 @@ def AddUserKey(param):
     try:
         for user in DB['users_list']:
              if param['user_id'] == user['user_id']:
-                 user['keys'].append(param['key'])
+                 if 'keys' in user.keys():
+                     user['keys'].append(param['key'])
+                 else:
+                    user['keys'] = [param['key']] 
                  return True
         return False
     except:
index 53f3de9..99127d7 100644 (file)
@@ -43,7 +43,9 @@ class DummyAggregate:
         slice = slices[0]
         
         # sort slivers by node id 
-        slice_nodes = self.driver.shell.GetNodes({'node_ids': slice['node_ids']})   
+        slice_nodes = []
+        if 'node_ids' in slice.keys():
+            slice_nodes = self.driver.shell.GetNodes({'node_ids': slice['node_ids']}) 
         for node in slice_nodes:
             slivers[node['node_id']] = node  
 
@@ -53,7 +55,7 @@ class DummyAggregate:
         # if we are dealing with a slice that has no node just return 
         # and empty list    
         if slice_xrn:
-            if not slice or not slice['node_ids']:
+            if not slice or 'node_ids' not in slice.keys() or not slice['node_ids']:
                 return []
 
         filter = {}
index 1fd0843..5f3138f 100644 (file)
@@ -359,7 +359,9 @@ class DummyDriver (Driver):
     def update_relation (self, subject_type, target_type, relation_name, subject_id, target_ids):
         # hard-wire the code for slice/user for now, could be smarter if needed
         if subject_type =='slice' and target_type == 'user' and relation_name == 'researcher':
-            subject=self.shell.GetSlices (subject_id)[0]
+            subject=self.shell.GetSlices ({'slice_id': subject_id})[0]
+            if 'user_ids' not in subject.keys():
+                 subject['user_ids'] = []
             current_target_ids = subject['user_ids']
             add_target_ids = list ( set (target_ids).difference(current_target_ids))
             del_target_ids = list ( set (current_target_ids).difference(target_ids))
@@ -487,9 +489,9 @@ class DummyDriver (Driver):
         requested_attributes = rspec.version.get_slice_attributes()
         
         # ensure slice record exists
-        slice = slices.verify_slice(slice_hrn, slice_record, peer, sfa_peer, options=options)
+        slice = slices.verify_slice(slice_hrn, slice_record, sfa_peer, options=options)
         # ensure user records exists
-        users = slices.verify_users(slice_hrn, slice, users, peer, sfa_peer, options=options)
+        #users = slices.verify_users(slice_hrn, slice, users, sfa_peer, options=options)
         
         # add/remove slice from nodes
         requested_slivers = []
@@ -501,7 +503,11 @@ class DummyDriver (Driver):
                 hostname = xrn_to_hostname(node.get('component_id').strip())
             if hostname:
                 requested_slivers.append(hostname)
-        nodes = slices.verify_slice_nodes(slice, requested_slivers, peer) 
+        requested_slivers_ids = []
+        for hostname in requested_slivers:
+            node_id = self.shell.GetNodes({'hostname': hostname})[0]['node_id']
+            requested_slivers_ids.append(node_id) 
+        nodes = slices.verify_slice_nodes(slice, requested_slivers_ids) 
     
         return aggregate.get_rspec(slice_xrn=slice_urn, version=rspec.version)
 
index a0ff74a..94f226c 100644 (file)
@@ -68,10 +68,11 @@ class DummySlices:
         return sfa_peer
 
 
-    def verify_slice_nodes(self, slice, requested_slivers, peer):
-        
+    def verify_slice_nodes(self, slice, requested_slivers):
+        if 'node_ids' not in slice.keys():
+            slice['node_ids']=[] 
         nodes = self.driver.shell.GetNodes({'node_ids': slice['node_ids']})
-        current_slivers = [node['hostname'] for node in nodes]
+        current_slivers = [node['node_id'] for node in nodes]
 
         # remove nodes not in rspec
         deleted_nodes = list(set(current_slivers).difference(requested_slivers))
@@ -89,7 +90,7 @@ class DummySlices:
 
         
 
-    def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, options={}):
+    def verify_slice(self, slice_hrn, slice_record, sfa_peer, options={}):
         slicename = hrn_to_dummy_slicename(slice_hrn)
         parts = slicename.split("_")
         login_base = parts[0]
@@ -109,14 +110,15 @@ class DummySlices:
        
         return slice
 
-    def verify_users(self, slice_hrn, slice_record, users, peer, sfa_peer, options={}):
+    def verify_users(self, slice_hrn, slice_record, users, sfa_peer, options={}):
         users_by_email = {}
         users_dict = {} 
+        users_by_site = {}
         for user in users:
             user['urn'] = user['urn'].lower()
             hrn, type = urn_to_hrn(user['urn'])
             username = get_leaf(hrn)
-            login_base = PlXrn(xrn=user['urn']).pl_login_base()
+            login_base = DummyXrn(xrn=user['urn']).dummy_login_base()
             user['username'] = username
             user['site'] = login_base
 
@@ -204,7 +206,7 @@ class DummySlices:
         # update_existing users
         updated_users_list = [user for user in users_dict.values() if user['email'] in \
           updated_user_ids]
-        self.verify_keys(existing_slice_users, updated_users_list, peer, options)
+        self.verify_keys(existing_slice_users, updated_users_list, options)
 
         added_persons = []
         # add new users
@@ -220,8 +222,6 @@ class DummySlices:
                 'key_ids': added_user.get('key_ids', []),
             }
             person['person_id'] = self.driver.shell.AddPerson(person)
-            if peer:
-                person['peer_person_id'] = added_user['person_id']
             added_persons.append(person)
            
             # enable the account 
@@ -250,7 +250,7 @@ class DummySlices:
         return added_persons
             
 
-    def verify_keys(self, old_users, new_users, peer, options={}):
+    def verify_keys(self, old_users, new_users, options={}):
         # existing keys 
         existing_keys = []
         for user in old_users:
index 6c06b8b..05c3681 100644 (file)
@@ -60,7 +60,7 @@ class DummyXrn (Xrn):
         sliver_id_parts = leaf.split(':')
         name = sliver_id_parts[0]
         name = re.sub('[^a-zA-Z0-9_]', '', name)
-        return self.pl_login_base() + '_' + name
+        return name
 
     #def hrn_to_pl_authname(hrn):
     def dummy_authname (self):
@@ -71,7 +71,7 @@ class DummyXrn (Xrn):
         self._normalize()
         return self.leaf
 
-    def pl_login_base (self):
+    def dummy_login_base (self):
         self._normalize()
         if self.type and self.type.startswith('authority'):
             base = self.leaf 
index 95b4ed2..c29130a 100644 (file)
@@ -400,12 +400,16 @@ class RegistryManager:
         # anyway the driver should receive an object 
         # (and then extract __dict__ itself if needed)
         print "DO NOT REMOVE ME before driver.update, record=%s"%record
-        (pointer, new_key_pointer) = self.driver.update (record.__dict__, new_record.__dict__, hrn, new_key)
-        if new_key and new_key_pointer:    
+        new_key_pointer = -1
+        try:
+           (pointer, new_key_pointer) = self.driver.update (record.__dict__, new_record.__dict__, hrn, new_key)
+        except:
+           pass
+        if new_key and new_key_pointer:
             record.reg_keys=[ RegKey (new_key, new_key_pointer)]
             record.gid = gid
 
-        dbsession.commit();
+        dbsession.commit()
         # update membership for researchers, pis, owners, operators
         self.update_driver_relations (record, new_record)
         
index c3d14ea..15442f5 100644 (file)
@@ -124,7 +124,7 @@ class PlDriver (Driver):
                 self.shell.AddPersonKey(pointer, {'key_type' : 'ssh', 'key' : pub_key})
 
         elif type == 'node':
-            login_base = PlXrn(xrn=sfa_record['authority'],type='node').pl_login_base()
+            login_base = PlXrn(xrn=sfa_record['authority'],type='authority').pl_login_base()
             nodes = self.shell.GetNodes([pl_record['hostname']])
             if not nodes:
                 pointer = self.shell.AddNode(login_base, pl_record)