-
Notifications
You must be signed in to change notification settings - Fork 291
/
hostlist.go
35 lines (29 loc) · 877 Bytes
/
hostlist.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// (C) Copyright 2020-2021 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
package control
import "github.com/daos-stack/daos/src/control/common"
// getRequestHosts returns a list of control plane addresses for
// the request. If the request does not supply its own hostlist,
// create one from the configuration's hostlist.
func getRequestHosts(cfg *Config, req targetChooser) (hosts []string, err error) {
if len(req.getHostList()) == 0 && len(cfg.HostList) == 0 {
return nil, FaultConfigEmptyHostList
}
if cfg.ControlPort == 0 {
return nil, FaultConfigBadControlPort
}
hosts, err = common.ParseHostList(req.getHostList(), cfg.ControlPort)
if err != nil {
return nil, err
}
if len(hosts) == 0 {
hosts, err = common.ParseHostList(cfg.HostList, cfg.ControlPort)
if err != nil {
return nil, err
}
}
return hosts, nil
}