Custom node types

You can create your own custom node types which inherit from the base node types. This can reduce the amount of coding in your templates if you have multiple nodes inheriting the properties from a custom node type.

You create your custom node types in the node_types: section of the template. Your custom node types must have unique names. Properties defined on the nodes you define in the node_templates: section will override properties from the inherited custom node types.

Example

The example below shows a custom Server node type named baseVM. Custom nodes are defined in the node_types: section which must be defined before the node_templates: section.

node_types:
    # baseVM is a custom Server node type
    baseVM:
      type: dcm.nodes.Server
      properties:                                                                # Retrieve these server launch properties from the "inputs"
        cloud: { get_input: [account_region_zone_selector, cloud] }              # Retrieve cloud from the AccountRegionSelector
        cloudAccountId: { get_input: [account_region_zone_selector, accountId] } # Retrieve the cloud account ID from the AccountRegionSelector
        region: { get_input: [account_region_zone_selector, region] }            # Retrieve region from the AccountRegionSelector
        zone: { get_input: [account_region_zone_selector, zone] }                # Retrieve zone from the AccountRegionSelector
        platform: { get_input: [product_selector, platform] }                    # Retrieve platform from the Product selector
        architecture: { get_input: [product_selector, architecture] }            # Retrieve architecture from the Product selector
        product: { get_input: [product_selector, product] }                      # Retrieve product from the Product selector
        image: { get_input: [product_selector, image] }                          # Retrieve machine from the Product selector
        serverProductId: { get_input: [product_selector, serverProductId] }      # Retrieve server product id from the Product selector

The example below shows a node being defined in the node_templates section which inherits properties from the custom node type baseVM.

node_templates:
  vm:
    type: baseVM
    properties:
      name: "test-server"
      startupScript: |
        #!/bin/bash
        ##########################################################################################################################################
        # Install the Dell Cloud Manager agent, point it to the Dell Cloud Manager server and configure it to startup at boot time.
        ##########################################################################################################################################
        export DCM_URL=${dcm.callback.url}

        ##########################################################################################################################################
        # The -Z argument configures the Dell Cloud Manager agent and allows it to accept unknown certificates. 
        # This is only recommended for testing and should not be done in a production environment.
        ##########################################################################################################################################
        curl -L --retry 10 https://linux-stable-agent.enstratius.com/installer.sh | bash -s - --url $DCM_URL --on-boot -Z

        ##########################################################################################################################################
        # Start the Dell Cloud Manager agent.
        ##########################################################################################################################################
        /etc/init.d/dcm-agent start

        apt-get update -y
        apt-get install apache2 -y

    requirements:                                                   # This virtual machine node has a requirement on a firewall
      - firewall: vm_firewall_rules                                 # The firewall statement is named "vm_firewall_rules"
        relationship_type: tosca.relationships.DependsOn