From: Tony Mack Date: Thu, 18 Oct 2012 22:15:11 +0000 (-0400) Subject: fix ListResources X-Git-Tag: sfa-3.0-0~110 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0b5439b861515854b78aa31e48e76f8fe9b64b43;p=sfa.git fix ListResources --- diff --git a/sfa/managers/aggregate_manager.py b/sfa/managers/aggregate_manager.py index bd26a45c..61c7d1dd 100644 --- a/sfa/managers/aggregate_manager.py +++ b/sfa/managers/aggregate_manager.py @@ -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) diff --git a/sfa/planetlab/plaggregate.py b/sfa/planetlab/plaggregate.py index 944d20a1..c25d9a93 100644 --- a/sfa/planetlab/plaggregate.py +++ b/sfa/planetlab/plaggregate.py @@ -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() diff --git a/sfa/rspecs/version_manager.py b/sfa/rspecs/version_manager.py index 28e98d09..e8c34110 100644 --- a/sfa/rspecs/version_manager.py +++ b/sfa/rspecs/version_manager.py @@ -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 diff --git a/sfa/trust/auth.py b/sfa/trust/auth.py index 5d48a943..e787fe42 100644 --- a/sfa/trust/auth.py +++ b/sfa/trust/auth.py @@ -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()