From: Thierry Parmentelat Date: Wed, 24 Apr 2019 08:07:35 +0000 (+0200) Subject: patch for dealing with clients that don't set a component_id X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=9f5e92dc455063b6cc6e52cef606393f40eb1ae0;p=sfa.git patch for dealing with clients that don't set a component_id when talking to a single-node testbed like R2lab --- diff --git a/sfa/planetlab/plslices.py b/sfa/planetlab/plslices.py index e868acd1..d0cd2cb8 100644 --- a/sfa/planetlab/plslices.py +++ b/sfa/planetlab/plslices.py @@ -220,17 +220,32 @@ class PlSlices: def verify_slice_nodes(self, slice_urn, slice, rspec_nodes): slivers = {} - for node in rspec_nodes: - hostname = node.get('component_name') - client_id = node.get('client_id') - component_id = node.get('component_id').strip() - if hostname: - hostname = hostname.strip() - elif component_id: - hostname = xrn_to_hostname(component_id) - if hostname: - slivers[hostname] = { - 'client_id': client_id, 'component_id': component_id} + try: + for node in rspec_nodes: + hostname = node.get('component_name') + client_id = node.get('client_id') + component_id = node.get('component_id').strip() + if hostname: + hostname = hostname.strip() + elif component_id: + hostname = xrn_to_hostname(component_id) + if hostname: + slivers[hostname] = { + 'client_id': client_id, 'component_id': component_id} + # for r2lab and similar use cases + # the incoming rspec has no component_id, and + # since there's only one node in the whole testbed + # we can assume that's the one + # admittedly quite hacky, but this is intended temporary + # in an attempt to make progress on the fed4fire-r2lab federation link + except AttributeError: + all_nodes = self.driver.shell.GetNodes({},['hostname']) + if len(all_nodes) == 1: + hostname = all_nodes[0]['hostname'] + component_id = Xrn(xrn=hostname).get_urn() + slivers[hostname] = dict( + client_id=client_id, + component_id=component_id) nodes = self.driver.shell.GetNodes( slice['node_ids'], ['node_id', 'hostname', 'interface_ids'])