Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue_63_Implemented #203

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/push_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflows will upload a Docker Image when a release is created

name: Upload Docker Image

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup environment for Docker image publish
run: |
echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
- name: Login to Docker Hub
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build the tagged Docker image
run: docker build . --file Dockerfile --tag hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:${{ env.RELEASE_VERSION }}-OV5.4
- name: Push the tagged Docker image
run: docker push hewlettpackardenterprise/hpe-oneview-sdk-for-terraform:${{ env.RELEASE_VERSION }}-OV5.4
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
# [v1.5.0] (unreleased)
### Notes
### Major changes:
- Refactored SDK to take default API version from Oneview appliance,
- Added support for automatic publish of Docker Image when there is a new release in GitHub.

### Bug fixes & Enhancements:
- [#29] (https://github.com/HewlettPackard/terraform-provider-oneview/issues/29) Add Description and Bios settings to server template
- [#63] (https://github.com/HewlettPackard/terraform-provider-oneview/issues/63) create util function to get scope by name while creating a resource instead of hardcoding it.

# [v1.4.0]
### Notes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ provider "oneview" {
}
```

Note: Currently this SDK supports OneView API 1800 minimally where we can test OneView API 1800 version with this SDK. No new fields have been added/deleted to support API 1800 version. Complete support will be done in next releases.
Note: Currently this SDK supports OneView API 1800 minimally where we can test OneView API 1800 version with this SDK. No new fields have been added/deleted to support API 1800 version. Complete support will be done in next releases.If API version is not provided then appliance's API version will be used. If API version used is not supported then error will be thrown.

### License

Expand Down
26 changes: 26 additions & 0 deletions docs/d/server_profile_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ output "oneview_server_profile_template_value" {
hardware is removed or replaced. This can be set to Bay or BayAndServer.
This defaults to Bay.

* `boot_order`- (Optional) Defines the order in which boot will be attempted on the available devices. Different hardware
take different boot orders. Refer to the api documentation for your specific boot order options.

* `network` - (Optional) Network connection to be configured for the server. Can be specified multiple times.
Network configuration is specified below.

* `enclosure_group` - (Required) Identifies the enclosure group name for which the Server Profile Template was designed.
The enclosure group is determined when the profile template is created and cannot be modified.

* `hide_unused_flex_nics` - (Optional) Hides flex nics that aren't in use.
This defaults to true.

* `server_hardware_type` - (Required) Identifies the server hardware type name for which the Server Profile Template was
designed. The server hardware type is determined when the profile template is created and cannot be modified.

* `serial_number_type` - (Optional) Specifies the type of Serial Number and UUID to be programmed into the server ROM.
The value can be 'Virtual' or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.
Expand All @@ -51,3 +60,20 @@ This defaults to 'Virtual'.
* `uri` - The URI of the created resource.

* `eTag` - Entity tag/version ID of the resource.

Network Resource Supports following:

* `name` - (Required) A unique name for the resource.

* `function_type` - (Required) Type of function required for the connection. Values can be 'Ethernet' or 'FibreChannel'
Changing this forces a new resoure.

* `network_uri` - (Required) Identifies the network or network set to be connected.

* `port_id` - (Optional) Identifies the port (FlexNIC) used for this connection. Defaults to "Lom 1:1-a".

* `requested_mbps` - (Optional) The transmit throughput (mbps) that should be allocated to this connection.
Defaults to `2500`

* `id` - (Optional) A unique identifier for this connection.

112 changes: 95 additions & 17 deletions docs/r/server_profile_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,79 @@ designed. The server hardware type is determined when the profile template is cr
hardware is removed or replaced. This can be set to Bay or BayAndServer.
This defaults to Bay.

* `bios` - (Optional) Server BIOS settings.
Bios configuration is specified below.

* `boot_mode` - (Optional) Boot mode settings to be configured on the server. For Gen 7 and Gen 8 servers these values should not be specified.
Boot mode configuration is specified below.

* `boot_order`- (Optional) Defines the order in which boot will be attempted on the available devices. Different hardware take different boot orders. Refer to the api documentation for your specific boot order options.

* `firmware` - (Optional) Firmware attributes required to configure firmware.
Firmware configuration is specified below.

* `hide_unused_flex_nics` - (Optional) Hides flex nics that aren't in use.
This defaults to true.

* `initial_scope_uris` - (Optional) A list of URIs of the scopes to which the resource shall be initially assigned. It is only meaningful at resource creation time and is not included on resource retrieval.

* `local_storage` - (Optional) Local storage settings to be configured on the server.

* `logical_drives` - (Optional) List of logical drives associated with the controller.

* `mac_type` - (Optional) Specifies the type of MAC address to be programmed into the IO devices. The value can be 'Virtual' or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.

* `manage_connections` - (Optional) Identifies whether connections should be managed by server profile template. If this is false then the compliance check between server profile template and server profile is disabled, this allows a server profile created from a profile template to define any connectivity.

* `network` - (Optional) Network connection to be configured for the server. Can be specified multiple times.
Network configuration is specified below.

* `hide_unused_flex_nics` - (Optional) Hides flex nics that aren't in use.
This defaults to true.

* `os_deployment_settings` - (Optional) OS Deployment settings applicable when deployment is invoked through a server profile.
OS Deploymennt Stting configuration is specified below.

* `san_storage` - (Optional)The profile SAN storage configuration.
San Storage configuration is specified below.

* `serial_number_type` - (Optional) Specifies the type of Serial Number and UUID to be programmed into the server ROM.
The value can be 'Virtual' or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.

* `type` - (Optional) Uniquely identifies the type of the JSON object.
This Defaults to ServerProfileTemplateV1

* `volume_attachments` - (Optional) The list of storage volume attachments.
Volume Attachment configuration is specified below.

* `wwn_type` - (Optional) Specifies the type of WWN address to be programmed into the IO devices. The value can be 'Virtual'
or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.

* `mac_type` - (Optional) Specifies the type of MAC address to be programmed into the IO devices. The value can be 'Virtual'
or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.
Bios Options Supports the following:

* `mac_type` - (Optional) Specifies the type of MAC address to be programmed into the IO devices. The value can be 'Virtual'
or 'Physical'. Changing this forces a new resource.
This defaults to 'Virtual'.
* `manage_bios` - (Required) Indicates whether the BIOS settings should be configured on the server profiles created from the template. Value can be 'true' or 'false'.

* `overridden_settings` - (Optional) The BIOS settings to be modified. All omitted BIOS settings are reset to their factory default values.

Boot Mode Supports the following:

* `boot_order`- (Optional) Defines the order in which boot will be attempted on the available devices. Different hardware
take different boot orders. Refer to the api documentation for your specific boot order options.
* `manage_mode` - (Required) Indicates whether the boot mode should be configured on server profiles created from the template. Value can be 'true' or 'false'. The value defaults to 'false' when unspecified.

* `mode` - (Required) The environment used for server boot operation. Possible values are "UEFI", "UEFIOptimized" or "BIOS". This field is required only when "manageMode" is set to 'true'.

* `pxe_boot_policy` - (Required) Defines the filtering or priority of the PXE boot options for each enabled NIC port. This field is required only when the "mode" is set to "UEFI" or "UEFIOptimized".

Firmware Supports the following:

* `force_install_firmware` - (Optional) Force installation of firmware even if same or newer version is installed. Downgrading the firmware can result in the installation of unsupported firmware which can cause the hardware to cease operating. Value can be 'true' or 'false'.

* `firmware_baseline_uri` - (Optional) Identifies the firmware baseline to be applied to the server hardware.

* `firmware_activation_type` - (Optional) Specifies when the applied Service Pack for ProLiant (SPP) will be activated.

* `manage_firmware` - (Optional) Indicates that the server firmware should be configured on the server profiles created from the template. Value can be 'true' or 'false'.

* `firmware_install_type` - (Optional) Force installation of firmware even if same or newer version is installed. Downgrading the firmware can result in the installation of unsupported firmware which can cause the hardware to cease operating. Value can be 'true' or 'false'.

Network supports the following:

Expand All @@ -77,18 +126,47 @@ Changing this forces a new resoure.
* `requested_mbps` - (Optional) The transmit throughput (mbps) that should be allocated to this connection.
Defaults to `2500`

* `bios_option` - (Optional) Bios setting required for the server profile template.
* `boot` - (Optional) Boot setting required for the server profile template.

* `firmware` - (Optional) Firmware attributes required to configure firmware.
* `id` - (Optional) A unique identifier for this connection.

* `local_storage` - (Optional) Local storage settings to be configured on the server.
* `ipv4` - (Optional) The IP information for a connection. This is only used for iSCSI connections. It must be omitted for other connection types.

* `logical_drives` - (Optional) List of logical drives associated with the controller.
Os Deployment Settings support the following:

* `san_storage` - (Optional)The profile SAN storage configuration.
* `os_deployment_plan_name` - (Optional) Identifies the OS deployment plan.

* `os_deployment_settings` - (Optional) OS Deployment settings applicable when deployment is invoked through a server profile.
* `os_volume_uri` - (Optional) Identifies the OS deployment plan. Use GET /rest/os-deployment-plans to retrieve the list of available OS deployment plans.

* `os_custom_attributes` - (Optional) Identifies the custom attributes to be configured with the OS deployment plan.

San Storage Supports the following:

* `host_os_type` - (Optional) The operating system type of the host. To retrieve the list of supported host OS types, issue a REST Get request using the /rest/storage-systems/host-types API.

* `manage_san_storage` - (Optional) Identifies whether SAN storage should be configured on server profiles created from the template.

* `server_hardware_type_uri` - (Optional) Identifies the server hardware type for which the Server Profile Template was designed. The serverHardwareTypeUri is determined when the profile template is created. Use GET /rest/server-hardware-types to retrieve the list of server hardware types.

Volume Attachments Support the following:

* `associated_template_attachment_id` - (Optional) A "key" value uniquely identifying the definition of a volume attachment in a template.

* `id` - (Optional) The ID of the storage volume attachment.

* `lun` - (Optional) Logical Unit Number. Typically a value from 0 to 255. A blank value is not allowed when lunType is "Manual". If lunType is "Auto", lun can be left blank.

* `lun_type` - (Optional) "Manual" or "Auto". If Manual, a lun value is required. If Auto, the lun value is returned as a read only value.

* `boot_volume_priority` - (Optional) Identifies whether the volume will be used as a boot volume and with what priority. This attribute can only be set on private volumes.

* `volume_storage_system_uri` - (Optional) The URI of the storage system associated with this volume attachment. This field is read-only when the storage pool URI in the volume properties is specified.

* `volume_uri` - (Optional) The URI of the storage volume associated with this volume attachment. This attribute is required when specifying an existing volume to attach, but is not used when defining a new volume to be created.

* `storage_paths` - (Optional) A list of host-to-target path associations.

* `volume` - (Optional) Contains properties describing a volume to be created. This attribute is required when defining a new volume to be created, but is not used when an existing volume is attached.

## Attributes Reference

Expand Down
3 changes: 1 addition & 2 deletions examples/enclosure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "oneview_enclosure" "enclosure_inst" {
user_name = "<enclosure_username>"
password = "<enclosure_password>"
licensing_intent = "Oneview"
initial_scope_uris = ["/rest/scopes/bf7df2e6-ebbb-4c6b-bc7a-be8cdac930bf"]
initial_scope_uris = ["scope_name1", "scope_name2"]
name = "Encl2"
}

Expand All @@ -32,5 +32,4 @@ data "oneview_enclosure" "enclosure" {
output "oneview_enclosure_value" {
value = "${data.oneview_enclosure.enclosure.uuid}"
}

*/
6 changes: 1 addition & 5 deletions examples/enclosure_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ provider "oneview" {
ov_ifmatch = "*"
}

data "oneview_scope" "scope" {
name = "Scope_Sample"
}

resource "oneview_enclosure_group" "eg_inst" {
name = "TestEnclosureGroup"
description = "Testing creation of Enclosure Group"
ip_addressing_mode = "External"
enclosure_count = 3
initial_scope_uris = ["${data.oneview_scope.scope.uri}"]
initial_scope_uris = ["scope_1", "scope_2"]
interconnect_bay_mappings = [
{
interconnect_bay = 1
Expand Down
18 changes: 15 additions & 3 deletions oneview/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package oneview

import (
"errors"

"fmt"
"github.com/HewlettPackard/oneview-golang/i3s"
"github.com/HewlettPackard/oneview-golang/ov"
)
Expand Down Expand Up @@ -41,9 +41,21 @@ func (c *Config) loadAndValidate() error {
}

client := (&ov.OVClient{}).NewOVClient(c.OVUsername, c.OVPassword, c.OVDomain, c.OVEndpoint, c.OVSSLVerify, c.OVAPIVersion, c.OVIfMatch)

c.ovClient = client

apiver, err := c.ovClient.GetAPIVersion()

//If no api version is provided use the current version to create client
if c.OVAPIVersion == 0 {
if err != nil {
return fmt.Errorf("Could not fetch the appliance %s api version", c.OVEndpoint)
}
c.OVAPIVersion = apiver.CurrentVersion
}
//Throw error if provided api version is not supported
if c.OVAPIVersion < apiver.MinimumVersion {
return fmt.Errorf("The minimum api version supported is %d", apiver.MinimumVersion)
}
client = (&ov.OVClient{}).NewOVClient(c.OVUsername, c.OVPassword, c.OVDomain, c.OVEndpoint, c.OVSSLVerify, c.OVAPIVersion, c.OVIfMatch)
session, err := c.ovClient.SessionLogin()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion oneview/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Provider() terraform.ResourceProvider {
"ov_apiversion": {
Type: schema.TypeInt,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("ONEVIEW_OV_API_VERSION", 200),
DefaultFunc: schema.EnvDefaultFunc("ONEVIEW_OV_API_VERSION", 0),
},
"ov_ifmatch": {
Type: schema.TypeString,
Expand Down
13 changes: 8 additions & 5 deletions oneview/resource_enclosure.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,15 @@ func resourceEnclosureCreate(d *schema.ResourceData, meta interface{}) error {
UpdateFirmwareOn: d.Get("update_firmware_on").(string),
}

rawInitialScopeUris := d.Get("initial_scope_uris").(*schema.Set).List()
initialScopeUris := make([]string, len(rawInitialScopeUris))
for i, raw := range rawInitialScopeUris {
initialScopeUris[i] = raw.(string)
if val, ok := d.GetOk("initial_scope_uris"); ok {
rawinitialScopeUris := val.(*schema.Set).List()
initialScopeUris := make([]utils.Nstring, len(rawinitialScopeUris))
for i, rawData := range rawinitialScopeUris {
scope, _ := config.ovClient.GetScopeByName(rawData.(string))
initialScopeUris[i] = utils.Nstring(scope.URI)
}
enclosureCreateMap.InitialScopeUris = initialScopeUris
}
enclosureCreateMap.InitialScopeUris = initialScopeUris

enclosureError := config.ovClient.CreateEnclosure(enclosureCreateMap)
d.SetId(d.Get("name").(string))
Expand Down
8 changes: 5 additions & 3 deletions oneview/resource_enclosure_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func resourceEnclosureGroupCreate(d *schema.ResourceData, meta interface{}) erro
rawinitialScopeUris := val.(*schema.Set).List()
initialScopeUris := make([]utils.Nstring, len(rawinitialScopeUris))
for i, rawData := range rawinitialScopeUris {
initialScopeUris[i] = utils.Nstring(rawData.(string))
scope, _ := config.ovClient.GetScopeByName(rawData.(string))
initialScopeUris[i] = utils.Nstring(scope.URI)
}
enclosureGroup.InitialScopeUris = initialScopeUris
}
Expand Down Expand Up @@ -303,8 +304,9 @@ func resourceEnclosureGroupUpdate(d *schema.ResourceData, meta interface{}) erro
if val, ok := d.GetOk("initial_scope_uris"); ok {
rawinitialScopeUris := val.(*schema.Set).List()
initialScopeUris := make([]utils.Nstring, 0)
for _, rawData := range rawinitialScopeUris {
initialScopeUris = append(initialScopeUris, utils.Nstring(rawData.(string)))
for i, rawData := range rawinitialScopeUris {
scope, _ := config.ovClient.GetScopeByName(rawData.(string))
initialScopeUris[i] = utils.Nstring(scope.URI)
}
enclosureGroup.InitialScopeUris = initialScopeUris
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.