func removeOrphanDHCPServers(vbox VBoxManager) error {
	dhcps, err := listDHCPServers(vbox)
	if err != nil {
		return err
	}

	if len(dhcps) == 0 {
		return nil
	}

	log.Debug("Removing orphan DHCP servers...")

	nets, err := listHostOnlyAdapters(vbox)
	if err != nil {
		return err
	}

	for name := range dhcps {
		if strings.HasPrefix(name, dhcpPrefix) {
			if _, present := nets[name]; !present {
				if err := vbox.vbm("dhcpserver", "remove", "--netname", name); err != nil {
					log.Warnf("Unable to remove orphan dhcp server %q: %s", name, err)
				}
			}
		}
	}

	return nil
}
func removeOrphanDHCPServers(vbox VBoxManager) error {
	dhcps, err := listDHCPServers(vbox)
	if err != nil {
		return err
	}

	if len(dhcps) == 0 {
		return nil
	}

	log.Debug("Removing orphan DHCP servers...")

	nets, err := listHostOnlyAdapters(vbox)
	if err != nil {
		return err
	}

	for name := range dhcps {
		if strings.HasPrefix(name, dhcpPrefix) {
			if _, present := nets[name]; !present {
				if err := vbox.vbm("dhcpserver", "remove", "--netname", name); err != nil {
					log.Warnf("Unable to remove orphan dhcp server %q: %s", name, err)
				}
			}
		}
	}

	return nil
}
func removeOrphanDHCPServers ( vbox VBoxManager ) error { dhcps , err := listDHCPServers ( vbox ) if err != nil { return err } if len ( dhcps ) == 0 { return nil } log . Debug ( " " ) nets , err := listHostOnlyAdapters ( vbox ) if err != nil { return err } for name := range dhcps { if strings . HasPrefix ( name , dhcpPrefix ) { if _ , present := nets [ name ] ; ! present { if err := vbox . vbm ( " " , " " , " " , name ) ; err != nil { log . Warnf ( " " , name , err ) } } } } return nil }
// removeOrphanDHCPServers removed the DHCP servers linked to no host-only adapter
removeOrphanDHCPServers removed the DHCP servers linked to no host - only adapter