top of page
  • Writer's picturekyle Hailey

DevOps & Delphix : Chef recipes

Delphix Engines expose all features via a stable WEB API built on top of HTTP and JSON.

Clients choose an HTTP client to interact with Delphix and integrate within their environment.

Delphix Engines are bundled with a command line interface which guides users for automation and integration with third party tools.

Delphix CLI example

Adding a SQL Server Source Environment:

Enter these commands through the command line interface:

   environment;

   create;
   set type=HostEnvironmentCreateParameters;

   set hostEnvironment.type=WindowsHostEnvironment;
   set hostEnvironment.name=<Source environment name>;
   set hostEnvironment.proxy=<target host name>;

   set hostParameters.type=WindowsHostCreateParameters;
   set hostParameters.host.type=WindowsHost;
   set hostParameters.host.addresses="<Source host IP address or hostname>";

   set primaryUser.name="<domain\username>";
   set primaryUser.credential.type=PasswordCredential;
   set primaryUser.credential.password=<password>;

   commit;

Delphix Curl API example

Example of refreshing a virtual database back to the newest version of the source database

  curl -v -X POST -k --data @- http://delphix-server/resources/json/delphix/database/ORACLE_DB_CONTAINER-13/refresh  \
    -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
       "type": "OracleRefreshParameters",
       "timeflowPointParameters": {
               "type": "TimeflowPointSemantic",
               "timeflow": "ORACLE_TIMEFLOW-13",
               "location": "LATEST_SNAPSHOT"
       }
}
EOF

 Chef as a database provisioning tool

Chef is an automation platform for provisioning physical or virtual environments to a specific state in a controlled and repeatable way.

Chef may install binaries, control users, configuration.

Chef as a database provisioning tool:

  1. Install binaries of the DBMS

  2. Configure the DBMS

  3. Provision data

Installing the binaries and configuring the database might be standard work for Chef but actually provisioning the data such as a copy of a source database is generally out of the purview of Chef, at least until now. Now with Delphix provisioning of the data, no matter the size, can be done in minutes with a few API calls.

With chef, one usually does not describe actions to take (“provision a VDB”), but the desired state of the system (“There must be a VDB running on that port”). This allows rules to be applied to heterogeneous systems in different states and continuously compared the actual with the desired state of the system (for instance, if a new server is added after the fact, it will notice that it needs to provision a VDB to get to the desired state). This is achieved through the separation of resources provider and recipes. The resource provider is the “library” which knows about the low level details of the implementation (is there a VDB running? how do I connect to a Delphix Engine? Which steps needs to be taken to go from the current state to a VDB being provisioned?). The “recipe” describe the state leveraging the resource providers.

Chef: Provisioning data from Delphix

Chef cookbooks (recipes) can use the Delphix Engine API to provision data.


Chef recipes describe the desired state of the system.

Chef & Delphix example to provision a virtual database

In the following “dlpx_pgsql_vdb” is the block in the recipe which indicates the state of the system. It means “We want a postgresql (pgsql) VDB running”.

dlpx_pgsql_vdb "HR" do
        action :provision
        port node[:dlpx][:port] || 5443
        container "HR"
        delphix_server node[:dlpx][:delphix_server]
end

In this code details the following means:

dlpx_pgsql_vdb “HR”; do

We are describing the desired state of a postgresql Delphix VDB, and the Chef name for that is “HR”

action :provision

We want the VDB to be provisioned (as opposed to deleted or refreshed daily for instance)

port node[:dlpx][:port] || 5433

The port is read from the host configuration and defaults to 5433 (the recipes could be shared by many hosts or servers, each of them with their own config)

container “HR”

We want Delphix to name that VDB “HR”

delphix_server node[:dlpx][:delphix_server]

Look at the configuration for the hostname and credentials of the Delphix engine

Chef Providers build the library of utilities which can be leveraged in recipes. A Delphix Chef Provider can be built on top of the HTTP API.

def provision(group, mount_base, name)
    response = RestClient.post("#{@url}/database/provision", {
      :type => "OracleProvisionParameters",
      :container => {
        :type => "OracleDatabaseContainer",
        :name => name,
        :group => group
      },
      :source => {
        :type => "OracleVirtualSource",
        :mountBase => mount_base
      }
    }.to_json,
    {
      :content_type => 'application/json',
      :cookies => @cookies
   })
end

In this exmple

  1. source –  hard coded as OracleVirtualSource

  2. group – the delphix user group

  3. mount_base –  nfs mount location on the target

  4. name –  the new VDB name

3 views0 comments

Comments


bottom of page