Tải bản đầy đủ (.pdf) (24 trang)

VMware vFabric Application Director and vFabric Data Director Integration Solution Guide pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.97 MB, 24 trang )


VMware vFabric Application
Director and vFabric Data
Director Integration Solution
Guide

T E C H N I C A L W H I T E P A P E R

T EC H N I C AL W H IT E P AP E R /1
VMware vFabric Application Director and Data Director Integration Solution Guide
Table of Contents
Introduction 2
vFabric Application Director 2
Product Overview 2
Key Concepts 3
vFabric Data Director 3
Product Overview 3
Key Concepts 4
REST API 5
vFabric Application Director and vFabric Data Director Integration Solution 5
Integration Benefits 5
Integration Solution 6
Example Use Case 7
1. Create new service in catalog 7
2. Define service properties 8
3. Implement service creation script 9
4. Create application and blueprint 10
5. Add service to the blueprint 11
6. Assign values to service properties 11
7. Create SQL Script component 12
8. Deploy the application 13


Conclusion 15
VMware Contact Information 16
Appendix A – vFabric Data Director Service script 17


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
Introduction
Application development is evolving faster than ever in the cloud. Daily updates to functionality, frequent
changes in scale, and constant user demands create rapid change. Cloud computing provides application
owners with instant access to infrastructure; however, building out applications still requires administrators to
individually install and configure components on each virtual machine to plug into the application
architecture. Organizations need a better way to accelerate and automate the configuration and deployment
of multi-tier applications across cloud environments.
Most of today’s applications contain a database component. Database creation, administration, and
management typically require a skill set that goes beyond that of application developers. Therefore,
databases are traditionally managed by DBAs in an organization. The separation of responsibilities and
resulted business processes may potentially lead to operational complexity and inefficiency among IT
administrators, DBAs, and application developers. Moreover, in a legacy database environment,
organizations often struggle with arduous development cycles, long deployment and provisioning times,
difficult and expensive database management, lack of centralized control over critical resources, and
expensive licensing schemes. Organizations have a strong demand for extending virtualization and cloud
computing benefits to their database environments to address these issues.
VMware vFabric™ Application Director is an application provisioning solution that provides deployment
automation and self-service provisioning by standardizing, streamlining and automating release into hybrid
cloud environments. VMware vFabric Data Director improves agility and drastically reduces database TCO
through database-aware virtualization and self-service lifecycle management, empowering administrators to
securely automate routine tasks including database provisioning, high availability, backup, and cloning.
Together, vFabric Application Director and vFabric Data Director offer a powerful solution that builds upon

the VMware virtualization and cloud infrastructure to automate and accelerate application development.
This paper provides a technical overview of how vFabric Application Director and vFabric Data Director can
be integrated together as a solution to automated application and database deployment. Detailed
procedures along with screenshots are provided in this paper to help readers understand the integration
method and implement it practically in their specific environments.
vFabric Application Director
Product Overview
vFabric Application Director is designed for application teams to leverage highly reusable and available
cloud infrastructure to simplify and automate application provisioning and release for cloud ready
applications. By standardizing infrastructure and application components, and abstracting application
specific deployment logic, vFabric Application Director untethers applications from the underlying
infrastructure so that applications can be provisioned across any VMware based cloud infrastructure flexibly.
vFabric Application Director offers the following key features:

Simple and automated application provisioning: use of graphical drag-and-drop canvas for creating
application blueprints, intuitive point-and-click interface for customizable scripts, and comprehensive
deployment execution plans.

Cloud-ready provisioning: abstraction of application specific deployment logic from the underlying
cloud infrastructure, automatically generated deployment execution plans, and open and extensible
architecture.

Standardized use of application components and middleware: ready-to-use out-of-the-box


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
middleware installation and configuration services, optimization for vFabric middleware stack, and
integration with cloud templates.

