Skip to content

Commit

Permalink
Convert SG id to integer before calling index allocator api
Browse files Browse the repository at this point in the history
Change-Id: Ie8ff18a58a7e713991c3b6e6a633c65bfb74ccae
Closes-Bug: 1472988
(cherry picked from commit 9168173)
  • Loading branch information
Sachin Bansal authored and Hampapur Ajay committed Oct 2, 2015
1 parent 05c2f31 commit 6557a4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/config/schema-transformer/to_bgp.py
Expand Up @@ -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):
Expand All @@ -1323,17 +1325,17 @@ 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:
do_alloc = True
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():
Expand Down

0 comments on commit 6557a4d

Please sign in to comment.