feat(join): check cluster conditions before join

This commit is contained in:
Yicheng Qin
2014-05-01 15:58:14 -07:00
parent 4e14604e5c
commit 001b1fcd46
3 changed files with 66 additions and 3 deletions

View File

@@ -60,6 +60,32 @@ func (c *Client) GetVersion(url string) (int, *etcdErr.Error) {
return version, nil
}
func (c *Client) GetMachines(url string) ([]*machineMessage, *etcdErr.Error) {
resp, err := c.Get(url + "/v2/admin/machines")
if err != nil {
return nil, clientError(err)
}
msgs := new([]*machineMessage)
if uerr := c.parseJSONResponse(resp, msgs); uerr != nil {
return nil, uerr
}
return *msgs, nil
}
func (c *Client) GetClusterConfig(url string) (*ClusterConfig, *etcdErr.Error) {
resp, err := c.Get(url + "/v2/admin/config")
if err != nil {
return nil, clientError(err)
}
config := new(ClusterConfig)
if uerr := c.parseJSONResponse(resp, config); uerr != nil {
return nil, uerr
}
return config, nil
}
// AddMachine adds machine to the cluster.
// The first return value is the commit index of join command.
func (c *Client) AddMachine(url string, cmd *JoinCommand) (uint64, *etcdErr.Error) {