Vcenter Orchestrator Plugin Development - Best Practices
Vcenter Orchestrator Plugin Development - Best Practices
This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs.
EN-000686-00
You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: [email protected]
Copyright 2011 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
Contents
Plug-Ins for Services 11 Plug-Ins for Systems 12 Plug-Ins for Object-Oriented Systems 13 Plug-Ins for Resource-Oriented Systems 13
4 Plug-In Implementation 15
Project Structure 15 Project Internals 16 Workflow Internals 17 Workflows and Actions 18 Workflow Presentation 18
5 Recommendations for Orchestrator Plug-In Development 21 6 Documenting Plug-In User Interface Strings and APIs 25
Index 27
VMware, Inc.
VMware, Inc.
VMware vCenter Orchestrator Plug-In Development Best Practices provides information about the common structure of a vCenter Orchestrator plug-in as well as helpful techniques and practices for plug-in development.
Intended Audience
This information is intended for developers who want to understand the structure and content of vCenter Orchestrator plug-ins as well as understand how to avoid specific problems and improve certain aspects of the plug-ins that they develop.
VMware, Inc.
VMware, Inc.
Orchestrator plug-ins have a common structure that consists of various types of layers that implement specific functionality. The bottom three layers of a vCO plug-in, that are, infrastructure classes, wrapping classes, and scripting objects, implement the connection between the plugged-in technology and Orchestrator. The user-visible parts of a vCO plug-in are the top three layers that are actions, building blocks, and high level workflows. Figure 1-1. Structure of a vCO Plug-In
high level workflows building block workflows
infrastructure classes
Infrastructure classes
A set of classes that provide the connection between the plugged-in technology and Orchestrator. The infrastructure classes include the classes to implement according to the plug-in definition, such as plug-in factory, plug-in adaptor, and so on. The infrastructure classes also include the classes that provide functionality for common tasks and objects such as helpers, caching, inventory, and so on. A set of classes that adapt the object model of the plugged-in technology to the object model that you want to expose inside Orchestrator. JavaScript object types that provide access to the wrapping classes, methods, and attributes in the plugged-in technology. In the vso.xml file you define which wrapping classes, attributes, and methods from the plugged-in technology will be exposed to Orchestrator.
VMware, Inc.
Actions
A set of JavaScript functions that you can use directly in workflows, Web views, and scripting tasks. Actions can take multiple input parameters and have a single return value. A set of workflows that cover all generic functionality that you want to provide with the plug-in. Typically, a building block workflow represents an operation in the user interface of the orchestrated technology. The building block workflows can be used directly or can be included inside high-level workflows. A set of workflows that cover specific functionality of the plug-in. You can provide high-level workflows to meet concrete requirements or to show complex examples of the plug-in usage.
VMware, Inc.
You can use different approaches to build your Orchestrator plug-ins. You can start building a plug-in layer by layer or you can start building all layers of the plug-in at the same time. This chapter includes the following topics:
n n
infrastructure classes
iteration 1
An advantage of the bottom-up plug-in development approach is that development is focused on one layer at a time. Consider the following disadvantages of bottom-up plug-in development approach.
n
The progress of the plug-in development is difficult to show until some insertions are completed.
VMware, Inc.
The bottom-up development process is considered good enough for small plug-ins, with reduced or nonexistent set of wrapping classes, scripting objects, actions, or workflows.
infrastructure classes
The progress of the plug-in development is easy to show from the first iteration because new functionality is completed for each iteration and the plug-in can be released and used after every iteration. Completing a vertical slice of functionality allows for very clearly defined success criteria and definition of what has been done, as well as better communication between developers, product management, and quality assurance (QA) engineers. Allows the QA engineers to start testing and automating from the beginning of the development process. Such an approach results in valuable feedback and decreases the overall project delivery time frame.
A disadvantage of the top-down plug-in development approach is that the development is in progress on different layers at the same time. You should apply the top-down plug-in development process for most plug-ins. It is appropriate for plug-ins with dynamic requirements.
10
VMware, Inc.
Using plug-ins, you can integrate in Orchestrator general-purpose libraries or utilities like XML or SSH as well as entire systems such as vCloud. Depending on the technology that you integrate in Orchestrator, plug-ins can be categorized as plug-ins for services, or general purpose plug-ins, and plug-ins for systems. This chapter includes the following topics:
n n
vCO
plugin core
adaptor
generic library
service
service plugin
Plug-ins for services expose generic libraries or utilities to Orchestrator, such as XML, SSH or SOAP. For example, the following plug-ins that are available in Orchestrator are plug-ins for services. JDBC plug-in Mail plug-in SSH plug-in XML plug-in Allows you to use any database within a workflow. Allows you to send emails within a workflow. Allows you to open SSH connections and run commands within a workflow. Allows you to manage XML documents within a workflow.
VMware, Inc.
11
Plug-ins for services have the following characteristics. Complexity Plug-ins for services have from low to medium level of complexity. Plug-ins for services expose a specific library, or part of a library, inside Orchestrator so as to provide concrete functionality. For example, the XML plug-in adds an implementation of a Document Object Model (DOM) XML parser to the Orchestrator JavaScript API. Plug-ins for services are relatively small in size. They require a basic set of classes that are the same as for all plug-ins, and other classes that offer new scripting objects to add new functionality. Plug-ins for services require a small inventory of objects to work, or they do not require an inventory at all. Plug-ins for services have a generic and small object model, and so, they do not need to show this model inside the vCO inventory.
Size
Inventory
Following are the main characteristics of plug-ins for systems. Complexity Plug-ins for systems have higher level of complexity, because the technologies that they expose are relatively complex. Plug-ins for systems must represent all the elements of the external system inside Orchestrator to interact with the external system and offer the same functionality as that system in Orchestrator. If the external system provides an integration mechanism, you can use it to expose the functionality of the system in Orchestrator more easily. However, besides representing the elements of the external system in Orchestrator, plugins for systems might also need to offer high scalability, provide a caching mechanism, deal with events and notifications, and so on. Plug-ins for system are from medium to big in size. Plug-ins for systems require many classes apart from the basic set of classes because usually they offer a large number of scripting objects. Plug-ins for systems might require some other helper and auxiliary classes that will interact with them. Usually, plug-ins for systems have a large number of objects, and you must expose these objects properly in the inventory so that you can locate them and work with them easily in vCO. Because of the large number of objects that plugins for systems need to expose, you should build auxiliary tool or a process to auto-generate as much code as possible for the plug-in. For example, vCenter Server plug-in provides such a tool.
Size
Inventory
Plug-Ins for Object-Oriented Systems on page 13 Object-oriented systems offer an interaction mechanism that is based on objects and RPC.
12
VMware, Inc.
Plug-Ins for Resource-Oriented Systems on page 13 Resource-oriented systems provide an interaction mechanism that is based on resources and simple operations that use HTTP methods.
You can consider the following when you implement plug-ins for object-oriented systems.
n
If you use SOAP, you can use the WSDL file to generate a set of classes that combine the object model and the communication mechanism. This object model is almost everything that you have to expose inside vCenter Orchestrator.
VMware, Inc.
13
You can consider the following when you develop plug-ins for resource-oriented systems.
n
If you use REST or only HTTP with XML, you get one or more XML schema files to be able to read and write messages. From these schemas, you can generate a set of classes that define the object model. This set of classes only defines the state of the objects because the operations are defined implicitly with the HTTP methods, for example, as defined in the vCloud Director plug-in, or explicitly with some specific XML messages, like the Cisco UCSM plug-in. You need to implement the communication mechanism in another set of classes. This set of classes defines a new object model to interact with the original object model. The object model for the communication mechanism consists of objects and methods only. You can expose both the original object model and the object model for the communication mechanism inside vCO. This could add some extra complexity depending on how both object models are exposed, and on whether you are merging related objects from both sides (to simulate an object-oriented system) or keeping them separate.
14
VMware, Inc.
Plug-In Implementation
You can use certain helpful practices and techniques when you structure your plug-ins, implement the required Java classes and JavaScript objects, develop the plug-in workflows and actions as well as provide the workflow presentation.
n
Project Structure on page 15 You can apply a standard structure for the projects of your Orchestrator plug-ins. Project Internals on page 16 You can apply certain approaches when implementing your plug-in, for example, cash objects, bring object in background, clone object, and so on. By applying such approaches, you can improve the performance of your plug-ins, avoid concurrency problems, and improve the responsiveness of the Orchestrator client.
Workflow Internals on page 17 You can implement a workflow to monitor long-time operations that your vCO plug-in performs. Workflows and Actions on page 18 To ease the workflow development and usage, you can use certain good practices. Workflow Presentation on page 18 When you create the presentation of a workflow, you should apply certain structure and rules.
Project Structure
You can apply a standard structure for the projects of your Orchestrator plug-ins. You can a use a standard Maven structure with modules for your plug-in projects to bring clarity in where every peace of functionality resides. Table 4-1. Structure of a plug-in project
Module /myAwesomePlugin-plugin /o11nplugin-myAwesomePlugin /o11nplugin-myAwesomePlugin-config /o11nplugin-myAwesomePlugin-core Description Root of the plug-in project. Module that composes the final plug-in DAR file. Module that contains the plug-in configuration Web application. It generates a standard WAR file. Module that contains all the classes that implement any of the standard Orchestrator plug-in interfaces and other auxiliary classes that they use. It generates a standard JAR file.
VMware, Inc.
15
/o11nplugin-myAwesomePlugin-package
Project Internals
You can apply certain approaches when implementing your plug-in, for example, cash objects, bring object in background, clone object, and so on. By applying such approaches, you can improve the performance of your plug-ins, avoid concurrency problems, and improve the responsiveness of the Orchestrator client.
16
VMware, Inc.
Workflow Internals
You can implement a workflow to monitor long-time operations that your vCO plug-in performs. You should implement a workflow for monitoring long-time running operations such as task monitoring. This workflow can be based on Orchestrator triggers and waiting events. You have to consider that a workflow that is blocked waiting for a task can be resumed as soon as the Orchestrator server starts, the plug-in must be able to get all the required information to resume the monitoring process properly. The monitoring workflow or the task that it can? use internally should provide a mechanism to specify the pooling rate and a possible timeout. The process of debugging a piece of scripting code inside a workflow is not easy, especially if the code does not invoke any Java code. Because of this, sometimes the only option is to use the logging methods offered by the default Orchestrator scripting objects.
VMware, Inc.
17
To create complex objects or parameters for scripting methods easily. To avoid repeating common pieces of code all the time. To perform UI validations.
Provide a description of the workflow or action. Provide a description of the input parameters. Provide a description of the outputs. Provide a description of the attributes for the workflows.
Workflow Presentation
When you create the presentation of a workflow, you should apply certain structure and rules. Use the following properties for the workflow inputs in the workflow presentation.
18
VMware, Inc.
Organize the inputs with steps and display group. Such organization helps the user to identify and distinguish all the input parameters of a workflow.
VMware, Inc.
19
20
VMware, Inc.
You can consider certain recommendations when developing the different components of your Orchestrator plug-ins. Table 5-1. Useful practices in plug-in implementation
Component General Item Access to third-party API Interface Action Scripting objects Description Plug-ins should provide simplified methods for accessing the third-party API wherever possible. Plug-ins should provide a coherent and standard interface for users, even when the API does not. You should create actions for every creation, modification, or deletion of a scripting object, and for every other method that is available on the object. The description of an action should describe what the action does instead of how it works. When you use scripting to get the properties or methods of an object, you can check whether the object value is different from null or undefined. If an action is deprecated, the comment or the throw statement should indicate the replacement action, or the action should call a new replacement action so that solutions that are built on the deprecated version of the action do not break. You should create a workflow for every operation that is available in the user interface of the orchestrated technology. The description of a workflow should describes what the workflow does instead of how it works. You need to set the mandatory input property for all mandatory workflow inputs. If you develop a workflow that configures an entity, the workflow presentation should load the default configuration values for this entity. For example, if you develop a workflow that is named Host Configuration, the presentation of the workflow must load the default values of the host configuration. You need to set the Show in inventory property to have contextual workflows on inventory objects. You should use this property in workflows when it is not necessary to browse the inventory from the tree root. You must validate workflows and fix all errors.
Description Scripting
Deprecation
Workflow
User interface operations in the orchestrated technology Description Presentation property mandatory input Presentation property default value
Presentation property Show in inventory Presentation property specify a root parameter Workflow validation
VMware, Inc.
21
Inventory
Host disconnection
Finder object
Scripting object
Implementation
22
VMware, Inc.
Trigger
Object properties
Session manager
Trigger
Trigger
Enumerations
Enums
vso.xml
VMware, Inc.
23
24
VMware, Inc.
When you write user interface (UI) strings for vCO plug-ins and the related API documentation, it is best practice to follow the accepted rules of style and format.
General Recommendations
n
Use the official names for any of VMware products involved in the plug-in. For example, use the official names for the following products and VMware terminology.
Correct Term vCenter Server vCloud Director virtual machine Do Not Use VC or vCenter vCloud VM
End all complete sentences with a period. For example, Creates a new Organization. is a workflow description. Use a text editor with a spell checker to write the descriptions and then move them to the plug-in. Ensure that the name of the plug-in exactly matches the approved third-party product name that it is associated with.
n n
Write informative descriptions. One or two sentences are enough for most of the actions and workflows. Higher-level workflows might include more extensive descriptions and comments. Start descriptions with a verb, for example, Creates. Do not use self-referential language like This workflow creates. Put a period at the end of descriptions that are complete sentences. Describe what a workflow or action does instead of how it is implemented. Workflows and actions usually are included in folders and packages. The enclosing folders and packages should include a small description as well. For example, a workflow folder can have a description similar to Set of workflows related to vApp Template management.
n n n
Start workflow and action descriptions with a descriptive noun phrase, for example, Name of. Do not use a phrase like It's the name of. Do not put a period at the end of parameter and action descriptions. They are not complete sentences.
VMware, Inc.
25
Input parameters of workflows must specify a label with appropriate names in the presentation view. In many cases, you can combine related inputs in a display group. For example, instead of having two inputs with the labels Name of the Organization and Full name of the Organization, you can create a display group with the label Organization and place the inputs Name and Full name in the Organization group. For steps and display groups, add descriptions or comments that appear in the workflow presentation as well.
Plug-in API
n
The documentation of the API refers to all of the documentation in the vso.xml file and the Java source files. For the vso.xml file, use the same rules for the descriptions of finder objects and scripting objects with their methods that you use for workflows and actions. Descriptions of object attributes and method parameters use the same rules as the workflow and action parameters. Avoid special characters in the vso.xml file by including the descriptions inside a <![CDATA[insert your description here!]]> tag. Use the standard Javadoc style for the Java source files.
26
VMware, Inc.
Index
A
advices 18 API documentation 25
O
overview 10 Overview 9
P
plug-in implementation project internals 16 project structure 15 workflow internals 17 workflow presentation 18 plug-in strings 25 plug-in structure 7 plug-in types plug-ins for services 11 plug-ins for systems 12 plug-ins for systems object-oriented systems 13 resource-oriented systems 13
V
vCO plug-in starter kit 5
VMware, Inc.
27
28
VMware, Inc.