From b94bb59dbb4b448992f6b1b7a84dfbbc7ce365ed Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Thu, 11 Mar 2010 22:05:53 +0000 Subject: [PATCH] Create a record for the slice if not found in the AM database --- sfa/managers/aggregate_manager_eucalyptus.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sfa/managers/aggregate_manager_eucalyptus.py b/sfa/managers/aggregate_manager_eucalyptus.py index e62381a1..9b970380 100644 --- a/sfa/managers/aggregate_manager_eucalyptus.py +++ b/sfa/managers/aggregate_manager_eucalyptus.py @@ -365,7 +365,13 @@ def get_rspec(api, xrn, origin_hrn): # Get the instances that belong to the given slice from sqlite3 # XXX use getOne() in production because the slice's hrn is supposed # to be unique. For testing, uniqueness is turned off in the db. - theSlice = list(Slice.select(Slice.q.slice_hrn == hrn))[-1] + # If the slice isn't found in the database, create a record for the + # slice. + matchedSlices = list(Slice.select(Slice.q.slice_hrn == hrn)) + if matchedSlices: + theSlice = matchedSlices[-1] + else: + theSlice = Slice(slice_hrn = hrn) for instance in theSlice.instances: instanceId.append(instance.instance_id) -- 2.43.0