Ask Your Question
1

Use condition to enable/disable one of the properties

asked 2019-02-19 03:52:49 -0500

Proximm gravatar image

How can I disable "scheduler_hints" in Nova:Server creation if the "enable_anti-affinity" is set to False?

heat_template_version: 2017-09-01
parameters:
    enable_anti-affinity:
    type: string
    default: False
conditions:
  cnd_enable_anti-affinity: { equals: [{get_param: enable_anti-affinity}, "False"]}
resources:
    stack-server-group:
      type: OS::Nova::ServerGroup
      condition: cnd_enable_anti-affinity
      properties:
        name: server-group1
        policies: [ 'soft-anti-affinity' ]
    node01_server:
     type: OS::Nova::Server
     properties:
       name: server01
       image: some_image
       flavor: some_flavor
       scheduler_hints:
         group: { get_resource: stack-server-group }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-02-19 17:00:20 -0500

zaneb gravatar image

Use the if macro:

          scheduler_hints:
            if:
              - cnd_enable_anti_affinity
              - group: {get_resource: stack-server-group}
              -
edit flag offensive delete link more

Comments

@zaneb: this does not work: CREATE_FAILED BadRequest: resources.node01_server: Invalid input for field/attribute group. Value: None. None is not of type 'string' (HTTP 400)

Proximm gravatar imageProximm ( 2019-02-20 04:57:46 -0500 )edit

That's weird, that is Nova complaining that the {get_resource: stack-server-group} part is resolving to None. Was it working before?

zaneb gravatar imagezaneb ( 2019-02-27 16:21:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2019-02-19 03:52:49 -0500

Seen: 23 times

Last updated: Feb 19