From 17138f6a3805ce3f9b290c603ca9431843ec4fcb Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Fri, 14 Jul 2017 18:02:24 +0100 Subject: [PATCH] Add Blazar custom constraint plugin This adds a reservation constraint for verifying a blazar reservation id. Change-Id: I27267e148c71288b4c7701fe704425b738e3e0b3 Story: 2005654 Task: 30942 --- heat/engine/clients/os/blazar.py | 15 +++++++++++++++ setup.cfg | 1 + 2 files changed, 16 insertions(+) diff --git a/heat/engine/clients/os/blazar.py b/heat/engine/clients/os/blazar.py index 099c6af5ba..1039430d95 100644 --- a/heat/engine/clients/os/blazar.py +++ b/heat/engine/clients/os/blazar.py @@ -14,7 +14,9 @@ from blazarclient import client as blazar_client from blazarclient import exception as client_exception +from heat.common import exception from heat.engine.clients import client_plugin +from heat.engine import constraints CLIENT_NAME = 'blazar' @@ -56,3 +58,16 @@ class BlazarClientPlugin(client_plugin.ClientPlugin): def get_host(self, id): return self.client().host.get(id) + + +class BlazarBaseConstraint(constraints.BaseCustomConstraint): + + resource_client_name = CLIENT_NAME + + +class ReservationConstraint(BlazarBaseConstraint): + expected_exceptions = ( + exception.EntityNotFound, + client_exception.BlazarClientException,) + + resource_getter_name = 'get_lease' diff --git a/setup.cfg b/setup.cfg index 0568c8e620..5d717adff4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,6 +108,7 @@ heat.constraints = # service constraints barbican.container = heat.engine.clients.os.barbican:ContainerConstraint barbican.secret = heat.engine.clients.os.barbican:SecretConstraint + blazar.reservation = heat.engine.clients.os.blazar:ReservationConstraint cinder.backup = heat.engine.clients.os.cinder:VolumeBackupConstraint cinder.qos_specs = heat.engine.clients.os.cinder:QoSSpecsConstraint cinder.snapshot = heat.engine.clients.os.cinder:VolumeSnapshotConstraint