diff --git a/aci/data_source_aci_topsystem.go b/aci/data_source_aci_topsystem.go deleted file mode 100644 index a9a352040..000000000 --- a/aci/data_source_aci_topsystem.go +++ /dev/null @@ -1,411 +0,0 @@ -package aci - -import ( - "context" - "fmt" - - "github.com/ciscoecosystem/aci-go-client/v2/client" - "github.com/ciscoecosystem/aci-go-client/v2/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceAciSystem() *schema.Resource { - return &schema.Resource{ - - ReadContext: dataSourceAciSystemRead, - - SchemaVersion: 1, - - Schema: map[string]*schema.Schema{ - - "system_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "pod_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "address": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "etep_addr": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "name_alias": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "node_type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "remote_network_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "remote_node": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "rldirect_mode": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "role": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "server_type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "boot_strap_tate": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "child_action": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "config_issues": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "control_plane_mtu": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "current_time": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "enforce_subnet_check": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "fabric_domain": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "fabric_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "fabric_mac": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_addr": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_addr6": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_addr6_mask": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_addr_mask": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_gateway": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "inb_mgmt_gateway6": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "last_reboot_time": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "last_reset_reason": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "lc_own": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "mod_ts": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "mode": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "mon_pol_dn": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_addr": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_addr6": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_addr6_mask": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_addr_mask": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_gateway": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "oob_mgmt_gateway6": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "rl_oper_pod_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "rl_routable_mode": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "serial": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "site_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "system_uptime": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "tep_pool": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "unicast_xr_ep_learn_disable": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "virtual_mode": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - }, - } -} - -func dataSourceAciSystemRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - aciClient := m.(*client.Client) - pod := d.Get("pod_id").(string) - node := d.Get("system_id").(string) - dn := fmt.Sprintf("topology/pod-%s/node-%s/sys", pod, node) - - topSystem, err := getRemoteSystem(aciClient, dn) - - if err != nil { - return diag.FromErr(err) - } - d.SetId(dn) - _, err = setSystemAttributes(topSystem, d) - - if err != nil { - return diag.FromErr(err) - } - return nil -} - -func getRemoteSystem(client *client.Client, dn string) (*models.System, error) { - topSystemCont, err := client.Get(dn) - if err != nil { - return nil, err - } - - topSystem := models.SystemFromContainer(topSystemCont) - - if topSystem.DistinguishedName == "" { - return nil, fmt.Errorf("System %s not found", topSystem.DistinguishedName) - } - - return topSystem, nil -} - -func setSystemAttributes(topSystem *models.System, d *schema.ResourceData) (*schema.ResourceData, error) { - d.SetId(topSystem.DistinguishedName) - d.Set("description", topSystem.Description) - - topSystemMap, err := topSystem.ToMap() - - if err != nil { - return d, err - } - d.Set("address", topSystemMap["address"]) - d.Set("etep_addr", topSystemMap["etepAddr"]) - d.Set("system_id", topSystemMap["id"]) - d.Set("name_alias", topSystemMap["nameAlias"]) - d.Set("node_type", topSystemMap["nodeType"]) - d.Set("remote_network_id", topSystemMap["remoteNetworkId"]) - d.Set("remote_node", topSystemMap["remoteNode"]) - d.Set("rldirect_mode", topSystemMap["rldirectMode"]) - d.Set("role", topSystemMap["role"]) - d.Set("server_type", topSystemMap["serverType"]) - d.Set("bootstrap_state", topSystemMap["bootstrapState"]) - d.Set("child_action", topSystemMap["childAction"]) - d.Set("config_issues", topSystemMap["configIssues"]) - d.Set("control_plane_mtu", topSystemMap["controlPlaneMTU"]) - d.Set("current_time", topSystemMap["currentTime"]) - d.Set("enforce_subnet_check", topSystemMap["enforceSubnetCheck"]) - d.Set("fabric_domain", topSystemMap["fabricDomain"]) - d.Set("fabric_id", topSystemMap["fabricId"]) - d.Set("fabric_mac", topSystemMap["fabricMAC"]) - d.Set("inb_mgmt_addr", topSystemMap["inbMgmtAddr"]) - d.Set("inb_mgmt_addr6", topSystemMap["inbMgmtAddr6"]) - d.Set("inb_mgmt_addr6_mask", topSystemMap["inbMgmtAddr6Mask"]) - d.Set("inb_mgmt_addr_mask", topSystemMap["inbMgmtAddrMask"]) - d.Set("inb_mgmt_gateway", topSystemMap["inbMgmtGateway"]) - d.Set("inb_mgmt_gateway6", topSystemMap["inbMgmtGateway6"]) - d.Set("last_reboot_time", topSystemMap["lastRebootTime"]) - d.Set("last_reset_reason", topSystemMap["lastResetReason"]) - d.Set("lc_own", topSystemMap["lcOwn"]) - d.Set("mod_ts", topSystemMap["modTs"]) - d.Set("mode", topSystemMap["mode"]) - d.Set("mon_pol_dn", topSystemMap["monPolDn"]) - d.Set("name", topSystemMap["name"]) - d.Set("oob_mgmt_addr", topSystemMap["oobMgmtAddr"]) - d.Set("oob_mgmt_addr6", topSystemMap["oobMgmtAddr6"]) - d.Set("oob_mgmt_addr6_mask", topSystemMap["oobMgmtAddr6Mask"]) - d.Set("oob_mgmt_addr_mask", topSystemMap["oobMgmtAddrMask"]) - d.Set("oob_mgmt_gateway", topSystemMap["oobMgmtGateway"]) - d.Set("oob_mgmt_gateway6", topSystemMap["oobMgmtGateway6"]) - d.Set("pod_id", topSystemMap["podId"]) - d.Set("rl_oper_pod_id", topSystemMap["rlOperPodId"]) - d.Set("rl_routable_mode", topSystemMap["rlRoutableMode"]) - d.Set("serial", topSystemMap["serial"]) - d.Set("site_id", topSystemMap["siteId"]) - d.Set("state", topSystemMap["state"]) - d.Set("system_uptime", topSystemMap["systemUpTime"]) - d.Set("tep_pool", topSystemMap["tepPool"]) - d.Set("unicast_xr_ep_learn_disable", topSystemMap["unicastXrEpLearnDisable"]) - d.Set("version", topSystemMap["version"]) - d.Set("virtual_mode", topSystemMap["virtualMode"]) - - return d, nil -} diff --git a/aci/provider.go b/aci/provider.go index d87cf84df..6a0b591c7 100644 --- a/aci/provider.go +++ b/aci/provider.go @@ -460,7 +460,6 @@ func Provider() *schema.Provider { "aci_l2_outside": dataSourceAciL2Outside(), "aci_node_mgmt_epg": dataSourceAciNodeManagementEPg(), "aci_connection": dataSourceAciConnection(), - "aci_system": dataSourceAciSystem(), "aci_l3out_bgp_external_policy": dataSourceAciL3outBgpExternalPolicy(), "aci_l3out_ospf_external_policy": dataSourceAciL3outOspfExternalPolicy(), "aci_l3out_path_attachment": dataSourceAciL3outPathAttachment(), diff --git a/docs/data-sources/system.md b/docs/data-sources/system.md index 50e623bf3..f2cc09de1 100644 --- a/docs/data-sources/system.md +++ b/docs/data-sources/system.md @@ -7,69 +7,88 @@ description: |- Data source for ACI System --- -# aci_system +# aci_system # Data source for ACI System -## Example Usage +## API Information ## + +* Class: [topSystem](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/topSystem/overview) + +* Supported in ACI versions: 1.0(1e) and later. + +* Distinguished Name Formats: + - `topology/pod-{id}/node-{id}/sys` + +## GUI Information ## + +* Location: `Generic` + +## Example Usage ## ```hcl + data "aci_system" "example" { - pod_id = "1" + pod_id = "1" system_id = "1" } + ``` -## Argument Reference - -- `system_id` - (Required) Unique system ID. -- `pod_id` - (Required) POD Idenitfier. - -## Attribute Reference - -- `id` - Attribute id set to the Dn of the system. -- `address` - (Optional) The IP address of the system. -- `etep_addr` - (Optional) The External TEP IP address of this PoD. -- `name_alias` - (Optional) Name alias of the system. -- `node_type`- (Optional) Role of this system. -- `remote_network_id`- (Optional) Remote Network ID. -- `remote_node` - (Optional) Remote system. -- `rldirect_mode` - (Optional) Remote Leaf Direct Mode. -- `role` - (Optional) The system role type. -- `server_type` - (Optional) Type of server. -- `bootstrap_state` - (Optional) Bootstrap state of this system. -- `child_action` - (Optional) Delete or ignore. For internal use only. -- `config_issues` - (Optional) Bitmask representation of the configuration issues found during the endpoint group deployment. -- `control_plane_mtu` - (Optional) MTU for control plane (SUP-originated) packets. -- `current_time` - (Optional) The current time on this system. -- `enforce_subnet_check` - (Optional) Enforce subnet check on all VRFs. -- `fabric_domain` - (Optional) Fabric domain of this node. -- `fabric_id` - (Optional) The latest system health score. Use the navigation bar at the top right of the table to select which health level to view. -- `fabric_mac` - (Optional) MAC address of fabric. -- `inb_mgmt_addr` - (Optional) The in-band management IPv4 address. -- `inb_mgmt_addr6` - (Optional) In-band management IPv6 address. -- `inb_mgmt_addr6_mask` - (Optional) In-band management IPv6 address Mask. -- `inb_mgmt_addr_mask` - (Optional) In-band management IP address Mask. -- `inb_mgmt_addr_gateway` - (Optional) In-band management IP Gateway. -- `inb_mgmt_addr_gateway6` - (Optional) In-band management IPv6 Gateway. -- `last_reset_reason`- (Optional) Last reset reason for this system. -- `lc_own` - (Optional) A value that indicates how this object was created. For internal use only. -- `mod_ts` - (Optional) The time when this object was last modified. -- `mode` - (Optional) Specifies if this system is configured in standalone mode or HA pair. -- `mon_pol_dn` - (Optional) The monitoring policy attached to this observable object. -- `name` - (Optional) The system name. -- `oob_mgmt_addr` - (Optional) The out-of-band management IPv4 address. -- `oob_mgmt_addr6` - (Optional) The out-of-band management IPv6 address. -- `oob_mgmt_addr6_mask` - (Optional) The out-of-band management IPv6 address Mask. -- `oob_mgmt_addr_mask` - (Optional) The out-of-band management IP address Mask. -- `oob_mgmt_gateway` - (Optional) Out-of-band management IP Gateway. -- `oob_mgmt_gateway6` - (Optional) Out-of-band management IPv6 Gateway -- `rl_oper_pod_id` - (Optional) Operational POD Idenitfier for RL Pod Redundancy. -- `rl_routable_mode` - (Optional) Is Remote-Leaf Routable. -- `serial` - (Optional) Serial Number of the system. -- `state` - (Optional) Operational state of this system. -- `system_uptime` - (Optional) The time (in seconds) since the system was booted. -- `tep_pool` - (Optional) Tep-Pool for this system -- `unicast_xr_ep_learn_disable` - (Optional) Disable xrLeanrs. -- `version` - (Optional) The version of the compatibility catalog. -- `virtual_mode` - (Optional) Virtual mode of system. +## Schema ## + +### Required ### + +* `system_id` (id) - (string) The identifier of the system object. +* `pod_id` (podId) - (string) The pod identifier. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the system object. +* `address` (address) - (string) The IP address of the system. +* `bootstrap_state` (bootstrapState) - (string) Bootstrap state of this system. +* `cluster_time_diff` (clusterTimeDiff) - (string) Difference in cluster time from local time for this system. +* `control_plane_mtu` (controlPlaneMTU) - (string) MTU for control plane (SUP-originated) packets. +* `current_time` (currentTime) - (string) The current time on this system. +* `enforce_subnet_check` (enforceSubnetCheck) - (string) Enforce subnet check on all VRFs. +* `external_tep_address` (etepAddr) - (string) The external TEP IP address of this pod. +* `fabric_domain` (fabricDomain) - (string) Fabric domain of this node. +* `fabric_id` (fabricId) - (string) The latest system health score. +* `fabric_mac` (fabricMAC) - (string) The MAC address of the fabric. +* `inband_management_address` (inbMgmtAddr) - (string) The In-band management IPv4 address. +* `inband_management_address_ipv6` (inbMgmtAddr6) - (string) The In-band management IPv6 address. +* `inband_management_address_mask_ipv6` (inbMgmtAddr6Mask) - (string) The In-band management IPv6 address subnet mask. +* `inband_management_address_mask` (inbMgmtAddrMask) - (string) The In-band management IPv4 address subnet mask. +* `inband_management_gateway` (inbMgmtGateway) - (string) The In-band management IPv4 gateway address. +* `inband_management_gateway_ipv6` (inbMgmtGateway6) - (string) The In-band management IPv6 gateway address. +* `last_reboot_time` (lastRebootTime) - (string) The last reboot time for this system. +* `last_reset_reason` (lastResetReason) - (string) The last reset reason for this system. +* `mod_ts` (modTs) - (string) The time when this object was last modified. +* `mode` (mode) - (string) Specifies if this system is configured in standalone mode or HA pair. +* `monitoring_policy_dn` (monPolDn) - (string) The monitoring policy attached to this observable object. +* `name` (name) - (string) The name of the system object. +* `name_alias` (nameAlias) - (string) The name alias of the system object. +* `node_type` (nodeType) - (string) The role of this system. +* `out_of_band_management_address` (oobMgmtAddr) - (string) The Out-of-band management IPv4 address. +* `out_of_band_management_address_ipv6` (oobMgmtAddr6) - (string) The Out-of-band management IPv6 address. +* `out_of_band_management_address_mask_ipv6` (oobMgmtAddr6Mask) - (string) The Out-of-band management IPv6 address subnet mask. +* `out_of_band_management_address_mask` (oobMgmtAddrMask) - (string) The Out-of-band management IPv4 address subnet mask. +* `out_of_band_management_gateway` (oobMgmtGateway) - (string) The Out-of-band management IPv4 gateway address. +* `out_of_band_management_gateway_ipv6` (oobMgmtGateway6) - (string) The Out-of-band management IPv6 gateway address. +* `remote_network_id` (remoteNetworkId) - (string) The remote network ID. +* `remote_node` (remoteNode) - (string) The remote system. +* `remote_leaf_auto_mode` (rlAutoMode) - (string) The remote leaf auto mode. +* `remote_leaf_group_id` (rlGroupId) - (string) The remote leaf site identifier. +* `remote_leaf_operational_pod_id` (rlOperPodId) - (string) The operational pod identifier for RL pod redundancy. +* `remote_leaf_routable_mode` (rlRoutableMode) - (string) Indicates whether the remote leaf is using a routable TEP IP address. +* `remote_leaf_direct_mode` (rldirectMode) - (string) The remote leaf direct mode. +* `role` (role) - (string) The system role type. +* `serial` (serial) - (string) The serial number of the system. +* `server_type` (serverType) - (string) DHCP server type. +* `site_id` (siteId) - (string) The site identifier. +* `state` (state) - (string) The operational state of this system. +* `system_uptime` (systemUpTime) - (string) The time (in seconds) since the system was booted. +* `tep_pool` (tepPool) - (string) The pool of TEP IP addresses allocated for this system. +* `unicast_xr_endpoint_learn_disable` (unicastXrEpLearnDisable) - (string) Indicates whether the learning of unicast endpoints for external routing is disabled. +* `version` (version) - (string) The version for this system. +* `virtual_mode` (virtualMode) - (string) The virtual mode of this system. diff --git a/examples/data-sources/aci_system/data-source.tf b/examples/data-sources/aci_system/data-source.tf new file mode 100644 index 000000000..1721a650c --- /dev/null +++ b/examples/data-sources/aci_system/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_system" "example" { + pod_id = "1" + system_id = "1" +} diff --git a/examples/data-sources/aci_system/provider.tf b/examples/data-sources/aci_system/provider.tf new file mode 100644 index 000000000..dc4be2420 --- /dev/null +++ b/examples/data-sources/aci_system/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 5a4b48ec7..02d139614 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -615,3 +615,8 @@ l3extRsLblToProfile: - "uni/tn-{name}/out-{name}/conslbl-{name}/rslblToProfile-[{tDn}]-{direction}" resource_notes: - "This resource should not be used in combination with the `l3out_consumer_label` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour." + +topSystem: + sub_category: "Fabric Inventory" + dn_formats: + - "topology/pod-{id}/node-{id}/sys" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 159e3c113..b5efc261a 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -1034,3 +1034,118 @@ l3extRsLblToProfile: properties: name: "rt_ctrl_profile_1" static: true + +topSystem: + overwrites: + id: "system_id" + podId: "pod_id" + etep_addr: "external_tep_address" + inb_mgmt_addr: "inband_management_address" + inb_mgmt_addr6: "inband_management_address_ipv6" + inb_mgmt_addr6_mask: "inband_management_address_mask_ipv6" + inb_mgmt_addr_mask: "inband_management_address_mask" + inb_mgmt_gateway: "inband_management_gateway" + inb_mgmt_gateway6: "inband_management_gateway_ipv6" + oob_mgmt_addr: "out_of_band_management_address" + oob_mgmt_addr6: "out_of_band_management_address_ipv6" + oob_mgmt_addr6_mask: "out_of_band_management_address_mask_ipv6" + oob_mgmt_addr_mask: "out_of_band_management_address_mask" + oob_mgmt_gateway: "out_of_band_management_gateway" + oob_mgmt_gateway6: "out_of_band_management_gateway_ipv6" + rl_auto_mode: "remote_leaf_auto_mode" + rl_group_id: "remote_leaf_group_id" + rl_oper_pod_id: "remote_leaf_operational_pod_id" + rl_routable_mode: "remote_leaf_routable_mode" + rldirect_mode: "remote_leaf_direct_mode" + mon_pol_dn: "monitoring_policy_dn" + system_up_time: "system_uptime" + unicast_xr_ep_learn_disable: "unicast_xr_endpoint_learn_disable" + datasource_required: + - "system_id" + - "pod_id" + read_only_properties: + - "address" + - "bootstrapState" + - "clusterTimeDiff" + - "controlPlaneMTU" + - "currentTime" + - "enforceSubnetCheck" + - "etepAddr" + - "fabricDomain" + - "fabricId" + - "fabricMAC" + - "inbMgmtAddr" + - "inbMgmtAddr6" + - "inbMgmtAddr6Mask" + - "inbMgmtAddrMask" + - "inbMgmtGateway" + - "inbMgmtGateway6" + - "lastRebootTime" + - "lastResetReason" + - "modTs" + - "mode" + - "monPolDn" + - "name" + - "nameAlias" + - "nodeType" + - "oobMgmtAddr" + - "oobMgmtAddr6" + - "oobMgmtAddr6Mask" + - "oobMgmtAddrMask" + - "oobMgmtGateway" + - "oobMgmtGateway6" + - "remoteNetworkId" + - "remoteNode" + - "rlAutoMode" + - "rlGroupId" + - "rlOperPodId" + - "rlRoutableMode" + - "rldirectMode" + - "role" + - "serial" + - "serverType" + - "siteId" + - "state" + - "systemUpTime" + - "tepPool" + - "unicastXrEpLearnDisable" + - "version" + - "virtualMode" + documentation: + id: "The identifier of the system object." + podId: "The pod identifier." + etepAddr: "The external TEP IP address of this pod." + fabricId: "The latest system health score." + fabricMAC: "The MAC address of the fabric." + inbMgmtAddr: "The In-band management IPv4 address." + inbMgmtAddr6: "The In-band management IPv6 address." + inbMgmtAddr6Mask: "The In-band management IPv6 address subnet mask." + inbMgmtAddrMask: "The In-band management IPv4 address subnet mask." + inbMgmtGateway: "The In-band management IPv4 gateway address." + inbMgmtGateway6: "The In-band management IPv6 gateway address." + lastRebootTime: "The last reboot time for this system." + lastResetReason: "The last reset reason for this system." + name: "The name of the system object." + nameAlias: "The name alias of the system object." + nodeType: "The role of this system." + oobMgmtAddr: "The Out-of-band management IPv4 address." + oobMgmtAddr6: "The Out-of-band management IPv6 address." + oobMgmtAddr6Mask: "The Out-of-band management IPv6 address subnet mask." + oobMgmtAddrMask: "The Out-of-band management IPv4 address subnet mask." + oobMgmtGateway: "The Out-of-band management IPv4 gateway address." + oobMgmtGateway6: "The Out-of-band management IPv6 gateway address." + remoteNetworkId: "The remote network ID." + remoteNode: "The remote system." + rlAutoMode: "The remote leaf auto mode." + rlGroupId: "The remote leaf site identifier." + rlOperPodId: "The operational pod identifier for RL pod redundancy." + rlRoutableMode: "Indicates whether the remote leaf is using a routable TEP IP address." + rldirectMode: "The remote leaf direct mode." + serial: "The serial number of the system." + serverType: "DHCP server type." + siteId: "The site identifier." + state: "The operational state of this system." + tepPool: "The pool of TEP IP addresses allocated for this system." + unicastXrEpLearnDisable: "Indicates whether the learning of unicast endpoints for external routing is disabled." + version: "The version for this system." + virtualMode: "The virtual mode of this system." diff --git a/gen/generator.go b/gen/generator.go index d499510b0..83cfad2f0 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -587,17 +587,16 @@ func migrateLegacyDocumentation() { // Container function to clean all directories properly func cleanDirectories() { cleanDirectory(docsPath, []string{"resources", "data-sources"}) - cleanDirectory(providerPath, []string{"provider_test.go", "utils.go", "test_constants.go", "resource_aci_rest_managed.go", "resource_aci_rest_managed_test.go", "data_source_aci_rest_managed.go", "data_source_aci_rest_managed_test.go", "annotation_unsupported.go"}) + cleanDirectory(providerPath, []string{"provider_test.go", "utils.go", "test_constants.go", "resource_aci_rest_managed.go", "resource_aci_rest_managed_test.go", "data_source_aci_rest_managed.go", "data_source_aci_rest_managed_test.go", "annotation_unsupported.go", "data_source_aci_system.go", "data_source_aci_system_test.go"}) cleanDirectory(resourcesDocsPath, []string{}) - cleanDirectory(datasourcesDocsPath, []string{}) + cleanDirectory(datasourcesDocsPath, []string{"system.md"}) cleanDirectory(testVarsPath, []string{}) // The *ExamplesPath directories are removed and recreated to ensure all previously rendered files are removed // The provider example file is not removed because it contains static provider configuration os.RemoveAll(resourcesExamplesPath) os.Mkdir(resourcesExamplesPath, 0755) - os.RemoveAll(datasourcesExamplesPath) - os.Mkdir(datasourcesExamplesPath, 0755) + cleanDirectory(datasourcesExamplesPath, []string{"aci_system"}) // Migrate legacy documentation directory ( /website/docs ) format ( .html.markdown ) to new documentation directory ( /docs ) and format ( .md ) migrateLegacyDocumentation() diff --git a/gen/templates/provider.go.tmpl b/gen/templates/provider.go.tmpl index d6c2440bc..dcd61f26a 100644 --- a/gen/templates/provider.go.tmpl +++ b/gen/templates/provider.go.tmpl @@ -220,6 +220,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS {{- end }} {{- end }} NewAciRestManagedDataSource, + NewTopSystemDataSource, } } diff --git a/internal/provider/data_source_aci_system.go b/internal/provider/data_source_aci_system.go new file mode 100644 index 000000000..ce723beee --- /dev/null +++ b/internal/provider/data_source_aci_system.go @@ -0,0 +1,760 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &TopSystemDataSource{} + +func NewTopSystemDataSource() datasource.DataSource { + return &TopSystemDataSource{} +} + +// TopSystemDataSource defines the data source implementation. +type TopSystemDataSource struct { + client *client.Client +} + +// TopSystemResourceModel describes the resource data model. +type TopSystemResourceModel struct { + Id types.String `tfsdk:"id"` + Address types.String `tfsdk:"address"` + BootstrapState types.String `tfsdk:"bootstrap_state"` + ClusterTimeDiff types.String `tfsdk:"cluster_time_diff"` + ControlPlaneMTU types.String `tfsdk:"control_plane_mtu"` + CurrentTime types.String `tfsdk:"current_time"` + EnforceSubnetCheck types.String `tfsdk:"enforce_subnet_check"` + EtepAddr types.String `tfsdk:"external_tep_address"` + FabricDomain types.String `tfsdk:"fabric_domain"` + FabricId types.String `tfsdk:"fabric_id"` + FabricMAC types.String `tfsdk:"fabric_mac"` + SystemId types.String `tfsdk:"system_id"` + InbMgmtAddr types.String `tfsdk:"inband_management_address"` + InbMgmtAddr6 types.String `tfsdk:"inband_management_address_ipv6"` + InbMgmtAddr6Mask types.String `tfsdk:"inband_management_address_mask_ipv6"` + InbMgmtAddrMask types.String `tfsdk:"inband_management_address_mask"` + InbMgmtGateway types.String `tfsdk:"inband_management_gateway"` + InbMgmtGateway6 types.String `tfsdk:"inband_management_gateway_ipv6"` + LastRebootTime types.String `tfsdk:"last_reboot_time"` + LastResetReason types.String `tfsdk:"last_reset_reason"` + ModTs types.String `tfsdk:"mod_ts"` + Mode types.String `tfsdk:"mode"` + MonPolDn types.String `tfsdk:"monitoring_policy_dn"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + NodeType types.String `tfsdk:"node_type"` + OobMgmtAddr types.String `tfsdk:"out_of_band_management_address"` + OobMgmtAddr6 types.String `tfsdk:"out_of_band_management_address_ipv6"` + OobMgmtAddr6Mask types.String `tfsdk:"out_of_band_management_address_mask_ipv6"` + OobMgmtAddrMask types.String `tfsdk:"out_of_band_management_address_mask"` + OobMgmtGateway types.String `tfsdk:"out_of_band_management_gateway"` + OobMgmtGateway6 types.String `tfsdk:"out_of_band_management_gateway_ipv6"` + PodId types.String `tfsdk:"pod_id"` + RemoteNetworkId types.String `tfsdk:"remote_network_id"` + RemoteNode types.String `tfsdk:"remote_node"` + RlAutoMode types.String `tfsdk:"remote_leaf_auto_mode"` + RlGroupId types.String `tfsdk:"remote_leaf_group_id"` + RlOperPodId types.String `tfsdk:"remote_leaf_operational_pod_id"` + RlRoutableMode types.String `tfsdk:"remote_leaf_routable_mode"` + RldirectMode types.String `tfsdk:"remote_leaf_direct_mode"` + Role types.String `tfsdk:"role"` + Serial types.String `tfsdk:"serial"` + ServerType types.String `tfsdk:"server_type"` + SiteId types.String `tfsdk:"site_id"` + State types.String `tfsdk:"state"` + SystemUpTime types.String `tfsdk:"system_uptime"` + TepPool types.String `tfsdk:"tep_pool"` + UnicastXrEpLearnDisable types.String `tfsdk:"unicast_xr_endpoint_learn_disable"` + Version types.String `tfsdk:"version"` + VirtualMode types.String `tfsdk:"virtual_mode"` + DeprecatedEtepAddr types.String `tfsdk:"etep_addr"` + DeprecatedOobMgmtAddr types.String `tfsdk:"oob_mgmt_addr"` + DeprecatedOobMgmtAddr6 types.String `tfsdk:"oob_mgmt_addr6"` + DeprecatedOobMgmtAddr6Mask types.String `tfsdk:"oob_mgmt_addr6_mask"` + DeprecatedOobMgmtAddrMask types.String `tfsdk:"oob_mgmt_addr_mask"` + DeprecatedOobMgmtGateway types.String `tfsdk:"oob_mgmt_gateway"` + DeprecatedOobMgmtGateway6 types.String `tfsdk:"oob_mgmt_gateway6"` + DeprecatedRlAutoMode types.String `tfsdk:"rl_auto_mode"` + DeprecatedRlGroupId types.String `tfsdk:"rl_group_id"` + DeprecatedRlOperPodId types.String `tfsdk:"rl_oper_pod_id"` + DeprecatedRlRoutableMode types.String `tfsdk:"rl_routable_mode"` + DeprecatedRldirectMode types.String `tfsdk:"rldirect_mode"` + DeprecatedInbMgmtAddr types.String `tfsdk:"inb_mgmt_addr"` + DeprecatedInbMgmtAddr6 types.String `tfsdk:"inb_mgmt_addr6"` + DeprecatedInbMgmtAddr6Mask types.String `tfsdk:"inb_mgmt_addr6_mask"` + DeprecatedInbMgmtAddrMask types.String `tfsdk:"inb_mgmt_addr_mask"` + DeprecatedInbMgmtGateway types.String `tfsdk:"inb_mgmt_gateway"` + DeprecatedInbMgmtGateway6 types.String `tfsdk:"inb_mgmt_gateway6"` + DeprecatedMonPolDn types.String `tfsdk:"mon_pol_dn"` + DeprecatedChildAction types.String `tfsdk:"child_action"` + DeprecatedConfigIssues types.String `tfsdk:"config_issues"` + DeprecatedLcOwn types.String `tfsdk:"lc_own"` + DeprecatedStatus types.String `tfsdk:"status"` + DeprecatedUnicastXrEpLearnDisable types.String `tfsdk:"unicast_xr_ep_learn_disable"` + DeprecatedBootstrapState types.String `tfsdk:"boot_strap_tate"` +} + +func (d *TopSystemDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_system") + resp.TypeName = req.ProviderTypeName + "_system" + tflog.Debug(ctx, "End metadata of datasource: aci_system") +} + +func (d *TopSystemDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_system") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The system datasource for the 'topSystem' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the System object.", + }, + "address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The IP address of the system.`, + }, + "bootstrap_state": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Bootstrap state of this system.`, + }, + "cluster_time_diff": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Difference in cluster time from local time for this system.`, + }, + "control_plane_mtu": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `MTU for control plane (SUP-originated) packets.`, + }, + "current_time": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The current time on this system.`, + }, + "enforce_subnet_check": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Enforce subnet check on all VRFs.`, + }, + "external_tep_address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The External TEP IP address of this PoD.`, + }, + "fabric_domain": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Fabric domain of this node.`, + }, + "fabric_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The latest system health score. Use the navigation bar at the top right of the table to select which health level to view.`, + }, + "fabric_mac": schema.StringAttribute{ + Computed: true, + MarkdownDescription: ``, + }, + "system_id": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The identifier of the System object.`, + }, + "inband_management_address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The in-band management IPv4 address.`, + }, + "inband_management_address_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `In-band management IPv6 address.`, + }, + "inband_management_address_mask_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `In-band management IPv6 address Mask.`, + }, + "inband_management_address_mask": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `In-band management IP address Mask.`, + }, + "inband_management_gateway": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `In-band management IP Gateway.`, + }, + "inband_management_gateway_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `In-band management IPv6 Gateway.`, + }, + "out_of_band_management_address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The out-of-band management IPv4 address.`, + }, + "out_of_band_management_address_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Out-of-band management IPv6 address.`, + }, + "out_of_band_management_address_mask_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Out-of-band management IPv6 address Mask.`, + }, + "out_of_band_management_address_mask": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Out-of-band management IP address Mask.`, + }, + "out_of_band_management_gateway": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Out-of-band management IP Gateway.`, + }, + "out_of_band_management_gateway_ipv6": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Out-of-band management IPv6 Gateway.`, + }, + "pod_id": schema.StringAttribute{ + Required: true, + MarkdownDescription: `POD Identifier.`, + }, + "remote_network_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote Network ID.`, + }, + "remote_node": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote system.`, + }, + "remote_leaf_auto_mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote Leaf Auto Mode.`, + }, + "remote_leaf_group_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote Leaf Site Identifier.`, + }, + "remote_leaf_operational_pod_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Operational POD Identifier for RL Pod Redundancy.`, + }, + "remote_leaf_routable_mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Is RemoteLeaf Routable.`, + }, + "remote_leaf_direct_mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Remote Leaf Direct Mode.`, + }, + "last_reboot_time": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `LastRebootTime for this system.`, + }, + "last_reset_reason": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `LastResetReason for this system.`, + }, + "mod_ts": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The time when this object was last modified.`, + }, + "mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Specifies if this system is configured in standalone mode or HA pair.`, + }, + "monitoring_policy_dn": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The monitoring policy attached to this observable object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the System object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the System object.`, + }, + "node_type": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Role of this system.`, + }, + "role": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The system role type.`, + }, + "serial": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Serial Number of the system.`, + }, + "server_type": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `DhcpServerType.`, + }, + "site_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Site Identifier.`, + }, + "state": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Operational state of this system.`, + }, + "system_uptime": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The time (in seconds) since the system was booted.`, + }, + "tep_pool": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `TepPool for this system.`, + }, + "unicast_xr_endpoint_learn_disable": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Disable xrLeanrs.`, + }, + "version": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `version for this system.`, + }, + "virtual_mode": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `Virtual mode of system.`, + }, + "boot_strap_tate": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'boot_strap_tate' will be deprecated soon, please refer to 'bootstrap_state' instead", + }, + "unicast_xr_ep_learn_disable": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'unicast_xr_ep_learn_disable' will be deprecated soon, please refer to 'unicast_xr_endpoint_learn_disable' instead", + }, + "etep_addr": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'etep_addr' will be deprecated soon, please refer to 'external_tep_address' instead", + }, + "inb_mgmt_addr": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_addr' will be deprecated soon, please refer to 'inband_management_address' instead", + }, + "inb_mgmt_addr6": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_addr6' will be deprecated soon, please refer to 'inband_management_address_ipv6' instead", + }, + "inb_mgmt_addr6_mask": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_addr6_mask' will be deprecated soon, please refer to 'inband_management_address_mask_ipv6' instead", + }, + "inb_mgmt_addr_mask": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_addr_mask' will be deprecated soon, please refer to 'inband_management_address_mask' instead", + }, + "inb_mgmt_gateway": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_gateway' will be deprecated soon, please refer to 'inband_management_gateway' instead", + }, + "inb_mgmt_gateway6": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'inb_mgmt_gateway6' will be deprecated soon, please refer to 'inband_management_gateway_ipv6' instead", + }, + "mon_pol_dn": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'mon_pol_dn' will be deprecated soon, please refer to 'monitoring_policy_dn' instead", + }, + "oob_mgmt_addr": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_addr' will be deprecated soon, please refer to 'out_of_band_management_address' instead", + }, + "oob_mgmt_addr6": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_addr6' will be deprecated soon, please refer to 'out_of_band_management_address_ipv6' instead", + }, + "oob_mgmt_addr6_mask": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_addr6_mask' will be deprecated soon, please refer to 'out_of_band_management_address_mask_ipv6' instead", + }, + "oob_mgmt_addr_mask": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_addr_mask' will be deprecated soon, please refer to 'out_of_band_management_address_mask' instead", + }, + "oob_mgmt_gateway": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_gateway' will be deprecated soon, please refer to 'out_of_band_management_gateway' instead", + }, + "oob_mgmt_gateway6": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'oob_mgmt_gateway6' will be deprecated soon, please refer to 'out_of_band_management_gateway_ipv6' instead", + }, + "rl_auto_mode": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'rl_auto_mode' will be deprecated soon, please refer to 'remote_leaf_auto_mode' instead", + }, + "rl_group_id": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'rl_group_id' will be deprecated soon, please refer to 'remote_leaf_group_id' instead", + }, + "rl_oper_pod_id": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'rl_oper_pod_id' will be deprecated soon, please refer to 'remote_leaf_operational_pod_id' instead", + }, + "rl_routable_mode": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'rl_routable_mode' will be deprecated soon, please refer to 'remote_leaf_routable_mode' instead", + }, + "rldirect_mode": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'rldirect_mode' will be deprecated soon, please refer to 'remote_leaf_direct_mode' instead", + }, + "child_action": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'child_action' will be deprecated soon", + }, + "config_issues": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'config_issues' will be deprecated soon", + }, + "lc_own": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'lc_own' will be deprecated soon", + }, + "status": schema.StringAttribute{ + Computed: true, + DeprecationMessage: "Attribute 'status' will be deprecated soon", + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_system") +} + +func (d *TopSystemDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_system") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_system") +} + +func (d *TopSystemDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_system") + var data *TopSystemResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setTopSystemId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetTopSystemAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_system with id '%s'", data.Id.ValueString())) + + getAndSetTopSystemAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_system data source", + fmt.Sprintf("The aci_system data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_system with id '%s'", data.Id.ValueString())) +} + +func getTopSystemRn(ctx context.Context, data *TopSystemResourceModel) string { + rn := "pod-{podId}/node-{nodeId}/sys" + identifiers := map[string]string{ + "podId": "PodId", + "nodeId": "SystemId", + } + for placeholder, fieldName := range identifiers { + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", placeholder), fieldValue) + } + return rn +} + +func setTopSystemId(ctx context.Context, data *TopSystemResourceModel) { + rn := getTopSystemRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", "topology", rn)) +} + +func getAndSetTopSystemAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *TopSystemResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("topSystem").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("topSystem").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "address" { + data.Address = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "bootstrapState" && attributeValue.(string) == "" { + data.BootstrapState = basetypes.NewStringValue("none") + } else if attributeName == "bootstrapState" { + data.BootstrapState = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "clusterTimeDiff" { + data.ClusterTimeDiff = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "controlPlaneMTU" { + data.ControlPlaneMTU = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "currentTime" { + data.CurrentTime = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "enforceSubnetCheck" { + data.EnforceSubnetCheck = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "etepAddr" { + data.EtepAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fabricDomain" { + data.FabricDomain = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fabricId" { + data.FabricId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fabricMAC" { + data.FabricMAC = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "id" { + data.SystemId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr" { + data.InbMgmtAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr6" { + data.InbMgmtAddr6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr6Mask" { + data.InbMgmtAddr6Mask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddrMask" { + data.InbMgmtAddrMask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtGateway" { + data.InbMgmtGateway = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtGateway6" { + data.InbMgmtGateway6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "lastRebootTime" { + data.LastRebootTime = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "lastResetReason" { + data.LastResetReason = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "modTs" { + data.ModTs = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "mode" { + data.Mode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "monPolDn" { + data.MonPolDn = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nodeType" { + data.NodeType = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr" { + data.OobMgmtAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr6" { + data.OobMgmtAddr6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr6Mask" { + data.OobMgmtAddr6Mask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddrMask" { + data.OobMgmtAddrMask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtGateway" { + data.OobMgmtGateway = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtGateway6" { + data.OobMgmtGateway6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "podId" { + data.PodId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "remoteNetworkId" { + data.RemoteNetworkId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "remoteNode" { + data.RemoteNode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlAutoMode" { + data.RlAutoMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlGroupId" { + data.RlGroupId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlOperPodId" { + data.RlOperPodId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlRoutableMode" { + data.RlRoutableMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rldirectMode" { + data.RldirectMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "role" { + data.Role = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "serial" { + data.Serial = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "serverType" { + data.ServerType = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "siteId" { + data.SiteId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "state" { + data.State = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "systemUpTime" { + data.SystemUpTime = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "tepPool" { + data.TepPool = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "unicastXrEpLearnDisable" { + data.UnicastXrEpLearnDisable = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "version" { + data.Version = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "virtualMode" { + data.VirtualMode = basetypes.NewStringValue(attributeValue.(string)) + } + } + setTopSystemLegacyAttributes(ctx, diags, data, classReadInfo) + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'topSystem'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func setTopSystemLegacyAttributes(ctx context.Context, diags *diag.Diagnostics, data *TopSystemResourceModel, classReadInfo []interface{}) { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "etepAddr" { + data.DeprecatedEtepAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr" { + data.DeprecatedInbMgmtAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr6" { + data.DeprecatedInbMgmtAddr6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddr6Mask" { + data.DeprecatedInbMgmtAddr6Mask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtAddrMask" { + data.DeprecatedInbMgmtAddrMask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtGateway" { + data.DeprecatedInbMgmtGateway = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "inbMgmtGateway6" { + data.DeprecatedInbMgmtGateway6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "monPolDn" { + data.DeprecatedMonPolDn = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr" { + data.DeprecatedOobMgmtAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr6" { + data.DeprecatedOobMgmtAddr6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddr6Mask" { + data.DeprecatedOobMgmtAddr6Mask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtAddrMask" { + data.DeprecatedOobMgmtAddrMask = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtGateway" { + data.DeprecatedOobMgmtGateway = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "oobMgmtGateway6" { + data.DeprecatedOobMgmtGateway6 = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlAutoMode" { + data.DeprecatedRlAutoMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlGroupId" { + data.DeprecatedRlGroupId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlOperPodId" { + data.DeprecatedRlOperPodId = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rlRoutableMode" { + data.DeprecatedRlRoutableMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "rldirectMode" { + data.DeprecatedRldirectMode = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "childAction" { + data.DeprecatedChildAction = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "configIssues" { + data.DeprecatedConfigIssues = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "lcOwn" { + data.DeprecatedLcOwn = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "status" { + data.DeprecatedStatus = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "unicastXrEpLearnDisable" { + data.DeprecatedUnicastXrEpLearnDisable = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "bootstrapState" { + data.DeprecatedBootstrapState = basetypes.NewStringValue(attributeValue.(string)) + } + } +} diff --git a/internal/provider/data_source_aci_system_test.go b/internal/provider/data_source_aci_system_test.go new file mode 100644 index 000000000..8073c11f5 --- /dev/null +++ b/internal/provider/data_source_aci_system_test.go @@ -0,0 +1,36 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceTopSystem(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigTopSystemDataSource, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_system.test", "pod_id", "1"), + resource.TestCheckResourceAttr("data.aci_system.test", "role", "controller"), + resource.TestCheckResourceAttr("data.aci_system.test", "system_id", "1"), + ), + }, + }, + }) +} + +const testConfigTopSystemDataSource = ` +data "aci_system" "test" { + pod_id = "1" + system_id = "1" +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index a285f5847..709f952f2 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -305,6 +305,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewTagTagDataSource, NewVzOOBBrCPDataSource, NewAciRestManagedDataSource, + NewTopSystemDataSource, } } diff --git a/legacy-docs/docs/d/system.html.markdown b/legacy-docs/docs/d/system.html.markdown deleted file mode 100644 index 50e623bf3..000000000 --- a/legacy-docs/docs/d/system.html.markdown +++ /dev/null @@ -1,75 +0,0 @@ ---- -subcategory: "Fabric Inventory" -layout: "aci" -page_title: "ACI: aci_system" -sidebar_current: "docs-aci-data-source-aci_system" -description: |- - Data source for ACI System ---- - -# aci_system - -Data source for ACI System - -## Example Usage - -```hcl -data "aci_system" "example" { - pod_id = "1" - system_id = "1" -} -``` - -## Argument Reference - -- `system_id` - (Required) Unique system ID. -- `pod_id` - (Required) POD Idenitfier. - -## Attribute Reference - -- `id` - Attribute id set to the Dn of the system. -- `address` - (Optional) The IP address of the system. -- `etep_addr` - (Optional) The External TEP IP address of this PoD. -- `name_alias` - (Optional) Name alias of the system. -- `node_type`- (Optional) Role of this system. -- `remote_network_id`- (Optional) Remote Network ID. -- `remote_node` - (Optional) Remote system. -- `rldirect_mode` - (Optional) Remote Leaf Direct Mode. -- `role` - (Optional) The system role type. -- `server_type` - (Optional) Type of server. -- `bootstrap_state` - (Optional) Bootstrap state of this system. -- `child_action` - (Optional) Delete or ignore. For internal use only. -- `config_issues` - (Optional) Bitmask representation of the configuration issues found during the endpoint group deployment. -- `control_plane_mtu` - (Optional) MTU for control plane (SUP-originated) packets. -- `current_time` - (Optional) The current time on this system. -- `enforce_subnet_check` - (Optional) Enforce subnet check on all VRFs. -- `fabric_domain` - (Optional) Fabric domain of this node. -- `fabric_id` - (Optional) The latest system health score. Use the navigation bar at the top right of the table to select which health level to view. -- `fabric_mac` - (Optional) MAC address of fabric. -- `inb_mgmt_addr` - (Optional) The in-band management IPv4 address. -- `inb_mgmt_addr6` - (Optional) In-band management IPv6 address. -- `inb_mgmt_addr6_mask` - (Optional) In-band management IPv6 address Mask. -- `inb_mgmt_addr_mask` - (Optional) In-band management IP address Mask. -- `inb_mgmt_addr_gateway` - (Optional) In-band management IP Gateway. -- `inb_mgmt_addr_gateway6` - (Optional) In-band management IPv6 Gateway. -- `last_reset_reason`- (Optional) Last reset reason for this system. -- `lc_own` - (Optional) A value that indicates how this object was created. For internal use only. -- `mod_ts` - (Optional) The time when this object was last modified. -- `mode` - (Optional) Specifies if this system is configured in standalone mode or HA pair. -- `mon_pol_dn` - (Optional) The monitoring policy attached to this observable object. -- `name` - (Optional) The system name. -- `oob_mgmt_addr` - (Optional) The out-of-band management IPv4 address. -- `oob_mgmt_addr6` - (Optional) The out-of-band management IPv6 address. -- `oob_mgmt_addr6_mask` - (Optional) The out-of-band management IPv6 address Mask. -- `oob_mgmt_addr_mask` - (Optional) The out-of-band management IP address Mask. -- `oob_mgmt_gateway` - (Optional) Out-of-band management IP Gateway. -- `oob_mgmt_gateway6` - (Optional) Out-of-band management IPv6 Gateway -- `rl_oper_pod_id` - (Optional) Operational POD Idenitfier for RL Pod Redundancy. -- `rl_routable_mode` - (Optional) Is Remote-Leaf Routable. -- `serial` - (Optional) Serial Number of the system. -- `state` - (Optional) Operational state of this system. -- `system_uptime` - (Optional) The time (in seconds) since the system was booted. -- `tep_pool` - (Optional) Tep-Pool for this system -- `unicast_xr_ep_learn_disable` - (Optional) Disable xrLeanrs. -- `version` - (Optional) The version of the compatibility catalog. -- `virtual_mode` - (Optional) Virtual mode of system.