1
// Copyright 2013 Joyent Inc.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"launchpad.net/juju-core/constraints"
10
"launchpad.net/juju-core/environs"
11
"launchpad.net/juju-core/environs/config"
12
"launchpad.net/juju-core/environs/storage"
13
"launchpad.net/juju-core/provider/common"
14
"launchpad.net/juju-core/state"
15
"launchpad.net/juju-core/state/api"
18
// This file contains the core of the joyent Environ implementation. You will
19
// probably not need to change this file very much to begin with; and if you
20
// never need to add any more fields, you may never need to touch it.
22
// The rest of the implementation is split into environ_instance.go (which
23
// must be implemented ) and environ_firewall.go (which can be safely
24
// ignored until you've got an environment bootstrapping successfully).
28
// All mutating operations should lock the mutex. Non-mutating operations
29
// should read all fields (other than name, which is immutable) from a
30
// shallow copy taken with getSnapshot().
31
// This advice is predicated on the goroutine-safety of the values of the
35
storage storage.Storage
38
var _ environs.Environ = (*environ)(nil)
40
func (env *environ) Name() string {
44
func (*environ) Provider() environs.EnvironProvider {
45
return providerInstance
48
func (env *environ) SetConfig(cfg *config.Config) error {
50
defer env.lock.Unlock()
51
ecfg, err := validateConfig(cfg, env.ecfg)
55
storage, err := newStorage(ecfg)
64
func (env *environ) getSnapshot() *environ {
68
clone.lock = sync.Mutex{}
72
func (env *environ) Config() *config.Config {
73
return env.getSnapshot().ecfg.Config
76
func (env *environ) Storage() storage.Storage {
77
return env.getSnapshot().storage
80
func (env *environ) PublicStorage() storage.StorageReader {
81
return environs.EmptyStorage
84
func (env *environ) Bootstrap(cons constraints.Value) error {
85
return common.Bootstrap(env, cons)
88
func (env *environ) StateInfo() (*state.Info, *api.Info, error) {
89
return common.StateInfo(env)
92
func (env *environ) Destroy() error {
93
return common.Destroy(env)