- if not self._blacklisted(host_hrn):
- if not self._reserved(host_hrn):
- # Node in reservation
- ping_ok = self._do_ping(hostname)
- if not ping_ok:
- self._blacklist_node(host_hrn)
- self.fail_node_not_alive(hostname)
- else:
- if self._check_if_in_slice([host_hrn]):
- self.debug("The node %s is already in the slice" % hostname)
- self._slicenode = True
- self._node_to_provision = host_hrn
- super(PlanetlabSfaNode, self).do_discover()
-
-# else:
-# # the user specifies constraints based on attributes, zero, one or
-# # more nodes can match these constraints
-# nodes = self._filter_based_on_attributes()
-#
-# # nodes that are already part of user's slice have the priority to
-# # provisioned
-# nodes_inslice = self._check_if_in_slice(nodes)
-# nodes_not_inslice = list(set(nodes) - set(nodes_inslice))
-#
-# node_id = None
-# if nodes_inslice:
-# node_id = self._choose_random_node(nodes_inslice)
-# self._slicenode = True
-#
-# if not node_id:
-# # Either there were no matching nodes in the user's slice, or
-# # the nodes in the slice were blacklisted or being provisioned
-# # by other RM. Note nodes_not_inslice is never empty
-# node_id = self._choose_random_node(nodes_not_inslice)
-# self._slicenode = False
-#
-# if node_id:
-# self._node_to_provision = node_id
-# try:
-# self._set_hostname_attr(node_id)
-# self.info(" Selected node to provision ")
-# super(PlanetlabSfaNode, self).do_discover()
-# except:
-# with PlanetlabSfaNode.lock:
-# self._blacklist_node(node_id)
-# self.do_discover()
-# else:
-# self.fail_not_enough_nodes()
-#
+ if not self._blacklisted(host_hrn) and not self._reserved(host_hrn):
+ # Node in reservation
+ ping_ok = self._do_ping(hostname)
+ if not ping_ok:
+ self._blacklist_node(host_hrn)
+ self.fail_node_not_alive(hostname)
+ else:
+ if self._check_if_in_slice([host_hrn]):
+ self.debug("The node %s is already in the slice" % hostname)
+ self._slicenode = True
+ self._node_to_provision = host_hrn
+ else:
+ self.fail_node_not_available(hostname)
+ super(PlanetlabSfaNode, self).do_discover()
+
+ else:
+ hosts_hrn = nodes.values()
+ nodes_inslice = self._check_if_in_slice(hosts_hrn)
+ nodes_not_inslice = list(set(hosts_hrn) - set(nodes_inslice))
+ host_hrn = None
+ if nodes_inslice:
+ host_hrn = self._choose_random_node(nodes, nodes_inslice)
+ self._slicenode = True
+
+ if not host_hrn:
+ # Either there were no matching nodes in the user's slice, or
+ # the nodes in the slice were blacklisted or being provisioned
+ # by other RM. Note nodes_not_inslice is never empty
+ host_hrn = self._choose_random_node(nodes, nodes_not_inslice)
+ self._slicenode = False
+
+ if host_hrn:
+ self._node_to_provision = host_hrn
+ try:
+ self._set_hostname_attr(host_hrn)
+ self.info(" Selected node to provision ")
+ super(PlanetlabSfaNode, self).do_discover()
+ except:
+ self._blacklist_node(host_hrn)
+ self.do_discover()
+ else:
+ self.fail_not_enough_nodes()
+