One of the most interesting features of CloudForms is the ability to define services that can include one or more virtual machines (VMs) or instances and can be deployed across hybrid environments. Services can be made available to users through a self-service portal that allows users to order predefined IT services without IT operations getting involved, thereby delivering on one of the major promises of #cloud computing.
The intention of this post is to provide you with step-by-step instructions to get you started with a simple service catalog. After you have gone through the basic concepts, you should have the skills to dive deeper into more complex setups.
Getting started with Service Catalogs
Let’s set the stage for this post: You added your Amazon Web Services (AWS) account to CloudForms as a cloud provider. Your AWS account includes a Red Hat Enterprise Linux (RHEL) image ready to use. Now you want to give your users the ability to deploy RHEL instances on AWS but you want to limit or predefine most of the options they could choose when deploying these instances.
Service Basics
Four items are required to make a service available to users from the CloudForms self-service portal:
A Provisioning Dialog which presents the basic configuration options for a VM or instance.
A Service Dialog where you allow users to configure VM or instance options.
A Service Catalog which is used to group Services Dialogs together.
A Service Catalog Item (ie. the actual Service) which joins a Service Dialog with a Provisioning Dialog.
Provisioning Dialogs
To work with services in CloudForms it is important to understand the concept of Provisioning Dialogs. When you begin the process of provisioning a VM or instance via CloudForms, you are presented with a Provisioning Dialog where you set certain options for the VM or instance. The options presented are dependent on the provider you are using. For instance, a cloud provider might have “flavors” of instances, whereas an infrastructure provider might allow you to set the Memory size or number of CPUs on a VM.
Every provider in CloudForms comes with a sample provisioning dialog covering the options specific to that provider. To have a look at some sample Provisioning Dialogs, go to Automate > Customization > Provisioning Dialogs > VM Provision and select &8220;Sample Provisioning Dialogs&8221;. This is a textual representation of the dialog you will get when you provision a VM or instance.
For this post, we need to make sure instance provisioning to AWS is working, so go to Compute > Clouds > Instances and create a new AWS instance by choosing &8220;Provision Instances&8221; from the &8220;Lifecycle&8221; drop-down. Select the image you are going to use, click “Continue” and walk through the Provisioning Dialog.
Service Dialogs
A Service Dialog determines which options the users get to change. The choice of options that are presented to the user is up to you. You could just give them the option to set the service name, or you could have them change all of the Provisioning Dialog options. You have to create a Service Dialog to define the options users are allowed to see and set. To help with creating a Service Dialog, CloudForms includes a simple form designer.
Anatomy of a Service Dialog
A Service Dialog contains three components:
One or more &8220;Tabs&8221;
Inside the &8220;Tabs&8221;, one or more &8220;Boxes&8221;
Inside the &8220;Boxes&8221;, one or more &8220;Elements&8221;
The &8220;Elements&8221; contain methods, like check boxes, drop-down lists or text fields, to fill in the options on the Provisioning Dialog. Here is the most important part: The names of the Elements have to correspond to the options used in the Provisioning Dialog!
What are the Element Names?
Very good question. As mentioned the options and values we provide in the Service Dialog must match those used in the Provisioning Dialog. There are some rather generic names like &8220;vm_name&8221; or &8220;service_name&8221;, while others might be specific to the provider in question.
So how do you find the options and values you can pass in a Service Dialog? The easiest way is to look at the Provisioning Dialog. In this case, for our Amazon EC2 instance:
As an administrator, go to Automate > Customization
Open the &8220;Provisioning Dialogs&8221; accordion and locate the &8220;VM Provision&8221; folder
Find the appropriate dialog, &8220;Sample Amazon Instance Provisioning Dialog&8221;
Now you can use your browser’s search capabilities to find options and their potential values. For practice just look for e.g. “vm_name”.
Creating a Service Dialog
Enough theory, let’s dive in and create our first simple Service Dialog. The Service Dialog should let users choose a service and instance name for an AWS instance.
As an administrator, go to Automate > Customization
Open the &8220;Service Dialogs&8221; accordion. You will find two example Service Dialogs.
Add a new Service Dialog: Configuration > Add a new Dialog
Type &8220;aws_single_rhel7_instance&8221; into the Label field, this will be the name of the Service Dialog in CloudForms. Add a description if you want, this is not mandatory but good practice.
For Buttons, check &8220;Submit&8221; and &8220;Cancel&8221;.
From this starting point, you can now add content to the Dialog:
From the drop-down with the &8220;+&8221; sign choose &8220;Add a new Tab to this Dialog&8221;.
For Label use &8220;instance_settings&8221;, as Description use &8220;Instance Settings&8221;.
With the &8220;instance_settings&8221; Tab selected choose &8220;Add a new Box to this Tab&8221; from the &8220;+&8221; drop-down.
Give the new Box a Label and Description of &8220;Instance and Service Name&8221;.
From the &8220;+&8221; drop-down choose &8220;Add a new Element to this Box&8221;.
Fill in Label and Description with &8220;Service Name&8221; and Name with &8220;service_name&8221;.
For the Type, choose &8220;Text Box&8221; with Value Type &8220;String&8221;.
Following the same procedure add a second Element to the Box. The Name field should be &8220;vm_name&8221; and the Label and Description fields should be &8220;Instance Name&8221;. Similarly, Type should be &8220;Text Box&8221; with Value Type &8220;String&8221;.
That’s it! Now you can finally hit the &8220;Add&8221; button at the lower right corner.
Create a Catalog
Now that you have created your Service Dialog, we can add it to a Service Catalog by creating its associated Catalog Item.
First, we will create a Catalog:
Go to Services > Catalogs and expand the &8220;Catalogs&8221; accordion.
Select the &8220;All Catalogs&8221; folder and click Configuration > Add a new Catalog.
For Name and Description fill in &8220;Amazon EC2&8221;.
We will assign Catalog Items to this Catalog later.
Create a Catalog Item
Now we have the Catalog without any content, the Service Dialog, and the Provisioning Dialog. To allow users to order the service from the self-service catalog, we have to create a Catalog Item. Let&8217;s create a Catalog Item to order a RHEL instance using our Service Dialog:
Go to Services > Catalogs and expand the &8220;Catalog Items&8221; accordion.
Select the &8220;Amazon EC2&8221; catalog and click Configuration > Add a new Catalog Item.
From the &8220;Catalog Item Type&8221; drop-down select &8220;Amazon&8221;.
For Name and Description use &8220;RHEL Instance&8221; and check the box labelled &8220;Display in Catalog&8221;
From the &8220;Catalog&8221; drop-down choose &8220;Amazon EC2&8221;
From the &8220;Dialog&8221; drop-down choose &8220;aws_single_rhel7_instance&8221;. This is the Service Dialog you created earlier.
The three fields below point to methods used when provisioning/reconfiguring or retiring the service. For now, just configure these to use built-in methods as follows:
Click into the “Provisioning Entry Point State Machine” field, you will be taken to the Datastore Explorer.
Under the “ManageIQ” subtree, navigate to the following method and hit &8220;Apply&8221;: &8220;/Service/Provisioning/StateMachines/ServiceProvision_Template/CatalogItemInitialization&8221;
Click into the “Retirement Entry Point State Machine” field, navigate to this method and hit apply: “/Service/Retirement/StateMachines/ServiceRetirement/Default”
Switch to the &8220;Details&8221; tab. In real life you would put a detailed description of your Service here. You could use HTML for better formatting, but for the purpose of this post &8220;Single Amazon EC2 instance&8221; will do.
Switch to the &8220;Request Info&8221; tab. Here you preset all of the options from the Provisioning Dialog. (Remember that the user is only allowed to set Service Name and the Instance Name options via the Service Dialog):
On the &8220;Catalog&8221; tab, set the image Name to your AWS image name (&8220;rhel7&8221; in this case) and the Instance Name to &8220;changeme&8221;
On the &8220;Properties&8221; tab set the Instance Type to &8220;T2 Micro&8221;. If you ever plan to access the instance you should of course select a &8220;Guest Access Key Pair&8221;, too.
On the &8220;Customize&8221; tab set the Root Password. And in Customize Template choose the &8220;Basic root pass template&8221; as a script for cloud-init.
Click Add at the bottom right.
As you can see your new Catalog Item is listed with a generic icon. Let’s change this by uploading an icon in the &8220;Custom Image&8221; section. You can pick any image you like.
Recap or &8220;What have we done so far&8221;?
We created a Provisioning Dialog that defines the options that can be set on a VM or instance. We created a Service Dialog which allows us to expose certain options to be set by the user. For our example, only the instance name and service name are configurable. Then we created a Service Catalog and finally a Catalog Item. The Catalog Item joins the Service Dialog with all of the options in the Provisioning Dialog. Now, users should be able to order RHEL instance from the self-service catalog.
Let’s Order a RHEL Instance
To order your new service:
Access the self-service portal on https://<your_cf_appliance>/self_service. You will be greeted by the self-service dashboard
Select &8220;Service Catalog&8221; on the menu bar.
You should now see your service. Select it and you will be taken to the form you have defined in your Service Dialog:
Fill in the &8220;Service Name&8221; and &8220;Instance Name&8221; fields. Recall that these are the only two options that you made available to users in your Service Dialog.
Click &8220;Add to Shopping Cart&8221; and access the &8220;Shopping Cart&8221; by clicking the icon on the top right (there should now be a number on it).
Click &8220;Order&8221;. You have created a new provisioning request. You can follow the request by selecting &8220;My Requests&8221; from the menu bar and selecting the specific request to see its progression and details.
Once the &8220;Request State&8221; is shown as &8220;finished&8221;, your AWS instance is provisioned.
Conclusion
As you can see, creating a basic service catalog and to use the self-service portal in CloudForms is not rocket science. Of course, there is a lot more to learn, but there are also a lot of good resources to help you on your journey. For example, articles on this blog, the official documentation, and of course the excellent “Mastering CloudForms Automation” book written by Peter McGowan that I cannot recommend highly enough.
Quelle: CloudForms