// listSwitches returns a slice of switches in the database.
503212
func listSwitches(c context.Context, names, racks, datacenters stringset.Set) ([]*crimson.Switch, error) {
	db := database.Get(c)
	rows, err := db.QueryContext(c, `
		SELECT s.name, s.description, s.ports, s.state, r.name, d.name
		FROM switches s, racks r, datacenters d
		WHERE s.rack_id = r.id
			AND r.datacenter_id = d.id
	`)
	if err != nil {
		return nil, errors.Annotate(err, "failed to fetch switches").Err()
	}
	defer rows.Close()

	var switches []*crimson.Switch
	for rows.Next() {
		s := &crimson.Switch{}
		if err = rows.Scan(&s.Name, &s.Description, &s.Ports, &s.State, &s.Rack, &s.Datacenter); err != nil {
			return nil, errors.Annotate(err, "failed to fetch switch").Err()
		}
		if matches(s.Name, names) && matches(s.Rack, racks) && matches(s.Datacenter, datacenters) {
			switches = append(switches, s)
		}
	}
	return switches, nil
}
710062
func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error {
	if done, err := k.srv.forward("KVS.ListKeys", args, args, reply); done {
		return err
	}

	aclToken, err := k.srv.ResolveToken(args.Token)
	if err != nil {
		return err
	}

	if aclToken != nil && k.srv.config.ACLEnableKeyListPolicy && !aclToken.KeyList(args.Prefix) {
		return acl.ErrPermissionDenied
	}

	return k.srv.blockingQuery(
		&args.QueryOptions,
		&reply.QueryMeta,
		func(ws memdb.WatchSet, state *state.Store) error {
			index, keys, err := state.KVSListKeys(ws, args.Prefix, args.Seperator)
			if err != nil {
				return err
			}

			// Must provide non-zero index to prevent blocking
			// Index 1 is impossible anyways (due to Raft internals)
			if index == 0 {
				reply.Index = 1
			} else {
				reply.Index = index
			}

			if aclToken != nil {
				keys = FilterKeys(aclToken, keys)
			}
			reply.Keys = keys
			return nil
		})
}
1127602
func (c *threadSafeMap) ListKeys() []string {
	c.lock.RLock()
	defer c.lock.RUnlock()
	list := make([]string, 0, len(c.items))
	for key := range c.items {
		list = append(list, key)
	}
	return list
}
1359434
func listRacks(c context.Context, req *crimson.ListRacksRequest) ([]*crimson.Rack, error) {
	stmt := squirrel.Select("r.name", "r.description", "r.state", "d.name", "h.name").
		From("(racks r, datacenters d)").
		LeftJoin("kvms k ON r.kvm_id = k.id").
		LeftJoin("hostnames h ON k.hostname_id = h.id").
		Where("r.datacenter_id = d.id")
	stmt = selectInString(stmt, "r.name", req.Names)
	stmt = selectInString(stmt, "d.name", req.Datacenters)
	stmt = selectInString(stmt, "h.name", req.Kvms)
	query, args, err := stmt.ToSql()
	if err != nil {
		return nil, errors.Annotate(err, "failed to generate statement").Err()
	}

	db := database.Get(c)
	rows, err := db.QueryContext(c, query, args...)
	if err != nil {
		return nil, errors.Annotate(err, "failed to fetch racks").Err()
	}
	defer rows.Close()

	var racks []*crimson.Rack
	for rows.Next() {
		rack := &crimson.Rack{}
		var kvm sql.NullString
		if err = rows.Scan(&rack.Name, &rack.Description, &rack.State, &rack.Datacenter, &kvm); err != nil {
			return nil, errors.Annotate(err, "failed to fetch rack").Err()
		}
		if kvm.Valid {
			rack.Kvm = kvm.String
		}
		racks = append(racks, rack)
	}
	return racks, nil
}
58752
func (client *Client) DeleteVSwitch(VSwitchId string) error {
	args := DeleteVSwitchArgs{
		VSwitchId: VSwitchId,
	}
	response := DeleteVSwitchResponse{}
	return client.Invoke("DeleteVSwitch", &args, &response)
}
934100
func (c *Client) ListNodes() (nodes []NodeState, err error) {
	resp, err := c.get(c.getURL("state/nodes"))
	if err != nil {
		return []NodeState{}, err
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		return []NodeState{}, fmt.Errorf("Expected: {1,2}xx listing nodes, got: %d", resp.StatusCode)
	}

	err = json.NewDecoder(resp.Body).Decode(&nodes)
	if err != nil {
		return []NodeState{}, err
	}
	return nodes, err
}
942995
func (c *Connect) ListNWFilters() ([]string, error) {
	const maxFilters = 1024
	var names [maxFilters](*C.char)
	namesPtr := unsafe.Pointer(&names)
	var err C.virError
	numNWFilters := C.virConnectListNWFiltersWrapper(
		c.ptr,
		(**C.char)(namesPtr),
		maxFilters, &err)
	if numNWFilters == -1 {
		return nil, makeError(&err)
	}
	goNames := make([]string, numNWFilters)
	for k := 0; k < int(numNWFilters); k++ {
		goNames[k] = C.GoString(names[k])
		C.free(unsafe.Pointer(names[k]))
	}
	return goNames, nil
}
13789
func (db *ProtoWrapper) ListKeys(prefix string) (keyval.ProtoKeyIterator, error) {
	return listKeysProtoInternal(db.broker, prefix)
}
693177
func (s *ChangesService) ListVotes(changeID string, accountID string) (map[string]int, *Response, error) {
	u := fmt.Sprintf("changes/%s/reviewers/%s/votes/", changeID, accountID)
	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var v map[string]int
	resp, err := s.client.Do(req, &v)
	if err != nil {
		return nil, resp, err
	}
	return v, resp, err
}
969852
func (api *VPCRouterAPI) DisconnectFromSwitch(id int64, nicIndex int) (bool, error) {
	var (
		method = "DELETE"
		uri    = fmt.Sprintf("%s/%d/interface/%d/to/switch", api.getResourceURL(), id, nicIndex)
	)
	return api.modify(method, uri, nil)
}
1133170
func (c *stringChanger) List() ([]string, error) {
	if c.err != nil {
		return nil, c.err
	}
	var list []string
	err := c.node.doChildren(func(cn *node) error {
		list = append(list, cn.content.value().(string))
		return nil
	})
	if err != nil {
		return nil, err
	}
	return list, nil
}
396938
func (f *FakeCustomStore) ListKeys() []string {
	if f.ListKeysFunc != nil {
		return f.ListKeysFunc()
	}
	return nil
}
1172172
func EnsureSwitches(c context.Context, cfgs []*config.Datacenter, rackIds map[string]int64) error {
	t := &SwitchesTable{}
	t.racks = rackIds
	if err := t.fetch(c); err != nil {
		return errors.Annotate(err, "failed to fetch switches").Err()
	}
	if err := t.computeChanges(c, cfgs); err != nil {
		return errors.Annotate(err, "failed to compute changes").Err()
	}
	if err := t.add(c); err != nil {
		return errors.Annotate(err, "failed to add switches").Err()
	}
	if err := t.remove(c); err != nil {
		return errors.Annotate(err, "failed to remove switches").Err()
	}
	if err := t.update(c); err != nil {
		return errors.Annotate(err, "failed to update switches").Err()
	}
	return nil
}
510169
func (c *Connect) ListNetworks() ([]string, error) {
	const maxNets = 1024
	var names [maxNets](*C.char)
	namesPtr := unsafe.Pointer(&names)
	var err C.virError
	numNetworks := C.virConnectListNetworksWrapper(
		c.ptr,
		(**C.char)(namesPtr),
		maxNets, &err)
	if numNetworks == -1 {
		return nil, makeError(&err)
	}
	goNames := make([]string, numNetworks)
	for k := 0; k < int(numNetworks); k++ {
		goNames[k] = C.GoString(names[k])
		C.free(unsafe.Pointer(names[k]))
	}
	return goNames, nil
}
208143
func (s *SystemVMService) ListSystemVms(p *ListSystemVmsParams) (*ListSystemVmsResponse, error) {
	resp, err := s.cs.newRequest("listSystemVms", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListSystemVmsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
309589
func NewAltSwitch(Cond node.Node, CaseList *CaseList) *AltSwitch {
	return &AltSwitch{
		FreeFloating: nil,
		Cond:         Cond,
		CaseList:     CaseList,
	}
}
258155
func (c *Conn) ListSessions() ([]Session, error) {
	out := [][]interface{}{}
	if err := c.object.Call(dbusInterface+".ListSessions", 0).Store(&out); err != nil {
		return nil, err
	}

	ret := []Session{}
	for _, el := range out {
		session, err := sessionFromInterfaces(el)
		if err != nil {
			return nil, err
		}
		ret = append(ret, *session)
	}
	return ret, nil
}