From aa71d0d1896475cc78951b815f4de3d1fc6c7984 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 14 Apr 2015 17:01:45 +0200 Subject: [PATCH] issue a warning when get_slivers is used against an existing but empty slice e.g. with this code one gets an exception when trying to renew an existing slice that has no node the warning would help spotting this --- sfa/planetlab/plaggregate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sfa/planetlab/plaggregate.py b/sfa/planetlab/plaggregate.py index 9ab8c6d5..6fabf79a 100644 --- a/sfa/planetlab/plaggregate.py +++ b/sfa/planetlab/plaggregate.py @@ -142,13 +142,18 @@ class PlAggregate: if slice_ids: filter['slice_id'] = list(slice_ids) # get all slices - all_slices = self.driver.shell.GetSlices(filter, ['slice_id', 'name', 'hrn', 'person_ids', 'node_ids', 'slice_tag_ids', 'expires']) + fields = ['slice_id', 'name', 'hrn', 'person_ids', 'node_ids', 'slice_tag_ids', 'expires'] + all_slices = self.driver.shell.GetSlices(filter, fields) if slice_hrn: slices = [slice for slice in all_slices if slice['hrn'] == slice_hrn] else: slices = all_slices if not slices: + if slice_hrn: + logger.error("PlAggregate.get_slivers : no slice found with hrn {}".format(slice_hrn)) + else: + logger.error("PlAggregate.get_slivers : no sliver found with urns {}".format(urns)) return [] slice = slices[0] slice['hrn'] = slice_hrn @@ -197,6 +202,8 @@ class PlAggregate: node['urn'] = node['sliver_id'] node['services_user'] = users slivers.append(node) + if not slivers: + logger.warning("PlAggregate.get_slivers : slice(s) found but with no sliver {}".format(urns)) return slivers def node_to_rspec_node(self, node, sites, interfaces, node_tags, pl_initscripts=None, grain=None, options=None): -- 2.43.0