~ubuntu-branches/ubuntu/vivid/juju-core/vivid-proposed

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/manual/environ.go

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-29 19:43:29 UTC
  • mfrom: (47.1.4 wily-proposed)
  • Revision ID: package-import@ubuntu.com-20150929194329-9y496tbic30hc7vp
Tags: 1.24.6-0ubuntu1~15.04.1
Backport of 1.24.6 from wily. (LP: #1500916, #1497087)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
        "github.com/juju/utils"
17
17
 
18
18
        "github.com/juju/juju/agent"
 
19
        "github.com/juju/juju/cloudconfig/instancecfg"
19
20
        "github.com/juju/juju/constraints"
20
21
        "github.com/juju/juju/environs"
21
 
        "github.com/juju/juju/environs/cloudinit"
22
22
        "github.com/juju/juju/environs/config"
23
23
        "github.com/juju/juju/environs/httpstorage"
24
24
        "github.com/juju/juju/environs/manual"
68
68
var errNoStartInstance = errors.New("manual provider cannot start instances")
69
69
var errNoStopInstance = errors.New("manual provider cannot stop instances")
70
70
 
 
71
// MaintainInstance is specified in the InstanceBroker interface.
 
72
func (*manualEnviron) MaintainInstance(args environs.StartInstanceParams) error {
 
73
        return nil
 
74
}
 
75
 
71
76
func (*manualEnviron) StartInstance(args environs.StartInstanceParams) (*environs.StartInstanceResult, error) {
72
77
        return nil, errNoStartInstance
73
78
}
96
101
        return arch.AllSupportedArches, nil
97
102
}
98
103
 
99
 
// SupportNetworks is specified on the EnvironCapability interface.
100
 
func (e *manualEnviron) SupportNetworks() bool {
101
 
        return false
102
 
}
103
 
 
104
 
// SupportAddressAllocation is specified on the EnvironCapability interface.
105
 
func (e *manualEnviron) SupportAddressAllocation(netId network.Id) (bool, error) {
106
 
        return false, nil
107
 
}
108
 
 
109
104
func (e *manualEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) (arch, series string, _ environs.BootstrapFinalizer, _ error) {
110
105
        // Set "use-sshstorage" to false, so agents know not to use sshstorage.
111
106
        cfg, err := e.Config().Apply(map[string]interface{}{"use-sshstorage": false})
133
128
        if err != nil {
134
129
                return "", "", nil, err
135
130
        }
136
 
        finalize := func(ctx environs.BootstrapContext, mcfg *cloudinit.MachineConfig) error {
137
 
                mcfg.InstanceId = BootstrapInstanceId
138
 
                mcfg.HardwareCharacteristics = &hc
139
 
                if err := environs.FinishMachineConfig(mcfg, e.Config()); err != nil {
 
131
        finalize := func(ctx environs.BootstrapContext, icfg *instancecfg.InstanceConfig) error {
 
132
                icfg.InstanceId = BootstrapInstanceId
 
133
                icfg.HardwareCharacteristics = &hc
 
134
                if err := instancecfg.FinishInstanceConfig(icfg, e.Config()); err != nil {
140
135
                        return err
141
136
                }
142
137
                for k, v := range agentEnv {
143
 
                        mcfg.AgentEnvironment[k] = v
 
138
                        icfg.AgentEnvironment[k] = v
144
139
                }
145
 
                return common.ConfigureMachine(ctx, ssh.DefaultClient, host, mcfg)
 
140
                return common.ConfigureMachine(ctx, ssh.DefaultClient, host, icfg)
146
141
        }
147
142
        return *hc.Arch, series, finalize, nil
148
143
}
254
249
        return instances, err
255
250
}
256
251
 
257
 
// AllocateAddress requests an address to be allocated for the
258
 
// given instance on the given network. This is not supported on the
259
 
// manual provider.
260
 
func (*manualEnviron) AllocateAddress(_ instance.Id, _ network.Id, _ network.Address) error {
261
 
        return errors.NotSupportedf("AllocateAddress")
262
 
}
263
 
 
264
 
// ReleaseAddress releases a specific address previously allocated with
265
 
// AllocateAddress.
266
 
func (*manualEnviron) ReleaseAddress(_ instance.Id, _ network.Id, _ network.Address) error {
267
 
        return errors.NotSupportedf("ReleaseAddress")
268
 
}
269
 
 
270
 
// Subnets returns basic information about all subnets known
271
 
// by the provider for the environment. They may be unknown to juju
272
 
// yet (i.e. when called initially or when a new network was created).
273
 
// This is not implemented by the manual provider yet.
274
 
func (*manualEnviron) Subnets(_ instance.Id) ([]network.SubnetInfo, error) {
275
 
        return nil, errors.NotSupportedf("Subnets")
276
 
}
277
 
 
278
252
var newSSHStorage = func(sshHost, storageDir, storageTmpdir string) (storage.Storage, error) {
279
253
        logger.Debugf("using ssh storage at host %q dir %q", sshHost, storageDir)
280
254
        return sshstorage.NewSSHStorage(sshstorage.NewSSHStorageParams{