@@ -49,10 +49,23 @@ func (i *NDFCEthernetInterface) DeleteInterface(ctx context.Context, dg *diag.Di
49
49
return
50
50
}
51
51
intfPayload := resource_interface_common.NDFCInterfacesPayload {}
52
- intfPayload .Policy = inData .Policy
53
52
54
53
ifDeployPayload := resource_interface_common.NDFCInterfacesDeploy {}
55
-
54
+ client := getNDFCClient ()
55
+ resp := client .GetDeviceRole (ctx , dg , inData .SerialNumber )
56
+ var role string
57
+ if ! resp .Exists () {
58
+ // Avoiding error if the device role is not found and assuming the role is leaf
59
+ role = "leaf"
60
+ } else {
61
+ role = resp .Array ()[0 ].Get ("role" ).String ()
62
+ }
63
+ tflog .Debug (ctx , fmt .Sprintf ("Device role: %s" , role ))
64
+ if role == "leaf" {
65
+ intfPayload .Policy = "int_trunk_host"
66
+ } else {
67
+ intfPayload .Policy = "int_routed_host"
68
+ }
56
69
for k , intf := range inData .Interfaces {
57
70
tflog .Debug (ctx , fmt .Sprintf ("Deleting interface: %s:%s" , intf .SerialNumber , intf .InterfaceName ))
58
71
@@ -66,13 +79,24 @@ func (i *NDFCEthernetInterface) DeleteInterface(ctx context.Context, dg *diag.Di
66
79
intf .NvPairs .Netflow = "false"
67
80
intf .NvPairs .NetflowMonitor = "###"
68
81
intf .NvPairs .NetflowSampler = "###"
69
-
70
- //Set some default values
71
- intf .NvPairs .Speed = "Auto"
72
- intf .NvPairs .Mtu = "default"
73
- intf .NvPairs .AdminState = "false"
74
- intf .NvPairs .AllowedVlans = "none"
75
-
82
+ intf .NvPairs .InterfaceName = intf .InterfaceName
83
+ if role == "leaf" {
84
+ //Set default values when role is leaf
85
+ intf .NvPairs .Speed = "Auto"
86
+ intf .NvPairs .Mtu = "jumbo"
87
+ intf .NvPairs .FreeformConfig = "no shutdown"
88
+ intf .NvPairs .AllowedVlans = "none"
89
+ intf .NvPairs .BpduGuard = "false"
90
+ intf .NvPairs .PortTypeFast = "true"
91
+ } else {
92
+ intf .NvPairs .Speed = "Auto"
93
+ intf .NvPairs .Mtu = "9216"
94
+ intf .NvPairs .FreeformConfig = "no shutdown"
95
+ intf .NvPairs .Vrf = ""
96
+ intf .NvPairs .Ipv4Address = ""
97
+ intf .NvPairs .Ipv4PrefixLength = ""
98
+ intf .NvPairs .RoutingTag = ""
99
+ }
76
100
inData .Interfaces [k ] = intf
77
101
intfPayload .Interfaces = append (intfPayload .Interfaces , intf )
78
102
ifDeployPayload = append (ifDeployPayload , resource_interface_common.NDFCInterfaceDeploy {
0 commit comments