mirror of
https://github.com/minio/minio.git
synced 2024-12-25 22:55: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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"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 {
|
func proxyRequest(method, host string, ssl bool, res interface{}) *probe.Error {
|
||||||
u := &url.URL{
|
u := &url.URL{}
|
||||||
Scheme: func() string {
|
|
||||||
if ssl {
|
if ssl {
|
||||||
return "https"
|
u.Scheme = "https"
|
||||||
|
} else {
|
||||||
|
u.Scheme = "http"
|
||||||
}
|
}
|
||||||
return "http"
|
u.Host = host
|
||||||
}(),
|
if _, _, err := net.SplitHostPort(host); err == nil {
|
||||||
Host: host,
|
u.Host = host
|
||||||
Path: "/rpc",
|
} else {
|
||||||
|
u.Host = host + ":9002"
|
||||||
}
|
}
|
||||||
|
u.Path = "/rpc"
|
||||||
|
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: method,
|
Method: method,
|
||||||
Request: ServerArg{},
|
Request: ServerArg{},
|
||||||
@ -203,47 +208,36 @@ func proxyRequest(method, host string, ssl bool, res interface{}) *probe.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerRPCService) AddServer(r *http.Request, args *ControllerArgs, res *ServerRep) error {
|
func (s *controllerRPCService) AddServer(r *http.Request, args *ControllerArgs, res *ServerRep) error {
|
||||||
for _, host := range args.Hosts {
|
err := proxyRequest("Server.Add", args.Host, args.SSL, res)
|
||||||
err := proxyRequest("Server.Add", host, args.SSL, res)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
}
|
}
|
||||||
s.serverList = append(s.serverList, *res)
|
s.serverList = append(s.serverList, *res)
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerRPCService) GetServerMemStats(r *http.Request, args *ControllerArgs, res *MemStatsRep) error {
|
func (s *controllerRPCService) GetServerMemStats(r *http.Request, args *ControllerArgs, res *MemStatsRep) error {
|
||||||
for _, host := range args.Hosts {
|
err := proxyRequest("Server.MemStats", args.Host, args.SSL, res)
|
||||||
err := proxyRequest("Server.MemStats", host, args.SSL, res)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
return errors.New("Invalid argument")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerRPCService) GetServerDiskStats(r *http.Request, args *ControllerArgs, res *DiskStatsRep) error {
|
func (s *controllerRPCService) GetServerDiskStats(r *http.Request, args *ControllerArgs, res *DiskStatsRep) error {
|
||||||
for _, host := range args.Hosts {
|
err := proxyRequest("Server.DiskStats", args.Host, args.SSL, res)
|
||||||
err := proxyRequest("Server.DiskStats", host, args.SSL, res)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
return errors.New("Invalid argument")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerRPCService) GetServerSysInfo(r *http.Request, args *ControllerArgs, res *SysInfoRep) error {
|
func (s *controllerRPCService) GetServerSysInfo(r *http.Request, args *ControllerArgs, res *SysInfoRep) error {
|
||||||
for _, host := range args.Hosts {
|
err := proxyRequest("Server.SysInfo", args.Host, args.SSL, res)
|
||||||
err := proxyRequest("Server.SysInfo", host, args.SSL, res)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
return errors.New("Invalid argument")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *controllerRPCService) ListServers(r *http.Request, args *ControllerArgs, res *ListRep) error {
|
func (s *controllerRPCService) ListServers(r *http.Request, args *ControllerArgs, res *ListRep) error {
|
||||||
@ -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 {
|
func (s *controllerRPCService) GetServerVersion(r *http.Request, args *ControllerArgs, res *VersionRep) error {
|
||||||
for _, host := range args.Hosts {
|
err := proxyRequest("Server.Version", args.Host, args.SSL, res)
|
||||||
err := proxyRequest("Server.Version", host, args.SSL, res)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.WrapError(err)
|
return probe.WrapError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
return errors.New("Invalid argument")
|
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ func (s *ControllerRPCSuite) TearDownSuite(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Controller.GetServerMemStats",
|
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)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@ -83,7 +83,7 @@ func (s *ControllerRPCSuite) TestMemStats(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestDiskStats(c *C) {
|
func (s *ControllerRPCSuite) TestDiskStats(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Controller.GetServerDiskStats",
|
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)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@ -101,7 +101,7 @@ func (s *ControllerRPCSuite) TestDiskStats(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Controller.GetServerSysInfo",
|
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)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@ -119,7 +119,7 @@ func (s *ControllerRPCSuite) TestSysInfo(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestServerList(c *C) {
|
func (s *ControllerRPCSuite) TestServerList(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Controller.ListServers",
|
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)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@ -137,7 +137,7 @@ func (s *ControllerRPCSuite) TestServerList(c *C) {
|
|||||||
func (s *ControllerRPCSuite) TestServerAdd(c *C) {
|
func (s *ControllerRPCSuite) TestServerAdd(c *C) {
|
||||||
op := rpcOperation{
|
op := rpcOperation{
|
||||||
Method: "Controller.AddServer",
|
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)
|
req, err := newRPCRequest(testControllerRPC.URL+"/rpc", op, http.DefaultTransport)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
@ -38,7 +38,7 @@ type ServerArg struct{}
|
|||||||
|
|
||||||
// ControllerArgs controller params
|
// ControllerArgs controller params
|
||||||
type ControllerArgs struct {
|
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"`
|
SSL bool `json:"ssl"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user