Skip to content
nabhajit-ray edited this page Feb 15, 2021 · 4 revisions

Welcome to HPE OneView SDK for Terraform Provider wiki!

Introduction

HPE OneView makes it simple to deploy and manage today’s complex hybrid cloud infrastructure. HPE OneView can help you transform your data center to software-defined, and it supports HPE’s broad portfolio of servers, storage, and networking solutions, ensuring the simple and automated management of your hybrid infrastructure. Software-defined intelligence enables a template-driven approach for deploying, provisioning, updating, and integrating compute, storage, and networking infrastructure.

The HPE OneView Terraform SDK enables developers to easily build integrations and scalable solutions with HPE OneView and HPE Image Streamer.

You can find the latest supported HPE OneView Terraform Provider SDK here

Please refer to notes for more information on the changes , features supported and issues fixed in this version


Installation

HPE OneView SDK for Terraform can be installed from Source or Docker container installation methods. You can either use a docker container which will have the HPE OneView SDK for terraform installed or perform local installation manually. The terraform-provider-oneview now supports both Terraform 0.11 and 0.12

Terraform 0.11

Installing from Docker

The light weight containerized version of the HPE OneView SDK for Terraform is available in the Docker Store. The Docker Store image tag consist of two sections: <sdk_version-OV_version>

# Download and store a local copy of oneview-sdk-for-terraform and use it as a Docker Image.
$ docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-11-OV5.6
# Run docker commands below given, which  will in turn create a sh session 
# where you can create files, issue commands and execute the examples.
$ docker run -it docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-11-OV5.5 /bin/sh

Installing in Local Setup

Local installation requires

Installing Go

$ apt-get install build-essential git wget
$ wget https://dl.google.com/go/go1.11.3.linux-amd64.tar.gz

#unzip and untar the file 
$ tar -zxvf go1.11.3.linux-amd64.tar.gz

# move it to /usr/local/ and create directory for Go.
$ mv go/ /usr/local/ 
$ mkdir ~/go
# Setting Environment Variable 
$ export GOROOT=/usr/local/go
$ export GOPATH=$HOME/go 
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Installing Terraform

