parameters:
flavor:
type: string
description: Flavor to be used for compute instance
default: "m1.small"
key_name:
type: string
description: Name of key-pair to be used for compute instance
default: "MyKey"
To
refer to these parameters in other places in the blueprint, use the
get_param function. For example, the following code shows a server
node. The properties for the node refer to the parameters in the previous
example.web-server:
type: OS::Nova::Server
properties:
flavor: { get_param: flavor }
image: "14243a29-9662-4b9d-b164-67884876fc91"
key_name: { get_param: key_name }
name: "web-server"
Blueprint resources also have attributes and properties. Properties are input values that are specified at or before provisioning time, such as the size of a storage volume. The previous example showed how to use parameters to specify values for properties.
For another example, assume that you are provisioning a two-node environment: one node hosts a database, and the other node hosts a web application. The web application needs the location of the database, but this information is not available until the environment is provisioned. Therefore, you must refer to the attribute that represents the IP address of the database node.
db-server:
type: OS::Nova::Server
properties:
networks:
- port: { get_resource: db-server_external-net_port }
flavor: { get_param: flavor }
image: "19033a29-9662-4b9d-b164-67884876fc91"
key_name: { get_param: key_name }
name: "db-server"
This
node, which is of the resource type OS::Nova::Server, has an attribute that
is named networks. This attribute is not shown in the code; it is implied
by the resource type. (The code shows a property that is named networks,
which is not to be confused with the attribute with the same name.) For information about
the properties and attributes on Heat resources, see the reference for the resource type.
See Heat resource types.outputs:
networks:
description: networks
value: {get_attr: [db-server_external-net, networks]}
web-component:
type: IBM::UrbanCode::SoftwareDeploy::UCD
properties:
apply_config: { get_resource: web-component_sw_config }
server: web-server
version: 5.1
agent_timeout: "360"
inputs:
db-server-ip: { get_attr: [db-server, networks, external-net, 0] }
This
code shows a custom property that is named db-server-ip, which represents
the IP address of the database node. To get the IP address, the code uses the
get_attr function. The arguments of the function refer first to the
resource db-server, then to the attribute networks. The
attribute networks is a map (a Python dict type) that
lists the network resources to which the database node is attached and the IP addresses in
those networks. For example, an OpenStack system might have two networks: an internal
network with IP addresses for use within the network and an external network with externally
accessible floating IP addresses. This map might look like the following
example:{
"internal-net":[192.168.80.11, 192.168.80.12],
"external-net":[172.24.50.21, 172.24.50.22]
}
This
map lists the IP addresses that are assigned to the resource. The IP addresses are organized
according to the network to which the IP address belongs. This example lists two internal
network IP addresses and two external network IP addresses. The last two arguments in the
get_attr function in the example refer to the name of the network and
the index of the IP address, based on this map.{ get_attr: [db-server, networks, external-net, 0] }