~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/storage/poollist.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
        "github.com/juju/juju/cmd/modelcmd"
12
12
)
13
13
 
 
14
// PoolCommandBase is a helper base structure for pool commands.
 
15
type PoolCommandBase struct {
 
16
        StorageCommandBase
 
17
}
 
18
 
 
19
// PoolInfo defines the serialization behaviour of the storage pool information.
 
20
type PoolInfo struct {
 
21
        Provider string                 `yaml:"provider" json:"provider"`
 
22
        Attrs    map[string]interface{} `yaml:"attrs,omitempty" json:"attrs,omitempty"`
 
23
}
 
24
 
 
25
func formatPoolInfo(all []params.StoragePool) map[string]PoolInfo {
 
26
        output := make(map[string]PoolInfo)
 
27
        for _, one := range all {
 
28
                output[one.Name] = PoolInfo{
 
29
                        Provider: one.Provider,
 
30
                        Attrs:    one.Attrs,
 
31
                }
 
32
        }
 
33
        return output
 
34
}
 
35
 
14
36
const poolListCommandDoc = `
15
37
Lists storage pools.
16
38
The user can filter on pool type, name.
38
60
 
39
61
`
40
62
 
41
 
func newPoolListCommand() cmd.Command {
 
63
// NewPoolListCommand returns a command that lists storage pools on a model
 
64
func NewPoolListCommand() cmd.Command {
42
65
        cmd := &poolListCommand{}
43
66
        cmd.newAPIFunc = func() (PoolListAPI, error) {
44
67
                return cmd.NewStorageAPI()
63
86
// Info implements Command.Info.
64
87
func (c *poolListCommand) Info() *cmd.Info {
65
88
        return &cmd.Info{
66
 
                Name:    "list",
 
89
                Name:    "list-storage-pools",
67
90
                Purpose: "list storage pools",
68
91
                Doc:     poolListCommandDoc,
69
92
        }
75
98
        f.Var(cmd.NewAppendStringsValue(&c.Providers), "provider", "only show pools of these provider types")
76
99
        f.Var(cmd.NewAppendStringsValue(&c.Names), "name", "only show pools with these names")
77
100
 
78
 
        c.out.AddFlags(f, "yaml", map[string]cmd.Formatter{
 
101
        c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
79
102
                "yaml":    cmd.FormatYaml,
80
103
                "json":    cmd.FormatJson,
81
104
                "tabular": formatPoolListTabular,