LEFT | RIGHT |
(no file at all) | |
1 package dummy | 1 package dummy |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "errors" | 5 "errors" |
6 "fmt" | 6 "fmt" |
7 "io" | 7 "io" |
8 "io/ioutil" | 8 "io/ioutil" |
9 "launchpad.net/juju/go/environs" | 9 "launchpad.net/juju/go/environs" |
10 "launchpad.net/juju/go/schema" | 10 "launchpad.net/juju/go/schema" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 const ( | 23 const ( |
24 OpNone OperationKind = iota | 24 OpNone OperationKind = iota |
25 OpBootstrap | 25 OpBootstrap |
26 OpDestroy | 26 OpDestroy |
27 OpStartInstance | 27 OpStartInstance |
28 OpStopInstances | 28 OpStopInstances |
29 ) | 29 ) |
30 | 30 |
31 var kindNames = []string{ | 31 var kindNames = []string{ |
32 » OpNone: "OpNone", | 32 » OpNone: "OpNone", |
33 OpBootstrap: "OpBootstrap", | 33 OpBootstrap: "OpBootstrap", |
34 OpDestroy: "OpDestroy", | 34 OpDestroy: "OpDestroy", |
35 OpStartInstance: "OpStartInstance", | 35 OpStartInstance: "OpStartInstance", |
36 OpStopInstances: "OpStopInstances", | 36 OpStopInstances: "OpStopInstances", |
37 } | 37 } |
38 | 38 |
39 func (k OperationKind) String() string { | 39 func (k OperationKind) String() string { |
40 return kindNames[k] | 40 return kindNames[k] |
41 } | 41 } |
42 | 42 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // of type boolean. If this is non-empty, any operation | 94 // of type boolean. If this is non-empty, any operation |
95 // after the environment has been opened will return | 95 // after the environment has been opened will return |
96 // the error "broken environment", and will also log that. | 96 // the error "broken environment", and will also log that. |
97 //· | 97 //· |
98 // The DNS name of instances is the same as the Id, | 98 // The DNS name of instances is the same as the Id, |
99 // with ".dns" appended. | 99 // with ".dns" appended. |
100 func Reset(c chan<- Operation) { | 100 func Reset(c chan<- Operation) { |
101 providerInstance.reset(c) | 101 providerInstance.reset(c) |
102 } | 102 } |
103 | 103 |
104 func (e *environProvider) reset(c chan <-Operation) { | 104 func (e *environProvider) reset(c chan<- Operation) { |
105 e.mu.Lock() | 105 e.mu.Lock() |
106 defer e.mu.Unlock() | 106 defer e.mu.Unlock() |
107 if c == nil { | 107 if c == nil { |
108 c = discardOperations | 108 c = discardOperations |
109 } | 109 } |
110 if ops := e.ops; ops != discardOperations && ops != nil { | 110 if ops := e.ops; ops != discardOperations && ops != nil { |
111 close(ops) | 111 close(ops) |
112 } | 112 } |
113 e.ops = c | 113 e.ops = c |
114 e.state = &environState{ | 114 e.state = &environState{ |
115 insts: make(map[string]*instance), | 115 insts: make(map[string]*instance), |
116 files: make(map[string][]byte), | 116 files: make(map[string][]byte), |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 func (e *environProvider) ConfigChecker() schema.Checker { | 120 func (e *environProvider) ConfigChecker() schema.Checker { |
121 return schema.FieldMap( | 121 return schema.FieldMap( |
122 schema.Fields{ | 122 schema.Fields{ |
123 "type": schema.Const("dummy"), | 123 "type": schema.Const("dummy"), |
124 "zookeeper": schema.Const(false), // TODO | 124 "zookeeper": schema.Const(false), // TODO |
125 » » » "broken": schema.Bool(), | 125 » » » "broken": schema.Bool(), |
126 }, | 126 }, |
127 []string{ | 127 []string{ |
128 "broken", | 128 "broken", |
129 }, | 129 }, |
130 ) | 130 ) |
131 } | 131 } |
132 | 132 |
133 func (e *environProvider) Open(name string, attributes interface{}) (environs.En
viron, error) { | 133 func (e *environProvider) Open(name string, attributes interface{}) (environs.En
viron, error) { |
134 e.mu.Lock() | 134 e.mu.Lock() |
135 defer e.mu.Unlock() | 135 defer e.mu.Unlock() |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return m.id | 291 return m.id |
292 } | 292 } |
293 | 293 |
294 func (m *instance) DNSName() (string, error) { | 294 func (m *instance) DNSName() (string, error) { |
295 return m.id + ".dns", nil | 295 return m.id + ".dns", nil |
296 } | 296 } |
297 | 297 |
298 func (m *instance) WaitDNSName() (string, error) { | 298 func (m *instance) WaitDNSName() (string, error) { |
299 return m.DNSName() | 299 return m.DNSName() |
300 } | 300 } |
LEFT | RIGHT |