For detailed product specifications and systems requirements, refer to the VMware vFabric Application
Director documentation.
Key Concepts
The following definitions help you understand the key vFabric Application Director concepts in this white
paper.
Application: logical deployment unit, consisting of application components and their dependent services
and operating systems that can be distributed across multiple virtual machines.
Application component: custom code packaged as EAR file, WAR files, and so on.
Blueprint: logical topology of an application for deployment. A blueprint captures the structure of an
application with logical nodes, their corresponding services and operating systems, dependencies, default
configurations, and network topology requirements.
Deployment profile: collection of deployment settings for a blueprint, including cluster size, CPU, memory,
cloud tmplates, and networks.
Node: virtual machine or a cluster of virtual machines defined in the blueprint.
Catalog: library that contains logical templates, which are pointers to cloud templates, as well as scripted
software, called services that can be installed on a virtual machine.
Service: scripted software that can be installed on a virtual machine and reused in multiple applications.
Properties: configuration name-value pairs for services and application components. These are variables
used by the scripts to set parameters on a script and run various configurations.
Actions: Life cycle stages for the install, configuration, and start scripts for services and application
components to be installed.
Execution plan: task plan for viewing the order in which virtual machines are created and software is
installed, configured, and started.
vFabric Data Director
Product Overview
vFabric Data Director enables database-aware virtualization on VMware vSphere® and provides self-service
lifecycle management for heterogeneous databases, increasing developer agility and reducing database
costs vFabric Data Director reduces capex through database-aware virtualization, increases agility through
automated lifecycle management, and accelerates application development through policy-based self-
service. Designed for both enterprises and service providers, vFabric Data Director empowers

administrators to securely automate and delegate routine tasks, including database provisioning, backup
and cloning. Currently, Oracle and VMware vFabric Postgres databases are supported, with more
databases to be supported in the future. Figure 1 shows the vFabric Data Director architecture.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 1. vFabric Data Director platform architecture
vFabric Data Director offers the following key features:

Database-aware virtualization: simplified virtualization process through a unified platform with
integrated capabilities, resource management and isolation, integrated template management and
database ingestion.

Automated lifecycle management: powerful Web-based management console, database provisioning
in minutes using database templates, innovative database cloning, policy compliance, and database-
aware high availability.

Self-service: self-service database provisioning, self-service database management, and robust role-
based access control (RBAC).
For detailed product specifications and systems requirements, refer to the VMware vFabric Application
Director documentation.
Key Concepts
The following definitions help you understand the key vFabric Data Director concepts in this white paper.
System: the database lifecycle management platform, which is the top level of the vFabric Data director
hierarchy.
Organization: the basic component of vFabric Data Director. A system can contain multiple organizations,
each of which can have its own administrator and allocated resources.

Database group: a component of an organization. Each database group contains a set of databases that
share the resources provided to the group, enabling subdivision of resources from the organization’s
allocated resources.
Database: a component of a database group. A database refers to an instance of a database such as
Oracle and vFabric Postgres.
DBVM: a virtual machine that contains the virtual hardware, structure, and the required files and
configuration information necessary to build database templates and to create and operate databases.
Base database template: a template that provides the blueprint for creating a database. A base DB
template is converted from a base DBVM.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
Database resource template: a template that defines the computing and storage resources for creating a
database, the database parameter group, and the high availability settings.
Resource settings: the specification of number of virtual CPUs, memory size, and recommended database
storage allocation in a resource template. Moreover, high availability for the template and all corresponding
databases, as well as CPU and memory priority can be specified in resource settings.
Parameter group: the specification of connection, memory, I/O, WAL, checkpoint, logging, and other
information for the database in a resource template.
Backup template: a template that defines backup settings for databases, such as internal and external
backup frequency, start time, retention, and point-in-time recovery.
Point-in-time recovery: when enabled, point-in-time recovery ensures that each database transaction is
recorded and enables reversion of the database to any point in time within a certain time range.
User tag: a tag to filter the list of databases that are viewed in an organization.
REST API
The vFabric Data Director API provides support for developers who build interactive clients of vFabric Data
Director using a RESTful application development style. The API calls communicate over HTTP, exchanging
representations of vFabric Data Director objects. These representations are encoded as XML elements or

