github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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 := jujucmd.NewSubSuperCommand(cmd.SuperCommandParams{
    25  		Name:        "pool",
    26  		Doc:         poolCmdDoc,
    27  		UsagePrefix: "juju storage",
    28  		Purpose:     poolCmdPurpose,
    29  	})
    30  	poolcmd.Register(envcmd.Wrap(&PoolListCommand{}))
    31  	poolcmd.Register(envcmd.Wrap(&PoolCreateCommand{}))
    32  	return poolcmd
    33  }
    34  
    35  // PoolCommandBase is a helper base structure for pool commands.
    36  type PoolCommandBase struct {
    37  	StorageCommandBase
    38  }
    39  
    40  // PoolInfo defines the serialization behaviour of the storage pool information.
    41  type PoolInfo struct {
    42  	Provider string                 `yaml:"provider" json:"provider"`
    43  	Attrs    map[string]interface{} `yaml:"attrs,omitempty" json:"attrs,omitempty"`
    44  }
    45  
    46  func formatPoolInfo(all []params.StoragePool) map[string]PoolInfo {
    47  	output := make(map[string]PoolInfo)
    48  	for _, one := range all {
    49  		output[one.Name] = PoolInfo{
    50  			Provider: one.Provider,
    51  			Attrs:    one.Attrs,
    52  		}
    53  	}
    54  	return output
    55  }