Reader small image

You're reading from  VMware vRealize Orchestrator Cookbook. - Second Edition

Product typeBook
Published inNov 2016
PublisherPackt
ISBN-139781786462787
Edition2nd Edition
Right arrow
Author (1)
Daniel Langenhan
Daniel Langenhan
author image
Daniel Langenhan

Daniel Langenhan is a Virtualisation expert with formidable skills in Architecture, Design and Implementation for large multi-tier systems. His experience and knowledge of process management, enterprise-level storage, Linux and Windows operation systems has made him and his business a highly sought after international consultancy in the Asia-Pacific and European regions for multinational clientele in the areas of Finance, Communication, Education and Government. Daniel has been working with VMware products since 2002 and is directly associated with VMWare since 2008. His proven track record of successful integrations of Virtualisation into different business areas while minimizing cost and maximizing reliability and effectiveness of the solution for his clients. Currently, Daniel is operating in the Europe and Asia-Pacific region with his company vLeet GmbH and Melbourne Business Boosters Pty Ltd. Daniel's expertise and practical approach to VMWare has resulted in the publication of the following books: Instant VMware vCloud Starter, Packt Publishing VMware View Security Essentials, Packt Publishing VMware vCloud Director Cookbook, Packt Publishing VMware vRealize Orchestrator Cookbook, Packt Publishing VMware vRealize Orchestrator Essentials, Packt Publishing He has also lent his expertise to many other publishing projects as a Technical Editor.
Read more about Daniel Langenhan

Right arrow

Chapter 12. Working with vSphere

