From 6557a4daebdf3ab927bbdc499fe4ce5985d5c121 Mon Sep 17 00:00:00 2001 From: Sachin Bansal Date: Thu, 20 Aug 2015 10:50:28 -0700 Subject: [PATCH] Convert SG id to integer before calling index allocator api Change-Id: Ie8ff18a58a7e713991c3b6e6a633c65bfb74ccae Closes-Bug: 1472988 (cherry picked from commit 9168173d55bbb23d3da52e54e3f8f5d43cf2dd1c) --- src/config/schema-transformer/to_bgp.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/config/schema-transformer/to_bgp.py b/src/config/schema-transformer/to_bgp.py index 2fb4c30180a..c33207938a3 100644 --- a/src/config/schema-transformer/to_bgp.py +++ b/src/config/schema-transformer/to_bgp.py @@ -1312,9 +1312,11 @@ def set_configured_security_group_id(self, config_id): return self.config_sgid = config_id sg_id = self.obj.get_security_group_id() + if sg_id is not None: + sg_id = int(sg_id) if config_id: if sg_id is not None: - if int(sg_id) > SGID_MIN_ALLOC: + if sg_id > SGID_MIN_ALLOC: self._sg_id_allocator.delete(sg_id - SGID_MIN_ALLOC) else: if self.name == self._sg_id_allocator.read(sg_id): @@ -1323,9 +1325,9 @@ def set_configured_security_group_id(self, config_id): else: do_alloc = False if sg_id is not None: - if int(sg_id) < SGID_MIN_ALLOC: - if self.name == self._sg_id_allocator.read(int(sg_id)): - self.obj.set_security_group_id(int(sg_id) + SGID_MIN_ALLOC) + if sg_id < SGID_MIN_ALLOC: + if self.name == self._sg_id_allocator.read(sg_id): + self.obj.set_security_group_id(sg_id + SGID_MIN_ALLOC) else: do_alloc = True else: @@ -1333,7 +1335,7 @@ def set_configured_security_group_id(self, config_id): if do_alloc: sg_id_num = self._sg_id_allocator.alloc(self.name) self.obj.set_security_group_id(sg_id_num + SGID_MIN_ALLOC) - if sg_id != self.obj.get_security_group_id(): + if sg_id != int(self.obj.get_security_group_id()): _vnc_lib.security_group_update(self.obj) from_value = self.sg_id or self.name for sg in self._dict.values():