mirror of
https://github.com/minio/minio.git
synced 2024-12-25 14:45:54 -05:00
Change ControllerArgs Hosts array to Host string
This commit is contained in:
parent
b45c6020e4
commit
53e87a0790
@ -18,6 +18,7 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -173,16 +174,20 @@ func (s *controllerRPCService) ResetAuth(r *http.Request, args *AuthArgs, reply
|
||||
}
|
||||
|
||||
func proxyRequest(method, host string, ssl bool, res interface{}) *probe.Error {
|
||||
u := &url.URL{
|
||||
Scheme: func() string {
|
||||
u := &url.URL{}
|
||||
if ssl {
|
||||
return "https"
|
||||
u.Scheme = "https"
|
||||
} else {
|
||||
u.Scheme = "http"
|
||||
}
|
||||
return "http"
|
||||
}(),
|
||||
Host: host,
|
||||
Path: "/rpc",
|
||||
u.Host = host
|
||||
if _, _, err := net.SplitHostPort(host); err == nil {
|
||||
u.Host = host
|
||||
} else {
|
||||
u.Host = host + ":9002"
|
||||
}
|
||||
u.Path = "/rpc"
|
||||
|
||||
op := rpcOperation{
|
||||
Method: method,
|
||||
Request: ServerArg{},
|
||||
@ -203,48 +208,37 @@ func proxyRequest(method, host string, ssl bool, res interface{}) *probe.Error {
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) AddServer(r *http.Request, args *ControllerArgs, res *ServerRep) error {
|
||||
for _, host := range args.Hosts {
|
||||
err := proxyRequest("Server.Add", host, args.SSL, res)
|
||||
err := proxyRequest("Server.Add", args.Host, args.SSL, res)
|
||||
if err != nil {
|
||||
return probe.WrapError(err)
|
||||
}
|
||||
s.serverList = append(s.serverList, *res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) GetServerMemStats(r *http.Request, args *ControllerArgs, res *MemStatsRep) error {
|
||||
for _, host := range args.Hosts {
|
||||
err := proxyRequest("Server.MemStats", host, args.SSL, res)
|
||||
err := proxyRequest("Server.MemStats", args.Host, args.SSL, res)
|
||||
if err != nil {
|
||||
return probe.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("Invalid argument")
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) GetServerDiskStats(r *http.Request, args *ControllerArgs, res *DiskStatsRep) error {
|
||||
for _, host := range args.Hosts {
|
||||
err := proxyRequest("Server.DiskStats", host, args.SSL, res)
|
||||
err := proxyRequest("Server.DiskStats", args.Host, args.SSL, res)
|
||||
if err != nil {
|
||||
return probe.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("Invalid argument")
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) GetServerSysInfo(r *http.Request, args *ControllerArgs, res *SysInfoRep) error {
|
||||
for _, host := range args.Hosts {
|
||||
err := proxyRequest("Server.SysInfo", host, args.SSL, res)
|
||||
err := proxyRequest("Server.SysInfo", args.Host, args.SSL, res)
|
||||
if err != nil {
|
||||
return probe.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("Invalid argument")
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) ListServers(r *http.Request, args *ControllerArgs, res *ListRep) error {
|
||||
res.List = s.serverList
|
||||
@ -252,12 +246,9 @@ func (s *controllerRPCService) ListServers(r *http.Request, args *ControllerArgs
|
||||
}
|
||||
|
||||
func (s *controllerRPCService) GetServerVersion(r *http.Request, args *ControllerArgs, res *VersionRep) error {
|
||||
for _, host := range args.Hosts {
|
||||
err := proxyRequest("Server.Version", host, args.SSL, res)
|
||||
err := proxyRequest("Server.Version", args.Host, args.SSL, res)
|
||||
if err != nil {
|
||||
return probe.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("Invalid argument")
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func (s *ControllerRPCSuite) TearDownSuite(c *C) {
|
||||
func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
||||
op := rpcOperation{
|
||||
Method: "Controller.GetServerMemStats",
|
||||
Request: ControllerArgs{Hosts: []string{s.url.Host}},
|
||||
Request: ControllerArgs{Host: s.url.Host},
|
||||
}
|
||||
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||
c.Assert(err, IsNil)
|
||||
@ -83,7 +83,7 @@ func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
||||
func (s *ControllerRPCSuite) TestDiskStats(c *C) {
|
||||
op := rpcOperation{
|
||||
Method: "Controller.GetServerDiskStats",
|
||||
Request: ControllerArgs{Hosts: []string{s.url.Host}},
|
||||
Request: ControllerArgs{Host: s.url.Host},
|
||||
}
|
||||
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||
c.Assert(err, IsNil)
|
||||
@ -101,7 +101,7 @@ func (s *ControllerRPCSuite) TestDiskStats(c *C) {
|
||||
func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
||||
op := rpcOperation{
|
||||
Method: "Controller.GetServerSysInfo",
|
||||
Request: ControllerArgs{Hosts: []string{s.url.Host}},
|
||||
Request: ControllerArgs{Host: s.url.Host},
|
||||
}
|
||||
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||
c.Assert(err, IsNil)
|
||||
@ -119,7 +119,7 @@ func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
||||
func (s *ControllerRPCSuite) TestServerList(c *C) {
|
||||
op := rpcOperation{
|
||||
Method: "Controller.ListServers",
|
||||
Request: ControllerArgs{Hosts: []string{s.url.Host}},
|
||||
Request: ControllerArgs{Host: s.url.Host},
|
||||
}
|
||||
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||
c.Assert(err, IsNil)
|
||||
@ -137,7 +137,7 @@ func (s *ControllerRPCSuite) TestServerList(c *C) {
|
||||
func (s *ControllerRPCSuite) TestServerAdd(c *C) {
|
||||
op := rpcOperation{
|
||||
Method: "Controller.AddServer",
|
||||
Request: ControllerArgs{Hosts: []string{s.url.Host}},
|
||||
Request: ControllerArgs{Host: s.url.Host},
|
||||
}
|
||||
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||
c.Assert(err, IsNil)
|
||||
|
@ -38,7 +38,7 @@ type ServerArg struct{}
|
||||
|
||||
// ControllerArgs controller params
|
||||
type ControllerArgs struct {
|
||||
Hosts []string `json:"hosts"` // hosts is a collection of host or host:port
|
||||
Host string `json:"host"` // host or host:port
|
||||
SSL bool `json:"ssl"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user