HewlettPackard / terraform-provider-oneview

Automates the provisioning of physical infrastructure from a private cloud using templates from HPE OneView with Terraform
Apache License 2.0
49 stars 30 forks source link

Cannot import a storage system as managed nor without a managed domain #469

Closed josyfj closed 2 years ago

josyfj commented 2 years ago

OV Version: 6.50.00-0452161 Terraform version: Terraform v1.1.7 Provider version: 6.5.0-13

Issue

When using the oneview_storage_system resource to add a new storage system to oneview, the added storage system will not appear in Oneview with its state being managed, but rather connected. Additionally, the storage system must have a managed domain in order to add it, while in a certain usage case, we want to add the storage system without a managed domain (it should appear as "none" in Oneview).

The module with the specified resource:

  required_providers {
    oneview = {
      source  = "HewlettPackard/oneview"
      version = "6.5.0-13"
    }
  }
}
provider "oneview" {
  ov_username = var.OV_User
  ov_password = var.OV_Password
  ov_endpoint = "https://${var.OV_Endpoint}"
  #ov_sslverify  = false
  ov_apiversion = 2400
  ov_ifmatch    = "*"
}

variable "hostname" {
  type    = string
}

variable "ss_username" {
  type    = string
}

variable "ss_password" {
  type    = string
}

variable "ss_family" {
  type    = string
}

# Extracting Server Certificate
data "oneview_server_certificate" "sc" {
  remote_ip = var.hostname
}

#Importing Server Certificate for adding storage system
resource "oneview_server_certificate" "ServerCertificate" {
  certificate_details {
    base64_data = element(tolist(data.oneview_server_certificate.sc.certificate_details[*].base64_data), 0)
    type        = "CertificateDetailV2"
    alias_name  = "TestServerCertificate"
  }
}

data "oneview_storage_system" "ss_inst" {
  name = "Alletra01"
}

resource "oneview_storage_system" "ss_inst" {
  credentials {
    username = var.ss_username
    password = var.ss_password
  }
    username = var.ss_username
    password = var.ss_password
  family= "Alletra9000"
  hostname = var.hostname
  name     = "Alletra01"
  storage_system_device_specific_attributes {
    #managed_domain = "TestDomain" #commented, we do not want to add a managed domain.
  }
  etag        = "--"
  description = "TestStorageSystem"
  uri         = data.oneview_storage_system.ss_inst.uri
  depends_on = [
    oneview_server_certificate.ServerCertificate,
    #oneview_storage_system.ss_inst
  ]
}

If the managed_domain section is commented, as shown above the following error is produced:

╷
│ Error: Invalid value for 'managedDomain' specified for the storage system. 
│ Verify that the value for 'managedDomain' is valid and contains no null values, then retry the 
request.
│
│   with oneview_storage_system.ss_inst,
│   on update_resource.tf line 46, in resource "oneview_storage_system" "ss_inst":
│   46: resource "oneview_storage_system" "ss_inst" {
│
╵

Expected output

The Storage system will appear in Oneview as managed and with no managed domain set.

If we provide a managed domain, the Storage system will appear in Oneview as connected, but not managed by Oneview.

Any assistance is greatly appreciated!

AvijitOS commented 2 years ago

Currently the use case, defined here can be achieved by two step processes as you have already mentioned. Current design is based on the API exposed by OneView. Since there are two different operations (POST+PUT) need to invoke, we have kept it separate. This use case-based request to combine and have one step approach in terraform will be added to our backlog. As discussed, closing this issue for now.