JSON objects, depending on the format of your request.
You can use HTTP GET requests to retrieve the current representation of an object, HTTP POST and PUT
requests to create or update an object, and HTTP DELETE requests to delete an object. Figure 2 displays
the structure of a request. More information about the API can be found in document vFabric Data Director
API Programming Guide at

Figure 2. Request format
vFabric Application Director and vFabric Data
Director Integration Solution
Integration Benefits
vFabric Application Director provides a set of out-of-the-box catalog services that allow certain databases,
including Oracle and vFabric Postgres, to be installed and configured for basic deployment. An integrated
Application Director and Data Director solution enables more advanced database provisioning and
management during the application development lifecycle. The integration solution offers the following
benefits:


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Data Director allows template-based database creation to give application developers more flexibility in
creating tailored databases. Each database template can be customized with configuration settings that
satisfy unique application requirements during application deployment.

Approved database templates help ensure that best practices widely applied in database deployment
are conformed to. Databases deployed from these templates can easily be patched and maintained.
More importantly, common compliance and security requirements associated with database deployment
in the organization can be enforced appropriately to eliminate potential vulnerabilities and risks in the
application environment.


Data Director makes it easy to ingest and clone databases from a production database and then mask
certain production data as needed, enabling application deployment where the application is tested with
and run against real or masked production data.

Since application developers and DBAs typically operate in different realms, while application
developers lack expertise to manage these databases, DBAs may not be aware of the existence of
them or have difficulty to locate them in order to manage the lifecycle of these databases centrally. This
easily leads to database sprawl in the organization where unmanaged and undermanaged databases
are difficult to patch, backup, clone, and recover. With the integration, each database is created in Data
Director, hence making it visible and available for central lifecycle management. DBAs can delegate
routine tasks on databases to application developers leveraging the built-in database management
capabilities in Data Director.
Integration Solution
The integration solution is built upon the vFabric Application Director framework for catalog services
management and the vFabric Data Director REST APIs. Figure 3 illustrates the workflow of the solution
implementation in vFabric Application Director.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 3. Steps to integrate vFabric Data Director into vFabric Application Director

As a prerequisite, the vFabric Application Director server must have network connectivity to the vFabric Data
Director server, and the application deployment environment must have network connectivity to the DBVMs.
Example Use Case
A use case is provided in this section to demonstrate how the solution works and how to implement the
solution in a real-world application deployment. In this use case, an application architect creates and

deploys an application blueprint for a 3-tier application that is consisted of the Web tier, the application tier,
and the database tier. The application tier runs the sample Dukes Bank application that is by default
included in vFabric Application Director installation, and the database tier operates a vFabric Postgres
database provided by vFabric Data Director. The implementation process follows the workflow in Figure 3.
1. Create new service in catalog
Log on to vFabric Application Director and click Manage Catalog Items. Click the button to create a new
service.
Create
vFDD
service
in
catalog
Define
service
propertie
s
Impleme
nt script
using
vFDD
REST
APIs
Create
applicati
on
blueprint
Add the
vFDD
service
to

blueprint
Specify
vFDD
service
property
values
create
SQL
Script
compone
nt
Deploy
applicati
on
Create script & service to
call vFDD API

Use the service & script

application blueprint




















VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 4. Create a service in vFabric Application Director
2. Define service properties
Service properties are used to parameterize service scripts so that vFabric Application Director can pass the
defined properties as environment variables to scripts running in a virtual machine. The vFabric Application
Director agent in the virtual machine communicates with the vFabric Application Director server to resolve
the properties. The agent then proceeds to create environment variables and passes them to the scripts.
The following properties must be defined for the service:
DD_HOST # vFDD server FQDN or IP
DD_USER # vFDD user that is authorized to create DB in the org
DD_PASSWD # vFDD user password
DB_NAME # name of the database to be created
DB_IP # connection string or IP of the database created
DB_OWNER # desired admin user for the database to be created
DB_PASSWD # Password for the desired database admin user
DD_ORG # the organization where the database is created
DD_DB_GROUP # the database group where the database is created
DD_DB_TEMPLATE # the base database template to be used

DD_PARAMETER_GRP # the database parameter group template to be used
DD_RESOURCE_TEMPLATE # the database resource settings template to be used
DB_DESCRIPTION # description of the database
DD_BACKUP_TEMPLATE # the database backup template to be used
DD_USER_TAG # the user tag to be applied to the database
DD_SNAPSHOT # whether a snapshot is created after database creation
APP_NODE_INDEX # the cluster node index of the application server in AppD
A default value can be assigned to each of these properties. These values can be overridden in application
blueprint to accommodate the needs of a specific application. The values can be further overridden in the
deployment profile to comply with the development environment. Figure 5 shows an example of the
definition of the service properties.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 5. Service properties

3. Implement service creation script
Each service includes the three predefined life cycle stages or actions to install, configure, and start scripts.
A bash script must be provided for at least one of the lifecycle stages. In this solution, a bash script is
created for only the INSTALL stage. The script uses the
cURL
command-line tool to communicate with the
vFabric Data Director server over HTTP. If the
cURL
tool is not installed in the logical template already, the
script assumes that Internet access is set up appropriately for the virtual machine to install the tool.


Figure 6. Service creation script
The script has a workflow described in Figure 7. The entire script is attached in Appendix A of this white
paper.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 7. DB creation script
vFabric Data Director uses its DB Name Server virtual machine to route database connections to the Data
Director-deployed databases. The database connection string has a format of
{UUID}.DBNameService_IP_Address, where the curly brackets, {}, are part of the connection string and
denote the UUID. This leads to the benefit that applications do not need to be modified or reconfigured to
connect to the database in case its IP address has changed. While this is the recommended method of
connecting to a database, you can also simply use the IP address to connect to the database in the
traditional way. The script will need to be modified slightly to fetch the database IP address rather than the
connection string after the database is created successfully.
4. Create application and blueprint
For illustration purpose in this use case, find the 3-tier Clustered Dukes Bank App application in vFabric
Application Director, and click the button to copy and create a new one named
ClusteredDukesBankWithDataDirector. The application blueprint contains a Apache load balancer, a cluster
of Dukes Bank application servers, and a MySQL database server using the out-of-the-box MySQL catalog
service.
Install the
curl tool
Query and find ID of
the specified org
Query and find ID of
the specified db group

DB exists?
Return db connection
string
Query and find ID of the
specified base db template
Query and find ID of the specified
db parameter group
Query and find ID of the
specified resource template
Query and find ID of the
specified backup template
Query and find ID of the
specified user tag
Node 0?
Create DB
Wait for DB
creation
Query and find ID of
the db being created
Query and find ID of the
db creation task
Check status of the db
creation task
Success?

n
y
y
n
y

n


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 8. Create application and blueprint
5. Add service to the blueprint
Remove the MySQL server from the blueprint, and drag-and-drop the vFabric Data Director Service onto the
cluster of application servers. The DBVM for the application will be created in the vFabric Data Director
environment instead of the vFabric Application Director deployment environment.
Theoretically, the service can be placed in any node of the application blueprint, in this example including
the Apache load balancer. If the service is considered a component of clustered nodes, as shown in this
paper, a mechanism is put in place to ensure that only one node of the cluster will run the service to create a
database while other nodes simply use the database after it is created.
6. Assign values to service properties
The Dukes_Bank_App component of the application needs to be updated slightly due to the original MySQL
server being replaced by the vFabric Postgres server. First, the database-related properties need to be
changed to have values shown in Figure 9.

