fix ListResources
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 18 Oct 2012 22:15:11 +0000 (18:15 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 18 Oct 2012 22:15:11 +0000 (18:15 -0400)
sfa/managers/aggregate_manager.py
sfa/planetlab/plaggregate.py
sfa/rspecs/version_manager.py
sfa/trust/auth.py

index bd26a45..61c7d1d 100644 (file)
@@ -78,13 +78,13 @@ class AggregateManager:
 
         # look in cache first
         cached_requested = options.get('cached', True)
-        if cached_requested and self.driver.cache and not slice_hrn:
+        if cached_requested and self.driver.cache:
             rspec = self.driver.cache.get(version_string)
             if rspec:
                 logger.debug("%s.ListResources returning cached advertisement" % (self.driver.__module__))
                 return rspec
        
-        rspec = self.driver.list_resources (version, options) 
+        rspec = self.driver.list_resources (rspec_version, options) 
         if self.driver.cache:
             logger.debug("%s.ListResources stores advertisement in cache" % (self.driver.__module__))
             self.driver.cache.add(version_string, rspec)    
index 944d20a..c25d9a9 100644 (file)
@@ -131,10 +131,10 @@ class PlAggregate:
             sliver['tags'] = tags_dict[node['node_id']]
         return slivers
 
-    def node_to_rspec_node(self, sites, interfaces, tags, pl_initscripts=[], grain=None, options={}):
+    def node_to_rspec_node(self, node, sites, interfaces, node_tags, pl_initscripts=[], grain=None, options={}):
         rspec_node = Node()
         # xxx how to retrieve site['login_base']
-        site=sites_dict[node['site_id']]
+        site=sites[node['site_id']]
         rspec_node['component_id'] = hostname_to_urn(self.driver.hrn, site['login_base'], node['hostname'])
         rspec_node['component_name'] = node['hostname']
         rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
@@ -293,14 +293,14 @@ class PlAggregate:
             interface_ids = []
             tag_ids = []
             nodes_dict = {}
-            for sliver in slivers:
-                site_ids.append(sliver['site_id'])
-                interface_ids.extend(sliver['interface_ids'])
-                tag_ids.extend(sliver['node_tag_ids'])
-                nodes_dict[sliver['node_id']] = sliver
+            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
             sites = self.get_sites({'site_id': site_ids})
             interfaces = self.get_interfaces({'interface_id':interface_ids})
-            node_tags = self.get_node_tags(tags_filter)
+            node_tags = self.get_node_tags({'node_tag_id': tag_ids})
             pl_initscripts = self.get_pl_initscripts()
             # convert nodes to rspec nodes
             rspec_nodes = []
@@ -310,7 +310,7 @@ class PlAggregate:
             rspec.version.add_nodes(rspec_nodes)
 
             # add links
-            links = self.get_links(sites_dict, nodes_dict, interfaces)        
+            links = self.get_links(sites, nodes_dict, interfaces)        
             rspec.version.add_links(links)
         return rspec.toxml()
 
index 28e98d0..e8c3411 100644 (file)
@@ -28,7 +28,7 @@ class VersionManager:
         retval = None
         for version in self.versions:
             if type is None or type.lower() == version.type.lower():
-                if version_num is None or str(version_num) == version.version:
+                if version_num is None or str(float(version_num)) == str(float(version.version)):
                     if content_type is None or content_type.lower() == version.content_type.lower() \
                       or version.content_type == '*':
                         retval = version
index 5d48a94..e787fe4 100644 (file)
@@ -45,7 +45,7 @@ class Auth:
         logger.debug("Auth.checkCredentials with %d creds on hrns=%s"%(len(creds),hrns))
         # won't work if either creds or hrns is empty - let's make it more explicit
         if not creds: raise InsufficientRights("Access denied - no credential provided")
-        if not hrns: raise InsufficientRights("Access denied - no subject xrn provided")
+        if not hrns: hrns = [None]
         for cred in creds:
             for hrn in hrns:
                 try:
@@ -63,7 +63,7 @@ class Auth:
         return valid
         
         
-    def check(self, cred, operation, hrn = None):
+    def check(self, cred_string, operation, hrn = None):
         """
         Check the credential against the peer cert (callerGID included 
         in the credential matches the caller that is connected to the 
@@ -71,7 +71,8 @@ class Auth:
         trusted cert and check if the credential is allowed to perform 
         the specified operation.    
         """
-        self.client_cred = Credential(string = cred)
+        cred = Credential(string = cred_string)    
+        self.client_cred = cred
         logger.debug("Auth.check: handling hrn=%s and credential=%s"%\
                          (hrn,cred.get_summary_tostring()))
         self.client_gid = self.client_cred.get_gid_caller()