github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/cmd/juju/environment/constraints.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environment 5 6 import ( 7 "github.com/juju/cmd" 8 "launchpad.net/gnuflag" 9 10 "github.com/juju/juju/cmd/juju/common" 11 "github.com/juju/juju/constraints" 12 ) 13 14 const getConstraintsDoc = ` 15 Shows a list of constraints that have been set on the environment 16 using juju environment set-constraints. You can also view constraints 17 set for a specific service by using juju service get-constraints <service>. 18 19 Constraints set on a service are combined with environment constraints for 20 commands (such as juju deploy) that provision machines for services. Where 21 environment and service constraints overlap, the service constraints take 22 precedence. 23 24 See Also: 25 juju help constraints 26 juju help environment set-constraints 27 juju help deploy 28 juju help machine add 29 juju help add-unit 30 ` 31 32 const setConstraintsDoc = ` 33 Sets machine constraints on the environment, which are used as the default 34 constraints for all new machines provisioned in the environment (unless 35 overridden). You can also set constraints on a specific service by using 36 juju service set-constraints. 37 38 Constraints set on a service are combined with environment constraints for 39 commands (such as juju deploy) that provision machines for services. Where 40 environment and service constraints overlap, the service constraints take 41 precedence. 42 43 Example: 44 45 juju environment set-constraints mem=8G (all new machines in the environment must have at least 8GB of RAM) 46 47 See Also: 48 juju help constraints 49 juju help environment get-constraints 50 juju help deploy 51 juju help machine add 52 juju help add-unit 53 ` 54 55 // EnvGetConstraintsCommand shows the constraints for an environment. 56 // It is just a wrapper for the common GetConstraintsCommand and 57 // enforces that no service arguments are passed in. 58 type EnvGetConstraintsCommand struct { 59 common.GetConstraintsCommand 60 } 61 62 func (c *EnvGetConstraintsCommand) Info() *cmd.Info { 63 return &cmd.Info{ 64 Name: "get-constraints", 65 Purpose: "view constraints on the environment", 66 Doc: getConstraintsDoc, 67 } 68 } 69 70 func (c *EnvGetConstraintsCommand) Init(args []string) error { 71 return cmd.CheckEmpty(args) 72 } 73 74 // EnvSetConstraintsCommand sets the constraints for an environment. 75 // It is just a wrapper for the common SetConstraintsCommand and 76 // enforces that no service arguments are passed in. 77 type EnvSetConstraintsCommand struct { 78 common.SetConstraintsCommand 79 } 80 81 func (c *EnvSetConstraintsCommand) Info() *cmd.Info { 82 return &cmd.Info{ 83 Name: "set-constraints", 84 Args: "[key=[value] ...]", 85 Purpose: "set constraints on the environment", 86 Doc: setConstraintsDoc, 87 } 88 } 89 90 // SetFlags overrides SetFlags for SetConstraintsCommand since that 91 // will register a flag to specify the service. 92 func (c *EnvSetConstraintsCommand) SetFlags(f *gnuflag.FlagSet) {} 93 94 func (c *EnvSetConstraintsCommand) Init(args []string) (err error) { 95 c.Constraints, err = constraints.Parse(args...) 96 return err 97 }