Skip to content

Commit

Permalink
Merge pull request #404 from akutz/feature/libstorage-part-deux
Browse files Browse the repository at this point in the history
More work for libStorage
  • Loading branch information
akutz committed May 4, 2016
2 parents 1f9a55e + 3e4be27 commit 30a3bee
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
20 changes: 15 additions & 5 deletions daemon/module/docker/volumedriver/voldriver.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/akutz/gofig"
"github.com/akutz/goof"
"github.com/akutz/gotil"
"github.com/emccode/libstorage"
"github.com/emccode/libstorage/api/context"
apitypes "github.com/emccode/libstorage/api/types"
apiutils "github.com/emccode/libstorage/api/utils"
Expand Down Expand Up @@ -62,10 +63,14 @@ func newModule(c *module.Config) (module.Module, error) {

c.Address = host

cc, err := c.Config.Copy()
/*cc, err := c.Config.Copy()
if err != nil {
return nil, err
}
}*/

// TODO The config should be copied, but it was causing an issue with
// duplicate, explicit values not being removed.
cc := c.Config

if !cc.GetBool("rexray.volume.path.disableCache") {
cc.Set("rexray.volume.path.cache", true)
Expand All @@ -75,7 +80,7 @@ func newModule(c *module.Config) (module.Module, error) {
"module", c.Name,
).WithServiceName(
cc.GetString("libstorage.service"),
)
).WithConfig(cc)

return &mod{
ctx: ctx,
Expand Down Expand Up @@ -109,9 +114,14 @@ type pluginRequest struct {

func (m *mod) Start() error {

lsc, err := apiclient.New(m.config)
m.config.SetLogLevel(log.DebugLevel)
lsc, _, err, _ := libstorage.New(m.config)

if err != nil {
return err
for k, v := range m.config.AllSettings() {
log.Errorf("%s=%v", k, v)
}
log.Fatal(err)
}
m.lsc = lsc

Expand Down
4 changes: 2 additions & 2 deletions daemon/module/module.go
Expand Up @@ -276,7 +276,7 @@ func StartModule(name string) error {

go func() {

defer func() {
/*defer func() {
r := recover()
m := "error starting module"
Expand All @@ -298,7 +298,7 @@ func StartModule(name string) error {
default:
startError <- goof.WithFields(lf, m)
}
}()
}()*/

sErr := mod.Inst.Start()
if sErr != nil {
Expand Down
3 changes: 0 additions & 3 deletions glide.yaml
Expand Up @@ -11,9 +11,6 @@ import:
- package: github.com/spf13/cobra
ref: 363816bb13ce1710460c2345017fd35593cbf5ed
repo: https://github.com/akutz/cobra
- package: github.com/spf13/viper
ref: support/rexray
repo: https://github.com/akutz/viper.git
- package: github.com/akutz/golf
ref: v0.1.1
- package: github.com/akutz/gofig
Expand Down
2 changes: 0 additions & 2 deletions rexray/cli/cli.go
Expand Up @@ -439,8 +439,6 @@ func printNonColorizedError(err error) {

func (c *CLI) isInitDriverManagersCmd(cmd *cobra.Command) bool {
return cmd.Parent() != nil &&
cmd != c.adapterCmd &&
cmd != c.adapterGetTypesCmd &&
cmd != c.versionCmd &&
cmd != c.envCmd &&
c.isServiceCmd(cmd) &&
Expand Down
23 changes: 19 additions & 4 deletions rexray/cli/cmds_adapter.go
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"fmt"
"log"
"strings"

"github.com/spf13/cobra"
)
Expand All @@ -28,12 +29,20 @@ func (c *CLI) initAdapterCmds() {

c.adapterGetTypesCmd = &cobra.Command{
Use: "types",
Short: "List the available adapter types",
Short: "List the configured services",
Aliases: []string{"ls", "list"},
Run: func(cmd *cobra.Command, args []string) {
//for n := range c.r.DriverNames() {
// fmt.Printf("Storage Driver: %v\n", n)
//}
services, err := c.r.API().Services(c.ctx)
if err != nil {
log.Fatalf("Error: %s", err)
}
if len(services) > 0 {
out, err := c.marshalOutput(&services)
if err != nil {
log.Fatal(err)
}
fmt.Println(out)
}
},
}
c.adapterCmd.AddCommand(c.adapterGetTypesCmd)
Expand All @@ -48,6 +57,11 @@ func (c *CLI) initAdapterCmds() {
log.Fatalf("Error: %s", err)
}

if strings.ToUpper(c.outputFormat) != "JSON" {
for _, i := range instances {
i.InstanceID.Metadata = nil
}
}
if len(instances) > 0 {
out, err := c.marshalOutput(&instances)
if err != nil {
Expand All @@ -61,5 +75,6 @@ func (c *CLI) initAdapterCmds() {
}

func (c *CLI) initAdapterFlags() {
c.addOutputFormatFlag(c.adapterGetTypesCmd.Flags())
c.addOutputFormatFlag(c.adapterGetInstancesCmd.Flags())
}
2 changes: 2 additions & 0 deletions rexray/cli/service.go
Expand Up @@ -59,8 +59,10 @@ func (c *CLI) start() {
}

if c.fg || c.client != "" {
log.Debug("starting in foreground")
c.startDaemon()
} else {
log.Debug("starting in background")
c.tryToStartDaemon()
}
}
Expand Down

0 comments on commit 30a3bee

Please sign in to comment.