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

oneview_server_hardware has license issues #389

Closed Schluggi closed 3 years ago

Schluggi commented 3 years ago

Hi,

after #309 was closed, I tested this and encountered a problem.

Demo code:

provider "oneview" {
    ov_endpoint = "https://test.com"
    ov_username = "Administrator"
    ov_password = "1234567890"
}

resource "oneview_server_hardware" "test_hardware" {
  configuration_state = "Managed"
  hostname = "192.168.1.27"
  username = "Administrator"
  password = "0987654321"
  licensing_intent = "OneView"
}

After applying this, tf shows an error and does not update the tfstate file. But the server hardware was added anyway.

Error: A "HPE OneView Advanced" license was not assigned because an existing "iLO Advanced" license was detected. Assigning a "HPE OneView Advanced w/o iLO" license instead.
Successfully assigned a "HPE OneView Advanced w/o iLO" license. 

So the second run fails, because the resource is already there.

New try: Now i changed the license to the right one.

resource "oneview_server_hardware" "test_hardware" {
  configuration_state = "Managed"
  hostname = "192.168.1.27"
  username = "Administrator"
  password = "0987654321"
  licensing_intent = "HPE OneView Advanced w/o iLO"  // <----------------
}

New error:

Error: Error in response: The supplied license intent, "HPE OneView Advanced w/o iLO", was invalid.
 Response Status: 400 Bad Request
 Response Details: 

  on main.tf line 17, in resource "oneview_server_hardware" "test_hardware":
  17: resource "oneview_server_hardware" "test_hardware" {

I would think, this should work. Any clues?

AsisBagga commented 3 years ago

Hi @Schluggi I think you are not providing the correct value for licensing_intent. Valid values are OneView, OneViewNoiLO or OneViewStandard In your case it should be OneViewNoiLO You can refer REST Docs for more details.

Schluggi commented 3 years ago

Hi @AsisBagga thanks for responding. If i change the value to OneViewNoiLO i got this error (and again, the ressource is not added to the tfstate, but to oneview).

Error: unable to retrieve server hardware %!s(<nil>)
AsisBagga commented 3 years ago

Hi @Schluggi I tried it in my environment it works fine. I am not sure why you're getting that error. I guess this error comes when terraform is not able to find the server hardware during the read operation. I hope you're using our latest branch to create our provider's binary but please confirm.

below is how my configuration looks like:-

provider "oneview" {
  ov_username   = var.username
  ov_password   = var.password
  ov_endpoint   = var.endpoint
  ov_sslverify  = var.ssl_enabled
  ov_apiversion =  2800
  ov_ifmatch    = "*"
}

// Adds Rack server to the appliance
// Licensing can be OneView or OneviewNoiLO for Managed
resource "oneview_server_hardware" "sh" {
  configuration_state = "Managed"
  hostname            = "--"
  username            = "--"
  password            = "--"
  licensing_intent    = "OneViewNoiLO"
}
AsisBagga commented 3 years ago

@Schluggi Hi, since we have not received any response from your end. We will proceed with closing this issue. If you still have any questions please feel free to reopen this issue or a new issue. Thank you.