Skip to content

Commit

Permalink
Merge pull request #479 from HewlettPackard/terraform_changes
Browse files Browse the repository at this point in the history
Terraform changes
  • Loading branch information
alisha-k-kalladassery authored May 13, 2022
2 parents 6ca63f5 + 4e8d54e commit 94cad9a
Show file tree
Hide file tree
Showing 37 changed files with 148 additions and 40 deletions.
5 changes: 4 additions & 1 deletion oneview/data_source_appliance_snmp_v1_trap_destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func dataSourceSNMPv1TrapDestinationRead(d *schema.ResourceData, meta interface{
config := meta.(*Config)
id := d.Get("destination_id").(string)
snmpTrap, err := config.ovClient.GetSNMPv1TrapDestinationsById(id)
if err != nil || snmpTrap.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if snmpTrap.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_appliance_snmpv3_trap_destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func dataSourceSNMPv3TrapDestinationRead(d *schema.ResourceData, meta interface{
config := meta.(*Config)
id := d.Get("id_field").(string)
snmpTrap, err := config.ovClient.GetSNMPv3TrapDestinationsById(id)
if err != nil || snmpTrap.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if snmpTrap.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_appliance_snmpv3_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func dataSourceSNMPv3UserRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
username := d.Get("user_name").(string)
snmpUser, err := config.ovClient.GetSNMPv3UserByUserName(username)
if err != nil || snmpUser.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if snmpUser.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions oneview/data_source_appliance_ssh_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func dataSourceSSHAccessRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
d.SetId("")
return err
} else if sshAccess.URI.IsNil() {
d.SetId("")
return nil
}
d.SetId(sshAccess.Type)
d.Set("allow_ssh_access", sshAccess.AllowSshAccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func dataSourceTimeAndLocaleRead(d *schema.ResourceData, meta interface{}) error
config := meta.(*Config)
timeLocale, err := config.ovClient.GetApplianceTimeandLocals("", "", "", "")
if err != nil {
d.SetId("")
return err
} else if timeLocale.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_connection_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ func dataSourceConnectionTemplatesRead(d *schema.ResourceData, meta interface{})
} else if uri, ok := d.Get("uri").(string); ok {
cTemplate, err = config.ovClient.GetConnectionTemplateByURI(utils.Nstring(uri))
}
if err != nil || cTemplate.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if cTemplate.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_deployment_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ func dataSourceDeploymentPlanRead(d *schema.ResourceData, meta interface{}) erro

id := d.Get("name").(string)
deploymentPlan, err := config.i3sClient.GetDeploymentPlanByName(id)
if err != nil || deploymentPlan.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if deploymentPlan.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_enclosure.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ func dataSourceEnclosureRead(d *schema.ResourceData, meta interface{}) error {
id := d.Get("name").(string)

enclosure, err := config.ovClient.GetEnclosureByName(id)
if err != nil || enclosure.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if enclosure.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_enclosure_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ func dataSourceEnclosureGroup() *schema.Resource {
func dataSourceEnclosureGroupRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
enclosureGroup, err := config.ovClient.GetEnclosureGroupByName(d.Get("name").(string))
if err != nil || enclosureGroup.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if enclosureGroup.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_ethernet_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ func dataSourceEthernetNetworkRead(d *schema.ResourceData, meta interface{}) err
config := meta.(*Config)
name := d.Get("name").(string)
eNet, err := config.ovClient.GetEthernetNetworkByName(name)
if err != nil || eNet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if eNet.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_fc_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ func dataSourceFCNetworkRead(d *schema.ResourceData, meta interface{}) error {
id := d.Get("name").(string)

fcNet, err := config.ovClient.GetFCNetworkByName(id)
if err != nil || fcNet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if fcNet.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_fcoe_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ func dataSourceFCoENetworkRead(d *schema.ResourceData, meta interface{}) error {
id := d.Get("name").(string)

fcoeNet, err := config.ovClient.GetFCoENetworkByName(id)
if err != nil || fcoeNet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if fcoeNet.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
6 changes: 4 additions & 2 deletions oneview/data_source_firmware_drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ func dataSourceFirmwareDriversRead(d *schema.ResourceData, meta interface{}) err
id := d.Get("id").(string)
firmware, err := config.ovClient.GetFirmwareBaselineByNameandVersion(id)

if err != nil || firmware.Uri.IsNil() {

if err != nil {
d.SetId("")
return err
} else if firmware.Uri.IsNil() {
d.SetId("")
return nil
}
d.Set("name", firmware.Name)
d.Set("type", firmware.Type)
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_hypervisor_cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ func datasourceHypervisorClusterProfileRead(d *schema.ResourceData, meta interfa
config := meta.(*Config)

hypCP, err := config.ovClient.GetHypervisorClusterProfileByName(d.Get("name").(string))
if err != nil || hypCP.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if hypCP.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_hypervisor_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ func dataSourceHypervisorManagerRead(d *schema.ResourceData, meta interface{}) e
id := d.Get("name").(string)

hypMan, err := config.ovClient.GetHypervisorManagerByName(id)
if err != nil || hypMan.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if hypMan.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_id_pools_ipv4_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ func dataSourceIPv4RangesRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
id := d.Get("id").(string)
ipv4range, err := config.ovClient.GetIPv4RangebyId("", id)
if err != nil || ipv4range.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if ipv4range.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
10 changes: 8 additions & 2 deletions oneview/data_source_id_pools_ipv4_subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,21 @@ func dataSourceIPv4SubnetsRead(d *schema.ResourceData, meta interface{}) error {
subnetId := d.Get("subnet_id").(string)
subnetById, err := config.ovClient.GetIPv4SubnetbyId(subnetId)
subnet = subnetById
if err != nil || subnet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if subnet.URI.IsNil() {
d.SetId("")
return nil
}
} else {
networkId := d.Get("network_id").(string)
subnetByNetwork, err := config.ovClient.GetSubnetByNetworkId(networkId)
subnet = subnetByNetwork
if err != nil || subnet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if subnet.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
6 changes: 4 additions & 2 deletions oneview/data_source_interconnect_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ func dataSourceInterconnectTypeRead(d *schema.ResourceData, meta interface{}) er
config := meta.(*Config)

interconnectType, err := config.ovClient.GetInterconnectTypeByName(d.Get("name").(string))
if err != nil || interconnectType.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if interconnectType.URI.IsNil() {
d.SetId("")

return nil
}
d.SetId(d.Get("name").(string))
Expand Down
6 changes: 4 additions & 2 deletions oneview/data_source_interconnects.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ func dataSourceInterconnectsRead(d *schema.ResourceData, meta interface{}) error
name := d.Get("name").(string)

interconnect, err := config.ovClient.GetInterconnectByName(name)
if err != nil || interconnect.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if interconnect.URI.IsNil() {
d.SetId("")

return nil
}

Expand Down
6 changes: 4 additions & 2 deletions oneview/data_source_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ func dataSourceLabel() *schema.Resource {
func dataSourceLabelRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
label, err := config.ovClient.GetAssignedLabels(utils.Nstring(d.Get("resource_uri").(string)))
if err != nil || label.Uri.IsNil() {
if err != nil {
d.SetId("")
return err
} else if label.Uri.IsNil() {
d.SetId("")
return nil
}

d.Set("category", label.Category)
d.Set("created", label.Created)
d.Set("etag", label.ETAG.String())
Expand Down
3 changes: 3 additions & 0 deletions oneview/data_source_logical_enclosure.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func dataSourceLogicalEnclosureRead(d *schema.ResourceData, meta interface{}) er

logicalEnclosure, err := config.ovClient.GetLogicalEnclosureByName(d.Get("name").(string))
if err != nil {
d.SetId("")
return err
} else if logicalEnclosure.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_logical_interconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ func dataSourceLogicalInterconnectRead(d *schema.ResourceData, meta interface{})
logInt = li
}
}
if err != nil || logInt.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if logInt.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_logical_interconnect_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,10 @@ func dataSourceLogicalInterconnectGroupRead(d *schema.ResourceData, meta interfa

logicalInterconnectGroup, err := config.ovClient.GetLogicalInterconnectGroupByName(id)

if err != nil || logicalInterconnectGroup.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if logicalInterconnectGroup.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_network_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ func dataSourceNetworkSetRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

netSet, err := config.ovClient.GetNetworkSetByName(d.Get("name").(string))
if err != nil || netSet.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if netSet.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ func dataSourceScopeRead(d *schema.ResourceData, meta interface{}) error {
name := d.Get("name").(string)

scope, err := config.ovClient.GetScopeByName(name)
if err != nil || scope.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if scope.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions oneview/data_source_server_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ func dataSourceServerCertificateRead(d *schema.ResourceData, meta interface{}) e
servC, err = config.ovClient.GetServerCertificateByName(id)

if err != nil {
d.SetId("")
return err
} else if servC.URI.IsNil() {
d.SetId("")
return nil
}
Expand All @@ -289,6 +292,9 @@ func dataSourceServerCertificateRead(d *schema.ResourceData, meta interface{}) e
servC, err = config.ovClient.GetServerCertificateByIp(id)

if err != nil {
d.SetId("")
return err
} else if servC.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_server_hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ func dataSourceServerHardwareRead(d *schema.ResourceData, meta interface{}) erro
config := meta.(*Config)

servHard, err := config.ovClient.GetServerHardwareByName(d.Get("name").(string))
if err != nil || servHard.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if servHard.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_server_hardware_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func dataSourceServerHardwareTypeRead(d *schema.ResourceData, meta interface{})
name := d.Get("name").(string)

serverHardwareType, err := config.ovClient.GetServerHardwareTypeByName(name)
if err != nil || serverHardwareType.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if serverHardwareType.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_server_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,10 @@ func dataSourceServerProfileRead(d *schema.ResourceData, meta interface{}) error
config := meta.(*Config)

serverProfile, err := config.ovClient.GetProfileByName(d.Get("name").(string))
if err != nil || serverProfile.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if serverProfile.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_server_profile_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,9 +1122,12 @@ func dataSourceServerProfileTemplateRead(d *schema.ResourceData, meta interface{

spt, err := config.ovClient.GetProfileTemplateByName(name)

if err != nil || spt.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if spt.URI.IsNil() {
d.SetId("")
return nil
}
d.Set("affinity", spt.Affinity)
d.Set("category", spt.Category)
Expand Down
5 changes: 4 additions & 1 deletion oneview/data_source_storage_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func dataSourceStorageAttachmentRead(d *schema.ResourceData, meta interface{}) e
id := d.Get("name").(string)

storageAttachment, err := config.ovClient.GetStorageAttachmentById(id)
if err != nil || storageAttachment.URI.IsNil() {
if err != nil {
d.SetId("")
return err
} else if storageAttachment.URI.IsNil() {
d.SetId("")
return nil
}
Expand Down
Loading

0 comments on commit 94cad9a

Please sign in to comment.