This commit is contained in:
2026-09-21 11:51:12 +03:00
parent 9cd93e4277
commit 2b229a84fb
240 changed files with 7735 additions and 3166 deletions

View File

@@ -74,6 +74,134 @@ func excludeFirewallSchema() *schema.Schema {
}
}
func statusSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation status",
},
"hypervisor_status": {
Type: schema.TypeString,
Computed: true,
Description: "Hypervisor status",
},
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation 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",
},
},
},
},
},
},
}
}
func bindingsSchema() *schema.Schema {
return &schema.Schema{
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",
},
"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",
},
"logical_port_addresses": logicalPortAddressesSchema(),
},
},
}
}
func computedLabelsSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vm_id": {
Type: schema.TypeString,
Computed: true,
Description: "VM ID label",
},
"vm_name": {
Type: schema.TypeString,
Computed: true,
Description: "VM name label",
},
},
},
Description: "Labels",
}
}
func resourceLogicalPortSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"access_group_id": {
@@ -200,15 +328,11 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"exclude_firewall": excludeFirewallSchema(),
"created_at": {
Type: schema.TypeString,
Computed: true,
},
"updated_at": {
Type: schema.TypeString,
Computed: true,
Description: "Last update time of the logical port",
},
"external_network_id": {
Type: schema.TypeString,
Computed: true,
@@ -221,107 +345,8 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"exclude_firewall": excludeFirewallSchema(),
"status": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation status",
},
"hypervisor_status": {
Type: schema.TypeString,
Computed: true,
Description: "Hypervisor status",
},
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation 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",
},
"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",
},
"logical_port_addresses": logicalPortAddressesSchema(),
},
},
},
"status": statusSchema(),
"bindings": bindingsSchema(),
"version_id": {
Type: schema.TypeInt,
Computed: true,
@@ -337,13 +362,11 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema {
"vm_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "VM ID label",
},
"vm_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "VM name label",
},
},
@@ -492,6 +515,7 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "If the adapter address detection is enabled",
},
"exclude_firewall": excludeFirewallSchema(),
"description": {
Type: schema.TypeString,
Computed: true,
@@ -525,57 +549,7 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation status",
},
"hypervisor_status": {
Type: schema.TypeString,
Computed: true,
Description: "Hypervisor status",
},
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation 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",
},
},
},
},
},
},
},
"status": statusSchema(),
"unique_identifier": {
Type: schema.TypeString,
Computed: true,
@@ -586,55 +560,7 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema {
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",
},
"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",
},
"logical_port_addresses": logicalPortAddressesSchema(),
},
},
},
"bindings": bindingsSchema(),
"created_at": {
Type: schema.TypeString,
Computed: true,
@@ -645,25 +571,7 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Update time the logical port",
},
"labels": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vm_id": {
Type: schema.TypeString,
Computed: true,
Description: "VM ID label",
},
"vm_name": {
Type: schema.TypeString,
Computed: true,
Description: "VM name label",
},
},
},
Description: "Labels",
},
"labels": computedLabelsSchema(),
},
},
},
@@ -698,6 +606,7 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "If the adapter address detection is enabled",
},
"exclude_firewall": excludeFirewallSchema(),
"description": {
Type: schema.TypeString,
Computed: true,
@@ -731,111 +640,13 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation status",
},
"hypervisor_status": {
Type: schema.TypeString,
Computed: true,
Description: "Hypervisor status",
},
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation 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",
},
},
},
},
},
},
},
"status": statusSchema(),
"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",
},
"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",
},
"logical_port_addresses": logicalPortAddressesSchema(),
},
},
},
"bindings": bindingsSchema(),
"created_at": {
Type: schema.TypeString,
Computed: true,
@@ -846,25 +657,7 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Update time the logical port",
},
"labels": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vm_id": {
Type: schema.TypeString,
Computed: true,
Description: "VM ID label",
},
"vm_name": {
Type: schema.TypeString,
Computed: true,
Description: "VM name label",
},
},
},
Description: "Labels",
},
"labels": computedLabelsSchema(),
}
return res
}
@@ -896,6 +689,7 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "If the adapter address detection is enabled",
},
"exclude_firewall": excludeFirewallSchema(),
"description": {
Type: schema.TypeString,
Computed: true,
@@ -929,57 +723,7 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation status",
},
"hypervisor_status": {
Type: schema.TypeString,
Computed: true,
Description: "Hypervisor status",
},
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operation_status": {
Type: schema.TypeString,
Computed: true,
Description: "Operation 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",
},
},
},
},
},
},
},
"status": statusSchema(),
"unique_identifier": {
Type: schema.TypeString,
Computed: true,
@@ -990,55 +734,7 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema {
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",
},
"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",
},
"logical_port_addresses": logicalPortAddressesSchema(),
},
},
},
"bindings": bindingsSchema(),
"created_at": {
Type: schema.TypeString,
Computed: true,
@@ -1049,25 +745,7 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Update time the logical port",
},
"labels": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vm_id": {
Type: schema.TypeString,
Computed: true,
Description: "VM ID label",
},
"vm_name": {
Type: schema.TypeString,
Computed: true,
Description: "VM name label",
},
},
},
Description: "Labels",
},
"labels": computedLabelsSchema(),
}
return res
}

