Ensure group exists on updates

Make sure the pool_group exists on updates as well to avoid breaking the
foreign key constraint.

Change-Id: I4e7149fea44313f50152dc8477910d590d042484
This commit is contained in:
Flavio Percoco 2015-09-09 14:13:05 +02:00
parent 161f5848d1
commit ef34e223e3

View File

@ -126,6 +126,9 @@ class PoolsController(base.PoolsBase):
if 'options' in fields:
fields['options'] = utils.json_encode(fields['options'])
if fields.get('group') is not None:
self._ensure_group_exists(fields.get('group'))
stmt = sa.sql.update(tables.Pools).where(
tables.Pools.c.name == name).values(**fields)