Example Heat template for changing the flavor of a virtual server using stack update

Updating_a_virtual_server.yaml

This template performs "Updating a stack" for a virtual server that was created using "Creating_a_virtual_server.yaml" of Example virtual server creation Heat template, and changes the flavor of the virtual server.

For the procedure for "Updating a stack", refer to "Updating a stack".

#
# This template changes the flavor of a virtual server created
# using "Creating_a_virtual_server.yaml". 
#
heat_template_version: 2013-05-23

description: >
  This template changes the flavor of a virtual server created using "Creating_a_virtual_server.yaml". 

parameters:
  VOLUME_NAME:
    type: string
    description: Name of the system volume of the Virtual Server
    default: Sample_Volume_01

  VOLUME_SIZE:
    type: string
    description: Volume size of the system volume of the Virtual Server
    default: 30

  AZ:
    type: string
    description: Name of the Availability Zone to deploy the Virtual Server in
    default: jp-east-1a

  FLAVOR:
    type: string
    description: Name or ID of the Flavor type of the Virtual Server to update
    default: S-2

  IMAGE_ID:
    type: string
    description: Image ID or image name to use for the Virtual Server
    default: c3867e5e-afd6-4858-918e-c445f9041c9d

  KEY_NAME:
    type: string
    description: Name of the existing key pair used for the Virtual Server
    default: Sample_Key_01

  SERVER_NAME:
    type: string
    description: Name of the Virtual Server to update
    default: Sample_Server_01

  NETWORK_NAME:
    type: string
    description: NAME of the Network to deploy the Virtual Server on
    default: Sample_Network_01

  NETWORK_ID:
    type: string
    description: ID of the Network to deploy the Virtual Server on
    default: 6eft72d8-a4ad-4h4f-8d2d-76soe8ba122b

  SECURITY_GROUP_NAME:
    type: string
    description: NAME of the Security Group associated with the Virtual Server
    default: Sample_Security_Group_01

resources:
  VOLUME_01:
    type: OS::Cinder::Volume
    properties:
      name: { get_param: VOLUME_NAME }
      size: { get_param: VOLUME_SIZE }
      volume_type: "M1"
      image : { get_param: IMAGE_ID }
      availability_zone: { get_param: AZ }

  SERVER_01:
    type: OS::Nova::Server
    properties:
      availability_zone: { get_param: AZ }
      block_device_mapping: [{"volume_size":{ get_param: VOLUME_SIZE }, "volume_id": { get_resource: VOLUME_01 }, "delete_on_termination": True, "device_name": "/dev/vda" }]
      flavor: { get_param: FLAVOR }
      flavor_update_policy: RESIZE
      image: { get_param: IMAGE_ID }
      key_name: { get_param: KEY_NAME }
      name: { get_param: SERVER_NAME }
      networks: [{"network": { get_param: NETWORK_ID }}]
      security_groups: [{ get_param: SECURITY_GROUP_NAME }]
      user_data_format: RAW


outputs:
  SERVER_01_DETAIL:
    description: 
    value: { get_attr: [SERVER_01, show] }

  SERVER_01_NETWORK:
    description: 
    value: { get_attr: [SERVER_01, networks] }

  SERVER_01_IP:
    description: 
    value: { get_attr: [SERVER_01, addresses,{ get_param: NETWORK_NAME }, 0, port] }