Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
384 changes: 384 additions & 0 deletions dcnm/data_source_dcnm_fabric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,384 @@
package dcnm

import (
"log"

"github.com/ciscoecosystem/dcnm-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func datasourceDCNMFabric() *schema.Resource {
return &schema.Resource{
Read: datasourceDCNMFabricRead,

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},

"fabric_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"asn": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"underlay_interface_numbering": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"underlay_subnet_mask": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"underlay_routing_protocol": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"route_reflectors_count": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"anycast_mac": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"replication_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"multicast_group_subnet": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"rendevous_point_count": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"rendevous_point_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"rendevous_loopback_id": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"vpc_peer_link_vlan": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"vpc_peer_keep_alive_option": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vpc_auto_recovery_time": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"vpc_delay_restore_time": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"underlay_routing_loopback_id": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"underlay_vtep_loopback_id": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"underlay_routing_protocol_tag": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"ospf_area_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"ospf_bfd": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"ibgp_bfd": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"isis_bfd": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"pim_bfd": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"bfd_authentication_key_id": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"bfd_authentication_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"ibgp_peer_template_config": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"leaf_ibgp_peer_template_config": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"network_template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_extension_template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"network_extension_template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"overlay_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"intra_fabric_interface_mtu": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"layer_2_host_interface_mtu": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"power_supply_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"copp_profile": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"enable_vxlan_oam": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"enable_nx_api": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"enable_nx_api_on_http": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"enable_ndfc_as_trap_host": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"underlay_routing_loopback_ip_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"underlay_vtep_loopback_ip_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"underlay_rp_loopback_ip_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"underlay_subnet_ip_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"layer_2_vxlan_vni_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"layer_3_vxlan_vni_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"network_vlan_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_vlan_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"subinterface_dot1q_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_lite_deployment": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_lite_subnet_ip_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"vrf_lite_subnet_mask": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"service_network_vlan_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"route_map_sequence_number_range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"template_props": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}

func datasourceDCNMFabricRead(d *schema.ResourceData, m interface{}) error {
log.Println("[DEBUG] Begining Read method ", d.Id())

dcnmClient := m.(*client.Client)

dn := d.Get("name").(string)

cont, err := getRemoteFabric(dcnmClient, dn)
if err != nil {
return err
}

if stripQuotes(cont.S("templateName").String()) != "Easy_Fabric" {
setFabricCustomTemplateAttributes(d, cont)
} else {
setFabricAttributes(d, cont)
}

return nil
}
Loading