Beispiel #1
0
func listHosts(store persist.Store, storePath string) ([]*host.Host, error) {
	cliHosts := []*host.Host{}

	hosts, err := store.List()
	if err != nil {
		return nil, fmt.Errorf("Error attempting to list hosts from store: %s", err)
	}

	for _, h := range hosts {
		h, err = loadHost(store, h.Name, storePath)
		if err != nil {
			return nil, err
		}
		cliHosts = append(cliHosts, h)
	}

	return cliHosts, nil
}
Beispiel #2
0
func getActiveHost(store persist.Store) (*host.Host, error) {
	hosts, err := store.List()
	if err != nil {
		return nil, err
	}

	hostListItems := getHostListItems(hosts)

	for _, item := range hostListItems {
		if item.Active {
			h, err := store.Load(item.Name)
			if err != nil {
				return nil, err
			}
			return h, nil
		}
	}

	return nil, errors.New("Active host not found")
}
Beispiel #3
0
func listHosts(store persist.Store) ([]*host.Host, error) {
	cliHosts := []*host.Host{}

	hosts, err := store.List()
	if err != nil {
		return nil, fmt.Errorf("Error attempting to list hosts from store: %s", err)
	}

	for _, h := range hosts {
		d, err := newPluginDriver(h.DriverName, h.RawDriver)
		if err != nil {
			return nil, fmt.Errorf("Error attempting to invoke binary for plugin '%s': %s", h.DriverName, err)
		}

		h.Driver = d

		cliHosts = append(cliHosts, h)
	}

	return cliHosts, nil
}