openstack:
  valid: &valid
    id: openstack_template
    provider: openstack
    template_body: |
      heat_template_version: 2013-05-23

      description: >
        Hello world HOT template that just defines a single server.
        Contains just base features to verify base HOT support.
      parameters:
        key_name:
          type: string
          description: Name of an existing key pair to use for the server
          constraints:
            - custom_constraint: nova.keypair
        flavor:
          type: string
          description: Flavor for the server to be created
          default: m1.small
          constraints:
            - custom_constraint: nova.flavor
        image:
          type: string
          description: Image ID or image name to use for the server
          constraints:
            - custom_constraint: glance.image
        admin_pass:
          type: string
          description: Admin password
          hidden: true
          constraints:
            - length: { min: 6, max: 8 }
              description: Password length must be between 6 and 8 characters
            - allowed_pattern: "[a-zA-Z0-9]+"
              description: Password must consist of characters and numbers only
            - allowed_pattern: "[A-Z]+[a-zA-Z0-9]*"
              description: Password must start with an uppercase character
        db_port:
          type: number
          description: Database port number
          default: 50000
          constraints:
            - range: { min: 40000, max: 60000 }
              description: Port number must be between 40000 and 60000

      resources:
        server:
          type: OS::Nova::Server
          properties:
            key_name: { get_param: key_name }
            image: { get_param: image }
            flavor: { get_param: flavor }
            admin_pass: { get_param: admin_pass }
            user_data:
              str_replace:
                template: |
                  #!/bin/bash
                  echo db_port
                params:
                  db_port: { get_param: db_port }

      outputs:
        server_networks:
          description: The networks of the deployed server
          value: { get_attr: [server, networks] }
