github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/cmd/juju/system/removeblocks.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package system 5 6 import ( 7 "github.com/juju/cmd" 8 "github.com/juju/errors" 9 10 "github.com/juju/juju/cmd/envcmd" 11 ) 12 13 // RemoveBlocksCommand returns the list of all systems the user is 14 // currently logged in to on the current machine. 15 type RemoveBlocksCommand struct { 16 envcmd.SysCommandBase 17 api removeBlocksAPI 18 } 19 20 type removeBlocksAPI interface { 21 Close() error 22 RemoveBlocks() error 23 } 24 25 var removeBlocksDoc = ` 26 Remove all blocks in the Juju system. 27 28 A system administrator is able to remove all the blocks that have been added 29 in a Juju system. 30 31 See Also: 32 juju help block 33 juju help unblock 34 ` 35 36 // Info implements Command.Info 37 func (c *RemoveBlocksCommand) Info() *cmd.Info { 38 return &cmd.Info{ 39 Name: "remove-blocks", 40 Purpose: "remove all blocks in the Juju system", 41 Doc: removeBlocksDoc, 42 } 43 } 44 45 func (c *RemoveBlocksCommand) getAPI() (removeBlocksAPI, error) { 46 if c.api != nil { 47 return c.api, nil 48 } 49 return c.NewSystemManagerAPIClient() 50 } 51 52 // Run implements Command.Run 53 func (c *RemoveBlocksCommand) Run(ctx *cmd.Context) error { 54 client, err := c.getAPI() 55 if err != nil { 56 return errors.Trace(err) 57 } 58 defer client.Close() 59 return errors.Annotatef(client.RemoveBlocks(), "cannot remove blocks") 60 }