First modification integration.
authorSandrine Avakian <sandrine.avakian@inria.fr>
Thu, 6 Sep 2012 12:29:15 +0000 (14:29 +0200)
committerSandrine Avakian <sandrine.avakian@inria.fr>
Thu, 6 Sep 2012 12:29:15 +0000 (14:29 +0200)
sfa/methods/CreateSliver.py
sfa/senslab/TestSuite.py
sfa/senslab/config/bash_nukem
sfa/senslab/config/senslab2/default_config.xml
sfa/senslab/slabaggregate.py
sfa/senslab/slabdriver.py

index b898c9d..334f3b7 100644 (file)
@@ -34,7 +34,6 @@ class CreateSliver(Method):
         hrn, type = urn_to_hrn(slice_xrn)
 
         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
-        print >>sys.stderr, " \r\n \r\n Createsliver.py call %s\ttarget-hrn: %s\tmethod-name: %s "%(self.api.interface, hrn, self.name)
         # Find the valid credentials
         valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', hrn)
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
index 4209409..3e09faa 100644 (file)
@@ -192,7 +192,7 @@ def TestOAR(job_id = None):
        job_id = job_id[0]
         
     oar = OARrestapi()
-    jobs = oar.parser.SendRequest("GET_reserved_nodes") 
+    jobs = oar.parser.SendRequest("GET_reserved_nodes", username = 'avakian'
     print "\r\n OAR GET_reserved_nodes ",jobs
     
    
@@ -227,17 +227,25 @@ def TestOAR(job_id = None):
     raw_json = get_stuff(oar,uri)
     print "\r\n OAR  ",uri, raw_json, "\r\n KKK \t",raw_json.keys()
     
-   
+    uri = '/oarapi/jobs.json?user=avakian'      
+    raw_json = get_stuff(oar,uri)
+    print "\r\nOAR ", uri, raw_json, "\r\n KKK \t",raw_json.keys()
     return
     
 def TestSlabDriver(job_id):
     if isinstance(job_id,list) and len(job_id) == 1:
        job_id = job_id[0]
     slabdriver = SlabDriver(Config())
-    l = slabdriver.GetSlices(slice_filter = 'senslab2.avakian_slice', slice_filter_type = 'slice_hrn')
-    print l
+    nodes = slabdriver.GetReservedNodes(username='avakian')
+    print "\r\n \r\n" ,nodes
+    
     l = slabdriver.GetSlices(slice_filter = '29', slice_filter_type = 'record_id_user')
-    print l
+    
+    
+    print "\r\n \r\nGetSlices" ,l
+    
+    persons = slabdriver.GetPersons()
+    print "\r\n \r\n  GetPersons" ,persons
     #slabdriver.DeleteJobs(job_id,'senslab2.avakian_slice')
    
 def RunAll():
index b1a56d5..8bcbf3f 100755 (executable)
@@ -60,9 +60,12 @@ sudo python setup.py install
 # and     /etc/sfa/configs/site.xml
 # into    /etc/sfa/sfa_config.xml
 # sudo sfa-config-tty
-sudo cp $git_local_repo/sfa/senslab/config/$vm/sfa_config /etc/sfa/sfa_config
+# 
+#sudo cp $git_local_repo/sfa/senslab/config/$vm/sfa_config /etc/sfa/sfa_config
 sudo cp $git_local_repo/sfa/senslab/config/$vm/sfa_config.xml /etc/sfa/sfa_config.xml
-sudo cp $git_local_repo/sfa/senslab/config/$vm/site.xml  /etc/sfa/site.xml
+sudo cp $git_local_repo/sfa/senslab/config/$vm/default_config.xml /etc/sfa/default_config.xml
+# sudo cp $git_local_repo/sfa/senslab/config/$vm/site.xml  /etc/sfa/site.xml
+sudo cp $git_local_repo/sfa/senslab/config/$vm/site_config  /etc/sfa/configs/site_config
 # sudo ln -s ldap_config.py  /etc/sfa/ldap_config.py
 sudo cp $git_local_repo/sfa/senslab/config/ldap_config.py  /etc/sfa/ldap_config.py 
 sudo service sfa restart
index b08f738..d5c6b15 100644 (file)
@@ -20,7 +20,7 @@ Thierry Parmentelat
       <variablelist>
         <variable id="generic_flavour" type="string">
           <name>Generic Flavour</name>
-          <value>pl</value>
+          <value>slab</value>
           <description>This string refers to a class located in sfa.generic that describes 
           which specific implementation needs to be used for api, manager and driver objects.
           PlanetLab users do not need to change this setting.
@@ -29,7 +29,7 @@ Thierry Parmentelat
 
         <variable id="interface_hrn" type="string">
           <name>Human readable name</name>
-          <value>plc</value>
+          <value>senslab2</value>
           <description>The human readable name for this interface.</description>
         </variable>
 
@@ -41,7 +41,7 @@ Thierry Parmentelat
 
         <variable id="api_loglevel" type="int">
           <name>Debug</name>
-          <value>0</value>
+          <value>2</value>
           <description>Logging level; 0=minimum, 1=info, 2=debug</description>
         </variable>
     
@@ -62,6 +62,13 @@ Thierry Parmentelat
             </description> 
         </variable>
 
+         <variable id="data_dir" type="string">
+            <name>Data Directory </name>
+            <value>/var/lib/sfa/</value>
+            <description>Directory where cached certficiates and other data is stored.
+            </description>
+        </variable>
+
       </variablelist>
     </category>
 
@@ -89,13 +96,13 @@ Thierry Parmentelat
 
        <variable id="port" type="int">
          <name>Port number</name>
-         <value>12345</value>
+         <value>52345</value>
          <description>The port where the registry is to be found.</description>
        </variable>
 
        <variable id="root_auth" type="string">
          <name>Root Authority</name>
-         <value>plc</value>
+         <value>senslab2</value>
          <description>The hrn of the registry's root auth.</description>
        </variable>
 
@@ -125,7 +132,7 @@ Thierry Parmentelat
 
        <variable id="port" type="int">
          <name>Port number</name>
-         <value>12347</value>
+         <value>52347</value>
          <description>The port where the slice manager is to be found.</description>
        </variable>
 
@@ -162,7 +169,7 @@ Thierry Parmentelat
 
        <variable id="port" type="int">
          <name>Port number</name>
-         <value>12346</value>
+         <value>52346</value>
          <description>The port where the aggregate is to be found.</description>
        </variable>
 
@@ -203,13 +210,13 @@ Thierry Parmentelat
 
        <variable id="user" type="string">
          <name>Database user</name>
-         <value>sfadbuser</value>
+         <value>sfa</value>
          <description>When SFA gets co-hosted with a myplc, this should match the PLC config.</description>
        </variable>
 
        <variable id="password" type="string">
          <name>Database password</name>
-         <value></value>
+         <value>sfa</value>
          <description>When SFA gets co-hosted with a myplc, this should match the PLC config.</description>
        </variable>
 
@@ -312,6 +319,11 @@ Thierry Parmentelat
           <value>8773</value>
           <description>The Nova/EC2 API port.</description>
         </variable>
+        <variable id="novarc" type="string">
+          <name>novarc</name>
+          <value>/root/novarc</value>
+          <description>Path to novarc client config file</description>
+        </variable>
       </variablelist>
     </category>
 
index 7298a33..0ec8dde 100644 (file)
@@ -1,9 +1,6 @@
-#import httplib
-#import json
 import time
 
 
-#from sfa.util.config import Config
 from sfa.util.xrn import hrn_to_urn, urn_to_hrn, urn_to_sliver_id
 
 from sfa.rspecs.rspec import RSpec
@@ -17,7 +14,6 @@ from sfa.rspecs.elements.lease import Lease
 from sfa.rspecs.elements.granularity import Granularity
 from sfa.rspecs.version_manager import VersionManager
 
-#from sfa.util.sfatime import datetime_to_epoch
 
 from sfa.rspecs.elements.versions.slabv1Node import SlabNode
 from sfa.util.sfalogging import logger
@@ -77,16 +73,14 @@ class SlabAggregate:
         #and therfore, node allocated to this slice
         for sfa_slice in slices:
             try:
-                    
+                   
                 for node in sfa_slice['node_ids']:
                     #node_id = self.driver.root_auth + '.' + node_id
-                    sliver = Sliver({'sliver_id': urn_to_sliver_id(slice_urn, \
-                                    sfa_slice['record_id_slice'], node['hostname']),
+                    sliver = Sliver({'sliver_id': Xrn(slice_urn, type='slice', id=node['hostname'], authority=self.driver.hrn).urn, 
                                     'name': sfa_slice['slice_hrn'],
                                     'type': 'slab-node', 
                                     'tags': []})
-                    logger.log_exc("SLABAGGREGATE \t \
-                                        get_slice_and_slivers node_id %s "%(node))
+                   
                     slivers[node['hostname']] = sliver
             except KeyError:
                 logger.log_exc("SLABAGGREGATE \t \
@@ -157,9 +151,7 @@ class SlabAggregate:
         #tag_ids = []
         nodes_dict = {}
         for node in nodes:
-            #site_ids.append(node['site_id'])
-            #interface_ids.extend(node['interface_ids'])
-            #tag_ids.extend(node['node_tag_ids'])
+           
             nodes_dict[node['node_id']] = node
         
         # get sites
index f009aa4..5ef99c8 100644 (file)
@@ -134,8 +134,10 @@ class SlabDriver(Driver):
                 res['pl_boot_state'] = nodeall_byhostname[node['hostname']]['boot_state']
                 #res['pl_last_contact'] = strftime(self.time_format, \
                                                     #gmtime(float(timestamp)))
-                sliver_id = urn_to_sliver_id(slice_urn, sl['record_id_slice'], \
-                                            nodeall_byhostname[node['hostname']]['node_id']) 
+                sliver_id =  Xrn(slice_urn, type='slice', \
+                        id=nodeall_byhostname[node['hostname']]['node_id'], \
+                        authority=self.hrn).urn
+    
                 res['geni_urn'] = sliver_id 
                 if nodeall_byhostname[node['hostname']]['boot_state'] == 'Alive':
 
@@ -364,57 +366,18 @@ class SlabDriver(Driver):
     
         return slice_urns
     
-    #No site or node register supported
+   
     def register (self, sfa_record, hrn, pub_key):
-        record_type = sfa_record['type']
-        slab_record = self.sfa_fields_to_slab_fields(record_type, hrn, \
-                                                            sfa_record)
-    
-
-        if record_type == 'slice':
-            acceptable_fields = ['url', 'instantiation', 'name', 'description']
-            for key in slab_record.keys():
-                if key not in acceptable_fields:
-                    slab_record.pop(key) 
-            logger.debug("SLABDRIVER.PY register")
-            slices = self.GetSlices(slice_filter=slab_record['hrn'], \
-                                            slice_filter_type = 'slice_hrn')
-            if not slices:
-                pointer = self.AddSlice(slab_record)
-            else:
-                pointer = slices[0]['slice_id']
-    
-        elif record_type == 'user':  
-            persons = self.GetPersons([sfa_record])
-            #persons = self.GetPersons([sfa_record['hrn']])
-            if not persons:
-                sfa_record['enabled'] = False
-                #For Senslab LDAP, if the user is a new one, disable the 
-                #account so that admins have to acknowledge the user first.
-                pointer = self.AddPerson(dict(sfa_record))
-                #add in LDAP 
-            else:
-                pointer = persons[0]['person_id']
-                
-            #Does this make sense to senslab ?
-            #if 'enabled' in sfa_record and sfa_record['enabled']:
-                #self.UpdatePerson(pointer, \
-                                    #{'enabled': sfa_record['enabled']})
-                
-            #TODO register Change this AddPersonToSite stuff 05/07/2012 SA   
-            #No site in senslab 28/08/12 SA
-           
-    
-            # What roles should this user have?
-            #No user roles in Slab/SFA 28/08/12 SA: roles are handled in LDAP
-            # Add the user's key
-            if pub_key:
-                self.AddPersonKey(pointer, {'key_type' : 'ssh', \
-                                                'key' : pub_key})
-                
-        #No node adding outside OAR
-
-        return pointer
+        """ 
+        Adding new user, slice, node or site should not be handled
+        by SFA.
+        
+        Adding nodes = OAR
+        Adding users = LDAP Senslab
+        Adding slice = Import from LDAP users
+        Adding site = OAR
+        """
+        return -1
             
     #No site or node record update allowed       
     def update (self, old_sfa_record, new_sfa_record, hrn, new_key):