github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/cmd/juju/storage/pool.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package storage 5 6 import ( 7 "github.com/juju/cmd" 8 9 "github.com/juju/juju/apiserver/params" 10 jujucmd "github.com/juju/juju/cmd" 11 "github.com/juju/juju/cmd/envcmd" 12 ) 13 14 const poolCmdDoc = ` 15 "juju storage pool" is used to manage storage pool instances in 16 Juju environment. 17 ` 18 19 const poolCmdPurpose = "manage storage pools" 20 21 // NewPoolSuperCommand creates the storage pool super subcommand and 22 // registers the subcommands that it supports. 23 func NewPoolSuperCommand() cmd.Command { 24 poolcmd := Command{ 25 SuperCommand: *jujucmd.NewSubSuperCommand(cmd.SuperCommandParams{ 26 Name: "pool", 27 Doc: poolCmdDoc, 28 UsagePrefix: "juju storage", 29 Purpose: poolCmdPurpose, 30 })} 31 poolcmd.Register(envcmd.Wrap(&PoolListCommand{})) 32 poolcmd.Register(envcmd.Wrap(&PoolCreateCommand{})) 33 return &poolcmd 34 } 35 36 // PoolCommandBase is a helper base structure for pool commands. 37 type PoolCommandBase struct { 38 StorageCommandBase 39 } 40 41 // PoolInfo defines the serialization behaviour of the storage pool information. 42 type PoolInfo struct { 43 Provider string `yaml:"provider" json:"provider"` 44 Attrs map[string]interface{} `yaml:"attrs,omitempty" json:"attrs,omitempty"` 45 } 46 47 func formatPoolInfo(all []params.StoragePool) map[string]PoolInfo { 48 output := make(map[string]PoolInfo) 49 for _, one := range all { 50 output[one.Name] = PoolInfo{ 51 Provider: one.Provider, 52 Attrs: one.Attrs, 53 } 54 } 55 return output 56 }