Figure 9. Application properties
Secondly, the bash script for the INSTALL lifecycle stage needs to be modified to replace the following two
lines:
export JBOSS_DS_CONNECTION_URL="jdbc:mysql://$db_host:$db_port/dukes_db"

export JBOSS_DS_CONNECTION_URL="jdbc:postgresql://$db_host/dukes_db"

export JBOSS_DS_DRIVER_CLASS="com.mysql.jdbc.Driver"


export JBOSS_DS_DRIVER_CLASS="org.postgresql.Driver"
Based on the application requirements, assign values to the vFabric Data Director Service properties. These
values override the ones specified in the service catalog. It is important to enter correct vFabric Data
Director information for the properties. The values are case sensitive, see figure 10.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 10. Blueprint values for the service properties
7. Create SQL Script component
An optional SQL SCRIPT component can be added to the vFabric Data Director Service to perform
database operations. In this example use case, such a component is added to create the database schema
and populate data for the Dukes Bank application to use during runtime.
First, drag-and-drop the SQL SCRIPT application component onto the vFabric Data Director Service in the
blueprint. Then, define the following properties for the component.

Figure 11. SQL Script component properties
Lastly create the following bash script for the INSTALL lifecycle stage of the component:
#!/bin/sh

export PATH=$PATH:/opt/vmware/vpostgres/9.1/bin/i686

# Install psql client
yum nogpgcheck -y clean all
yum –-nogpgcheck –y localinstall $eula_rpm


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com

Copyright © 2010 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
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.
yum nogpgcheck -y localinstall $client_rpm

#run the sql file
if [ $APP_NODE_INDEX -eq 0 ]
then
export LDAPTLS_REQCERT=allow
PGPASSWORD=$db_password psql -U $db_user -h $db_host -d $db_name < $sql_file
fi
The open source Postgres client tools can be installed to connect to the vPostgres database using its IP
address. However, it is highly recommended to use the VMware-provided vPostgres client tools to
communicate with the vPostgres database. You need to download the EULA and client rpm files and place
them on the vFabric Application Director server under the path defined in the eula_rpm and client_rpm
properties (full physical path /opt/vmware/darwin/htdocs/artifacts/services/aurora on the Application Director
server) as shown in Figure 11.
After clicking the button to create a relation between the Dukes_Bank_App component and the
vFabric_Data_Director_Service, the application is ready to be deployed. Figure 12 shows the complete
application blueprint.

Figure 12. Completed application blueprint
8. Deploy the application
Click the button to deploy the application. The deployment environment must be mapped out first.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 13. Application deployment environment

In the next step, application properties, including the vFabric Data Director Service properties, can be
overridden to tailor to the specific deployment profile.

Figure 14. Application properties for deployment
A deployment execution plan is created automatically to detail how the deployment proceeds step by step.
During the deployment, you can review component properties and scripts, as well as viewing deployment
status and logs.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.

Figure 15. Deployment execution plan
When the vFabric Data Director Service is installed during execution, the database is created in vFabric
Data Director as shown in Figure 16.

Figure 16. Database creation
Conclusion
Organizations increasingly face the challenges of developing and deploying applications in a timely manner
to satisfy business requirements. Moreover, they have to respond to these challenges with speed, agility and
efficiency while at the same time applications are becoming more and more complex in size and scale.
Consequently, tools are in great demand to help organizations simplify, streamline, and automate their
application development lifecycle.


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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 vFabric Application Director is an application provisioning solution that simplifies creating and

standardizing application deployment topologies on infrastructure clouds. VMware vFabric Data Director
enables self-service database provisioning and lifecycle management. Both products provide essential tools
to help application development.
The integration solution described in this white paper bridges the best of both products to help application
developers, IT administrators, and database administrators deploy and manage applications and one of the
most critical application components - databases. The solution is easy to implement in a customer
environment, and can be leveraged to greatly accelerate application development for organizations in their
cloud infrastructure.
For more information about VMware vFabric Application Director and vFabric Data Directo, please visit the
product pages at


