# Creating XaaS Instance Types with HPE Morpheus Enterprise

HPE Morpheus Enterprise version 5.4.2 and higher includes the ability to build and provision XaaS Instance Types. These are non-VM backed Layouts which allow users to represent anything as an Instance. This includes the ability to utilize Provisioning Workflows to manage all phases of the Instance lifecycles consistently and automatically. XaaS Instance Types can also be tied into service plans to track costs or bill customers.

In this specific example, we will create an XaaS Instance Type to manage the lifecycle of folders within a Dropbox account. Users will be able to visit the HPE Morpheus Enterprise Catalog and have the folder created by entering a name for the folder and clicking a single button. We’ll see how each folder is then represented as an Instance. With the Instance standing, users will be able to update the folder name by simply editing a custom value on the Instance. Finally, when the Instance is deleted, the folder is deleted from Dropbox as well.

In this guide, we’ll use the following HPE Morpheus Enterprise constructs:

- Clouds
- Inputs
- Tasks
- Workflows
- Instance Types
- Layouts
- Catalog Items
- Instances

NOTE

XaaS Instances are associated with HPE Morpheus Enterprise-type Clouds. HPE Morpheus Enterprise Clouds are generic cloud wrappers that can be used to contain manually-managed servers, VMs, and (in this case) non-VM based resources. In this guide we will go through the process of creating a HPE Morpheus Enterprise-type Cloud which can be used to hold your XaaS resources.

## Create Cypher

Cypher is a secure key/value store in HPE Morpheus Enterprise. Using Cypher, we can securely store passwords and other secret values (such as API keys) which can then be called into automation Tasks and templates. Here we will store the Dropbox API token as a Cypher entry. Creating Dropbox developer accounts and obtaining API keys goes beyond the scope of this guide but Dropbox developer tools are well-documented if you want to try this out for yourself. In the HPE Morpheus Enterprise UI, go to Tools > Cypher and click + ADD.

There are a number of different types of Cypher keys, which are useful in different contexts. Here we’ll use the “secret” type which allows us to enter some known value which can be securely accessed later. Enter the following:

- **KEY:** secret/dropboxtoken
- **VALUE:** Enter Dropbox API token here
- **LEASE:** 0 (Lease time is given in seconds, with “0” being unlimited)

Click SAVE CHANGES

![../../_images/1cypher.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-865BCB56-4457-4DA6-A9A1-34CFCD22EEAE-high.png)

One of my Tasks will also send a request to the HPE Morpheus Enterprise API so I’ll create a second Cypher entry to store a HPE Morpheus Enterprise API key:

- **KEY:** secret/morphapitoken
- **VALUE:** Enter Dropbox API token here
- **LEASE:** 0 (Lease time is given in seconds, with “0” being unlimited)

Click SAVE CHANGES

## Create Cloud

XaaS Instances are associated with HPE Morpheus Enterprise-type Clouds. HPE Morpheus Enterprise Clouds are generic cloud wrappers that can be used to contain manually-managed servers, VMs, and (in this case) non-VM based resources. For this example, I’m creating a Cloud just to organize Dropbox folders. Navigate to Infrastructure > Clouds and click + ADD. The only required steps to create the Cloud are to give it a name and associate it with a Group. I’ve given mine a generic name but you could opt to be more targeted with your naming if you will use many HPE Morpheus Enterprise-type Clouds to manage other types of resources.

- **NAME:** MorphCloud

![../../_images/1cloud.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-B1A71913-825C-4533-BBBD-AEF60F33F4F1-high.png)

## Create Inputs

Inputs are custom input fields which can be added to Layouts, Instance Types, and other constructs in HPE Morpheus Enterprise. The input can be consumed as variables within templates and scripts. We’ll create two Inputs in this case, one to allow the user to enter a name for their folder on provisioning and another which will be visible when editing the Instance to allow the user to rename their folder.

In HPE Morpheus Enterprise UI, navigate to Library > Options > Inputs. Click + ADD. Complete the following fields:

- **NAME:** DropBox Folder Name (The name for the Input object in HPE Morpheus Enterprise)
- **FIELD NAME:** dbfoldername (The internal property which the input value is assigned to)
- **TYPE:** Text (The input type, in this case an open text field for the user)
- **SHOW ON EDIT:** Checked (When checked, this Option is visible when editing an Instance)
- **EDITABLE:** Checked (When checked, this Option is editable in addition to being visible while editing the Instance)
- **LABEL:** DropBox Folder Name (The label the user sees next to the input field)

Once done, click SAVE CHANGES

![../../_images/2input.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-13B6ACC4-D949-465D-B229-1A7E9D065999-high.png)

Next, configure a second Input with the following attributes:

- **NAME:** DropBox Folder New Name
- **FIELD NAME:** dbfoldernewname
- **TYPE:** Text
- **SHOW ON EDIT:** Checked
- **EDITABLE:** Checked
- **LABEL:**

