rook: remove block mount and unmount on mac

Block mount and unmount is not supported and will error so I've removed it from the rook client (only on mac) for now.
This commit is contained in:
Michael Goff committed 2016-11-18 10:21:19 -08:00
1 parent 25bede2162
commit e804c5f778
4 files changed
+70 -17

No files matched your search

+15 -12
View File
@@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
"os"
"runtime"
"strings"
"github.com/rook/rook/pkg/rook/client"
@@ -66,20 +67,22 @@ func listBlocks(rbdSysBusPath string, c client.RookRestClient, executor exec.Exe
return "", nil
}
// for each image returned from the client API call, look up local details
for i := range images {
image := &(images[i])
if runtime.GOOS == "linux" {
// for each image returned from the client API call, look up local details
for i := range images {
image := &(images[i])
// look up local device and mount point, ignoring errors
devPath, _ := findDevicePath(image.Name, image.PoolName, rbdSysBusPath)
dev := strings.TrimPrefix(devPath, devicePathPrefix)
var mountPoint string
if dev != "" {
mountPoint, _ = sys.GetDeviceMountPoint(dev, executor)
// look up local device and mount point, ignoring errors
devPath, _ := findDevicePath(image.Name, image.PoolName, rbdSysBusPath)
dev := strings.TrimPrefix(devPath, devicePathPrefix)
var mountPoint string
if dev != "" {
mountPoint, _ = sys.GetDeviceMountPoint(dev, executor)
}
image.Device = dev
image.MountPoint = mountPoint
}
image.Device = dev
image.MountPoint = mountPoint
}
var buffer bytes.Buffer
+7 -2
View File
@@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
@@ -58,8 +59,12 @@ func TestListBlockImages(t *testing.T) {
out, err := listBlocks(mockRBDSysBusPath, c, e)
assert.Nil(t, err)
expectedOut := "NAME POOL SIZE DEVICE MOUNT\n" +
"myimage1 mypool1 1.00 KiB rbd5 /tmp/mymount1\n"
expectedOut := "NAME POOL SIZE DEVICE MOUNT\n"
if runtime.GOOS == "linux" {
expectedOut += "myimage1 mypool1 1.00 KiB rbd5 /tmp/mymount1\n"
} else {
expectedOut += "myimage1 mypool1 1.00 KiB \n"
}
assert.Equal(t, expectedOut, out)
}
+10 -3
View File
@@ -15,7 +15,11 @@ limitations under the License.
*/
package rook
import "github.com/spf13/cobra"
import (
"runtime"
"github.com/spf13/cobra"
)
var blockCmd = &cobra.Command{
Use: "block",
@@ -25,6 +29,9 @@ var blockCmd = &cobra.Command{
func init() {
blockCmd.AddCommand(blockListCmd)
blockCmd.AddCommand(blockCreateCmd)
blockCmd.AddCommand(blockMountCmd)
blockCmd.AddCommand(blockUnmountCmd)
if runtime.GOOS == "linux" {
blockCmd.AddCommand(blockMountCmd)
blockCmd.AddCommand(blockUnmountCmd)
}
}
+38
View File
@@ -0,0 +1,38 @@
/*
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 rook
import (
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBlockCommand(t *testing.T) {
assert.Equal(t, "block", blockCmd.Use)
commands := []string{}
for _, command := range blockCmd.Commands() {
commands = append(commands, command.Name())
}
if runtime.GOOS == "linux" {
assert.Equal(t, []string{"create", "ls", "mount", "unmount"}, commands)
} else {
assert.Equal(t, []string{"create", "ls"}, commands)
}
}