VMware Contact Information
For additional information or to purchase VMware vFabric Application Director and vFabric Data Director,
VMware’s global network of solutions providers is ready to assist. If you would like to contact VMware
directly, you can reach a sales representative at 1-877-4VMWARE (650-475-5000 outside North America) or
email When emailing, please include the state, country, and company name from
which you are inquiring. You can also purchase both products online.



VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
Appendix A – vFabric Data Director Service script
#!/bin/bash

# Install prerequisite curl
# . $global_conf


##### Change the http_proxy to fit your environment
export http_proxy=:3128
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

#Setup repository, should be done at template level
rm -rf /etc/yum.repos.d/*
fixed_repository_name=onemirror
repository_url="
cat > "/etc/yum.repos.d/$fixed_repository_name.repo" << YUMREPOCONFIG
[$fixed_repository_name]
name=$fixed_repository_name
baseurl=$repository_url
gpgcheck=0
YUMREPOCONFIG
yum repolist
yum nogpgcheck noplugins -y install curl

### Define global parameters, these parameters need to be defined in vAppD as input to
the script
#DD_HOST
#DD_USER
#DD_PASSWD
#DB_NAME
#DB_IP
#DB_OWNER
#DB_PASSWD
#DD_ORG
#DD_DB_GROUP
#DD_DB_TEMPLATE
#DD_PARAMETER_GRP

#DD_RESOURCE_TEMPLATE
#DB_DESCRIPTION
#DD_BACKUP_TEMPLATE
#DD_USER_TAG
#DD_SNAPSHOT
#APP_NODE_INDEX
### Done defining input parameters

DBVM_NAME="$DB_NAME"
REST_URL="https://"$DD_HOST"/datadirector/api/"
CONTENT_TYPE="application/json"
CONTENT_ACCEPT="application/json"

# This function takes the curl JSON format output and breaks it into an array of vFDD
objects


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
function json_parser () {
local json_str=`echo $cmd_out | sed "s/^\[\(.*\)\]$/\1/"` # remove the leading [ and
ending ] characters
json_str=`echo $json_str | sed -r "s/\},\{/\}|\{/g"` # replace the delimiter for
objects from "," to "|"
IFS="|"
read -ra vfdd_objects <<< "$json_str" # break the string into an array
with the "|" delimiter
}


function name2id () {
local name=$1
local id
local object

for object in ${vfdd_objects[@]}
do
if [[ $object =~ \"name\"\:\"$name\" ]]
then
# Get the object ID based on the object name
id=`echo $object | sed "s/.*\"href\"\:\"https.*datadirector\/api\/.*\/\([0-
9]*\)\"\,.*/\1/"`
return $id
fi
done
return 0
}


:##### This script calls vFDD REST APIs to create a DBVM with the minimumly required
parameters #####
# The minimumly required parameters are: name, DB name, DBGroup ID, base DB template ID,
parameter group ID, DB administrator name,
# DB administrator password, resource template ID
########################################################################################
############

cmd_out="" # A global variable to store API return string
vfdd_objects=() # An array to store vFDD objects after processing the API return


# Query and find the ID of the specified vFDD org
REST_API="orgs"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_ORG
org_id=$?
if [ $org_id -eq 0 ]
then
echo "Could not find ORG $DD_ORG"
return 1
else


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
echo "Found ORG $DD_ORG with id $org_id"
fi

# Query and find the ID of the specified DB group
REST_API="org/$org_id/dbgroups"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_DB_GROUP
dbgroup_id=$?
if [ $dbgroup_id -eq 0 ]

then
echo "Could not find DBGroup $DD_DB_GROUP"
return 1
else
echo "Found DBGroup $DD_DB_GROUP with id $dbgroup_id"
fi

