Defining Weaver infrastructure façades for virtual system patterns

Façade files are simplified forms of infrastructure patterns. They provide a layer of abstraction that lets you customize the infrastructure pattern without editing the pattern directly.

Before you begin

Import an infrastructure pattern to a Weaver file; see Importing virtual system patterns into Weaver infrastructure patterns.

About this task

Using a façade file is optional; if you prefer, you can work with the infrastructure pattern directly. However, façade files are convenient because they can simplify and rename elements in the virtual system pattern for easier use.

Procedure

  1. Create an empty Weaver file.
  2. In the Weaver file, import the infrastructure pattern. For example, if the infrastructure pattern is named sample_infra_pattern.weaver, use the following code in the façade file:
    import "sample_infra_pattern.weaver" => original
  3. With a Weaver use statement, import the main element from the infrastructure pattern. For example, assume that the infrastructure pattern starts with the following line of code:
    cloud_pattern (:sample_infra_pattern) {
    In this case, use the following code in the façade file:
    use original.sample_infra_pattern => :sample_infra_facade
    The code sample_infra_pattern refers to the ID of the façade, which you create in the next step. You can use any string of characters, numbers, and underscores for the ID.
  4. Create the façade element. For example, give the façade an ID of sample_infra_facade, use the following code:
    cloud_pattern (:sample_infra_facade) {
    
    }
  5. Within the cloud_pattern element, give meaningful names to the nodes in the infrastructure pattern. For example, assume that the infrastructure pattern specifies a node with the following code:
      cloud_node (:os_part) {
    In this case, you can give the node a human-readable name in the façade file. For example, if this node hosts a database, you can rename the node with the following code:
    rename os_part => database_node
  6. Similarly, give meaningful names to the properties in the infrastructure pattern. For example, assume that the node has the following properties.
    property :password => "passw0rd", :name => "password", 
      :label => "Password (root)"
    property :password_0 => "passw0rd", :name => "password", 
      :label => "Password (virtuser)"
    These properties specify the root password and the user password. However, because the IDs are automatically generated, it is not clear which password relates to which account. In the façade file, you can assign new IDs to these properties to make the meaning clear:
    rename database_node.password => root_password
    rename database_node.password_0 => virtuser_password
    Now you can refer to these properties with the new, simpler IDs.
  7. Save the file.

Example

A simple façade file based on the examples in these instructions might look like the following code:
import "sample_infra_pattern.weaver" => original
use original.sample_infra_pattern => :sample_infra_facade

cloud_pattern (:sample_infra_facade) {

  rename os_part => database_node

  rename database_node.password => root_password
  rename database_node.password_0 => virtuser_password

}

Feedback