View File

@@ -542,30 +542,16 @@ func externalNetworkPortsComputedSchema() *schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {Type: schema.TypeString, Computed: true},
"access_group_id": {Type: schema.TypeString, Computed: true},
"access_group_name": {Type: schema.TypeString, Computed: true},
"bridge_network_name": {Type: schema.TypeString, Computed: true},
"comment": {Type: schema.TypeString, Computed: true},
"default_gateway_ipv4": {Type: schema.TypeString, Computed: true},
"default_gateway_ipv6": {Type: schema.TypeString, Computed: true},
"description": {Type: schema.TypeString, Computed: true},
"enabled": {Type: schema.TypeBool, Computed: true},
"external_network_ports": externalNetworkPortFieldsComputedSchema(),
"hypervisors": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"ipv4": {Type: schema.TypeString, Computed: true},
"status": statusComputedSchema(),
"version_id": {Type: schema.TypeInt, Computed: true},
"subnet_v4": {Type: schema.TypeString, Computed: true},
"subnet_v6": {Type: schema.TypeString, Computed: true},
"created_at": {Type: schema.TypeString, Computed: true},
"updated_at": {Type: schema.TypeString, Computed: true},
"vlan_tag": {Type: schema.TypeInt, Computed: true},
"mac": {Type: schema.TypeString, Computed: true},
"id": {Type: schema.TypeString, Computed: true},
"access_group_id": {Type: schema.TypeString, Computed: true},
"access_group_name": {Type: schema.TypeString, Computed: true},
"comment": {Type: schema.TypeString, Computed: true},
"display_name": {Type: schema.TypeString, Computed: true},
"enabled": {Type: schema.TypeBool, Computed: true},
"external_network_id": {Type: schema.TypeString, Computed: true},
"ipv4": {Type: schema.TypeString, Computed: true},
"version_id": {Type: schema.TypeInt, Computed: true},
"mac": {Type: schema.TypeString, Computed: true},
},
},
}

View File

@@ -102,6 +102,10 @@ func dataSourceNetworkObjectGroupListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Optional: true,
},
"items": {
Type: schema.TypeList,
Computed: true,

View File

@@ -405,31 +405,16 @@ func flattenExternalNetworkPortFields(ports netobjgroups.ExternalNetworkPortsFie
func flattenExternalNetworkPorts(ports netobjgroups.ExternalNetworkPorts) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ports))
for _, p := range ports {
hypervisors := make([]interface{}, 0, len(p.Hypervisors))
for _, h := range p.Hypervisors {
hypervisors = append(hypervisors, h)
}
res = append(res, map[string]interface{}{
"id": p.ID,
"access_group_id": p.AccessGroupID,
"access_group_name": p.AccessGroupName,
"bridge_network_name": p.BridgeNetworkName,
"comment": p.Comment,
"default_gateway_ipv4": p.DefaultGatewayIPv4,
"default_gateway_ipv6": p.DefaultGatewayIPv6,
"description": p.Description,
"enabled": p.Enabled,
"external_network_ports": flattenExternalNetworkPortFields(p.ExternalNetworkPorts),
"hypervisors": hypervisors,
"ipv4": p.IPv4,
"status": flattenStatus(p.Status),
"version_id": int(p.VersionID),
"subnet_v4": p.SubnetV4,
"subnet_v6": p.SubnetV6,
"created_at": p.CreatedAt,
"updated_at": p.UpdatedAt,
"vlan_tag": p.VLANTag,
"mac": p.MAC,
"id": p.ID,
"access_group_id": p.AccessGroupID,
"access_group_name": p.AccessGroupName,
"comment": p.Comment,
"display_name": p.DisplayName,
"enabled": p.Enabled,
"ipv4": p.IPv4,
"mac": p.MAC,
"version_id": int(p.VersionID),
})
}
return res

View File

@@ -77,6 +77,10 @@ func utilityNetworkObjectGroupListCheckPresence(ctx context.Context, d *schema.R
req.UpdatedTo = updatedTo.(string)
}
if typeObj, ok := d.GetOk("type"); ok {
req.Type = typeObj.(string)
}
log.Debugf("utilityNetworkObjectGroupListCheckPresence")
list, err := c.SDN().NetworkObjectGroups().List(ctx, req)
if err != nil {