Click SAVE CHANGES

## Create Tasks

Tasks, in HPE Morpheus Enterprise, are individual automation scripts. They can be pieced together into Workflows (as we’ll see later) to create more comprehensive automation packages. They can be written in a number of different languages (including BASH, Powershell, Python, Javascript, and more) or to accomplish specific functions like restarting a server or sending an email notification. In this case, I’ll write the Task configuration directly into the HPE Morpheus Enterprise Tasks. However, Tasks can also be sourced directly from integrated version control repositories (like Github) so you never have to copy and paste code or make manual updates when your code changes.

For this example, we need to create four Tasks. One to create the folder, one to rename the folder, one to rename the HPE Morpheus Enterprise Instance, and one to delete the folder. I’ve used Python Tasks to interact with the Dropbox Python SDK. I won’t go into how to write the individual Tasks here but the Python SDK is well-documented if you want to try things out for yourself. The same functions could be carried out using other Task types as well.

![../../_images/3tasks.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-BBDD2BA6-FF48-4A8B-903C-7F8C08E972A2-high.png)

Navigate to Library > Automation > Tasks and click + ADD. Create a new Task with the following configuration:

- **NAME:** Dropbox - Create Folder
- **TYPE:** Python Script (Once Type is selected, available fields will be updated to those specific to the chosen type)
- **RESULT TYPE:** None
- **SOURCE:** Local (Select Repository to source your code from an integrated version control repository)
- **CONTENT:** Enter Task content here
- **COMMAND ARGUMENTS:** Optional command line arguments for the Python script. In my case, I’m passing the Dropbox API token from Cypher as a command line argument (as seen in the screenshot) and consuming it in my code using the sys module, which is part of the Python standard library. There are other ways to consume Cypher secrets in Python scripts as well, which are laid out in a [Knowledge Base article](https://support.morpheusdata.com/s/article/How-to-use-stored-cypher-secrets-in-python-task?language=en_US)
- **ADDITIONAL PACKAGES:** List packages used which are not part of the standard Python library

Once done, click SAVE CHANGES

![../../_images/5createtask.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-82B72BAF-618B-4F5A-B82F-8D4BE96BD27A-high.png)

The process for creating the remaining three Tasks is very similar, expand the sections below to see screenshots of the Task config, if desired:

### Dropbox - Delete Folder

![../../_images/6deletetask.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-020E198F-49C6-4228-ABE8-C5580D223F15-high.png)

### Dropbox - Rename Folder

![../../_images/7renametask.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-05551E97-6453-4079-A6D5-B0CF880BC840-high.png)

### Dropbox - Reset Instance Name

![../../_images/8resetinstancetask.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-BFB5EBC7-4C8A-4F58-AB33-90475BCB8B6E-high.png)

## Create Provisioning Workflow

HPE Morpheus Enterprise Workflows pull multiple Tasks together into a logical group. There are two types of Workflows: Operational and Provisioning. We won’t use any Operational Workflows here but these Workflows can be run on-demand as needed or set to run on a recurring time schedule (like a cronjob). Provisioning Workflows are associated with an Instance at provision time and will automatically run the appropriate Tasks when the Instance reaches certain phases of its lifecycle, such as during provisioning, teardown, startup, or shutdown. In our case, we need the following to occurring during the Instance lifecycle:

- At the provisioning phase, we want a folder to be created
- At the reconfigure phase (when the Instance is edited), we want the folder to be renamed and the Instance name to be updated
- At the teardown phase (when the Instance is deleted), we want the folder to be deleted

Navigate to Library > Automation > Workflows and click + ADD. Set the following configurations:

- **NAME:** XaaS - Dropbox
- **PLATFORM:** All
- **TASKS - Provision:** Dropbox - Create Folder
- **TASKS - Reconfigure:** Dropbox - Rename Folder; Dropbox - Reset Instance Name
- **TASKS - Teardown:** Dropbox - Delete Folder

Once done, click SAVE CHANGES

![../../_images/9workflow.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-4710C85B-97B8-4EFB-B607-8D8289BEE58C-high.png)

## Create Instance Type

With the Workflow and Inputs complete, we’re ready to put them all together into a custom Instance Type for our HPE Morpheus Enterprise Library. From this, we’ll create a catalog item that our users can order in a later step.

Navigate to Library > Blueprints > Instance Types and click + ADD. Enter the following configurations:

- **NAME:** XaaS - Dropbox
- **CODE:** xaas
- **CATEGORY:** Utility
- **ICON:** If desired, search the file system on your local computer for a Dropbox logo icon for easier identification of this Instance Type at provision time
- **ENVIRONMENT PREFIX:** XAAS

![../../_images/10instype.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-08F8C46C-E7EE-4E11-B0D2-D204B32405B6-high.png)

Click SAVE CHANGES.

## Create Layout

After creating the Instance Type, click into it and then click + ADD LAYOUT from the Instance Type Detail Page. A Layout specifies the technology the Instance will run on, in this case Workflow. It’s possible to have multiple Layouts associated with an Instance Type which can be selected depending on the chosen Cloud the user might be provisioning on (when dealing with VM-based Instance Types). Configure the Layout as follows:

- **NAME:** XaaS - Dropbox
- **VERSION:** Latest
- **CREATABLE:** Checked (If unchecked, this Layout won’t be an available option at provision time)
- **TECHNOLOGY:** Workflow
- **WORKFLOW:** Select the Workflow we’ve just created, “XaaS - Dropbox”. By selecting this, all Instances provisioned with this Layout will automatically have our chosen Tasks run during specific Instance lifecycle phases
- **INPUTS:** Search and find the two custom Inputs we created earlier, “DropBox Folder Name” and “DropBox Folder New Name”

![../../_images/11layout.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-3C57ACEF-141F-4DED-929C-1724C2B1F81C-high.png)

## Create Catalog Item

Catalog Items offer a simplified provisioning process. Administrators can create Catalog Items using existing Instance Types, App Blueprints, or Workflows. Most or all of the provisioning options can be pre-selected leaving fewer decisions up to the user and allowing them to easily create what they need. In this case, we’ll create one based on the Instance Type that was made in the previous sections. Navigate to Library > Blueprints > Catalog Items and click + ADD, then Instance. Configure the following:

- **NAME:** XaaS - Dropbox Folder
- **ENABLED:** Checked (If unchecked, this Catalog Item will not be displayed in the provisioning catalog for users)
- **LOGO:** If desired, browse your local disk for a Dropbox logo to make this Catalog Item easily recognizable

Then, click CONFIGURATION WIZARD. On the “TYPE” tab, search for the Instance Type we created and click NEXT. On the “Group” tab, select the HPE Morpheus Enterprise-type Cloud and enter any name (we’ll override this name value later so it’s dynamic based on user input). Click NEXT. On the “CONFIGURE” tab, the Layout and Plan fields should default to acceptable values. Enter anything for the “Dropbox Folder Name”, we will also update this to be dynamic in the next step. Click through the final two tabs, there’s no need to attach our Workflow on the “AUTOMATION TAB” since we already have it on our Layout. Finally, click COMPLETE.

Once finished, you’ll see the JSON configuration map for the Instance loaded into the “CONFIG” field. Update the “dbfoldername” Input value and the Instance name value to dynamically take on the user-entered value on the “Dropbox Folder Name” field as I’ve done in my screenshot below:

![../../_images/12catitem.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-F93420D1-2F2A-479B-9ACD-56A52256AD43-high.png)

Near the bottom of the modal window, search for and attach the “DropBox Folder Name” Input. This will be the only input our users need to make to order their folder. Then, click SAVE CHANGES

## Ordering Catalog Item

At this point, the configuration steps are completed. As a test, we can order a folder from the provisioning Catalog. Navigate to Provisioning > Catalog and click “Order” on our “XaaS - Dropbox Folder” item. We need only provide a name for our folder and click “Order Now”.

![../../_images/13orderitem.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-27E8619F-240F-43AE-A00F-70489E83CE32-high.png)

If we now head to Provisioning > Instances, we can see a new Instance entry has been created for our Dropbox folder. Note that the Instance is named for our folder name exactly as we configured earlier.

![../../_images/14inslist.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-2FA0BA43-267B-4BFD-8C3A-46A8879844F4-high.png)

Taking a look in the Dropbox web console, we can also see a folder has been created just as we’d expect.

![../../_images/15dbcreate.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-38887B6A-8B2B-44AA-BDA0-91C557D414F8-high.png)

## Managing and Deleting Instances

Back in HPE Morpheus Enterprise, we can take a look at the Instance detail page (Provisioning > Instances > Specific Instance) and perform some Day 2 actions. By clicking EDIT, we can update Instance details. When Input values are updated, HPE Morpheus Enterprise will automatically trigger reconfigure actions on our Instance. In our case, we’ve configured it to update the folder name in Dropbox and update the Instance name in HPE Morpheus Enterprise for easier identification. As you can see in the screen shot, I’m providing a new folder name value:

![../../_images/16editins.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-4A83E6DE-B560-4FBC-A948-892DA9AFBBE2-high.png)

As expected, our Instance name is updated and the folder is renamed on the Dropbox side:

![../../_images/17insdetail.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-9E516B64-6C3D-4577-B7C6-E67FC23ADBB2-high.png) ![../../_images/18dbupdate.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-FB2B154B-85F7-4AA0-B77E-FB596CE9F7FE-high.png)

Finally, I’ll delete the Instance. This has the effect of deleting the Instance object out of HPE Morpheus Enterprise and triggering our Teardown-phase action which deletes the folder from Dropbox:

![../../_images/19dbdelete.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-5D5388E9-5251-499E-ABE9-36A1342F356C-high.png)
