Merge branch 'master' of ssh://git.onelab.eu/git/sfa
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 9 Jan 2012 08:35:12 +0000 (09:35 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 9 Jan 2012 08:35:12 +0000 (09:35 +0100)
sfa.spec
sfa/managers/aggregate_manager.py
sfa/plc/plaggregate.py
sfa/plc/plslices.py
sfa/rspecs/elements/login.py
sfa/rspecs/elements/versions/pgv2SliverType.py
sfa/server/sfaapi.py
sfa/util/sfatime.py
sfa/util/xml.py

index ffc8d7e..90f7677 100644 (file)
--- a/sfa.spec
+++ b/sfa.spec
@@ -1,6 +1,6 @@
 %define name sfa
 %define version 2.0
-%define taglevel 8
+%define taglevel 9
 
 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
 %global python_sitearch        %( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" )
@@ -224,6 +224,19 @@ fi
 [ "$1" -ge "1" ] && service sfa-cm restart || :
 
 %changelog
+* Sat Jan 7 2012 Tony Mack <tmack@cs.princeton.edu> - sfa-2.0-9
+- bugfix: 'geni_api' should be in the top level struct, not the code struct
+- bugfix: Display the correct host and port in 'geni_api_versions' field of the GetVersion
+          output returned by the Aggregate Manager.
+- bugfix: sfa.util.sfatime now handles numeric string inputs correctly.
+- bugfix: sfa.util.sfatime.datetime_to_epoch() returns integers instead of doubles.
+- bugfix: Fixed bug that prevented the rspec parser from identifying an rspec's schema when
+          there is extra whitespace in the schemaLocation field.
+- bugfix: Fixed bug that caused PlanetLab initscripts from showing up in the PGv2 and GENIv3 
+          advertisement rspecs.
+- bugfix: <login> RSpec element should contain the 'username' attribute.
+- bugfix: Use sfa.util.plxrn.PlXrn to parse the login_base (authority) out of a urn.      
 * Wed Jan 4 2012 Tony Mack <tmack@cs.princeton.edu> - sfa-2.0-8
 - bugfix: Fixed a bug in the sfa-import-plc.py script that caused the script to 
   exit when it encountered a user with an invalid public key.
index 5d8fc8d..fab2af8 100644 (file)
@@ -16,7 +16,7 @@ class AggregateManager:
             'interface':'aggregate',
             'sfa': 2,
             'geni_api': 2,
-            'geni_api_versions': {'2': 'http://%s:%s' % (api.config.SFA_SM_HOST, api.config.SFA_SM_PORT)}, 
+            'geni_api_versions': {'2': 'http://%s:%s' % (api.config.SFA_AGGREGATE_HOST, api.config.SFA_AGGREGATE_PORT)}, 
             'hrn':xrn.get_hrn(),
             'urn':xrn.get_urn(),
             }
index d581210..1cace7a 100644 (file)
@@ -127,7 +127,8 @@ class PlAggregate:
             # most likely a default/global sliver attribute (node_id == None)
             if tag['node_id'] not in slivers:
                 sliver = Sliver({'sliver_id': urn_to_sliver_id(slice_urn, slice['slice_id'], ""),
-                                 'name': 'plab-vserver',
+                                 'name': slice['name'],
+                                 'type': 'plab-vserver',
                                  'tags': []})
                 slivers[tag['node_id']] = sliver
             slivers[tag['node_id']]['tags'].append(tag)
@@ -221,7 +222,7 @@ class PlAggregate:
                 rspec_node['slivers'] = [sliver]
                 
                 # slivers always provide the ssh service
-                login = Login({'authentication': 'ssh-keys', 'hostname': node['hostname'], 'port':'22'})
+                login = Login({'authentication': 'ssh-keys', 'hostname': node['hostname'], 'port':'22', 'username': sliver['name']})
                 service = Services({'login': login})
                 rspec_node['services'] = [service]
             rspec_nodes.append(rspec_node)
index 1bf6043..9413e81 100644 (file)
@@ -5,7 +5,7 @@ from sfa.util.sfatime import utcparse, datetime_to_epoch
 from sfa.util.sfalogging import logger
 from sfa.util.xrn import Xrn, get_leaf, get_authority, urn_to_hrn
 #from sfa.util.policy import Policy
-from sfa.util.xrn import Xrn
+from sfa.util.plxrn import PlXrn
 from sfa.rspecs.rspec import RSpec
 from sfa.plc.vlink import VLink
 from sfa.util.plxrn import hrn_to_pl_slicename
@@ -342,9 +342,10 @@ class PlSlices:
                 # unbind from peer so we can modify if necessary. Will bind back later
                 self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
                #Update existing record (e.g. expires field) it with the latest info.
-            requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires'])))
-            if requested_expires and slice['expires'] != requested_expires:
-                self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires})
+            if slice_record.get('expires'):
+                requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires'])))
+                if requested_expires and slice['expires'] != requested_expires:
+                    self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires})
        
         return slice
 
@@ -356,7 +357,7 @@ class PlSlices:
         for user in users:
             hrn, type = urn_to_hrn(user['urn'])
             username = get_leaf(hrn)
