Remove scsi non portable code, instead "donut make" implements functionality to instantiate a donut

This commit is contained in:
Harshavardhana
2015-07-15 11:55:49 -07:00
parent 49c705da99
commit 4498662c16
20 changed files with 40 additions and 563 deletions

View File

@@ -114,7 +114,6 @@ func getRPCHandler() http.Handler {
s.RegisterService(new(rpc.VersionService), "Version")
s.RegisterService(new(rpc.SysInfoService), "SysInfo")
s.RegisterService(new(rpc.MemStatsService), "MemStats")
s.RegisterService(new(rpc.DiskInfoService), "DiskInfo")
s.RegisterService(new(rpc.DonutService), "Donut")
s.RegisterService(new(rpc.AuthService), "Auth")
// Add new RPC services here

View File

@@ -1,67 +0,0 @@
/*
* Minimalist Object Storage, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rpc
import (
"net/http"
"os"
"github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/utils/scsi"
)
// DiskInfoService disk info service
type DiskInfoService struct{}
// DiskInfoReply disk info reply for disk info service
type DiskInfoReply struct {
Hostname string `json:"hostname"`
Mounts map[string]scsi.Mountinfo `json:"mounts"`
Disks []string `json:"disks"`
DiskAttributes map[string]scsi.Attributes `json:"-"` // for the time being not unmarshalling this
}
func setDiskInfoReply(sis *DiskInfoReply) error {
var err error
sis.Hostname, err = os.Hostname()
if err != nil {
return iodine.New(err, nil)
}
mounts, err := scsi.GetMountInfo()
if err != nil {
return iodine.New(err, nil)
}
sis.Mounts = make(map[string]scsi.Mountinfo)
sis.Mounts = mounts
disks, err := scsi.GetDisks()
if err != nil {
return iodine.New(err, nil)
}
sis.DiskAttributes = make(map[string]scsi.Attributes)
for k, v := range disks {
sis.Disks = append(sis.Disks, k)
sis.DiskAttributes[k] = v
}
return nil
}
// Get method
func (s *DiskInfoService) Get(r *http.Request, args *Args, reply *DiskInfoReply) error {
return setDiskInfoReply(reply)
}

View File

@@ -43,25 +43,6 @@ func (s *MyRPCSuite) TearDownSuite(c *C) {
testRPCServer.Close()
}
func (s *MyRPCSuite) TestDiskInfo(c *C) {
op := controller.RPCOps{
Method: "DiskInfo.Get",
Request: rpc.Args{Request: ""},
}
req, err := controller.NewRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
c.Assert(err, IsNil)
c.Assert(req.Get("Content-Type"), Equals, "application/json")
resp, err := req.Do()
c.Assert(err, IsNil)
c.Assert(resp.StatusCode, Equals, http.StatusOK)
var reply rpc.DiskInfoReply
err = jsonrpc.DecodeClientResponse(resp.Body, &reply)
c.Assert(err, IsNil)
resp.Body.Close()
c.Assert(reply, Not(DeepEquals), rpc.DiskInfoReply{})
}
func (s *MyRPCSuite) TestMemStats(c *C) {
op := controller.RPCOps{
Method: "MemStats.Get",