From 9f5e92dc455063b6cc6e52cef606393f40eb1ae0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 24 Apr 2019 10:07:35 +0200 Subject: [PATCH] patch for dealing with clients that don't set a component_id when talking to a single-node testbed like R2lab --- sfa/planetlab/plslices.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) 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']) -- 2.43.0