From 782ada6e20fadd2fc6e5462dac03778c4e8f4949 Mon Sep 17 00:00:00 2001 From: tengqm Date: Sat, 3 Jan 2015 12:19:23 +0800 Subject: [PATCH] Added profile type checking for UPDATE actions We only allow UPDATE actions with the same profile type. --- senlin/engine/node.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/senlin/engine/node.py b/senlin/engine/node.py index b8c587ae3..46dcb1d9f 100644 --- a/senlin/engine/node.py +++ b/senlin/engine/node.py @@ -172,6 +172,16 @@ class Node(object): if not self.physical_id: return False + # Check if profile types match + old_profile = db_api.get_profile(context, self.profile_id) + new_profile = db_api.get_profile(context, new_profile_id) + if old_profile.type != new_profile.type: + events.warning(_LW('Node cannot be updated to a different ' + 'profile type (%(oldt)s->%(newt)s)'), + {'oldt': old_profile.type, + 'newt': new_profile.type}) + return False + res = profiles.update_object(self, new_profile_id) if res: self.rt['profile'] = profiles.load(self.context, new_profile_id)