# Check and return the ip of the specified DB if it already exists
if [ $APP_NODE_INDEX -eq 0 ]
then
REST_API="dbgroup/$dbgroup_id/databases"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
if [[ $cmd_out =~ \"name\"\:\"$DBVM_NAME\" ]]
then
name2id $DBVM_NAME
db_id=$?
REST_API="database/$db_id"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})
#DB_IP=`echo $cmd_out| sed "s/.*\"ipAddress\"\:\"\([^\"]*\)\",.*/\1/" `
DB_IP=`echo $cmd_out| sed "s/.*\"connectionString\"\:\"\([^\"]*\)\",.*/\1/" | sed
"s/.*\/\/\(.*\)\:.*\/.*/\1/"`
echo "DB $DBVM_NAME EXISTS ALREADY AT $DB_IP"
return 0
fi
fi


# Query and find the ID of the specified base DB template
REST_API="basedbtemplates"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_DB_TEMPLATE
dbtemplate_id=$?
if [ $dbtemplate_id -eq 0 ]
then
echo "Could not find DBTemplate $DD_DB_TEMPLATE"


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
return 1
else
echo "Found DBTemplate $DD_DB_TEMPLATE with id $dbtemplate_id"
fi

# Query and find the ID of the specified DB parameter group
REST_API="org/$org_id/basedbtemplate/$dbtemplate_id/dbparametergroups"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_PARAMETER_GRP
parametergrp_id=$?
if [ $parametergrp_id -eq 0 ]

then
echo "Could not find ParameterGroup $DD_PARAMETER_GRP"
return 1
else
echo "Found ParameterGroup $DD_PARAMETER_GRP with id $parametergrp_id"
fi

# Query and find the ID of the specified resource template
REST_API="org/$org_id/resourcetemplates"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_RESOURCE_TEMPLATE
resourcetemplate_id=$?
if [ $resourcetemplate_id -eq 0 ]
then
echo "Could not find ResourceTemplate $DD_RESOURCE_TEMPLATE"
return 1
else
echo "Found ResourceTemplate $DD_RESOURCE_TEMPLATE with id $resourcetemplate_id"
fi

# Query and find the ID of the specified backup template
REST_API="org/$org_id/backuptemplates"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_BACKUP_TEMPLATE

backuptemplate_id=$?
if [ $backuptemplate_id -eq 0 ]
then
echo "Could not find BackupTemplate $DD_BACKUP_TEMPLATE"
return 1
else
echo "Found BackupTemplate $DD_BACKUP_TEMPLATE with id $backuptemplate_id"
fi



VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
# Query and find the ID of the specified user tag
if [ -n "$DD_USER_TAG" ]
then
REST_API="usertags"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})

json_parser $cmd_out
name2id $DD_USER_TAG
usertag_id=$?

if [ $usertag_id -eq 0 ]
then
echo "Could not find UserTag $DD_USER_TAG"
return 1
else

echo "Found UserTag $DD_USER_TAG with id $usertag_id"
fi
fi

