forked from rook/rook
Refactor rook tool so each command has its own package
This commit is contained in:
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
@@ -21,17 +21,17 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var blockCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "block",
|
||||
Short: "Performs commands and operations on block devices and images in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockCmd.AddCommand(blockListCmd)
|
||||
blockCmd.AddCommand(blockCreateCmd)
|
||||
Cmd.AddCommand(listCmd)
|
||||
Cmd.AddCommand(createCmd)
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
blockCmd.AddCommand(blockMountCmd)
|
||||
blockCmd.AddCommand(blockUnmountCmd)
|
||||
Cmd.AddCommand(mountCmd)
|
||||
Cmd.AddCommand(unmountCmd)
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
@@ -23,10 +23,10 @@ import (
|
||||
)
|
||||
|
||||
func TestBlockCommand(t *testing.T) {
|
||||
assert.Equal(t, "block", blockCmd.Use)
|
||||
assert.Equal(t, "block", Cmd.Use)
|
||||
|
||||
commands := []string{}
|
||||
for _, command := range blockCmd.Commands() {
|
||||
for _, command := range Cmd.Commands() {
|
||||
commands = append(commands, command.Name())
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
@@ -32,22 +33,24 @@ var (
|
||||
newImageSize uint64
|
||||
)
|
||||
|
||||
var blockCreateCmd = &cobra.Command{
|
||||
var createCmd = &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Creates a new block image in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockCreateCmd.Flags().StringVar(&newImageName, "name", "", "Name of new block image to create (required)")
|
||||
blockCreateCmd.Flags().StringVar(&newImagePoolName, "pool-name", "rbd", "Name of storage pool to create new block image in")
|
||||
blockCreateCmd.Flags().Uint64Var(&newImageSize, "size", 0, "Size in bytes of the new block image to create (required)")
|
||||
createCmd.Flags().StringVar(&newImageName, "name", "", "Name of new block image to create (required)")
|
||||
createCmd.Flags().StringVar(&newImagePoolName, "pool-name", "rbd", "Name of storage pool to create new block image in")
|
||||
createCmd.Flags().Uint64Var(&newImageSize, "size", 0, "Size in bytes of the new block image to create (required)")
|
||||
|
||||
blockCreateCmd.MarkFlagRequired("name")
|
||||
blockCreateCmd.MarkFlagRequired("size")
|
||||
blockCreateCmd.RunE = createBlockImagesEntry
|
||||
createCmd.MarkFlagRequired("name")
|
||||
createCmd.MarkFlagRequired("size")
|
||||
createCmd.RunE = createBlockImagesEntry
|
||||
}
|
||||
|
||||
func createBlockImagesEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name"}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -56,7 +59,7 @@ func createBlockImagesEntry(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := createBlockImage(newImageName, newImagePoolName, newImageSize, c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/display"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
@@ -31,21 +32,23 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var blockListCmd = &cobra.Command{
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "ls",
|
||||
Short: "Gets a listing with details of all block images in the cluster and their locally mapped devices",
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockListCmd.RunE = listBlocksEntry
|
||||
listCmd.RunE = listBlocksEntry
|
||||
}
|
||||
|
||||
func listBlocksEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
e := &exec.CommandExecutor{}
|
||||
out, err := listBlocks(rbdSysBusPathDefault, c, e)
|
||||
if err != nil {
|
||||
@@ -86,7 +89,7 @@ func listBlocks(rbdSysBusPath string, c client.RookRestClient, executor exec.Exe
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
w := NewTableWriter(&buffer)
|
||||
w := rook.NewTableWriter(&buffer)
|
||||
|
||||
fmt.Fprintln(w, "NAME\tPOOL\tSIZE\tDEVICE\tMOUNT")
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
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 block
|
||||
|
||||
import "github.com/coreos/pkg/capnslog"
|
||||
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "rookblock")
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -24,6 +24,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
rc "github.com/rook/rook/cmd/rook/client"
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
@@ -51,28 +53,30 @@ var (
|
||||
mountImagePath string
|
||||
)
|
||||
|
||||
var blockMountCmd = &cobra.Command{
|
||||
var mountCmd = &cobra.Command{
|
||||
Use: "mount",
|
||||
Short: "Mounts a block image from the cluster as a local block device with the given file system path",
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockMountCmd.Flags().StringVar(&mountImageName, "name", "", "Name of block image to mount (required)")
|
||||
blockMountCmd.Flags().StringVar(&mountImagePoolName, "pool-name", "rbd", "Name of storage pool that contains block image to mount")
|
||||
blockMountCmd.Flags().StringVar(&mountImagePath, "path", "", "File system path to mount block device on (required)")
|
||||
mountCmd.Flags().StringVar(&mountImageName, "name", "", "Name of block image to mount (required)")
|
||||
mountCmd.Flags().StringVar(&mountImagePoolName, "pool-name", "rbd", "Name of storage pool that contains block image to mount")
|
||||
mountCmd.Flags().StringVar(&mountImagePath, "path", "", "File system path to mount block device on (required)")
|
||||
|
||||
blockMountCmd.MarkFlagRequired("name")
|
||||
blockMountCmd.MarkFlagRequired("path")
|
||||
mountCmd.MarkFlagRequired("name")
|
||||
mountCmd.MarkFlagRequired("path")
|
||||
|
||||
blockMountCmd.RunE = mountBlockEntry
|
||||
mountCmd.RunE = mountBlockEntry
|
||||
}
|
||||
|
||||
func mountBlockEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name", "path"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
e := &exec.CommandExecutor{}
|
||||
out, err := mountBlock(mountImageName, mountImagePoolName, mountImagePath, rbdSysBusPathDefault, c, e)
|
||||
if err != nil {
|
||||
@@ -145,11 +149,11 @@ func mountBlock(name, poolName, mountPoint, rbdSysBusPath string, c client.RookR
|
||||
}
|
||||
|
||||
func getRBDAddData(name, poolName string, clientAccessInfo model.ClientAccessInfo) (string, error) {
|
||||
if err := verifyClientAccessInfo(clientAccessInfo); err != nil {
|
||||
if err := rc.VerifyClientAccessInfo(clientAccessInfo); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
monAddrs := processMonAddresses(clientAccessInfo)
|
||||
monAddrs := rc.ProcessMonAddresses(clientAccessInfo)
|
||||
|
||||
// mon address list (comma separated), user name, secret, pool name, image name
|
||||
rbdAddData := fmt.Sprintf(
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
"github.com/rook/rook/pkg/util/sys"
|
||||
@@ -32,19 +33,21 @@ var (
|
||||
unmountPath string
|
||||
)
|
||||
|
||||
var blockUnmountCmd = &cobra.Command{
|
||||
var unmountCmd = &cobra.Command{
|
||||
Use: "unmount",
|
||||
Short: "Unmounts and destroys a block device from the local machine",
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockUnmountCmd.Flags().StringVar(&unmountDeviceName, "device", "", "Name of device to unmount (e.g., rbd0)")
|
||||
blockUnmountCmd.Flags().StringVar(&unmountPath, "path", "", "File system path to unmount")
|
||||
unmountCmd.Flags().StringVar(&unmountDeviceName, "device", "", "Name of device to unmount (e.g., rbd0)")
|
||||
unmountCmd.Flags().StringVar(&unmountPath, "path", "", "File system path to unmount")
|
||||
|
||||
blockUnmountCmd.RunE = unmountBlockEntry
|
||||
unmountCmd.RunE = unmountBlockEntry
|
||||
}
|
||||
|
||||
func unmountBlockEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package block
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/rook/rook/pkg/model"
|
||||
)
|
||||
|
||||
func verifyClientAccessInfo(clientAccessInfo model.ClientAccessInfo) error {
|
||||
func VerifyClientAccessInfo(clientAccessInfo model.ClientAccessInfo) error {
|
||||
if clientAccessInfo.MonAddresses == nil || len(clientAccessInfo.MonAddresses) == 0 {
|
||||
return fmt.Errorf("missing mon addresses: %+v", clientAccessInfo)
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func verifyClientAccessInfo(clientAccessInfo model.ClientAccessInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func processMonAddresses(clientAccessInfo model.ClientAccessInfo) []string {
|
||||
func ProcessMonAddresses(clientAccessInfo model.ClientAccessInfo) []string {
|
||||
monAddrs := make([]string, len(clientAccessInfo.MonAddresses))
|
||||
for i, addr := range clientAccessInfo.MonAddresses {
|
||||
lastIndex := strings.LastIndex(addr, "/")
|
||||
@@ -13,13 +13,14 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
@@ -30,24 +31,26 @@ var (
|
||||
newFilesystemName string
|
||||
)
|
||||
|
||||
var filesystemCreateCmd = &cobra.Command{
|
||||
var createCmd = &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Creates a new shared filesystem in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemCreateCmd.Flags().StringVarP(&newFilesystemName, "name", "n", "", "Name of new filesystem to create (required)")
|
||||
createCmd.Flags().StringVarP(&newFilesystemName, "name", "n", "", "Name of new filesystem to create (required)")
|
||||
|
||||
filesystemCreateCmd.MarkFlagRequired("name")
|
||||
filesystemCreateCmd.RunE = createFilesystemEntry
|
||||
createCmd.MarkFlagRequired("name")
|
||||
createCmd.RunE = createFilesystemEntry
|
||||
}
|
||||
|
||||
func createFilesystemEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := createFilesystem(newFilesystemName, c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,13 +13,14 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
@@ -30,24 +31,26 @@ var (
|
||||
deleteFilesystemName string
|
||||
)
|
||||
|
||||
var filesystemDeleteCmd = &cobra.Command{
|
||||
var deleteCmd = &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Deletes a shared filesystem from the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemDeleteCmd.Flags().StringVarP(&deleteFilesystemName, "name", "n", "", "Name of filesystem to delete (required)")
|
||||
deleteCmd.Flags().StringVarP(&deleteFilesystemName, "name", "n", "", "Name of filesystem to delete (required)")
|
||||
|
||||
filesystemDeleteCmd.MarkFlagRequired("name")
|
||||
filesystemDeleteCmd.RunE = deleteFilesystemEntry
|
||||
deleteCmd.MarkFlagRequired("name")
|
||||
deleteCmd.RunE = deleteFilesystemEntry
|
||||
}
|
||||
|
||||
func deleteFilesystemEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := deleteFilesystem(deleteFilesystemName, c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,20 +13,20 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var filesystemCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "filesystem",
|
||||
Aliases: []string{"fs"},
|
||||
Short: "Performs commands and operations on shared filesystems in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemCmd.AddCommand(filesystemListCmd)
|
||||
filesystemCmd.AddCommand(filesystemCreateCmd)
|
||||
filesystemCmd.AddCommand(filesystemMountCmd)
|
||||
filesystemCmd.AddCommand(filesystemUnmountCmd)
|
||||
filesystemCmd.AddCommand(filesystemDeleteCmd)
|
||||
Cmd.AddCommand(listCmd)
|
||||
Cmd.AddCommand(createCmd)
|
||||
Cmd.AddCommand(mountCmd)
|
||||
Cmd.AddCommand(unmountCmd)
|
||||
Cmd.AddCommand(deleteCmd)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -22,26 +22,29 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var filesystemListCmd = &cobra.Command{
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "ls",
|
||||
Short: "Gets a listing with details of all shared file systems in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemListCmd.RunE = listFilesystemEntry
|
||||
listCmd.RunE = listFilesystemEntry
|
||||
}
|
||||
|
||||
func listFilesystemEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := listFilesystems(c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -63,7 +66,7 @@ func listFilesystems(c client.RookRestClient) (string, error) {
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
w := NewTableWriter(&buffer)
|
||||
w := rook.NewTableWriter(&buffer)
|
||||
|
||||
fmt.Fprintln(w, "NAME\tMETADATA POOL\tDATA POOLS")
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
rc "github.com/rook/rook/cmd/rook/client"
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
@@ -33,26 +35,28 @@ var (
|
||||
mountFilesystemPath string
|
||||
)
|
||||
|
||||
var filesystemMountCmd = &cobra.Command{
|
||||
var mountCmd = &cobra.Command{
|
||||
Use: "mount",
|
||||
Short: "Mounts a shared filesystem from the cluster to the given local mount point",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemMountCmd.Flags().StringVarP(&mountFilesystemName, "name", "n", "", "Name of filesystem to mount (required)")
|
||||
filesystemMountCmd.Flags().StringVarP(&mountFilesystemPath, "path", "p", "", "Path to mount shared filesystem (required)")
|
||||
mountCmd.Flags().StringVarP(&mountFilesystemName, "name", "n", "", "Name of filesystem to mount (required)")
|
||||
mountCmd.Flags().StringVarP(&mountFilesystemPath, "path", "p", "", "Path to mount shared filesystem (required)")
|
||||
|
||||
filesystemMountCmd.MarkFlagRequired("name")
|
||||
filesystemMountCmd.MarkFlagRequired("path")
|
||||
filesystemMountCmd.RunE = mountFilesystemEntry
|
||||
mountCmd.MarkFlagRequired("name")
|
||||
mountCmd.MarkFlagRequired("path")
|
||||
mountCmd.RunE = mountFilesystemEntry
|
||||
}
|
||||
|
||||
func mountFilesystemEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name", "path"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
e := &exec.CommandExecutor{}
|
||||
out, err := mountFilesystem(mountFilesystemName, mountFilesystemPath, c, e)
|
||||
if err != nil {
|
||||
@@ -70,11 +74,11 @@ func mountFilesystem(name, path string, c client.RookRestClient, executor exec.E
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err := verifyClientAccessInfo(clientAccessInfo); err != nil {
|
||||
if err := rc.VerifyClientAccessInfo(clientAccessInfo); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
monAddrs := processMonAddresses(clientAccessInfo)
|
||||
monAddrs := rc.ProcessMonAddresses(clientAccessInfo)
|
||||
devicePath := strings.Join(monAddrs, ",") + ":/"
|
||||
options := fmt.Sprintf("name=%s,secret=%s", clientAccessInfo.UserName, clientAccessInfo.SecretKey)
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,12 +13,13 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
"github.com/rook/rook/pkg/util/sys"
|
||||
@@ -29,20 +30,22 @@ var (
|
||||
unmountFilesystemPath string
|
||||
)
|
||||
|
||||
var filesystemUnmountCmd = &cobra.Command{
|
||||
var unmountCmd = &cobra.Command{
|
||||
Use: "unmount",
|
||||
Aliases: []string{"umount"},
|
||||
Short: "Unmounts a shared filesystem from its local mount point (data is still persisted in the cluster)",
|
||||
}
|
||||
|
||||
func init() {
|
||||
filesystemUnmountCmd.Flags().StringVarP(&unmountFilesystemPath, "path", "p", "", "Path to unmount shared filesystem from (required)")
|
||||
unmountCmd.Flags().StringVarP(&unmountFilesystemPath, "path", "p", "", "Path to unmount shared filesystem from (required)")
|
||||
|
||||
filesystemUnmountCmd.MarkFlagRequired("path")
|
||||
filesystemUnmountCmd.RunE = unmountFilesystemEntry
|
||||
unmountCmd.MarkFlagRequired("path")
|
||||
unmountCmd.RunE = unmountFilesystemEntry
|
||||
}
|
||||
|
||||
func unmountFilesystemEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"path"}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
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 rookmain
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/block"
|
||||
"github.com/rook/rook/cmd/rook/filesystem"
|
||||
"github.com/rook/rook/cmd/rook/node"
|
||||
"github.com/rook/rook/cmd/rook/pool"
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/cmd/rook/status"
|
||||
"github.com/rook/rook/cmd/rook/version"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
addCommands()
|
||||
if err := rook.RootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func addCommands() {
|
||||
rook.RootCmd.AddCommand(node.Cmd)
|
||||
rook.RootCmd.AddCommand(pool.Cmd)
|
||||
rook.RootCmd.AddCommand(block.Cmd)
|
||||
rook.RootCmd.AddCommand(filesystem.Cmd)
|
||||
rook.RootCmd.AddCommand(status.Cmd)
|
||||
rook.RootCmd.AddCommand(version.Cmd)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package node
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -21,25 +21,28 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/display"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeListCmd = &cobra.Command{
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "ls",
|
||||
Short: "Gets a listing with details of all nodes in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
nodeListCmd.RunE = listNodesEntry
|
||||
listCmd.RunE = listNodesEntry
|
||||
}
|
||||
|
||||
func listNodesEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
// verify required flags. currently there are none
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := listNodes(c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -61,7 +64,7 @@ func listNodes(c client.RookRestClient) (string, error) {
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
w := NewTableWriter(&buffer)
|
||||
w := rook.NewTableWriter(&buffer)
|
||||
|
||||
// write header columns
|
||||
fmt.Fprintln(w, "PUBLIC\tPRIVATE\tSTATE\tCLUSTER\tSIZE\tLOCATION\tUPDATED\t")
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,15 +13,15 @@ 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 rook
|
||||
package node
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var nodeCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "node",
|
||||
Short: "Performs commands and operations on nodes in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
nodeCmd.AddCommand(nodeListCmd)
|
||||
Cmd.AddCommand(listCmd)
|
||||
}
|
||||
@@ -13,13 +13,14 @@ 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 rook
|
||||
package pool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/flags"
|
||||
@@ -39,37 +40,39 @@ var (
|
||||
newPoolCodingChunks uint
|
||||
)
|
||||
|
||||
var poolCreateCmd = &cobra.Command{
|
||||
var createCmd = &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Creates a new storage pool in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
poolCreateCmd.Flags().StringVarP(&newPoolName, "name", "n", "", "Name of new storage pool to create (required)")
|
||||
createCmd.Flags().StringVarP(&newPoolName, "name", "n", "", "Name of new storage pool to create (required)")
|
||||
|
||||
poolCreateCmd.Flags().StringVarP(&newPoolType, "type", "t", PoolTypeReplicated,
|
||||
createCmd.Flags().StringVarP(&newPoolType, "type", "t", PoolTypeReplicated,
|
||||
fmt.Sprintf("Type of storage pool, '%s' or '%s' (required)", PoolTypeReplicated, PoolTypeErasureCoded))
|
||||
|
||||
poolCreateCmd.Flags().UintVarP(&newPoolReplicaCount, "replica-count", "r", 0,
|
||||
createCmd.Flags().UintVarP(&newPoolReplicaCount, "replica-count", "r", 0,
|
||||
fmt.Sprintf("Number of copies per object in a replicated storage pool, including the object itself (required for %s pool type)", PoolTypeReplicated))
|
||||
|
||||
poolCreateCmd.Flags().UintVarP(&newPoolDataChunks, "ec-data-chunks", "d", 0,
|
||||
createCmd.Flags().UintVarP(&newPoolDataChunks, "ec-data-chunks", "d", 0,
|
||||
fmt.Sprintf("Number of data chunks per object in an erasure coded storage pool (required for %s pool type)", PoolTypeErasureCoded))
|
||||
|
||||
poolCreateCmd.Flags().UintVarP(&newPoolCodingChunks, "ec-coding-chunks", "c", 0,
|
||||
createCmd.Flags().UintVarP(&newPoolCodingChunks, "ec-coding-chunks", "c", 0,
|
||||
fmt.Sprintf("Number of coding chunks per object in an erasure coded storage pool (required for %s pool type)", PoolTypeErasureCoded))
|
||||
|
||||
poolCreateCmd.MarkFlagRequired("name")
|
||||
poolCreateCmd.MarkFlagRequired("type")
|
||||
poolCreateCmd.RunE = createPoolsEntry
|
||||
createCmd.MarkFlagRequired("name")
|
||||
createCmd.MarkFlagRequired("type")
|
||||
createCmd.RunE = createPoolsEntry
|
||||
}
|
||||
|
||||
func createPoolsEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{"name", "type"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := createPool(newPoolName, newPoolType, newPoolReplicaCount, newPoolDataChunks, newPoolCodingChunks, c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package pool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package pool
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/display"
|
||||
@@ -28,21 +29,23 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var poolListCmd = &cobra.Command{
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "ls",
|
||||
Short: "Gets a listing with details of all storage pools in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
poolListCmd.RunE = listPoolsEntry
|
||||
listCmd.RunE = listPoolsEntry
|
||||
}
|
||||
|
||||
func listPoolsEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
if err := flags.VerifyRequiredFlags(cmd, []string{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := listPools(c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -64,7 +67,7 @@ func listPools(c client.RookRestClient) (string, error) {
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
w := NewTableWriter(&buffer)
|
||||
w := rook.NewTableWriter(&buffer)
|
||||
|
||||
fmt.Fprintln(w, "NAME\tNUMBER\tTYPE\tSIZE\tDATA\tCODING\tALGORITHM")
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package pool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -13,16 +13,16 @@ 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 rook
|
||||
package pool
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var poolCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "pool",
|
||||
Short: "Performs commands and operations on storage pools in the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
poolCmd.AddCommand(poolListCmd)
|
||||
poolCmd.AddCommand(poolCreateCmd)
|
||||
Cmd.AddCommand(listCmd)
|
||||
Cmd.AddCommand(createCmd)
|
||||
}
|
||||
@@ -26,7 +26,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
apiServerEndpoint string
|
||||
APIServerEndpoint string
|
||||
logLevelRaw string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -36,23 +37,20 @@ const (
|
||||
outputPadChar = ' '
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "rook",
|
||||
Short: "A command line client for working with a rook cluster",
|
||||
Long: `https://github.com/rook/rook`,
|
||||
}
|
||||
|
||||
var logLevelRaw string
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "rook")
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringVar(&apiServerEndpoint, "api-server-endpoint", "127.0.0.1:8124", "IP endpoint of API server instance (required)")
|
||||
rootCmd.PersistentFlags().StringVar(&logLevelRaw, "log-level", "WARNING", "logging level for logging/tracing output (valid values: CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,TRACE)")
|
||||
RootCmd.PersistentFlags().StringVar(&APIServerEndpoint, "api-server-endpoint", "127.0.0.1:8124", "IP endpoint of API server instance (required)")
|
||||
RootCmd.PersistentFlags().StringVar(&logLevelRaw, "log-level", "WARNING", "logging level for logging/tracing output (valid values: CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,TRACE)")
|
||||
|
||||
rootCmd.MarkFlagRequired("api-server-endpoint")
|
||||
RootCmd.MarkFlagRequired("api-server-endpoint")
|
||||
}
|
||||
|
||||
func Main() {
|
||||
func SetupLogging() {
|
||||
// parse the given log level and set it at a global level
|
||||
logLevel, err := capnslog.ParseLevel(logLevelRaw)
|
||||
if err != nil {
|
||||
@@ -60,21 +58,6 @@ func Main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
capnslog.SetGlobalLogLevel(logLevel)
|
||||
|
||||
addCommands()
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func addCommands() {
|
||||
rootCmd.AddCommand(nodeCmd)
|
||||
rootCmd.AddCommand(poolCmd)
|
||||
rootCmd.AddCommand(blockCmd)
|
||||
rootCmd.AddCommand(filesystemCmd)
|
||||
rootCmd.AddCommand(statusCmd)
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
func NewTableWriter(buffer io.Writer) *tabwriter.Writer {
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package status
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -21,24 +21,26 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rook/rook/cmd/rook/rook"
|
||||
"github.com/rook/rook/pkg/model"
|
||||
"github.com/rook/rook/pkg/rook/client"
|
||||
"github.com/rook/rook/pkg/util/display"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "Outputs a summary of the status of the cluster",
|
||||
}
|
||||
|
||||
func init() {
|
||||
statusCmd.RunE = getStatusEntry
|
||||
Cmd.RunE = getStatusEntry
|
||||
}
|
||||
|
||||
func getStatusEntry(cmd *cobra.Command, args []string) error {
|
||||
rook.SetupLogging()
|
||||
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(apiServerEndpoint), http.DefaultClient)
|
||||
c := client.NewRookNetworkRestClient(client.GetRestURL(rook.APIServerEndpoint), http.DefaultClient)
|
||||
out, err := getStatus(c)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@@ -56,7 +58,7 @@ func getStatus(c client.RookRestClient) (string, error) {
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
w := NewTableWriter(&buffer)
|
||||
w := rook.NewTableWriter(&buffer)
|
||||
|
||||
// overall status
|
||||
buffer.WriteString(fmt.Sprintf("OVERALL STATUS: %s\n", model.HealthStatusToString(statusDetails.OverallStatus)))
|
||||
@@ -13,7 +13,7 @@ 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 rook
|
||||
package status
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,4 +1,4 @@
|
||||
package rook
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version number of rookd",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Reference in New Issue
Block a user