4.10.1
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceLogicalPortRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
logicalPort, err := utilityLogicalPortCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenLogicalPort(d, logicalPort)
|
||||
d.SetId(logicalPort.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLogicalPort() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLogicalPortRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceLogicalPortSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceLogicalPortByUniqueIDRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
logicalPort, err := utilityLogicalPortByUniqueIDCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenLogicalPort(d, logicalPort)
|
||||
d.SetId(logicalPort.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLogicalPortByUniqueID() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLogicalPortByUniqueIDRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceLogicalPortByUniqueIDSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceLogicalPortListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
logicalPortList, err := utilityLogicalPortListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenLogicalPortList(logicalPortList))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLogicalPortList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLogicalPortListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceLogicalPortListSchemaMake(),
|
||||
}
|
||||
}
|
||||
114
internal/service/sdn/logicalports/flattens.go
Normal file
114
internal/service/sdn/logicalports/flattens.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
|
||||
)
|
||||
|
||||
func flattenLogicalPortResource(d *schema.ResourceData, logicalPort *logicalports.LogicalPort) {
|
||||
d.Set("id", logicalPort.ID)
|
||||
d.Set("access_group_id", logicalPort.AccessGroupID)
|
||||
d.Set("access_group_name", logicalPort.AccessGroupName)
|
||||
d.Set("adapter_mac", logicalPort.AdapterMAC)
|
||||
d.Set("address_detection", logicalPort.AddressDetection)
|
||||
d.Set("description", logicalPort.Description)
|
||||
d.Set("display_name", logicalPort.DisplayName)
|
||||
d.Set("enabled", logicalPort.Enabled)
|
||||
d.Set("hypervisor", logicalPort.Hypervisor)
|
||||
d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName)
|
||||
d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV)
|
||||
d.Set("status", flattenStatus(logicalPort.Status))
|
||||
d.Set("unique_identifier", logicalPort.UniqueIdentifier)
|
||||
d.Set("version_id", logicalPort.VersionID)
|
||||
d.Set("bindings", flattenBindings(logicalPort.Bindings))
|
||||
d.Set("created_at", logicalPort.CreatedAt)
|
||||
}
|
||||
|
||||
func flattenLogicalPortList(lpl *logicalports.LogicalPortsList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lpl.Ports))
|
||||
for _, v := range lpl.Ports {
|
||||
temp := map[string]interface{}{
|
||||
"id": v.ID,
|
||||
"access_group_id": v.AccessGroupID,
|
||||
"access_group_name": v.AccessGroupName,
|
||||
"adapter_mac": v.AdapterMAC,
|
||||
"address_detection": v.AddressDetection,
|
||||
"description": v.Description,
|
||||
"display_name": v.DisplayName,
|
||||
"enabled": v.Enabled,
|
||||
"hypervisor": v.Hypervisor,
|
||||
"hypervisor_display_name": v.HypervisorDisplayName,
|
||||
"live_migration_target_hv": v.LiveMigrationTargetHV,
|
||||
"status": flattenStatus(v.Status),
|
||||
"unique_identifier": v.UniqueIdentifier,
|
||||
"version_id": v.VersionID,
|
||||
"bindings": flattenBindings(v.Bindings),
|
||||
"created_at": v.CreatedAt,
|
||||
"updated_at": v.UpdatedAt,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLogicalPort(d *schema.ResourceData, logicalPort *logicalports.LogicalPort) {
|
||||
d.Set("id", logicalPort.ID)
|
||||
d.Set("access_group_id", logicalPort.AccessGroupID)
|
||||
d.Set("access_group_name", logicalPort.AccessGroupName)
|
||||
d.Set("adapter_mac", logicalPort.AdapterMAC)
|
||||
d.Set("address_detection", logicalPort.AddressDetection)
|
||||
d.Set("description", logicalPort.Description)
|
||||
d.Set("display_name", logicalPort.DisplayName)
|
||||
d.Set("enabled", logicalPort.Enabled)
|
||||
d.Set("hypervisor", logicalPort.Hypervisor)
|
||||
d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName)
|
||||
d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV)
|
||||
d.Set("status", flattenStatus(logicalPort.Status))
|
||||
d.Set("unique_identifier", logicalPort.UniqueIdentifier)
|
||||
d.Set("version_id", logicalPort.VersionID)
|
||||
d.Set("bindings", flattenBindings(logicalPort.Bindings))
|
||||
d.Set("created_at", logicalPort.CreatedAt)
|
||||
d.Set("updated_at", logicalPort.UpdatedAt)
|
||||
}
|
||||
|
||||
func flattenBindings(bindings logicalports.Bindings) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"id": bindings.ID,
|
||||
"segment_id": bindings.SegmentID,
|
||||
"segment_display_name": bindings.SegmentDisplayName,
|
||||
"port_security": bindings.PortSecurity,
|
||||
"address_detection": bindings.AddressDetection,
|
||||
"is_excluded_from_firewall": bindings.IsExcludedFromFirewall,
|
||||
"version_id": bindings.VersionID,
|
||||
"created_at": bindings.CreatedAt,
|
||||
"updated_at": bindings.UpdatedAt,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenStatus(status logicalports.Status) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"common": status.Common,
|
||||
"hypervisors": flattenHypervisors(status.Hypervisors),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenHypervisors(hv []logicalports.HypervisorStatus) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(hv))
|
||||
for _, v := range hv {
|
||||
temp := map[string]interface{}{
|
||||
"status": v.Status,
|
||||
"name": v.Name,
|
||||
"display_name": v.DisplayName,
|
||||
"hypervisor_status": v.HypervisorStatus,
|
||||
"synced_at": v.SyncedAt,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
226
internal/service/sdn/logicalports/resource_logical_port.go
Normal file
226
internal/service/sdn/logicalports/resource_logical_port.go
Normal file
@@ -0,0 +1,226 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func resourceLogicalPortCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLogicalPortCreate: called logical port with name %s",
|
||||
d.Get("display_name").(string))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := logicalports.CreateRequest{
|
||||
AccessGroupID: d.Get("access_group_id").(string),
|
||||
Description: d.Get("description").(string),
|
||||
DisplayName: d.Get("display_name").(string),
|
||||
Enabled: d.Get("enabled").(bool),
|
||||
IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool),
|
||||
Hypervisor: d.Get("hypervisor").(string),
|
||||
PortSecurity: d.Get("port_security").(bool),
|
||||
SegmentID: d.Get("segment_id").(string),
|
||||
}
|
||||
|
||||
if adapterMAC, ok := d.GetOk("adapter_mac"); ok {
|
||||
req.AdapterMAC = adapterMAC.(string)
|
||||
}
|
||||
if uniqueID, ok := d.GetOk("unique_identifier"); ok {
|
||||
req.UniqueIdentifier = uniqueID.(string)
|
||||
}
|
||||
if logicalPortAddresses, ok := d.GetOk("logical_port_addresses"); ok {
|
||||
logicalPortAddressesList := logicalPortAddresses.([]interface{})
|
||||
logicalPortsAddressesArr := make([]logicalports.LogicalPortAddress, 0)
|
||||
for _, logicalPortAddressRaw := range logicalPortAddressesList {
|
||||
logicalPortAddressMap := logicalPortAddressRaw.(map[string]interface{})
|
||||
logicalPortAddress := logicalports.LogicalPortAddress{
|
||||
IP: logicalPortAddressMap["ip"].(string),
|
||||
IPType: logicalPortAddressMap["ip_type"].(string),
|
||||
IsPrimary: logicalPortAddressMap["is_primary"].(bool),
|
||||
}
|
||||
if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok {
|
||||
logicalPortAddress.IsDiscovered = isDiscovered.(bool)
|
||||
}
|
||||
if mac, ok := logicalPortAddressMap["mac_address"]; ok {
|
||||
logicalPortAddress.MAC = mac.(string)
|
||||
}
|
||||
logicalPortsAddressesArr = append(logicalPortsAddressesArr, logicalPortAddress)
|
||||
}
|
||||
req.LogicalPortAddresses = logicalPortsAddressesArr
|
||||
}
|
||||
|
||||
logicalPort, err := c.SDN().LogicalPorts().Create(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(logicalPort.ID)
|
||||
|
||||
return resourceLogicalPortRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceLogicalPortRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLogicalPortRead: called logical port with id %s", d.Id())
|
||||
|
||||
logicalPort, err := utilityLogicalPortCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenLogicalPortResource(d, logicalPort)
|
||||
d.SetId(logicalPort.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLogicalPortUpdate: called logical port with id %s", d.Id())
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := logicalports.UpdateRequest{
|
||||
LogicalPortID: d.Id(),
|
||||
VersionID: uint64(d.Get("version_id").(int)),
|
||||
AdapterMAC: d.Get("adapter_mac").(string),
|
||||
Description: d.Get("description").(string),
|
||||
DisplayName: d.Get("display_name").(string),
|
||||
Enabled: d.Get("enabled").(bool),
|
||||
Hypervisor: d.Get("hypervisor").(string),
|
||||
PortSecurity: d.Get("port_security").(bool),
|
||||
IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool),
|
||||
SegmentID: d.Get("segment_id").(string),
|
||||
}
|
||||
|
||||
if d.HasChange("logical_port_addresses") {
|
||||
oldAddresses, newAddresses := d.GetChange("logical_port_addresses")
|
||||
oldAddressesList := oldAddresses.([]interface{})
|
||||
newAddressesList := newAddresses.([]interface{})
|
||||
oldAddressesMap := make(map[string]logicalports.LogicalPortAddress)
|
||||
for _, oldAddressRaw := range oldAddressesList {
|
||||
logicalPortAddressMap := oldAddressRaw.(map[string]interface{})
|
||||
logicalPortAddress := logicalports.LogicalPortAddress{
|
||||
IP: logicalPortAddressMap["ip"].(string),
|
||||
IPType: logicalPortAddressMap["ip_type"].(string),
|
||||
IsPrimary: logicalPortAddressMap["is_primary"].(bool),
|
||||
}
|
||||
if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok {
|
||||
logicalPortAddress.IsDiscovered = isDiscovered.(bool)
|
||||
}
|
||||
if mac, ok := logicalPortAddressMap["mac_address"]; ok {
|
||||
logicalPortAddress.MAC = mac.(string)
|
||||
}
|
||||
oldAddressesMap[logicalPortAddress.IP] = logicalPortAddress
|
||||
}
|
||||
newAddressesMap := make(map[string]logicalports.LogicalPortAddress)
|
||||
for _, newAddressRaw := range newAddressesList {
|
||||
logicalPortAddressMap := newAddressRaw.(map[string]interface{})
|
||||
logicalPortAddress := logicalports.LogicalPortAddress{
|
||||
IP: logicalPortAddressMap["ip"].(string),
|
||||
IPType: logicalPortAddressMap["ip_type"].(string),
|
||||
IsPrimary: logicalPortAddressMap["is_primary"].(bool),
|
||||
}
|
||||
if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok {
|
||||
logicalPortAddress.IsDiscovered = isDiscovered.(bool)
|
||||
}
|
||||
if mac, ok := logicalPortAddressMap["mac_address"]; ok {
|
||||
logicalPortAddress.MAC = mac.(string)
|
||||
}
|
||||
newAddressesMap[logicalPortAddress.IP] = logicalPortAddress
|
||||
}
|
||||
|
||||
for addressIP, _ := range oldAddressesMap {
|
||||
removeAddresses := make([]string, 0)
|
||||
if _, exists := newAddressesMap[addressIP]; !exists {
|
||||
removeAddresses = append(removeAddresses, addressIP)
|
||||
}
|
||||
req.RemoveAddresses = removeAddresses
|
||||
}
|
||||
|
||||
for addressIP, address := range newAddressesMap {
|
||||
if oldAddressIP, exists := oldAddressesMap[addressIP]; !exists || address != oldAddressIP {
|
||||
if !exists {
|
||||
logicalPortAddress := logicalports.AddAddress{
|
||||
IP: address.IP,
|
||||
IPType: address.IPType,
|
||||
IsPrimary: address.IsPrimary,
|
||||
IsDiscovered: address.IsDiscovered,
|
||||
MAC: address.MAC,
|
||||
}
|
||||
req.AddAddresses = append(req.AddAddresses, logicalPortAddress)
|
||||
} else if address != oldAddressIP {
|
||||
logicalPortAddress := logicalports.UpdateAddress{
|
||||
IP: address.IP,
|
||||
IPType: address.IPType,
|
||||
IsPrimary: address.IsPrimary,
|
||||
IsDiscovered: address.IsDiscovered,
|
||||
MAC: address.MAC,
|
||||
}
|
||||
req.UpdateAddresses = append(req.UpdateAddresses, logicalPortAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_, err := c.SDN().LogicalPorts().Update(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
return resourceLogicalPortRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceLogicalPortDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLogicalPortDelete: called logical port with id %s", d.Id())
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := logicalports.DeleteRequest{
|
||||
ID: d.Id(),
|
||||
Version: uint64(d.Get("version_id").(int)),
|
||||
}
|
||||
|
||||
if force, ok := d.GetOk("force"); ok {
|
||||
req.Force = force.(bool)
|
||||
}
|
||||
|
||||
_, err := c.SDN().LogicalPorts().Delete(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResourceLogicalPort() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLogicalPortCreate,
|
||||
ReadContext: resourceLogicalPortRead,
|
||||
UpdateContext: resourceLogicalPortUpdate,
|
||||
DeleteContext: resourceLogicalPortDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout600s,
|
||||
Read: &constants.Timeout300s,
|
||||
Update: &constants.Timeout600s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
},
|
||||
|
||||
Schema: resourceLogicalPortSchemaMake(),
|
||||
}
|
||||
}
|
||||
858
internal/service/sdn/logicalports/schema.go
Normal file
858
internal/service/sdn/logicalports/schema.go
Normal file
@@ -0,0 +1,858 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func resourceLogicalPortSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Access Group ID",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Description",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Display Name",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Required: true,
|
||||
Description: "Whether the logical port should be enabled",
|
||||
},
|
||||
"is_excluded_from_firewall": {
|
||||
Type: schema.TypeBool,
|
||||
Required: true,
|
||||
},
|
||||
"hypervisor": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Hypervisor",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Required: true,
|
||||
Description: "Whether the port security is enabled",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Segment ID",
|
||||
},
|
||||
"adapter_mac": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Adapter MAC address",
|
||||
},
|
||||
"unique_identifier": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Unique identifier of the logical port",
|
||||
},
|
||||
"force": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"logical_port_addresses": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "IP address of the logical port",
|
||||
},
|
||||
"ip_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"IPv4", "IPv6"}, false),
|
||||
},
|
||||
"is_primary": {
|
||||
Type: schema.TypeBool,
|
||||
Required: true,
|
||||
},
|
||||
"is_discovered": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the logical port",
|
||||
},
|
||||
"access_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the access group",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"external_network_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"hypervisor_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"live_migration_target_hv": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"common": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Common status",
|
||||
},
|
||||
"hypervisors": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the hypervisor",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"hypervisor_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"synced_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Sync time of the hypervisor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the binding",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the segment",
|
||||
},
|
||||
"segment_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the segment",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the port is secured",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"is_excluded_from_firewall": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the binding",
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the binding",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time of the binding",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the logical port",
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Access Group ID",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Segment ID",
|
||||
},
|
||||
"segment_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Segment display name",
|
||||
},
|
||||
"external_network_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "External Network ID",
|
||||
},
|
||||
"unique_identifier": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Unique identifier",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Display name",
|
||||
},
|
||||
"adapter_mac": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Adapter mac",
|
||||
},
|
||||
"hypervisor": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Hypervisor",
|
||||
},
|
||||
"hypervisor_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Hypervisor display name",
|
||||
},
|
||||
"live_migration_target_hv": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Live migration target HV",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"created_from": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"created_to": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"per_page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"display_name", "created_at", "updated_at",
|
||||
"deleted_at", "segment_id", "hypervisor",
|
||||
"port_security", "segment_display_name", "primary_address",
|
||||
"hypervisor_display_name"}, false),
|
||||
},
|
||||
"sort_order": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"asc", "dec"}, false),
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the logical port to use",
|
||||
},
|
||||
"access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the access group",
|
||||
},
|
||||
"access_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the access group",
|
||||
},
|
||||
"adapter_mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address of the adapter",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Description of the logical port",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the logical port",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the logical port is enabled",
|
||||
},
|
||||
"hypervisor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the hypervisor",
|
||||
},
|
||||
"hypervisor_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"live_migration_target_hv": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"common": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Common status",
|
||||
},
|
||||
"hypervisors": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the hypervisor",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"hypervisor_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"synced_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Sync time of the hypervisor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"unique_identifier": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the logical port",
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the logical port",
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the binding",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the segment",
|
||||
},
|
||||
"segment_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the segment",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the port is secured",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"is_excluded_from_firewall": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the binding",
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the binding",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time of the binding",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the logical port",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time the logical port",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"unique_identifier": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Unique ID of the logical port to use",
|
||||
},
|
||||
"access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the access group",
|
||||
},
|
||||
"access_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the access group",
|
||||
},
|
||||
"adapter_mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address of the adapter",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Description of the logical port",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the logical port",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the logical port is enabled",
|
||||
},
|
||||
"hypervisor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the hypervisor",
|
||||
},
|
||||
"hypervisor_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"live_migration_target_hv": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"common": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Common status",
|
||||
},
|
||||
"hypervisors": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the hypervisor",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"hypervisor_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"synced_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Sync time of the hypervisor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the logical port",
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the binding",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the segment",
|
||||
},
|
||||
"segment_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the segment",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the port is secured",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"is_excluded_from_firewall": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the binding",
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the binding",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time of the binding",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the logical port",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time the logical port",
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"logical_port_id": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "ID of the logical port to use",
|
||||
},
|
||||
"access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the access group",
|
||||
},
|
||||
"access_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the access group",
|
||||
},
|
||||
"adapter_mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address of the adapter",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Description of the logical port",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the logical port",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the logical port is enabled",
|
||||
},
|
||||
"hypervisor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the hypervisor",
|
||||
},
|
||||
"hypervisor_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"live_migration_target_hv": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"common": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Common status",
|
||||
},
|
||||
"hypervisors": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the hypervisor",
|
||||
},
|
||||
"display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the hypervisor",
|
||||
},
|
||||
"hypervisor_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Status of the hypervisor",
|
||||
},
|
||||
"synced_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Sync time of the hypervisor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"unique_identifier": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the logical port",
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the logical port",
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the binding",
|
||||
},
|
||||
"segment_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Unique identifier of the segment",
|
||||
},
|
||||
"segment_display_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Display name of the segment",
|
||||
},
|
||||
"port_security": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the port is secured",
|
||||
},
|
||||
"address_detection": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "If the adapter address detection is enabled",
|
||||
},
|
||||
"is_excluded_from_firewall": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"version_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Version ID of the binding",
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the binding",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time of the binding",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Creation time of the logical port",
|
||||
},
|
||||
"updated_at": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Update time the logical port",
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
30
internal/service/sdn/logicalports/utility_logical_port.go
Normal file
30
internal/service/sdn/logicalports/utility_logical_port.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLogicalPortCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPort, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := logicalports.GetRequest{
|
||||
ID: d.Id(),
|
||||
}
|
||||
|
||||
if d.Id() != "" {
|
||||
req.ID = d.Id()
|
||||
} else {
|
||||
req.ID = d.Get("logical_port_id").(string)
|
||||
}
|
||||
|
||||
logicalPort, err := c.SDN().LogicalPorts().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return logicalPort, nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLogicalPortByUniqueIDCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPort, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := logicalports.GetByUniqueIdentifierRequest{
|
||||
ID: d.Id(),
|
||||
}
|
||||
|
||||
if d.Id() != "" {
|
||||
req.ID = d.Id()
|
||||
} else {
|
||||
req.ID = d.Get("unique_identifier").(string)
|
||||
}
|
||||
|
||||
logicalPort, err := c.SDN().LogicalPorts().GetByUniqueIdentifier(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return logicalPort, nil
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLogicalPortListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPortsList, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := logicalports.ListRequest{}
|
||||
|
||||
if accessGroupID, ok := d.GetOk("access_group_id"); ok {
|
||||
req.AccessGroupID = accessGroupID.(string)
|
||||
}
|
||||
if segmentID, ok := d.GetOk("segment_id"); ok {
|
||||
req.SegmentID = segmentID.(string)
|
||||
}
|
||||
if segmentDisplayName, ok := d.GetOk("segment_display_name"); ok {
|
||||
req.SegmentDisplayName = segmentDisplayName.(string)
|
||||
}
|
||||
if externalNetworkID, ok := d.GetOk("external_network_id"); ok {
|
||||
req.ExternalNetworkID = externalNetworkID.(string)
|
||||
}
|
||||
if uniqueID, ok := d.GetOk("unique_identifier"); ok {
|
||||
req.UniqueIdentifier = uniqueID.(string)
|
||||
}
|
||||
if displayName, ok := d.GetOk("display_name"); ok {
|
||||
req.DisplayName = displayName.(string)
|
||||
}
|
||||
if adapterMAC, ok := d.GetOk("adapter_mac"); ok {
|
||||
req.AdapterMAC = adapterMAC.(string)
|
||||
}
|
||||
if hypervisor, ok := d.GetOk("hypervisor"); ok {
|
||||
req.Hypervisor = hypervisor.(string)
|
||||
}
|
||||
if hypervisorDisplayName, ok := d.GetOk("hypervisor_display_name"); ok {
|
||||
req.HypervisorDisplayName = hypervisorDisplayName.(string)
|
||||
}
|
||||
if liveMigrationTargetHV, ok := d.GetOk("live_migration_target_hv"); ok {
|
||||
req.LiveMigrationTargetHv = liveMigrationTargetHV.(string)
|
||||
}
|
||||
if portSecurity, ok := d.GetOk("port_security"); ok {
|
||||
req.PortSecurity = portSecurity.(bool)
|
||||
}
|
||||
if addressDetection, ok := d.GetOk("address_detection"); ok {
|
||||
req.AddressDetection = addressDetection.(bool)
|
||||
}
|
||||
if enabled, ok := d.GetOk("enabled"); ok {
|
||||
req.Enabled = enabled.(bool)
|
||||
}
|
||||
if createdFrom, ok := d.GetOk("created_from"); ok {
|
||||
req.CreatedFrom = createdFrom.(string)
|
||||
}
|
||||
if createdTo, ok := d.GetOk("created_to"); ok {
|
||||
req.CreatedTo = createdTo.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if perPage, ok := d.GetOk("per_page"); ok {
|
||||
req.PerPage = uint64(perPage.(int))
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if sortOrder, ok := d.GetOk("sort_order"); ok {
|
||||
req.SortOrder = sortOrder.(string)
|
||||
}
|
||||
|
||||
logicalPortList, err := c.SDN().LogicalPorts().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return logicalPortList, nil
|
||||
}
|
||||
Reference in New Issue
Block a user