# Create the DBVM if the AppD node (in a cluster) is 0, otherwise, should just wait for
the DB to be created.
# Basically only one DB should be created for the cluster of App servers.
if [ $APP_NODE_INDEX -eq 0 ]
then
REST_API="databases"
if [ -n "$DD_USER_TAG" ]
then
cmd_out=$(curl -s -X POST -u ${DD_USER}:${DD_PASSWD} -H "Content-Type:
${CONTENT_TYPE}" -k -d \
"{\"name\":\"$DBVM_NAME\", \"description\":\"$DB_DESCRIPTION\",
\"dbName\":\"$DB_NAME\", \"dbgroupId\":$dbgroup_id, \
\"baseDbTemplateId\":$dbtemplate_id,
\"backupSetting\":{\"backupTemplateId\":$backuptemplate_id}, \
\"parameterGroupSetting\":{\"parameterGroupId\":$parametergrp_id},
\"administratorConfig\":{ \
\"ownerName\":\"$DB_OWNER\", \"ownerPassword\":\"$DB_PASSWD\"},
\"resourceSetting\":{ \
\"resourceTemplateId\":$resourcetemplate_id}, \
\"userTag\":{\"instance\":[{\"tagId\":$usertag_id}]},
\"takeSnapshotAfterCreation\":$DD_SNAPSHOT}" ${REST_URL}${REST_API})
else
cmd_out=$(curl -s -X POST -u ${DD_USER}:${DD_PASSWD} -H "Content-Type:
${CONTENT_TYPE}" -k -d \
"{\"name\":\"$DBVM_NAME\", \"description\":\"$DB_DESCRIPTION\",
\"dbName\":\"$DB_NAME\", \"dbgroupId\":$dbgroup_id, \

\"baseDbTemplateId\":$dbtemplate_id,
\"backupSetting\":{\"backupTemplateId\":$backuptemplate_id}, \
\"parameterGroupSetting\":{\"parameterGroupId\":$parametergrp_id},
\"administratorConfig\":{ \
\"ownerName\":\"$DB_OWNER\", \"ownerPassword\":\"$DB_PASSWD\"},
\"resourceSetting\":{ \
\"resourceTemplateId\":$resourcetemplate_id}, \


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
\"takeSnapshotAfterCreation\":$DD_SNAPSHOT}" ${REST_URL}${REST_API})
fi

if [ -n "$cmd_out" ]
then
echo "DB CREATION FAILED"
return 1
fi
sleep 30 # wait 30 seconds to allow DB creation to start
else
sleep 60 # wait 60 seconds for the DB creation in node 0 to kick off
fi

# Find the newly created DB ID
REST_API="dbgroup/$dbgroup_id/databases"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})
json_parser $cmd_out

name2id $DBVM_NAME
db_id=$?
echo "Found Newly created DBVM_NAME $DBVM_NAME with id $db_id"

# Find the ID of the DB creation task
REST_API="database/$db_id/tasks"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})
if [[ $cmd_out =~ \"name\"\:\"Create\ Database\" ]]
then
task_id=`echo $cmd_out | sed "s/.*\"href\"\:\"https.*datadirector\/api\/.*\/\([0-
9]*\)\"\,.*/\1/"`
echo "Found the database creation task ID $task_id"
fi

# Check the status of the DB creation task
REST_API="task/$task_id"
echo "Waiting for DB $DB_NAME to be created"
while true
do
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k
${REST_URL}${REST_API})
shopt -s nocasematch
if [[ $cmd_out =~ \"status\"\:\"error.*\" ]]
then
echo "The DB creation has failed"
break
elif [[ $cmd_out =~ \"status\"\:\"RUNNING\" ]]
then
echo "DB is still being created"

sleep 30
elif [[ $cmd_out =~ \"status\"\:\"SUCCESS\" ]]
then
REST_API="database/$db_id"
cmd_out=$(curl -s -u ${DD_USER}:${DD_PASSWD} -H "Accept: ${CONTENT_ACCEPT}" -k


VMware, Inc. 3401 Hillview Avenue Palo Alto CA 94304 USA Tel 877-486-9273 Fax 650-427-5001 www.vmware.com
Copyright © 2010 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
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.
${REST_URL}${REST_API})
# DB_IP=`echo $cmd_out| sed "s/.*\"ipAddress\"\:\"\([^\"]*\)\",.*/\1/" `
DB_IP=`echo $cmd_out| sed "s/.*\"connectionString\"\:\"\([^\"]*\)\",.*/\1/" | sed
"s/.*\/\/\(.*\)\:.*\/.*/\1/"`
echo "DB $DB_NAME CREATED SUCCESSFULLY AT $DB_IP"
break
fi
done

×