### Install gRPC-Go Package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md This snippet shows the command to install the grpc-go package using the go get command. It's a common way to fetch Go dependencies. ```console go get -u google.golang.org/grpc ``` -------------------------------- ### Check Go Installation Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Verifies if the Go binary is installed and accessible in the system's PATH. This command is crucial after installing Go to ensure the environment is set up correctly. ```Shell go version ``` -------------------------------- ### Install Go for Local Setup (Terraform 0.11) Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs Go and necessary build tools for a local setup of the HPE OneView Terraform Provider on Terraform 0.11. This includes downloading Go, extracting it, and setting environment variables. ```Bash $ 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 ``` ```Bash # Setting Environment Variable $ export GOROOT=/usr/local/go $ export GOPATH=$HOME/go $ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin ``` -------------------------------- ### Install Go for Local Setup (Terraform 0.12) Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs Go for a local setup of the HPE OneView Terraform Provider on Terraform 0.12. This includes downloading a specific Go version, extracting it, and preparing the directory structure. ```Bash $ 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 ``` -------------------------------- ### Install Go Color Package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/fatih/color/README.md This snippet shows how to install the Go Color package using the go get command. ```Bash go get github.com/fatih/color ``` -------------------------------- ### Install Google Cloud Go Package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/README.md Shows the command to install a specific Google Cloud client library package for Go using the `go get` command. This is necessary before using the library in your project. ```bash go get cloud.google.com/go/firestore # Replace with the package you want to use. ``` -------------------------------- ### List Datastore Git Tags Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Lists all existing Git tags for the datastore submodule, excluding beta and alpha versions. This helps identify the current latest tag for the release process. ```Shell git tag -l | grep datastore | grep -v beta | grep -v alpha ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/go.opencensus.io/README.md This snippet shows the command to install the OpenCensus Go library using the go get command. It requires Go 1.8 or later. ```bash go get -u go.opencensus.io ``` -------------------------------- ### Install Golint Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/golang.org/x/lint/README.md Installs the Golint tool using the Go build command. It requires a supported Go release and can be made available globally by adding its installation directory to the system's PATH. ```Go go get -u golang.org/x/lint/golint ``` -------------------------------- ### Generate Version Information Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Navigates to the internal version directory, generates version information, and then returns to the previous directory. This step is part of preparing a new release. ```Shell cd internal/version && go generate && cd - ``` -------------------------------- ### Docker Setup for HPE OneView Terraform Provider Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/README.md This snippet demonstrates how to pull and run the HPE OneView SDK for Terraform using a Docker container. It's a convenient way to get started without local installations. ```bash # 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:v10.1.0-13-OV10.1 # 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:v10.1.0-13-OV10.1 /bin/sh ``` -------------------------------- ### Tag and Push New Release Version Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Tags the repository with the next release version and pushes the new tag to the origin. This is a critical step after all changes have been committed and merged. ```Shell git tag $NV git push origin $NV ``` -------------------------------- ### List Git Tags Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Lists all Git tags in the repository, filtering out tags containing 'beta' or 'alpha'. This command helps in identifying the current latest release tag. ```Shell git tag -l | grep -v beta | grep -v alpha ``` -------------------------------- ### Show Changes Since Last Release Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Displays the commit history since a specified tag. This is used to review changes that will be included in the next release. ```Shell git log $CV... ``` -------------------------------- ### Clone Repository Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Clones the specified Git repository from a remote URL. This is a standard command for obtaining the source code of a project. ```Shell git clone https://github.com/googleapis/google-cloud-go ``` -------------------------------- ### List Go Modules Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md This snippet displays how to find and list all Go modules within a project by searching for 'go.mod' files and extracting the module path. It helps in understanding the project's modular structure. ```Shell cat `find . -name go.mod` | grep module ``` -------------------------------- ### Local Go Installation for HPE OneView Terraform Provider Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/README.md This section details the steps for setting up the Go environment locally, which is a prerequisite for installing the HPE OneView Terraform Provider manually. It includes installing necessary packages, downloading Go, and configuring environment variables. ```bash $ 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 ``` ```bash # Setting Environment Variable $ export GOROOT=/usr/local/go $ export GOPATH=$HOME/go $ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin ``` -------------------------------- ### Install go-getter Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-getter/README.md Installs the go-getter library using the standard Go package management command. ```Shell go get github.com/hashicorp/go-getter ``` -------------------------------- ### Tag New Release Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Creates a new Git tag for the repository, marking a specific version. This is a critical step in the release process. ```Shell git tag $NV ``` -------------------------------- ### Navigate to Repository Directory Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Changes the current working directory to the root of the cloned repository. This is a necessary step before performing any operations on the project's files. ```Shell cd google-cloud-go ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mattn/go-isatty/README.md This command shows how to install the go-isatty package using the Go build tools. It fetches the package and makes it available for use in your Go projects. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install Levenshtein Package (Go) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/agext/levenshtein/README.md This command installs the Levenshtein package for Go using the go get command. It fetches the latest version of the package from its repository. ```Go go get github.com/agext/levenshtein ``` -------------------------------- ### Run Project Tests Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/go.opencensus.io/CONTRIBUTING.md Installs necessary tools and runs the project's test suite. 'make install-tools' is typically a one-time setup. ```shell make install-tools # Only first time. make ``` -------------------------------- ### Install go-getter CLI Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-getter/README.md Installs the command-line interface for go-getter, which can be used to test URL strings. ```Shell go install github.com/hashicorp/go-getter/cmd/go-getter ``` -------------------------------- ### Push Tag to Origin Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Pushes the newly created Git tag to the remote repository (origin). This makes the release tag visible to others and is part of publishing the release. ```Shell git push origin $NV ``` -------------------------------- ### Install go-junit-report Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/jstemmer/go-junit-report/README.md Installs or updates the go-junit-report package using the 'go get' command. Requires Go version 1.2 or higher. ```bash go get -u github.com/jstemmer/go-junit-report ``` -------------------------------- ### View Datastore Changes Since Last Release Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Lists all changes made to the datastore submodule directory since the last release. This information is crucial for updating the submodule's changelog. ```Shell git log $CV.. -- datastore/ ``` -------------------------------- ### Install copystructure Go Library Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mitchellh/copystructure/README.md Installs the copystructure Go library using the standard 'go get' command. This is the primary method for obtaining the library for use in Go projects. ```bash go get github.com/mitchellh/copystructure ``` -------------------------------- ### Troubleshoot gRPC-Go Installation with Go Modules Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md This snippet illustrates how to use the 'replace' feature in go.mod to alias golang.org packages, which can help resolve installation issues when accessing golang.org resources from certain regions. It includes commands to edit the go.mod file, tidy dependencies, and vendor for building. ```Go go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest go mod tidy go mod vendor go build -mod=vendor ``` -------------------------------- ### Install msgpack Go package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/vmihailenco/msgpack/README.md This command installs the msgpack package for Golang using the go get command. It ensures you have the latest version of the library for use in your projects. ```shell go get -u github.com/vmihailenco/msgpack ``` -------------------------------- ### Generate Version Information Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/RELEASING.md Executes a Go generate command within the 'internal/version' directory, likely to update version-related files based on the current state of the repository. ```Shell cd internal/version && go generate && cd - ``` -------------------------------- ### Install HPE OneView Terraform Provider via Docker (Terraform 0.11) Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs the HPE OneView SDK for Terraform using a Docker image for Terraform 0.11. This involves pulling the image and running it to access a shell environment for executing commands and examples. ```Bash # 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 ``` -------------------------------- ### HCL JSON Equivalent Syntax Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/hcl/v2/README.md The JSON representation of the HCL native syntax example. This demonstrates how HCL configurations can be represented in JSON, facilitating machine generation and parsing. ```JSON { "io_mode": "async", "service": { "http": { "web_proxy": { "listen_addr": "127.0.0.1:8080", "process": { "main": { "command": ["/usr/local/bin/awesome-app", "server"] }, "mgmt": { "command": ["/usr/local/bin/awesome-app", "mgmt"] }, } } } } } ``` -------------------------------- ### Install HPE OneView Terraform Provider via Docker (Terraform 0.12) Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs the HPE OneView SDK for Terraform using a Docker image for Terraform 0.12. This involves pulling the image and running it to access a shell environment for executing commands and examples. ```Bash # 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 ``` -------------------------------- ### Import gRPC-Go in Go Code Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md This Go code snippet demonstrates how to import the gRPC-Go library into your project when using Go modules. This is the standard way to include external packages. ```Go import "google.golang.org/grpc" ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mitchellh/mapstructure/README.md This snippet shows the standard Go command to get the mapstructure library. It's a prerequisite for using the library in your Go projects. ```Shell go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Update Protobuf and gRPC for Compilation Fixes Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md This console command sequence shows how to update the protobuf and gRPC packages and then rebuild proto files. This is useful for resolving compilation errors like 'undefined: grpc.SupportPackageIsVersion'. ```console go get -u github.com/golang/protobuf/{proto,protoc-gen-go} go get -u google.golang.org/grpc protoc --go_out=plugins=grpc:. *.proto ``` -------------------------------- ### HCL Native Syntax Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/hcl/v2/README.md An example of HCL's native syntax, showcasing attributes like 'io_mode' and nested blocks for defining services and processes. This syntax is designed to be human-readable. ```HCL io_mode = "async" service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "main" { command = ["/usr/local/bin/awesome-app", "server"] } process "mgmt" { command = ["/usr/local/bin/awesome-app", "mgmt"] } } ``` -------------------------------- ### Install Go on Linux Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs Go on a Linux system by downloading a pre-compiled binary, extracting it, and moving it to the appropriate directory. It also sets up the necessary environment variables for Go. ```bash $ 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 ``` -------------------------------- ### Refactor Examples to Reduce Module Dependencies Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/CHANGES.md Examples within the provider have been refactored to minimize their reliance on external modules, simplifying the setup and usage of examples. ```Go examples ``` -------------------------------- ### Install go-colorable package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mattn/go-colorable/README.md This command shows how to install the go-colorable package using the Go build tools. It fetches the package and its dependencies, making it available for use in your Go projects. ```bash go get github.com/mattn/go-colorable ``` -------------------------------- ### Install OAuth2 Package for Go Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/golang.org/x/oauth2/README.md This snippet shows how to install the OAuth2 package for Go using the 'go get' command. It's a prerequisite for using the OAuth 2.0 client implementation in your Go projects. ```bash go get golang.org/x/oauth2 ``` -------------------------------- ### Retrieve Available Networks (GET) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md This snippet focuses on retrieving a list of available networks that can be used when configuring server profiles. The GET request to this endpoint provides network configuration options, which are critical for network setup in server deployments. ```Go package main import ( "fmt" "github.com/HewlettPackard/oneview-go-sdk/oneview" ) func main() { // Example for GET operation (Get available networks) // client.ServerProfileTemplates.GetAvailableNetworks() fmt.Println("GET /rest/server-profile-templates/available-networks") } ``` -------------------------------- ### Get Oneview Logical Interconnect Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/logical_interconnects.html.markdown This example demonstrates how to retrieve a specific logical interconnect by its name and output its URI. ```hcl data "oneview_logical_interconnect" "test" { name = "Test Interconnect" } output "oneview_logical_interconnect_value" { value = "${data.oneview_logical_interconnect.test.uri}" } ``` -------------------------------- ### Execute Terraform Commands for Testing Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/README.md Provides the necessary Terraform commands to initialize, plan, and apply resources for testing. It requires a single example Terraform file in the home directory. ```terraform $ terraform init $ terraform plan $ terraform apply ``` -------------------------------- ### Setup Terraform Provider Location Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home This snippet demonstrates how to create the plugin directory and move the provider binary to the correct location for Terraform to recognize it. ```Bash $ mkdir -p ~/.terraform.d/plugins/ $ mv terraform-provider-oneview ~/.terraform.d./plugins/ ``` -------------------------------- ### Go Word Wrap Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mitchellh/go-wordwrap/README.md Demonstrates how to use the go-wordwrap package to wrap a string into multiple lines with a specified width. The output is printed to the console. ```go package main import ( "fmt" "github.com/mitchellh/go-wordwrap" ) func main() { wrapped := wordwrap.WrapString("foo bar baz", 3) fmt.Println(wrapped) } ``` -------------------------------- ### xxhash Benchmarking Commands Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md Shows the Go test commands used to generate benchmarks for the xxhash package. It demonstrates how to compare the performance of the pure Go implementation against the assembly-optimized version for different input sizes. ```Shell $ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes' $ go test -benchtime 10s -bench '/xxhash,direct,bytes' ``` -------------------------------- ### Go: Create and Use New Logger Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-hclog/README.md Shows how to create a new logger instance with custom options, such as setting a name and log level, and then logging a message with key/value pairs. ```Go appLogger := hclog.New(&hclog.LoggerOptions{ Name: "my-app", Level: hclog.LevelFromString("DEBUG"), }) input := "5.5" _, err := strconv.ParseInt(input, 10, 32) if err != nil { appLogger.Info("Invalid input for ParseInt", "input", input, "error", err) } ``` -------------------------------- ### Use go-getter CLI Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-getter/README.md Demonstrates how to use the go-getter command-line tool to download a resource from a URL to a specified directory. ```Shell go-getter github.com/foo/bar ./foo ``` -------------------------------- ### Install HPE OneView Terraform Provider SDK (Terraform 0.11) Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Installs the HPE OneView Terraform Provider SDK by fetching the source code and building the binary for Terraform 0.11. It also includes instructions for using a Docker image. ```Go # 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 ``` -------------------------------- ### Go Test Helper Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/mitchellh/go-testing-interface/README.md Demonstrates how to define a test helper function that accepts the testing interface and how to call it within a standard Go test. ```go import "github.com/mitchellh/go-testing-interface" func TestHelper(t testing.T) { t.Fatal("I failed") } ``` ```go import "testing" func TestThing(t *testing.T) { TestHelper(t) } ``` -------------------------------- ### Get Oneview Interconnect Type Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/interconnect_type.html.markdown This example demonstrates how to retrieve an existing interconnect type by its name and output its URI. It requires the 'oneview' provider and specifies the name of the interconnect type to query. ```HCL data "oneview_interconnect_type" "test" { name = "Test interconnect type" } output "oneview_interconnect_type_value" { value = "${data.oneview_interconnect_type.test.uri}" } ``` -------------------------------- ### Enable gRPC-Go Logging Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md These environment variables are used to enable logging for gRPC-Go. Setting GRPC_GO_LOG_VERBOSITY_LEVEL to 99 turns on all verbosity, and GRPC_GO_LOG_SEVERITY_LEVEL to 'info' sets the minimum severity level for logs. ```console export GRPC_GO_LOG_VERBOSITY_LEVEL=99 export GRPC_GO_LOG_SEVERITY_LEVEL=info ``` -------------------------------- ### Import Google Cloud Go Package Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/README.md Demonstrates how to import a Google Cloud client library package in Go. This is a common starting point for interacting with Google Cloud services. ```Go import "cloud.google.com/go" ``` -------------------------------- ### Get Oneview Server Profile Template Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/server_profile_template.html.markdown This example demonstrates how to retrieve an existing Server Profile Template by its name and output its URI. It requires the OneView provider and a valid template name. ```HCL data "oneview_server_profile_template" "test" { name = "Test server profile template" } output "oneview_server_profile_template_value" { value = "${data.oneview_server_profile_template.test.uri}" } ``` -------------------------------- ### Oneview Storage System Data Source Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/storage_systems.html.markdown This example demonstrates how to use the `oneview_storage_system` data source to retrieve information about a storage system and output its URI. It requires the name of the storage system as input. ```hcl data "oneview_storage_system" "test" { name = "Test storage system" } output "oneview_storage_system_value" { value = "${data.oneview_storage_system.test.uri}" } ``` -------------------------------- ### Go Applying Profiler Labels with Tags Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/go.opencensus.io/README.md Shows how to use OpenCensus tags to apply labels to profiler samples. This involves creating a context with tags and then executing a function within `tag.Do` to associate the tags with profiled operations. ```Go ctx, err = tag.New(ctx, tag.Insert(osKey, "macOS-10.12.5"), tag.Insert(userIDKey, "fff0989878"), ) if err != nil { log.Fatal(err) } tag.Do(ctx, func(ctx context.Context) { // Do work. // When profiling is on, samples will be // recorded with the key/values from the tag map. }) ``` -------------------------------- ### Get Oneview Server Hardware Type Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/server_hardware_type.html.markdown This data source retrieves information about a specific server hardware type by its name. The example demonstrates how to fetch the URI of a server hardware type named 'Test Server Hardware Type'. ```hcl data "oneview_server_hardware_type" "test" { name = "Test Server Hardware Type" } output "oneview_server_hardware_type_value" { value = "${data.oneview_server_hardware_type.test.uri}" } ``` -------------------------------- ### Go: Wrap hclog.Logger for Standard Library Compatibility Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-hclog/README.md Explains how to obtain a standard library `log.Logger` compatible writer from an hclog.Logger using `StandardLogger()`, enabling the use of familiar logging methods like Printf. ```Go stdLogger := appLogger.StandardLogger(&hclog.StandardLoggerOptions{InferLevels: true}) stdLogger.Printf("[DEBUG] %+v", stdLogger) ``` -------------------------------- ### Specify gRPC-Go Version with Go Modules Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/google.golang.org/grpc/README.md This Go code snippet shows how to specify the required version of gRPC-Go in the go.mod file. This is crucial for resolving compilation errors related toSupportPackageIsVersion, ensuring compatibility between generated code and the gRPC library. ```Go module require ( google.golang.org/grpc v1.27.0 ) ``` -------------------------------- ### Go: Compress and Decompress Text using xz API Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/ulikunitz/xz/README.md Demonstrates how to use the xz package API in Go to compress a string into a buffer and then decompress it, writing the output to standard output. Requires the 'bytes', 'io', 'log', 'os', and 'github.com/ulikunitz/xz' packages. ```Go package main import ( "bytes" "io" "log" "os" "github.com/ulikunitz/xz" ) func main() { const text = "The quick brown fox jumps over the lazy dog.\n" var buf bytes.Buffer // compress text w, err := xz.NewWriter(&buf) if err != nil { log.Fatalf("xz.NewWriter error %s", err) } if _, err := io.WriteString(w, text); err != nil { log.Fatalf("WriteString error %s", err) } if err := w.Close(); err != nil { log.Fatalf("w.Close error %s", err) } // decompress buffer and write output to stdout r, err := xz.NewReader(&buf) if err != nil { log.Fatalf("NewReader error %s", err) } if _, err = io.Copy(os.Stdout, r); err != nil { log.Fatalf("io.Copy error %s", err) } } ``` -------------------------------- ### Get FC Networks (GET) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a list of all Fibre Channel (FC) networks configured in the environment using a GET request. This is a function of the OneView Terraform provider. ```Go package main import ( "fmt" "github.com/HewlettPackard/oneview-go-sdk/oneview" ) func main() { // Example usage for GET all FC Networks // This is a placeholder and requires actual OneView client initialization. fmt.Println("Example for GET /rest/fc-networks") // client := oneview.NewClient(...) // fcNetworks, err := client.FCNets.GetFCNetworks() // if err != nil { // fmt.Printf("Error getting FC networks: %v\n", err) // } // fmt.Printf("FC Networks: %+v\n", fcNetworks) } ``` -------------------------------- ### Go: Create Logger with Fixed Key/Value Pairs Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-hclog/README.md Demonstrates how to create a logger with pre-defined key/value pairs using the With() method. These pairs are included in all log messages emitted by that logger. ```Go requestID := "5fb446b6-6eba-821d-df1b-cd7501b6a363" requestLogger := subsystemLogger.With("request", requestID) requestLogger.Info("we are transporting a request") ``` -------------------------------- ### Get Associated Profiles for Ethernet Network (GET) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a list of profiles associated with a specific Ethernet network via a GET request. This is a feature of the OneView Terraform provider. ```Go package main import ( "fmt" "github.com/HewlettPackard/oneview-go-sdk/oneview" ) func main() { // Example usage for GET associated profiles for Ethernet Network // This is a placeholder and requires actual OneView client initialization. fmt.Println("Example for GET /rest/ethernet-networks/{id}/associatedProfiles") // client := oneview.NewClient(...) // profiles, err := client.EthernetNetworks.GetAssociatedProfiles("some-id") // if err != nil { // fmt.Printf("Error getting associated profiles: %v\n", err) // } // fmt.Printf("Associated Profiles: %+v\n", profiles) } ``` -------------------------------- ### Yamux Server Setup and Stream Acceptance in Go Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/yamux/README.md Illustrates how to set up a Yamux server to accept incoming TCP connections and then accept streams from clients. The server initializes a Yamux session, accepts a stream, and reads data from it. ```go func server() { // Accept a TCP connection conn, err := listener.Accept() if err != nil { panic(err) } // Setup server side of yamux session, err := yamux.Server(conn, nil) if err != nil { panic(err) } // Accept a stream stream, err := session.Accept() if err != nil { panic(err) } // Listen for a message buf := make([]byte, 4) stream.Read(buf) } ``` -------------------------------- ### Install OneView Terraform Provider SDK Source: https://github.com/hewlettpackard/terraform-provider-oneview/wiki/Home Downloads the source code for the OneView Terraform Provider, builds the necessary binary, and installs it in the Terraform plugin directory. This enables Terraform to use the OneView provider. ```go # 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/ ``` -------------------------------- ### Get Associated Uplink Groups for Ethernet Network (GET) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Fetches uplink groups associated with a given Ethernet network using a GET request. This functionality is part of the OneView Terraform provider. ```Go package main import ( "fmt" "github.com/HewlettPackard/oneview-go-sdk/oneview" ) func main() { // Example usage for GET associated uplink groups for Ethernet Network // This is a placeholder and requires actual OneView client initialization. fmt.Println("Example for GET /rest/ethernet-networks/{id}/associatedUplinkGroups") // client := oneview.NewClient(...) // uplinkGroups, err := client.EthernetNetworks.GetAssociatedUplinkGroups("some-id") // if err != nil { // fmt.Printf("Error getting associated uplink groups: %v\n", err) // } // fmt.Printf("Associated Uplink Groups: %+v\n", uplinkGroups) } ``` -------------------------------- ### OpenCensus Go: Tagging Context Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/go.opencensus.io/README.md Demonstrates how to create or update tags within a context using the OpenCensus Go tag package. Tags are key-value pairs propagated through context or encoded for transmission. ```Go ctx, err := tag.New(ctx, tag.Insert(osKey, "macOS-10.12.5"), tag.Upsert(userIDKey, "cde36753ed"), ) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Oneview Storage Volume Data Source Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/docs/d/storage_volume.html.markdown This example demonstrates how to use the `oneview_storage_volume` data source to fetch details of a storage volume named 'Test volume' and output its URI. ```hcl data "oneview_volume" "test" { name = "Test volume" } output "oneview_volume_value" { value = "${data.oneview_volume.test.uri}" } ``` -------------------------------- ### Get Labels - OneView API Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a list of all labels configured in OneView. This is a GET request. ```Go package main import ( "fmt" "github.com/HewlettPackard/oneview-go-sdk/oneview" ) func main() { // Example usage (replace with your actual OneView client initialization) // client, err := oneview.NewClient(oneview.Config{ // Endpoint: "https://10.0.0.1", // Username: "admin", // Password: "password", // // Other configuration options... // }) // if err != nil { // fmt.Printf("Error creating OneView client: %v\n", err) // return // } fmt.Println("GET /rest/labels") // labels, err := client.Labels.GetLabels() // if err != nil { // fmt.Printf("Error getting labels: %v\n", err) // return // } // fmt.Printf("Found %d labels.\n", len(labels)) // for _, lbl := range labels { // fmt.Printf("- %s (ID: %s)\n", lbl.Name, lbl.ID) // } } ``` -------------------------------- ### Get SAS Interconnects Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a list of SAS Interconnects via a GET request. This functionality is available. ```REST GET /rest/sas-interconnects ``` -------------------------------- ### Go Propagating Spans with Context Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/go.opencensus.io/README.md Demonstrates how spans are propagated using `context.Context` in Go. `trace.StartSpan` creates a root span or a child span based on the context, allowing for hierarchical tracing. ```Go ctx, span := trace.StartSpan(ctx, "cache.Get") deffer span.End() // Do work to get from cache. ``` -------------------------------- ### GET Server Profile Ports Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves information about server profile ports. This endpoint is available for GET requests. ```REST GET /rest/server-profiles/profile-ports ``` -------------------------------- ### Generate Files with mkall.sh (Old Build System) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/golang.org/x/sys/unix/README.md This command generates Go files for the sys/unix package using the old build system, which relies on local C header files. Ensure GOOS and GOARCH are set correctly for your target system. Running with `-n` shows the commands without execution. ```bash mkall.sh mkall.sh -n ``` -------------------------------- ### Forced Protocol Syntax Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-getter/README.md Illustrates the syntax for forcing a specific protocol when downloading a resource, overriding default detectors. This ensures the resource is downloaded using the specified protocol, even if the URL is ambiguous. ```Go git::http://github.com/mitchellh/vagrant.git ``` -------------------------------- ### Datastore: Add MultiError Handling Example Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/CHANGES.md An example demonstrating how to handle MultiError in Datastore operations has been added. ```Go // Example of Datastore MultiError handling // (Specific code not provided in the input text) ``` -------------------------------- ### Go: Create Storage Client with Default Credentials Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/cloud.google.com/go/README.md Demonstrates how to create a new Google Cloud Storage client using Application Default Credentials for authorization. This is the default method and requires no explicit configuration for many environments. ```Go client, err := storage.NewClient(ctx) ``` -------------------------------- ### GET New Server Profile Template Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a new server profile template. This endpoint is available for GET requests. ```REST GET /rest/server-profiles/{id}/new-profile-template ``` -------------------------------- ### GET Server Profile Compliance Preview Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a preview of server profile compliance. This endpoint supports GET requests. ```REST GET /rest/server-profiles/{id}/compliance-preview ``` -------------------------------- ### Generate Files with mkall.sh (New Build System) Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/golang.org/x/sys/unix/README.md This command generates Go files for the sys/unix package using the new build system, which utilizes a Docker container for reproducible builds. This process requires an amd64/Linux system with Docker installed and GOOS/GOARCH set correctly. Running with `-n` displays the commands without execution. ```bash mkall.sh mkall.sh -n ``` -------------------------------- ### Go: Sort Versions Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/vendor/github.com/hashicorp/go-version/README.md Demonstrates sorting a slice of version strings using the go-version library. It correctly handles prerelease versions and standard SemVer sorting. ```Go versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"} versions := make([]*version.Version, len(versionsRaw)) for i, raw := range versionsRaw { v, _ := version.NewVersion(raw) versions[i] = v } // After this, the versions are properly sorted sort.Sort(version.Collection(versions)) ``` -------------------------------- ### Get SAS Logical JBODs Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Retrieves a list of SAS Logical JBODs. This operation is available via the GET method. ```Terraform data "oneview_sas_logical_jbods" "all" { } output "sas_logical_jbods_list" { value = data.oneview_sas_logical_jbods.all.sas_logical_jbods } ``` -------------------------------- ### Get SAS Interconnect by ID Source: https://github.com/hewlettpackard/terraform-provider-oneview/blob/master/endpoints-support.md Fetches a specific SAS Interconnect by its ID using a GET request. This operation is supported. ```REST GET /rest/sas-interconnects/{id} ```