- def _filter_based_on_attributes(self):
- """
- Retrive the list of nodes hrn that match user's constraints
- """
- # Map user's defined attributes with tagnames of PlanetLab
- timeframe = self.get("timeframe")[0]
- attr_to_tags = {
- 'city' : 'city',
- 'country' : 'country',
- 'region' : 'region',
- 'architecture' : 'arch',
- 'operatingSystem' : 'fcdistro',
- 'minReliability' : 'reliability%s' % timeframe,
- 'maxReliability' : 'reliability%s' % timeframe,
- 'minBandwidth' : 'bw%s' % timeframe,
- 'maxBandwidth' : 'bw%s' % timeframe,
- 'minLoad' : 'load%s' % timeframe,
- 'maxLoad' : 'load%s' % timeframe,
- 'minCpu' : 'cpu%s' % timeframe,
- 'maxCpu' : 'cpu%s' % timeframe,
- }
-
- nodes_hrn = []
- filters = {}
-
- for attr_name, attr_obj in self._attrs.iteritems():
- attr_value = self.get(attr_name)
-
- if attr_value is not None and attr_obj.has_flag(Flags.Filter) and \
- attr_name != 'timeframe':
-
- attr_tag = attr_to_tags[attr_name]
- filters['tagname'] = attr_tag
-
- # filter nodes by fixed constraints e.g. operating system
- if not 'min' in attr_name and not 'max' in attr_name:
- filters['value'] = attr_value
- nodes_hrn = self._filter_by_fixed_attr(filters, nodes_hrn)
-
- # filter nodes by range constraints e.g. max bandwidth
- elif ('min' or 'max') in attr_name:
- nodes_hrn = self._filter_by_range_attr(attr_name, attr_value, filters, nodes_hrn)
-
- if not filters:
- nodes = self.sfaapi.get_resources_hrn()
- for node in nodes:
- nodes_hrn.append(node[node.key()])
- return nodes_hrn
-
- def _filter_by_fixed_attr(self, filters, nodes_hrn):
- """
- Query SFA API for nodes matching fixed attributes defined by the
- user
- """
- pass
-# node_tags = self.sfaapi.get_resources_tags(filters)
-# if node_tags is not None:
-#
-# if len(nodes_id) == 0:
-# # first attribute being matched
-# for node_tag in node_tags:
-# nodes_id.append(node_tag['node_id'])
-# else:
-# # remove the nodes ids that don't match the new attribute
-# # that is being match
-#
-# nodes_id_tmp = []
-# for node_tag in node_tags:
-# if node_tag['node_id'] in nodes_id:
-# nodes_id_tmp.append(node_tag['node_id'])
+ def do_release(self):
+ super(PlanetlabSfaNode, self).do_release()
+ if self.state == ResourceState.RELEASED and not self._skip_provision():
+ self.debug(" Releasing SFA API ")
+ self.sfaapi.release()
+
+# def _filter_based_on_attributes(self):
+# """
+# Retrive the list of nodes hrn that match user's constraints
+# """
+# # Map user's defined attributes with tagnames of PlanetLab
+# timeframe = self.get("timeframe")[0]
+# attr_to_tags = {
+# 'city' : 'city',
+# 'country' : 'country',
+# 'region' : 'region',
+# 'architecture' : 'arch',
+# 'operatingSystem' : 'fcdistro',
+# 'minReliability' : 'reliability%s' % timeframe,
+# 'maxReliability' : 'reliability%s' % timeframe,
+# 'minBandwidth' : 'bw%s' % timeframe,
+# 'maxBandwidth' : 'bw%s' % timeframe,
+# 'minLoad' : 'load%s' % timeframe,
+# 'maxLoad' : 'load%s' % timeframe,
+# 'minCpu' : 'cpu%s' % timeframe,
+# 'maxCpu' : 'cpu%s' % timeframe,
+# }
+#
+# nodes_hrn = []
+# filters = {}