func (s *STPInterfaceEntity) SetPortfastDefault(name string) bool {
	cmd := s.CommandBuilder("spanning-tree portfast", "", true, false)
	return s.ConfigureInterface(name, cmd)
}
SetPortfastDefault sets the spanning-tree portfast for the interface name(string)
back to the default config. Returns true(bool) if configuration successful
package module
import (
	"regexp"
	"strconv"
	"github.com/aristanetworks/goeapi"
)
type STPEntity struct {
	instances  *STPInstanceEntity
	interfaces *STPInterfaceEntity
	*AbstractBaseEntity
}
func Stp(node *goeapi.Node) *STPEntity {
	return &STPEntity{AbstractBaseEntity: &AbstractBaseEntity{node}}
}
func (s *STPEntity) Get() {
}
func (s *STPEntity) Interfaces() *STPInterfaceEntity {
	if s.interfaces == nil {
		s.interfaces = STPInterfaces(s.AbstractBaseEntity.node)
	}
	return s.interfaces
}
func (s *STPEntity) Instances() *STPInstanceEntity {
	if s.instances == nil {
		s.instances = STPInstance(s.AbstractBaseEntity.node)
	}
	return s.instances
}
func (s *STPEntity) SetMode(value string) bool {
	if value == "" {
		return s.Configure("no spanning-tree mode")
	}
	if value != "mstp" && value != "none" {
		return false
	}
	return s.Configure("spanning-tree mode " + value)
}
type STPInstanceEntity struct {
	*AbstractBaseEntity
}
func STPInstance(node *goeapi.Node) *STPInstanceEntity {
	return &STPInstanceEntity{&AbstractBaseEntity{node}}
}
type STPInterfaceConfig map[string]string
type STPInterfaceCollection map[string]STPInterfaceConfig
type STPInterfaceEntity struct {
	*AbstractBaseEntity
}
func STPInterfaces(node *goeapi.Node) *STPInterfaceEntity {
	return &STPInterfaceEntity{&AbstractBaseEntity{node}}
}
func (s *STPInterfaceEntity) Get(name string) STPInterfaceConfig {
	parent := `interface\s+` + name
	config, _ := s.GetBlock(parent)
	return STPInterfaceConfig{
		"bpduguard":     strconv.FormatBool(s.parseBPDUGuard(config)),
		"portfast":      strconv.FormatBool(s.parsePortfast(config)),
		"portfast_type": s.parsePortfastType(config),
	}
}
func (s *STPInterfaceEntity) GetAll() STPInterfaceCollection {
	config := s.Config()
	re := regexp.MustCompile(`(?m)^interface\s(Eth.+|Po.+)$`)
	interfaces := re.FindAllStringSubmatch(config, -1)
	collection := make(STPInterfaceCollection)
	for _, matchedLine := range interfaces {
		intf := matchedLine[1]
		if tmp := s.Get(intf); tmp != nil {
			collection[intf] = tmp
		}
	}
	return collection
}
func (s *STPInterfaceEntity) parseBPDUGuard(config string) bool {
	matched, _ := regexp.MatchString("spanning-tree bpduguard enable", config)
	return matched
}
func (s *STPInterfaceEntity) parsePortfast(config string) bool {
	matched, _ := regexp.MatchString("no spanning-tree portfast", config)
	return !matched
}
func (s *STPInterfaceEntity) parsePortfastType(config string) string {
	found, _ := regexp.MatchString("spanning-tree portfast network", config)
	if found {
		return "network"
	}
	found, _ = regexp.MatchString("no spanning-tree portfast", config)
	if found {
		return "normal"
	}
	return "edge"
}
func (s *STPInterfaceEntity) ConfigureInterface(name string, cmds ...string) bool {
	if !isValidStpInterface(name) {
		return false
	}
	return s.AbstractBaseEntity.ConfigureInterface(name, cmds...)
}
func (s *STPInterfaceEntity) SetPortfastType(name string, value string) bool {
	validTypes := map[string]bool{
		"network": true,
		"edge":    true,
		"normal":  true,
	}
	if _, found := validTypes[value]; !found {
		return false
	}
	cmds := []string{"spanning-tree portfast " + value}
	if value == "edge" {
		cmds = append(cmds, "spanning-tree portfast auto")
	}
	return s.ConfigureInterface(name, cmds...)
}
func (s *STPInterfaceEntity) SetPortfast(name string, enable bool) bool {
	cmds := s.CommandBuilder("spanning-tree portfast", "", false, enable)
	return s.ConfigureInterface(name, cmds)
}