github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/environs/broker.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environs 5 6 import ( 7 "github.com/juju/juju/constraints" 8 "github.com/juju/juju/environs/cloudinit" 9 "github.com/juju/juju/instance" 10 "github.com/juju/juju/network" 11 "github.com/juju/juju/tools" 12 ) 13 14 // StartInstanceParams holds parameters for the 15 // InstanceBroker.StartInstance method. 16 type StartInstanceParams struct { 17 // Constraints is a set of constraints on 18 // the kind of instance to create. 19 Constraints constraints.Value 20 21 // Tools is a list of tools that may be used 22 // to start a Juju agent on the machine. 23 Tools tools.List 24 25 // MachineConfig describes the machine's configuration. 26 MachineConfig *cloudinit.MachineConfig 27 28 // Placement, if non-empty, contains an environment-specific 29 // placement directive that may be used to decide how the 30 // instance should be started. 31 Placement string 32 33 // DistributionGroup, if non-nil, is a function 34 // that returns a slice of instance.Ids that belong 35 // to the same distribution group as the machine 36 // being provisioned. The InstanceBroker may use 37 // this information to distribute instances for 38 // high availability. 39 DistributionGroup func() ([]instance.Id, error) 40 } 41 42 // TODO(wallyworld) - we want this in the environs/instance package but import loops 43 // stop that from being possible right now. 44 type InstanceBroker interface { 45 // StartInstance asks for a new instance to be created, associated with 46 // the provided config in machineConfig. The given config describes the juju 47 // state for the new instance to connect to. The config MachineNonce, which must be 48 // unique within an environment, is used by juju to protect against the 49 // consequences of multiple instances being started with the same machine 50 // id. 51 StartInstance(args StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, []network.Info, error) 52 53 // StopInstances shuts down the instances with the specified IDs. 54 // Unknown instance IDs are ignored, to enable idempotency. 55 StopInstances(...instance.Id) error 56 57 // AllInstances returns all instances currently known to the broker. 58 AllInstances() ([]instance.Instance, error) 59 }