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

Adding a volume without a volume template #473

Closed josyfj closed 2 years ago

josyfj commented 2 years ago

Issue: A new volume cannot be created without having a volume template created first.

Below is the code containing the resource:

resource "oneview_volume" "volume" {
  properties {
    name              = "VolToAdd"
     /* uncomment the below two lines to provide the size and storage pool uri or it will be taken from the volume template*/
    storage_pool      = data.oneview_storage_pool.st_pool.uri
    size              = 1221225472
    provisioning_type = "Thin" 
    is_deduplicated   = false

  }
  #volume_template_uri = data.oneview_storage_volume_template.test.uri
  #template_name        = "TerraformStorageTemplate"
  #template_uri         = data.oneview_storage_volume_template.test.uri
  is_permanent= true
  #templateUri = data.oneview_storage_volume_template.test.uri
  name                 = "VolToAdd"
  description          = "Description here"
  initial_scope_uris   = [data.oneview_scope.scope_obj.uri]
  provisioned_capacity = "268435456"
}

We are trying to create a new volume, but have not created any volume templates. We have tried to comment out the template_name and template_uri attributes, but get the following error:

╷
│ Error: Error in response: One or more required fields are missing.
│  Response Status: 400 Bad Request
│  Response Details: Missing value for property 'templateUri'.
│
│   with module.Add_Volume.oneview_volume.volume,
│   on 04-Add-Volume-Terraform\main.tf line 25, in resource "oneview_volume" "volume":
│   25: resource "oneview_volume" "volume" {
│
╵

Expected output: A volume is added without having used a template.

Is it possible to do this in the current revision of the provider?

nabhajit-ray commented 2 years ago

Hi @josyfj ,

We will look into this and get back to you. Thanks

nabhajit-ray commented 2 years ago

The fix is now part of master. We are closing it here.

josyfj commented 2 years ago

Hello Nabhajit,

I'm still seeing an error when attempting to run this. I've made sure to update the provider to version 7. Below is the resource exactly as I have it configured as well as the output I get:

The resource had to be modified from the example. I removed the "description" parameter and moved the "name" parameter from inside the properties subset into the main resource parameters.

resource "oneview_volume" "volume" {
  properties {

    #description = "Test Volume with no template"
    storage_pool      = data.oneview_storage_pool.st_pool.uri
    size              = 1221225472
    provisioning_type = "Thin"
    is_deduplicated   = false
  }
  name              = "testvol3"
  initial_scope_uris   = [data.oneview_scope.scope_obj.uri]
  provisioned_capacity = "1221225472"
}

2022-06-20T10:35:55.876+0200 [DEBUG] created provider logger: level=debug
2022-06-20T10:35:55.878+0200 [INFO]  provider: configuring client automatic mTLS
2022-06-20T10:35:55.897+0200 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hewlettpackard/oneview/7.0.0-13/windows_amd64/terraform-provider-oneview_v7.0.0-13.exe args=[.terraform/providers/registry.terraform.io/hewlettpackard/oneview/7.0.0-13/windows_amd64/terraform-provider-oneview_v7.0.0-13.exe]
2022-06-20T10:35:55.917+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hewlettpackard/oneview/7.0.0-13/windows_amd64/terraform-provider-oneview_v7.0.0-13.exe pid=70760
2022-06-20T10:35:55.917+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hewlettpackard/oneview/7.0.0-13/windows_amd64/terraform-provider-oneview_v7.0.0-13.exe
2022-06-20T10:35:55.975+0200 [INFO]  provider.terraform-provider-oneview_v7.0.0-13.exe: configuring 
server automatic mTLS: timestamp=2022-06-20T10:35:55.971+0200
2022-06-20T10:35:56.031+0200 [DEBUG] provider: using plugin: version=5
2022-06-20T10:35:56.031+0200 [DEBUG] provider.terraform-provider-oneview_v7.0.0-13.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp=2022-06-20T10:35:56.030+0200
2022-06-20T10:35:56.158+0200 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/hewlettpackard/oneview\"]" changed the config value, but that value is unused
2022-06-20T10:35:57.553+0200 [INFO]  provider.terraform-provider-oneview_v7.0.0-13.exe: 2022/06/20 10:35:57 [WARN] Truncating attribute path of 0 diagnostics for TypeSet: timestamp=2022-06-20T10:35:57.553+0200
2022-06-20T10:35:57.554+0200 [INFO]  provider.terraform-provider-oneview_v7.0.0-13.exe: 2022/06/20 10:35:57 [WARN] Truncating attribute path of 0 diagnostics for TypeSet: timestamp=2022-06-20T10:35:57.553+0200
module.Add_Volume_Terraform.oneview_volume.volume: Creating...
2022-06-20T10:35:57.560+0200 [INFO]  Starting apply for module.Add_Volume_Terraform.oneview_volume.volume
2022-06-20T10:35:57.563+0200 [DEBUG] module.Add_Volume_Terraform.oneview_volume.volume: applying the planned Create change
2022-06-20T10:35:57.569+0200 [INFO]  provider.terraform-provider-oneview_v7.0.0-13.exe: 2022/06/20 10:35:57 [DEBUG] setting computed for "device_specific_attributes" from ComputedKeys: timestamp=2022-06-20T10:35:57.569+0200
2022-06-20T10:35:58.241+0200 [DEBUG] provider.terraform-provider-oneview_v7.0.0-13.exe: Error submitting new storage volume request: Error in response: One or more required fields are missing.        
2022-06-20T10:35:58.242+0200 [DEBUG] provider.terraform-provider-oneview_v7.0.0-13.exe:  Response Status: 400 Bad Request
2022-06-20T10:35:58.243+0200 [DEBUG] provider.terraform-provider-oneview_v7.0.0-13.exe:  Response Details: Missing value for property 'templateUri'.
2022-06-20T10:35:58.280+0200 [ERROR] vertex "module.Add_Volume_Terraform.oneview_volume.volume" error: Error in response: One or more required fields are missing.
 Response Status: 400 Bad Request
 Response Details: Missing value for property 'templateUri'.
╷
│ Error: Error in response: One or more required fields are missing.
│  Response Status: 400 Bad Request
│  Response Details: Missing value for property 'templateUri'.
│
│   with module.Add_Volume_Terraform.oneview_volume.volume,
me":
│   30: resource "oneview_volume" "volume" {
│
╵```

Is there something I'm missing in my resource or configuration that could be causing this?

Thank you
nabhajit-ray commented 2 years ago

Hi Josyf,

Have you pull the latest changes and build the provider locally ?

josyfj commented 2 years ago

Hi Nabhajit,

I've synced the latest changes and ran the provider locally by using a terraform mirror C:\<directory> command followed by a terraform init -plugin-dir C:\<directory>. If I run terraform providers I get the following response:


.
├── provider[registry.terraform.io/hewlettpackard/oneview] 7.0.0-13
├── provider[registry.terraform.io/hashicorp/null] 3.0.0
└── module.Add_Volume_Terraform
    └── provider[registry.terraform.io/hewlettpackard/oneview] 7.0.0-13

Providers required by state:

    provider[registry.terraform.io/hewlettpackard/oneview]```

It appears that Terraform is using the latest provider version, unless there is something I'm missing?

Thank you again
nabhajit-ray commented 2 years ago

Hi @josyfj ,

You have to build the provider and installed it locally to get the changes from main branch. Let us know if that works for you

nabhajit-ray commented 2 years ago

Hi @josyfj ,

We did not hear from you if the fix is working. Closing it here. Please reopen if it is not working