Launching a stack

Let's use the HOT hello world. The template can be passed to the Heat stack-create command as a local file, a URL to pull it from the network somewhere, or even as a Swift object if it was stored in Swift. It is important to validate a template. Pull down a copy of the template to your local filesystem.

Before you use this template, edit it and remove the constraints from admin_pass. It will make it easier to experiment with. Remove the lines under admin_pass that include constraints, length, and its description and both allowed_pattern and its description lines.

A template can be validated with Heat's template-validate command. Validating a template requires you to source a keystonerc file, use your overcloudrc file and then make sure that the template still validates with the changes you have made, as shown here:

undercloud# heat template-validate -f hello_world.yaml

Once the template validates, Heat will output a JSON representation of what it parsed from the template:

{
  "Description": "Hello world HOT template that just defines a single server. Contains just base features to verify base HOT support.
", 
  "Parameters": {
    "admin_pass": {
      "Type": "String", 
      "Description": "Admin password", 
      "MinLength": 6, 
      "Label": "admin_pass", 
      "AllowedPattern": "[A-Z]+[a-zA-Z0-9]*", 
      "NoEcho": "true", 
      "MaxLength": 8, 
      "ConstraintDescription": "Password length must be between 6 and 8 characters Password must consist of characters and numbers only Password must start with an uppercase character"
    }, 
    "image": {
      "CustomConstraint": "glance.image", 
      "Type": "String", 
      "NoEcho": "false", 
      "Description": "Image ID or image name to use for the server", 
      "Label": "image"
    }, 
    "flavor": {
      "Description": "Flavor for the server to be created", 
      "Default": "m1.small", 
      "Label": "flavor", 
      "CustomConstraint": "nova.flavor", 
      "NoEcho": "false", 
      "Type": "String"
    }, 
    "key_name": {
      "CustomConstraint": "nova.keypair", 
      "Type": "String", 
      "NoEcho": "false", 
      "Description": "Name of an existing key pair to use for the server", 
      "Label": "key_name"
    }, 
    "db_port": {
      "Description": "Database port number", 
      "Default": 50000, 
      "Type": "Number", 
      "MaxValue": 60000, 
      "MinValue": 40000, 
      "NoEcho": "false", 
      "Label": "db_port", 
      "ConstraintDescription": "Port number must be between 40000 and 60000"
    }
  }
}

Next, pass into the stack-create command a stack name and all the parameters that the template requires to launch:

undercloud# heat stack-create -f hello_world.yaml -P key_name=keypair_name -P image=Fedora -P admin_pass=Abadpass my_first_stack

This command will launch a stack named my_first_stack from the template that you just downloaded. Once a stack has been launched, you can keep track of the stack's progress and details using Heat's stack-list command and the stack-show command. If there are nested stacks, add the –show-nested parameter to the stack-list command. This is useful when listing asking the undercloud for the overcloud heat stack, it has nested stacks as part of its deployment. Further, you can list the resources associated with the stack with the resource-list command, and you can see the individual resources through the other OpenStack components using the appropriate command associated with those resources. In this example, the only resource created was an instance through Nova, so use the openstack server list command to see the instance that the stack created. A stack also has a set of events. Those events can be listed with the event-list command. The details of resources and events can be seen with their respective show commands:

undercloud# heat stack-list
undercloud# heat stack-show {STACK_ID}
undercloud# heat resource-list {STACK_ID}
undercloud# heat resource-show {RESOURCE_ID}
undercloud# openstack server list
undercloud# heat event-list {STACK_ID}
undercloud# heat event-show {EVENT_ID}

Note here that the resources that are created through Heat can be managed independently of Heat. The instance that was created by way of the hello world stack could be deleted directly through Nova. Deleting the instance will not delete the stack, but deleting the stack will delete all the resources that are associated with the stack.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.137.12