diff --git a/cmd/admin-info.go b/cmd/admin-info.go new file mode 100644 index 00000000..8ce16d4a --- /dev/null +++ b/cmd/admin-info.go @@ -0,0 +1,207 @@ +/* + * Minio Client (C) 2016 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 cmd + +import ( + "encoding/json" + "fmt" + "net/url" + + humanize "github.com/dustin/go-humanize" + "github.com/fatih/color" + "github.com/minio/cli" + "github.com/minio/mc/pkg/console" + "github.com/minio/minio/pkg/madmin" + "github.com/minio/minio/pkg/probe" +) + +var ( + adminInfoFlags = []cli.Flag{} +) + +var adminInfoCmd = cli.Command{ + Name: "info", + Usage: "Get information of a Minio server", + Action: mainAdminInfo, + Before: setGlobalsFromContext, + Flags: append(adminInfoFlags, globalFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Get server information of the 'play' Minio server. + $ {{.HelpName}} play/ + +`, +} + +// backendType - indicates the type of backend storage +type backendType string + +const ( + fsType = backendType("FS") + erasureType = backendType("Erasure") +) + +// fsBackend contains specific FS storage information +type fsBackend struct { + Type backendType `json:"backendType"` +} + +// xlBackend contains specific erasure storage information +type xlBackend struct { + Type backendType `json:"backendType"` + OnlineDisks int `json:"onlineDisks"` + OfflineDisks int `json:"offlineDisks"` +} + +// backendStatus represents the overall information of all backend storage types +type backendStatus struct { + Total int64 `json:"total"` + Free int64 `json:"free"` + Backend interface{} `json:"backend"` +} + +// ServerInfo holds the whole server information that will be +// returned by ServerInfo API. +type ServerInfo struct { + StorageInfo backendStatus `json:"storage"` + ConnStats madmin.ServerConnStats `json:"network"` + Properties madmin.ServerProperties `json:"server"` +} + +// infoMessage container to hold service status information. +type infoMessage struct { + Status string `json:"status"` + Service bool `json:"service"` + *ServerInfo +} + +// String colorized service status message. +func (u infoMessage) String() (msg string) { + defer func() { + msg = console.Colorize("Info", msg) + }() + // When service is offline + if !u.Service { + msg = "The server is offline." + return + } + msg += fmt.Sprintf(" Version : %s\n", u.ServerInfo.Properties.Version) + msg += fmt.Sprintf(" Uptime : %s\n", timeDurationToHumanizedDuration(u.ServerInfo.Properties.Uptime)) + msg += fmt.Sprintf(" Region : %s\n", u.ServerInfo.Properties.Region) + msg += fmt.Sprintf(" Network : Incoming %s, Outgoing %s\n", + humanize.IBytes(u.ServerInfo.ConnStats.TotalInputBytes), + humanize.IBytes(u.ServerInfo.ConnStats.TotalOutputBytes)) + + // Online service, get backend information + msg += fmt.Sprintf(" Storage : Total %s, Free %s", + humanize.IBytes(uint64(u.StorageInfo.Total)), + humanize.IBytes(uint64(u.StorageInfo.Free)), + ) + if v, ok := u.ServerInfo.StorageInfo.Backend.(xlBackend); ok { + msg += fmt.Sprintf(", Online Disks: %d, Offline Disks: %d\n", v.OnlineDisks, v.OfflineDisks) + } + return +} + +// JSON jsonified service status Message message. +func (u infoMessage) JSON() string { + u.Status = "success" + statusJSONBytes, e := json.Marshal(u) + fatalIf(probe.NewError(e), "Unable to marshal into JSON.") + + return string(statusJSONBytes) +} + +// checkAdminInfoSyntax - validate all the passed arguments +func checkAdminInfoSyntax(ctx *cli.Context) { + if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 { + cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code + } +} + +func mainAdminInfo(ctx *cli.Context) error { + // Validate service status syntax. + checkAdminInfoSyntax(ctx) + + console.SetColor("Info", color.New(color.FgGreen, color.Bold)) + + // Get the alias parameter from cli + args := ctx.Args() + aliasedURL := args.Get(0) + + // Create a new Minio Admin Client + client, err := newAdminClient(aliasedURL) + fatalIf(err, "Cannot get a configured admin connection.") + + // Fetch the server info of the specified Minio server + serverInfo, e := client.ServerInfo() + + // Check the availability of the server: online or offline. A server is considered + // offline if we can't get any response or we get a bad format response + var serviceOffline bool + switch v := e.(type) { + case *json.SyntaxError: + serviceOffline = true + case *url.Error: + if v.Timeout() { + serviceOffline = true + } + } + if serviceOffline { + printMsg(infoMessage{Service: false}) + return nil + } + + // If the error is not nil and not unrecognizable, just print it and exit + fatalIf(probe.NewError(e), "Cannot get service status.") + + // Construct the backend status + storageInfo := backendStatus{ + Total: serverInfo.StorageInfo.Total, + Free: serverInfo.StorageInfo.Free, + } + if serverInfo.StorageInfo.Backend.Type == madmin.Erasure { + storageInfo.Backend = xlBackend{ + Type: erasureType, + OnlineDisks: serverInfo.StorageInfo.Backend.OnlineDisks, + OfflineDisks: serverInfo.StorageInfo.Backend.OfflineDisks, + } + } else { + storageInfo.Backend = fsBackend{ + Type: fsType, + } + } + + printMsg(infoMessage{ + Service: true, + ServerInfo: &ServerInfo{ + StorageInfo: storageInfo, + ConnStats: serverInfo.ConnStats, + Properties: serverInfo.Properties, + }, + }) + + return nil +} diff --git a/cmd/admin-main.go b/cmd/admin-main.go index fdc2c795..5ae911d8 100644 --- a/cmd/admin-main.go +++ b/cmd/admin-main.go @@ -31,6 +31,7 @@ var adminCmd = cli.Command{ Flags: append(adminFlags, globalFlags...), Subcommands: []cli.Command{ adminServiceCmd, + adminInfoCmd, adminPasswordCmd, adminLockCmd, adminHealCmd, diff --git a/cmd/admin-password.go b/cmd/admin-password.go index 29016cc0..2a254b8e 100644 --- a/cmd/admin-password.go +++ b/cmd/admin-password.go @@ -70,7 +70,7 @@ func mainAdminPassword(ctx *cli.Context) error { fatalIf(err, "Cannot get a configured admin connection.") // Change the password of the specified Minio server - e := client.ServiceSetCredentials(accessKey, secretKey) + e := client.SetCredentials(accessKey, secretKey) fatalIf(probe.NewError(e), "Unable to set new credentials to '"+aliasedURL+"'") return nil diff --git a/cmd/admin-service-status.go b/cmd/admin-service-status.go index 51910b6f..c61782ee 100644 --- a/cmd/admin-service-status.go +++ b/cmd/admin-service-status.go @@ -1,5 +1,5 @@ /* - * Minio Client (C) 2016 Minio, Inc. + * Minio Client (C) 2016, 2017 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,11 @@ import ( "encoding/json" "fmt" "net/url" + "time" - humanize "github.com/dustin/go-humanize" "github.com/fatih/color" "github.com/minio/cli" "github.com/minio/mc/pkg/console" - "github.com/minio/minio/pkg/madmin" "github.com/minio/minio/pkg/probe" ) @@ -49,49 +48,16 @@ FLAGS: {{range .VisibleFlags}}{{.}} {{end}} EXAMPLES: - 1. Get storage information of a Minio server represented by its alias 'play'. + 1. Check if the 'play' Minio server is online and show its uptime. $ {{.HelpName}} play/ `, } -// backendType - indicates the type of backend storage -type backendType string - -const ( - fsType = backendType("FS") - xlType = backendType("XL") -) - -// fsBackend contains specific FS storage information -type fsBackend struct { - Type backendType `json:"backendType"` -} - -// xlBackend contains specific XL storage information -type xlBackend struct { - Type backendType `json:"backendType"` - OnlineDisks int `json:"onlineDisks"` - OfflineDisks int `json:"offlineDisks"` -} - -// backendStatus represents the overall information of all backend storage types -type backendStatus struct { - Total int64 `json:"total"` - Free int64 `json:"free"` - Backend interface{} `json:"backend"` -} - -type serverVersion struct { - Version string `json:"version"` - CommitID string `json:"commitID"` -} - // serviceStatusMessage container to hold service status information. type serviceStatusMessage struct { - Status string `json:"status"` - Service bool `json:"service"` - StorageInfo backendStatus `json:"storageInfo"` - ServerVersion serverVersion `json:"server"` + Status string `json:"status"` + Service bool `json:"service"` + Uptime time.Duration `json:"uptime"` } // String colorized service status message. @@ -104,14 +70,7 @@ func (u serviceStatusMessage) String() (msg string) { msg = "The server is offline." return } - // Online service, get backend information - msg = fmt.Sprintf("Total: %s, Free: %s.", - humanize.IBytes(uint64(u.StorageInfo.Total)), - humanize.IBytes(uint64(u.StorageInfo.Free)), - ) - if v, ok := u.StorageInfo.Backend.(xlBackend); ok { - msg += fmt.Sprintf(" Online Disks: %d, Offline Disks: %d.\n", v.OnlineDisks, v.OfflineDisks) - } + msg = fmt.Sprintf("Uptime: %s.", timeDurationToHumanizedDuration(u.Uptime)) return } @@ -146,7 +105,7 @@ func mainAdminServiceStatus(ctx *cli.Context) error { client, err := newAdminClient(aliasedURL) fatalIf(err, "Cannot get a configured admin connection.") - // Fetch the storage info of the specified Minio server + // Fetch the service status of the specified Minio server st, e := client.ServiceStatus() // Check the availability of the server: online or offline. A server is considered @@ -168,34 +127,10 @@ func mainAdminServiceStatus(ctx *cli.Context) error { // If the error is not nil and not unrecognizable, just print it and exit fatalIf(probe.NewError(e), "Cannot get service status.") - // Construct the version response - version := serverVersion{ - Version: st.ServerVersion.Version, - CommitID: st.ServerVersion.CommitID, - } - - // Construct the backend status - storageInfo := backendStatus{ - Total: st.StorageInfo.Total, - Free: st.StorageInfo.Free, - } - if st.StorageInfo.Backend.Type == madmin.XL { - storageInfo.Backend = xlBackend{ - Type: xlType, - OnlineDisks: st.StorageInfo.Backend.OnlineDisks, - OfflineDisks: st.StorageInfo.Backend.OfflineDisks, - } - } else { - storageInfo.Backend = fsBackend{ - Type: fsType, - } - } - // Print the whole response printMsg(serviceStatusMessage{ - Service: true, - StorageInfo: storageInfo, - ServerVersion: version, + Service: true, + Uptime: st.Uptime, }) return nil diff --git a/vendor/github.com/minio/minio/pkg/madmin/API.md b/vendor/github.com/minio/minio/pkg/madmin/API.md index 36c79b1a..36103409 100644 --- a/vendor/github.com/minio/minio/pkg/madmin/API.md +++ b/vendor/github.com/minio/minio/pkg/madmin/API.md @@ -36,13 +36,13 @@ func main() { ``` -| Service operations|LockInfo operations|Healing operations| -|:---|:---|:---| -|[`ServiceStatus`](#ServiceStatus)| [`ListLocks`](#ListLocks)| [`ListObjectsHeal`](#ListObjectsHeal)| -|[`ServiceRestart`](#ServiceRestart)| [`ClearLocks`](#ClearLocks)| [`ListBucketsHeal`](#ListBucketsHeal)| -| | |[`HealBucket`](#HealBucket) | -| | |[`HealObject`](#HealObject)| -| | |[`HealFormat`](#HealFormat)| +| Service operations|LockInfo operations|Healing operations|Config operations| Misc | +|:---|:---|:---|:---|:---| +|[`ServiceStatus`](#ServiceStatus)| [`ListLocks`](#ListLocks)| [`ListObjectsHeal`](#ListObjectsHeal)|[`GetConfig`](#GetConfig)| [`SetCredentials`](#SetCredentials)| +|[`ServiceRestart`](#ServiceRestart)| [`ClearLocks`](#ClearLocks)| [`ListBucketsHeal`](#ListBucketsHeal)||| +| | |[`HealBucket`](#HealBucket) ||| +| | |[`HealObject`](#HealObject)||| +| | |[`HealFormat`](#HealFormat)||| ## 1. Constructor @@ -82,9 +82,9 @@ Fetch service status, replies disk space used, backend type and total disks offl | Param | Type | Description | |---|---|---| -|`backend.Type` | _BackendType_ | Type of backend used by the server currently only FS or XL. | -|`backend.OnlineDisks`| _int_ | Total number of disks online (only applies to XL backend), is empty for FS. | -|`backend.OfflineDisks` | _int_ | Total number of disks offline (only applies to XL backend), is empty for FS. | +|`backend.Type` | _BackendType_ | Type of backend used by the server currently only FS or Erasure. | +|`backend.OnlineDisks`| _int_ | Total number of disks online (only applies to Erasure backend), is empty for FS. | +|`backend.OfflineDisks` | _int_ | Total number of disks offline (only applies to Erasure backend), is empty for FS. | |`backend.ReadQuorum` | _int_ | Current total read quorum threshold before reads will be unavailable, is empty for FS. | |`backend.WriteQuorum` | _int_ | Current total write quorum threshold before writes will be unavailable, is empty for FS. | @@ -119,6 +119,9 @@ If successful restarts the running minio service, for distributed setup restarts log.Printf("Success") ``` + +## 3. Lock operations + ### ListLocks(bucket, prefix string, duration time.Duration) ([]VolumeLockInfo, error) If successful returns information on the list of locks held on ``bucket`` matching ``prefix`` for longer than ``duration`` seconds. @@ -149,6 +152,8 @@ __Example__ ``` +## 4. Heal operations + ### ListObjectsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan ObjectInfo, error) If successful returns information on the list of objects that need healing in ``bucket`` matching ``prefix``. @@ -272,3 +277,47 @@ __Example__ log.Println("successfully healed storage format on available disks.") ``` + +## 5. Config operations + + +### GetConfig() ([]byte, error) +Get config.json of a minio setup. + +__Example__ + +``` go + configBytes, err := madmClnt.GetConfig() + if err != nil { + log.Fatalf("failed due to: %v", err) + } + + // Pretty-print config received as json. + var buf bytes.Buffer + err = json.Indent(buf, configBytes, "", "\t") + if err != nil { + log.Fatalf("failed due to: %v", err) + } + + log.Println("config received successfully: ", string(buf.Bytes())) +``` + +## 6. Misc operations + + + +### SetCredentials() error +Set new credentials of a Minio setup. + +__Example__ + +``` go + err = madmClnt.SetCredentials("YOUR-NEW-ACCESSKEY", "YOUR-NEW-SECRETKEY") + if err != nil { + log.Fatalln(err) + } + log.Println("New credentials successfully set.") + +``` + + diff --git a/vendor/github.com/minio/minio/pkg/madmin/config-commands.go b/vendor/github.com/minio/minio/pkg/madmin/config-commands.go new file mode 100644 index 00000000..2e839bac --- /dev/null +++ b/vendor/github.com/minio/minio/pkg/madmin/config-commands.go @@ -0,0 +1,49 @@ +/* + * Minio Cloud Storage, (C) 2017 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 madmin + +import ( + "io/ioutil" + "net/http" + "net/url" +) + +// GetConfig - returns the config.json of a minio setup. +func (adm *AdminClient) GetConfig() ([]byte, error) { + queryVal := make(url.Values) + queryVal.Set("config", "") + + hdrs := make(http.Header) + hdrs.Set(minioAdminOpHeader, "get") + + reqData := requestData{ + queryValues: queryVal, + customHeaders: hdrs, + } + + // Execute GET on /?lock to list locks. + resp, err := adm.executeMethod("GET", reqData) + + defer closeResponse(resp) + if err != nil { + return nil, err + } + + // Return the JSON marshalled bytes to user. + return ioutil.ReadAll(resp.Body) +} diff --git a/vendor/github.com/minio/minio/pkg/madmin/generic-commands.go b/vendor/github.com/minio/minio/pkg/madmin/generic-commands.go new file mode 100644 index 00000000..9cef9427 --- /dev/null +++ b/vendor/github.com/minio/minio/pkg/madmin/generic-commands.go @@ -0,0 +1,72 @@ +/* + * Minio Cloud Storage, (C) 2016, 2017 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 madmin + +import ( + "bytes" + "encoding/xml" + "errors" + "net/http" + "net/url" +) + +// setCredsReq - xml to send to the server to set new credentials +type setCredsReq struct { + Username string `xml:"username"` + Password string `xml:"password"` +} + +// SetCredentials - Call Set Credentials API to set new access and secret keys in the specified Minio server +func (adm *AdminClient) SetCredentials(access, secret string) error { + + // Disallow sending with the server if the connection is not secure + if !adm.secure { + return errors.New("setting new credentials requires HTTPS connection to the server") + } + + // Setup new request + reqData := requestData{} + reqData.queryValues = make(url.Values) + reqData.queryValues.Set("service", "") + reqData.customHeaders = make(http.Header) + reqData.customHeaders.Set(minioAdminOpHeader, "set-credentials") + + // Setup request's body + body, err := xml.Marshal(setCredsReq{Username: access, Password: secret}) + if err != nil { + return err + } + reqData.contentBody = bytes.NewReader(body) + reqData.contentLength = int64(len(body)) + reqData.contentMD5Bytes = sumMD5(body) + reqData.contentSHA256Bytes = sum256(body) + + // Execute GET on bucket to list objects. + resp, err := adm.executeMethod("POST", reqData) + + defer closeResponse(resp) + if err != nil { + return err + } + + // Return error to the caller if http response code is different from 200 + if resp.StatusCode != http.StatusOK { + return httpRespToErrorResponse(resp) + } + return nil +} diff --git a/vendor/github.com/minio/minio/pkg/madmin/info-commands.go b/vendor/github.com/minio/minio/pkg/madmin/info-commands.go new file mode 100644 index 00000000..1c41fdf8 --- /dev/null +++ b/vendor/github.com/minio/minio/pkg/madmin/info-commands.go @@ -0,0 +1,119 @@ +/* + * Minio Cloud Storage, (C) 2017 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 madmin + +import ( + "encoding/json" + "io/ioutil" + "net/http" + "net/url" + "time" +) + +// BackendType - represents different backend types. +type BackendType int + +// Enum for different backend types. +const ( + Unknown BackendType = iota + // Filesystem backend. + FS + // Multi disk Erasure (single, distributed) backend. + Erasure + + // Add your own backend. +) + +// StorageInfo - represents total capacity of underlying storage. +type StorageInfo struct { + // Total disk space. + Total int64 + // Free available disk space. + Free int64 + // Backend type. + Backend struct { + // Represents various backend types, currently on FS and Erasure. + Type BackendType + + // Following fields are only meaningful if BackendType is Erasure. + OnlineDisks int // Online disks during server startup. + OfflineDisks int // Offline disks during server startup. + ReadQuorum int // Minimum disks required for successful read operations. + WriteQuorum int // Minimum disks required for successful write operations. + } +} + +// ServerProperties holds some of the server's information such as uptime, +// version, region, .. +type ServerProperties struct { + Uptime time.Duration `json:"uptime"` + Version string `json:"version"` + CommitID string `json:"commitID"` + Region string `json:"region"` + SQSARN []string `json:"sqsARN"` +} + +// ServerConnStats holds network information +type ServerConnStats struct { + TotalInputBytes uint64 `json:"transferred"` + TotalOutputBytes uint64 `json:"received"` +} + +// ServerInfo holds the whole server information that will be +// returned by ServerInfo API. +type ServerInfo struct { + StorageInfo StorageInfo `json:"storage"` + ConnStats ServerConnStats `json:"network"` + Properties ServerProperties `json:"server"` +} + +// ServerInfo - Connect to a minio server and call Server Info Management API +// to fetch server's information represented by ServerInfo structure +func (adm *AdminClient) ServerInfo() (ServerInfo, error) { + // Prepare web service request + reqData := requestData{} + reqData.queryValues = make(url.Values) + reqData.queryValues.Set("info", "") + reqData.customHeaders = make(http.Header) + + resp, err := adm.executeMethod("GET", reqData) + defer closeResponse(resp) + if err != nil { + return ServerInfo{}, err + } + + // Check response http status code + if resp.StatusCode != http.StatusOK { + return ServerInfo{}, httpRespToErrorResponse(resp) + } + + // Unmarshal the server's json response + var info ServerInfo + + respBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return ServerInfo{}, err + } + + err = json.Unmarshal(respBytes, &info) + if err != nil { + return ServerInfo{}, err + } + + return info, nil +} diff --git a/vendor/github.com/minio/minio/pkg/madmin/service-commands.go b/vendor/github.com/minio/minio/pkg/madmin/service-commands.go index 37869cd6..62bf8cb4 100644 --- a/vendor/github.com/minio/minio/pkg/madmin/service-commands.go +++ b/vendor/github.com/minio/minio/pkg/madmin/service-commands.go @@ -1,5 +1,5 @@ /* - * Minio Cloud Storage, (C) 2016 Minio, Inc. + * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,58 +18,16 @@ package madmin import ( - "bytes" "encoding/json" - "encoding/xml" - "errors" "io/ioutil" "net/http" "net/url" + "time" ) -// BackendType - represents different backend types. -type BackendType int - -// Enum for different backend types. -const ( - Unknown BackendType = iota - // Filesystem backend. - FS - // Multi disk XL (single, distributed) backend. - XL - - // Add your own backend. -) - -// StorageInfo - represents total capacity of underlying storage. -type StorageInfo struct { - // Total disk space. - Total int64 - // Free available disk space. - Free int64 - // Backend type. - Backend struct { - // Represents various backend types, currently on FS and XL. - Type BackendType - - // Following fields are only meaningful if BackendType is XL. - OnlineDisks int // Online disks during server startup. - OfflineDisks int // Offline disks during server startup. - ReadQuorum int // Minimum disks required for successful read operations. - WriteQuorum int // Minimum disks required for successful write operations. - } -} - -// 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"` + Uptime time.Duration `json:"uptime"` } // ServiceStatus - Connect to a minio server and call Service Status Management API @@ -133,49 +91,3 @@ func (adm *AdminClient) ServiceRestart() error { } return nil } - -// setCredsReq - xml to send to the server to set new credentials -type setCredsReq struct { - Username string `xml:"username"` - Password string `xml:"password"` -} - -// ServiceSetCredentials - Call Service Set Credentials API to set new access and secret keys in the specified Minio server -func (adm *AdminClient) ServiceSetCredentials(access, secret string) error { - - // Disallow sending with the server if the connection is not secure - if !adm.secure { - return errors.New("setting new credentials requires HTTPS connection to the server") - } - - // Setup new request - reqData := requestData{} - reqData.queryValues = make(url.Values) - reqData.queryValues.Set("service", "") - reqData.customHeaders = make(http.Header) - reqData.customHeaders.Set(minioAdminOpHeader, "set-credentials") - - // Setup request's body - body, err := xml.Marshal(setCredsReq{Username: access, Password: secret}) - if err != nil { - return err - } - reqData.contentBody = bytes.NewReader(body) - reqData.contentLength = int64(len(body)) - reqData.contentMD5Bytes = sumMD5(body) - reqData.contentSHA256Bytes = sum256(body) - - // Execute GET on bucket to list objects. - resp, err := adm.executeMethod("POST", reqData) - - defer closeResponse(resp) - if err != nil { - return err - } - - // Return error to the caller if http response code is different from 200 - if resp.StatusCode != http.StatusOK { - return httpRespToErrorResponse(resp) - } - return nil -} diff --git a/vendor/vendor.json b/vendor/vendor.json index 54d98eea..3cff1eba 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -80,10 +80,10 @@ "revisionTime": "2016-08-18T00:31:20Z" }, { - "checksumSHA1": "/sSaCssOzqtaSoIFhV0V8SPW5nk=", + "checksumSHA1": "YXWc03D9uOm36IsMc5jNVFrtgY4=", "path": "github.com/minio/minio/pkg/madmin", - "revision": "f612a7dd8574ed98ac30ca0f3758f49fa5369635", - "revisionTime": "2017-02-01T19:46:49Z" + "revision": "f170f7b9d828ebc59b5cc53be1b7a997c87ea8dd", + "revisionTime": "2017-02-25T15:19:50Z" }, { "path": "github.com/minio/minio/pkg/probe",