user2352151
user2352151

Reputation: 81

How to write a custom constraint in the heat template of openstack?

I find I can write anything,like this constraints: - custom_constraint:here anything description: Value must be one of m1.medium, m1.large or m1.xlarge and in CLI do this WILL BE OK -> heat template-validate -f bad.yaml

And in the document ,just tell you that's a plugin,how should i write a validation plugin????

Upvotes: 0

Views: 794

Answers (1)

KiwiMartin
KiwiMartin

Reputation: 832

If you look at the setup.cfg file in the heat source code you will find there is a section that lists the constraints:

heat.constraints =
     nova.flavor = heat.engine.clients.os.nova:FlavorConstraint
     nova.network = heat.engine.clients.os.nova:NetworkConstraint
     ...

These reference classes: so if you look at the FlavorConstraint, you will find it in the file heat/heat/engine/clients/os/nova.py

An examination of the class should give you an idea of how to write your own.

That is, if I'm understanding your question (and the code!) correctly.

Upvotes: 1

Related Questions