This chapter is dedicated to working with vSphere—or, to put it bluntly, the vCenter itself. We will be looking at the following recipes:

  • Working with the vCenter API (to change a VM's HA settings)

  • Standard vSwitch and Distributed Switch ports

  • Getting started with vAPI

  • Custom Attributes and Tags (vAPI)

  • Executing a program inside a VM

  • An approval process for VM provisioning

Introduction


Here we will have a look into the vSphere plugin and what we can do with it.

vSphere automation

The interaction between Orchestrator and vCenter is done using the vCenter API. Let's have a closer look at the interaction, and how it works, in more detail.

A user starts an Orchestrator workflow (1) either in an interactive way through the vSphere Web Client or the Orchestrator Client, or through the API. The workflow in Orchestrator will then send a job (2) to vCenter and receive a task ID back (type VC:Task). vCenter will then start enacting the job (3). Using the vim3WaitTaskEnd action (4), Orchestrator pauses until the task has been completed. If we do not use the wait task, we can't be certain whether the task has ended, was successful, or has failed. It is extremely important to use the vim3WaitTaskEnd action whenever we send a job to vCenter. When the wait task reports that the job has finished, the workflow will be marked as finished, as shown in the following diagram:

The...

Working with the vCenter API (to change a VM's HA settings)


This recipe will showcase how to derive a function for a more complicated feature. We will be configuring the HA setting for a single VM. Here, we will primarily be focusing on how to work with the vCenter API.

Getting ready

For this recipe, we will need a vCenter cluster that is configured for VMware High Availability (HA), as well as a VM which has an HA restart priority that we can change.

To do this, you should have an understanding of the introduction to Chapter 6, Advanced Programming, as well as the recipes Working with the API and JavaScript complex variables in the same chapter.

How to do it...

We will use the API and find out how to set VM's HA restart priority. This recipe requires you to take a close look at each of the objects that we will visit and read its properties and external documentation.

It is best to follow this step by step using the API browser:

  1. Create a new workflow and create the following variables:

    Standard vSwitch and Distributed Switch ports


    Here, we will discuss the problems that arise in vCenter from the difference between vSwitch and Distributed Switch ports in vCenter. We will learn how to bypass these problems, and create a workflow that will connect a VM to a Standard vSwitch or Distributed Switch port.

    Getting ready

    We need a vSphere environment that has at least one vSwitch and at least one Distributed Switch configured, each with at least one VM Network port group. For this recipe, it is not necessary for the switches to be actually connected to any NICs; they can be implemented as blind switches.

    To understand the creation of the action, you should understand how to use the vCenter API, as showcased in the recipe Working with the vCenter API (to change a VM's HA settings).

    We also need a VM with a virtual network card.

    How to do it...

    We will split this recipe into three parts: building an action, building a workflow that uses the action, and the final piece, to make it work...

    Getting started with vAPI


    In this recipe, we will look at the vAPI plugin that comes with vSphere 6.

    Getting ready

    You will need the vAPI plugin (which is already integrated into vRO 7.x).

    How to do it...

    This recipe is broken up into two parts just work though them in sequence.

    Configuring vCenter endpoint and metadata

    We will now create a vCenter vAPI endpoint and import the metadata:

    1. Run the workflow Library | VAPI | Add vAPI Endpoint.

    2. The vAPI endpoint is the https://[FDQN vCenter]/api.

    3. Using SSL is always a good idea.

    4. If you are using self-signed certificates you can import them without warnings.

    5. Use a user that will be the connection between Orchestrator and vCenter:

    6. We now need to import the metamodel of the vAPI endpoint. Run the workflow Library | VAPI | import vAPI metamodel.

    7. The inputs are the same as with adding the endpoint.

    Exploring the content

    Now we have created an endpoint and imported the metamodel, let's have a look what we get.

    1. Select Tools | API Explorer from the upper right-hand...

    Custom Attributes and Tags (vAPI)


    In this recipe, we will see how to create and use custom attributes and tags. We are talking about vCenter tags and not about Orchestrator tags, which have no common ground. This recipe will also use the vAPI plugin.

    Getting ready

    You need to have a VM to which you can tag or assign a custom attribute.

    For tagging, you need to have a vAPI vCenter Endpoint. See the Getting started with vAPI recipe in this chapter.

    How to do it...

    We will split this recipe into two parts. The first part concerns Custom Attributes, while the second concerns Tags.

    Custom Attributes

    Please note that Custom Attributes are only visible in the vSphere Client (also called Fat client or c-Client).

    We will now work through the lifecycle of a Custom Attribute:

    1. Create a new workflow.

    2. Drag the setOrCreateCustomField action onto the schema. This action will create a definition and set a value to an object.

    3. Drag the getCustomField action onto the schema. This action will read a Custom Attribute from...

    Executing a program inside a VM


    In this recipe, we will take a look at how to use Guest Operations (formerly called VIX) with Orchestrator. Guest Operations is a method by which vCenter can transfer files and execute programs inside a VM using VMware Tools. This method is of interest in DMZs, where security reduces the amount of automation possible.

    Getting ready

    We will need a running VM of any OS flavor you are happy with. This VM also needs to have VMware Tools installed. In this example, we will use a Windows VM.

    We also need a program to install in the operating system. In this example, we will use Java for Windows. The silent install instructions can be found at https://www.java.com/en/download/help/silent_install.xml .

    You will need to upload this file to Orchestrator in a directory that is accessible to Orchestrator. Refer to the Configuring access to the local filesystem recipe in Chapter 2, Optimizing Orchestrator Configuration. In this example, we will upload the file to the Orchestrator...

    An approval process for VM provisioning


    This recipe looks at how to build an approval process. If you don't happen to have vRealize Automation this could be an easy way forward.

    Getting ready

    Depending on how you want to build it, you may either need an e-mail server or a web server.

    How to do it...

    The approval process we are discussing is not a finished program but more of an architecture on how to construct one.

    Using User interaction

    This would be a program that uses User interaction for approval:

    1. Create a workflow that will provision a VM.

    2. Before the VM is actually provisioned, add a User interaction.

    3. Make sure the user interaction's timeout.date is somewhat in the future.

    4. Make sure that the security.group or the security.assignees have the users that are allowed to approve this VM assigned.

    5. Add a Boolean into the external inputs that approves or disapproves a VM.

    6. After the User interaction, add a base decision that works on the Boolean:

    Using e-mail

    This would be a program that uses email for...

    lock icon
    The rest of the chapter is locked
    You have been reading a chapter from
    VMware vRealize Orchestrator Cookbook. - Second Edition
    Published in: Nov 2016Publisher: PacktISBN-13: 9781786462787
    Register for a free Packt account to unlock a world of extra content!
    A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
    undefined
    Unlock this book and the full library FREE for 7 days
    Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
    Renews at €14.99/month. Cancel anytime

    Author (1)

    author image
    Daniel Langenhan

    Daniel Langenhan is a Virtualisation expert with formidable skills in Architecture, Design and Implementation for large multi-tier systems. His experience and knowledge of process management, enterprise-level storage, Linux and Windows operation systems has made him and his business a highly sought after international consultancy in the Asia-Pacific and European regions for multinational clientele in the areas of Finance, Communication, Education and Government. Daniel has been working with VMware products since 2002 and is directly associated with VMWare since 2008. His proven track record of successful integrations of Virtualisation into different business areas while minimizing cost and maximizing reliability and effectiveness of the solution for his clients. Currently, Daniel is operating in the Europe and Asia-Pacific region with his company vLeet GmbH and Melbourne Business Boosters Pty Ltd. Daniel's expertise and practical approach to VMWare has resulted in the publication of the following books: Instant VMware vCloud Starter, Packt Publishing VMware View Security Essentials, Packt Publishing VMware vCloud Director Cookbook, Packt Publishing VMware vRealize Orchestrator Cookbook, Packt Publishing VMware vRealize Orchestrator Essentials, Packt Publishing He has also lent his expertise to many other publishing projects as a Technical Editor.
    Read more about Daniel Langenhan

    Name

    ...