|
|
@ -41,8 +41,8 @@ const ( |
|
|
|
// Add your own backend.
|
|
|
|
// Add your own backend.
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// ServiceStatusMetadata - represents total capacity of underlying storage.
|
|
|
|
// StorageInfo - represents total capacity of underlying storage.
|
|
|
|
type ServiceStatusMetadata struct { |
|
|
|
type StorageInfo struct { |
|
|
|
// Total disk space.
|
|
|
|
// Total disk space.
|
|
|
|
Total int64 |
|
|
|
Total int64 |
|
|
|
// Free available disk space.
|
|
|
|
// Free available disk space.
|
|
|
@ -60,10 +60,23 @@ type ServiceStatusMetadata struct { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ServerVersion - server version
|
|
|
|
|
|
|
|
type ServerVersion struct { |
|
|
|
|
|
|
|
Version string `json:"version"` |
|
|
|
|
|
|
|
CommitID string `json:"commitID"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ServiceStatusMetadata - contains the response of service status API
|
|
|
|
|
|
|
|
type ServiceStatusMetadata struct { |
|
|
|
|
|
|
|
StorageInfo StorageInfo `json:"storageInfo"` |
|
|
|
|
|
|
|
ServerVersion ServerVersion `json:"serverVersion"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ServiceStatus - Connect to a minio server and call Service Status Management API
|
|
|
|
// ServiceStatus - Connect to a minio server and call Service Status Management API
|
|
|
|
// to fetch server's storage information represented by ServiceStatusMetadata structure
|
|
|
|
// to fetch server's storage information represented by ServiceStatusMetadata structure
|
|
|
|
func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) { |
|
|
|
func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare web service request
|
|
|
|
reqData := requestData{} |
|
|
|
reqData := requestData{} |
|
|
|
reqData.queryValues = make(url.Values) |
|
|
|
reqData.queryValues = make(url.Values) |
|
|
|
reqData.queryValues.Set("service", "") |
|
|
|
reqData.queryValues.Set("service", "") |
|
|
@ -72,29 +85,30 @@ func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) { |
|
|
|
|
|
|
|
|
|
|
|
// Execute GET on bucket to list objects.
|
|
|
|
// Execute GET on bucket to list objects.
|
|
|
|
resp, err := adm.executeMethod("GET", reqData) |
|
|
|
resp, err := adm.executeMethod("GET", reqData) |
|
|
|
|
|
|
|
|
|
|
|
defer closeResponse(resp) |
|
|
|
defer closeResponse(resp) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check response http status code
|
|
|
|
if resp.StatusCode != http.StatusOK { |
|
|
|
if resp.StatusCode != http.StatusOK { |
|
|
|
return ServiceStatusMetadata{}, errors.New("Got HTTP Status: " + resp.Status) |
|
|
|
return ServiceStatusMetadata{}, errors.New("Got HTTP Status: " + resp.Status) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Unmarshal the server's json response
|
|
|
|
|
|
|
|
var serviceStatus ServiceStatusMetadata |
|
|
|
|
|
|
|
|
|
|
|
respBytes, err := ioutil.ReadAll(resp.Body) |
|
|
|
respBytes, err := ioutil.ReadAll(resp.Body) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var storageInfo ServiceStatusMetadata |
|
|
|
err = json.Unmarshal(respBytes, &serviceStatus) |
|
|
|
|
|
|
|
|
|
|
|
err = json.Unmarshal(respBytes, &storageInfo) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
return ServiceStatusMetadata{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return storageInfo, nil |
|
|
|
return serviceStatus, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ServiceRestart - Call Service Restart API to restart a specified Minio server
|
|
|
|
// ServiceRestart - Call Service Restart API to restart a specified Minio server
|
|
|
|