-            login_base = get_leaf(get_authority(user['urn']))
+            login_base = PlXrn(xrn=user['urn']).pl_login_base()
             user['username'] = username
             user['site'] = login_base
 
@@ -594,7 +595,7 @@ class PlSlices:
                 self.driver.shell.DeleteSliceTag(attribute['slice_tag_id'])
             except Exception, e:
                 logger.warn('Failed to remove sliver attribute. name: %s, value: %s, node_id: %s\nCause:%s'\
-                                % (name, value,  node_id, str(e)))
+                                % (slice['name'], attribute['value'],  attribute.get('node_id'), str(e)))
 
         # add requested_attributes
         for attribute in added_slice_attributes:
@@ -602,5 +603,5 @@ class PlSlices:
                 self.driver.shell.AddSliceTag(slice['name'], attribute['name'], attribute['value'], attribute.get('node_id', None))
             except Exception, e:
                 logger.warn('Failed to add sliver attribute. name: %s, value: %s, node_id: %s\nCause:%s'\
-                                % (name, value,  node_id, str(e)))
+                                % (slice['name'], attribute['value'],  attribute.get('node_id'), str(e)))
 
index ae42641..99dc5c3 100644 (file)
@@ -4,5 +4,6 @@ class Login(Element):
     fields = [
         'authentication',
         'hostname',
-        'port'
+        'port',
+        'username'
     ]
index 94a9f63..ffa4b41 100644 (file)
@@ -15,18 +15,19 @@ class PGv2SliverType:
                 sliver_elem.set('name', sliver['type'])
             if sliver.get('client_id'):
                 sliver_elem.set('client_id', sliver['client_id'])  
-            PGv2SliverType.add_sliver_attributes(sliver_elem, sliver.get('pl_tags', []))
+            PGv2SliverType.add_sliver_attributes(sliver_elem, sliver.get('tags', []))
     
     @staticmethod
     def add_sliver_attributes(xml, attributes):
-        for attribute in attributes:
-            if attribute['name'] == 'initscript':
-                xml.add_element('{%s}initscript' % xml.namespaces['planetlab'], name=attribute['value'])
-            elif tag['tagname'] == 'flack_info':
-                attrib_elem = xml.add_element('{%s}info' % self.namespaces['flack'])
-                attrib_dict = eval(tag['value'])
-                for (key, value) in attrib_dict.items():
-                    attrib_elem.set(key, value)                
+        if attributes: 
+            for attribute in attributes:
+                if attribute['name'] == 'initscript':
+                    xml.add_element('{%s}initscript' % xml.namespaces['planetlab'], name=attribute['value'])
+                elif tag['tagname'] == 'flack_info':
+                    attrib_elem = xml.add_element('{%s}info' % self.namespaces['flack'])
+                    attrib_dict = eval(tag['value'])
+                    for (key, value) in attrib_dict.items():
+                        attrib_elem.set(key, value)                
     @staticmethod
     def get_slivers(xml, filter={}):
         xpath = './default:sliver_type | ./sliver_type'
index afb71a4..b783369 100644 (file)
@@ -214,7 +214,6 @@ class SfaApi (XmlrpcApi):
 
     def get_geni_code(self, result):
         code = {
-            'geni_api': 2,             
             'geni_code': GENICODE.SUCCESS, 
             'am_type': 'sfa',
             'am_code': None,
@@ -239,6 +238,7 @@ class SfaApi (XmlrpcApi):
 
     def prepare_response_v2_am(self, result):
         response = {
+            'geni_api': 2,             
             'code': self.get_geni_code(result),
             'value': self.get_geni_value(result),
             'output': self.get_geni_output(result),
index 478c5be..34f4dce 100644 (file)
@@ -13,7 +13,14 @@ the timezone, so that it's compatible with normal datetime.datetime objects.
 
 For safety this can also handle inputs that are either timestamps, or datetimes
 """
-    
+    # perpare the input for the checks below by
+    # casting strings ('1327098335') to ints
+    if isinstance(input, StringTypes):
+        try:
+            input = int(input)
+        except ValueError:
+            pass
+          
     if isinstance (input, datetime.datetime):
         logger.warn ("argument to utcparse already a datetime - doing nothing")
         return input
@@ -34,7 +41,7 @@ def datetime_to_utc(input):
     return time.gmtime(datetime_to_epoch(input))    
 
 def datetime_to_epoch(input):
-    return time.mktime(input.timetuple())
+    return int(time.mktime(input.timetuple()))
 
 
 
index 90693f2..d438e24 100755 (executable)
@@ -198,8 +198,9 @@ class XML:
         # set schema
         for key in self.root.attrib.keys():
             if key.endswith('schemaLocation'):
-                # schema location should be at the end of the list
-                schema_parts  = self.root.attrib[key].split(' ')
+                # schemaLocation should be at the end of the list.
+                # Use list comprehension to filter out empty strings 
+                schema_parts  = [x for x in self.root.attrib[key].split(' ') if x]
                 self.schema = schema_parts[1]    
                 namespace, schema  = schema_parts[0], schema_parts[1]
                 break