Install Terraform 0.11.x from here and save it into /usr/local/bin/terraform folder (create it if it doesn't exists).

Install OneView Terraform Provider SDK

# Download the source code for terraform-provider-oneview
# Build the needed binary

go get github.com/HewlettPackard/terraform-provider-oneview
$ cd $GOPATH/src/github.com/HewlettPackard/terraform-provider-oneview    

```bash

# Download and store a local copy of terraform-provider-oneview and
# use it as a Docker image.
$ docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-11-OV5.5

# Run docker commands using the "ash" shell from Alpine, this will in turn create
# a sh session where you can create files, issue commands and execute both
# terraform and the provider with ease.
$ docker run -it hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-11-OV5.5 /bin/sh
Terraform 0.12

Installing from Docker

The light weight containerized version of the HPE OneView SDK for Terraform is available in the Docker Store. The Docker Store image tag consist of two sections: <sdk_version-OV_version>

# Download and store a local copy of oneview-sdk-for-terraform and use it as a Docker Image.
$ docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-12-OV5.6
# Run docker commands below given, which  will in turn create a sh session 
# where you can create files, issue commands and execute the examples.
$ docker run -it docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:v1.7.0-12-OV5.6 /bin/sh

Local Setup

Local installation requires

  • Installing Go
$ apt-get install build-essential git wget
$ wget https://golang.org/dl/go1.15.7.linux-amd64.tar.gz

#unzip and untar the file 
$ tar -zxvf go1.15.7.linux-amd64.tar.gz

# move it to /usr/local/ and create directory for Go.
$ mv go/ /usr/local/ 
$ mkdir ~/go
# Setting Environment Variable 
$ export GOROOT=/usr/local/go
$ export GOPATH=$HOME/go 
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  • Installing Terraform

    Install Terraform 0.12.x from here and save it into /usr/local/bin/terraform folder (create it if it doesn't exists).

  • Install Oneview Terraform Provider SDK
# Download the source code for terraform-provider-oneview
# Build the needed binary
# Get the branch 'Terraform-0.12' terraform-provider-oneview which is supports Terraform v0.12.x.
$ git clone -b Terraform-0.12  https://github.com/HewlettPackard/terraform-provider-oneview.git
$ cd terraform-provider-oneview
# Build the provider
$ go build -o terraform-provider-oneview
# Create the plugin location if it does not exist and copy the  provider binary there.
$ mkdir -p ~/.terraform.d/plugins/
$ mv terraform-provider-oneview ~/.terraform.d./plugins/

Configuration

Environment Variables

Following environment variables can be set for testing:

# Required
$ export TF_VAR_endpoint=<ov_endpoint>
$ export TF_VAR_username=<ov_username>
$ export TF_VAR_password=<ov_password>
$ export TF_VAR_ssl_enabled=false
$ export TF_VAR_ov_domain=<ov_domain>

OneView Client Configuration

The OneView Client configuration options that can be passed during OneView Client object creation: The variables are defined in variable.tf file.

For OneView authentication, you need to provide the provider information in examples:

# Create terraform OneView client
provider "oneview" {
	ov_username  = "${var.username}"
	ov_password  = "${var.password}"
	ov_endpoint  = "${var.endpoint}"
	ov_sslverify = "${var.ssl_enabled}"
	ov_domain    = "${var.ov_domain}"
	ov_apiversion = <ov_apiversion>
	ov_ifmatch = "*"
}

🔒 Tip: Check the file permissions because the password is stored in clear-text as Environment Variable.

Image Streamer Client Configuration:

The Image Streamer (I3S) client is very much similar to the OneView client. Following extra environment variables should be set for testing:

# Required
$ export TF_VAR_i3s_endpoint=<i3s_endpoint>

Here we create the Image Streamer(I3S) client.

# Create I3s Client
provider "oneview" {
	ov_username      = "${var.username}"
	ov_password      = "${var.password}"
	ov_endpoint      = "${var.endpoint}"
	ov_i3s_endpoint  = "${var.i3s_endpoint}"
	ov_sslverify     = "${var.ssl_enabled}"
	ov_domain        = "${var.ov_domain}"
	ov_apiversion    = <i3s_apiversion>
	ov_ifmatch = "*"
}

🔒 Tip: Check the file permissions because the password is stored in clear-text as Environment Variable.

Testing the Terraform Resources:

In the home directory of project(terraform-provider-oneview) user needs to create (or) copy the file that is to be executed.

Sample example manifests are available in example directory.

The following terraform commands has to be executed to test the example.

$ terraform init 
$ terraform plan 
$ terraform apply

Note: Only a single terraform file (example file) should exist in the home folder to execute the above mentioned three commands. Once the resource is tested move that file to examples folder.

Note: Currently this SDK supports OneView API 2400 minimally, where we can test OneView API 2400 version with this SDK. If API version used is not supported then error will be thrown. If API version is not provided then appliance's maximum supported API version will be used.

Migration from Terraform version 0.11 to 0.12.x

Planning for a Migration

Installing Go

$ apt-get install build-essential git wget
$ wget https://golang.org/dl/go1.15.7.linux-amd64.tar.gz

#unzip and untar the file 
$ tar -zxvf go1.15.7.linux-amd64.tar.gz

# move it to /usr/local/ and create directory for Go.
$ mv go/ /usr/local/ 
$ mkdir ~/go
# Setting Environment Variable 
$ export GOROOT=/usr/local/go
$ export GOPATH=$HOME/go 
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  • Installing Terraform

    Install Terraform 0.12.x from here and save it into /usr/local/bin/terraform folder (create it if it doesn't exists).

  • Install Oneview Terraform Provider SDK
# Download the source code for terraform-provider-oneview
# Build the needed binary
# Get the branch 'Terraform-0.12' terraform-provider-oneview which is supports Terraform v0.12.x.
$ git clone -b Terraform-0.12  https://github.com/HewlettPackard/terraform-provider-oneview.git
$ cd terraform-provider-oneview
# Build the provider
$ go build -o terraform-provider-oneview
# Create the plugin location if it does not exist and copy the  provider binary there.
$ mkdir -p ~/.terraform.d/plugins/
$ mv terraform-provider-oneview ~/.terraform.d./plugins/

Migrating existing Terraform-0.11 configuration file(.tf file) to Terraform-0.12

The terraform-provider-oneview now supports Terraform 0.12.x . If you were using the configuration files which were compatible to Terraform 0.11 , those need to be upgraded to Terraform 0.12 using the below command :

terraform 0.12upgrade 

More details about upgrade process can be found here

Terraform 0.12 compatible provider is available in branch Terraform-0.12.

https://github.com/HewlettPackard/terraform-provider-oneview/tree/Terraform-0.12

Provider upgradation

If you have your own custom oneview resources you have to follow the steps to upgrade terraform-provider-oneview. If you are not using plugin sdk you have upgrade that first. Provider upgradation steps are available here

API Implementation

A detailed list of the HPE OneView REST interfaces that have been implemented in this SDK can be found in the endpoints-support.md file.

Getting Help

Are you running into a road block? Have an issue with unexpected behavior? Feel free to open a new issue on the issue tracker

License

This project is licensed under the Apache 2.0 license. Please see LICENSE for more info.

Contributing and feature requests

We welcome your contributions to the HPE OneView for Terraform Provider SDK.

Contributing: You know the drill. Fork it, branch it, change it, commit it, and pull-request it. We are passionate about improving this project, and glad to accept help to make it better. For more information refer CONTRIBUTING.md file.

NOTE: We reserve the right to reject changes that we feel do not fit the scope of this project, so for feature additions, please open an issue to discuss your ideas before doing the work.

Feature Requests: If you have a need that is not met by the current implementation, please let us know opening an new enhancement request/issue. This feedback is important for us to deliver a useful product.

Additional Resources

SDKs for HPE OneView

HPE OneView Documentation

HPE OneView Community

HPE OneView Community Forums

Learn more about HPE OneView at hpe.com/info/oneview