Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(116)

Delta Between Two Patch Sets: state/open.go

Issue 10447045: Add machine instance metadata to state (Closed)
Left Patch Set: Add machine instance metadata to state Created 11 years, 9 months ago
Right Patch Set: Add machine instance metadata to state Created 11 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package state 4 package state
5 5
6 import ( 6 import (
7 "crypto/tls" 7 "crypto/tls"
8 "crypto/x509" 8 "crypto/x509"
9 stderrors "errors" 9 stderrors "errors"
10 "fmt" 10 "fmt"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return &errors.UnauthorizedError{err, msg} 191 return &errors.UnauthorizedError{err, msg}
192 } 192 }
193 return fmt.Errorf("%s: %v", msg, err) 193 return fmt.Errorf("%s: %v", msg, err)
194 } 194 }
195 195
196 func newState(session *mgo.Session, info *Info) (*State, error) { 196 func newState(session *mgo.Session, info *Info) (*State, error) {
197 db := session.DB("juju") 197 db := session.DB("juju")
198 pdb := session.DB("presence") 198 pdb := session.DB("presence")
199 if info.Tag != "" { 199 if info.Tag != "" {
200 if err := db.Login(info.Tag, info.Password); err != nil { 200 if err := db.Login(info.Tag, info.Password); err != nil {
201 » » » return nil, maybeUnauthorized(err, "cannot log in to juj u database") 201 » » » return nil, maybeUnauthorized(err, fmt.Sprintf("cannot l og in to juju database as %q", info.Tag))
202 } 202 }
203 if err := pdb.Login(info.Tag, info.Password); err != nil { 203 if err := pdb.Login(info.Tag, info.Password); err != nil {
204 » » » return nil, maybeUnauthorized(err, "cannot log in to pre sence database") 204 » » » return nil, maybeUnauthorized(err, fmt.Sprintf("cannot l og in to presence database as %q", info.Tag))
205 } 205 }
206 } else if info.Password != "" { 206 } else if info.Password != "" {
207 admin := session.DB("admin") 207 admin := session.DB("admin")
208 if err := admin.Login("admin", info.Password); err != nil { 208 if err := admin.Login("admin", info.Password); err != nil {
209 return nil, maybeUnauthorized(err, "cannot log in to adm in database") 209 return nil, maybeUnauthorized(err, "cannot log in to adm in database")
210 } 210 }
211 } 211 }
212 st := &State{ 212 st := &State{
213 info: info, 213 info: info,
214 db: db, 214 db: db,
215 environments: db.C("environments"), 215 environments: db.C("environments"),
216 charms: db.C("charms"), 216 charms: db.C("charms"),
217 machines: db.C("machines"), 217 machines: db.C("machines"),
218 containerRefs: db.C("containerRefs"), 218 containerRefs: db.C("containerRefs"),
219 instanceData: db.C("instanceData"), 219 instanceData: db.C("instanceData"),
220 relations: db.C("relations"), 220 relations: db.C("relations"),
221 relationScopes: db.C("relationscopes"), 221 relationScopes: db.C("relationscopes"),
222 services: db.C("services"), 222 services: db.C("services"),
223 minUnits: db.C("minunits"),
223 settings: db.C("settings"), 224 settings: db.C("settings"),
224 settingsrefs: db.C("settingsrefs"), 225 settingsrefs: db.C("settingsrefs"),
225 constraints: db.C("constraints"), 226 constraints: db.C("constraints"),
226 units: db.C("units"), 227 units: db.C("units"),
227 users: db.C("users"), 228 users: db.C("users"),
228 presence: pdb.C("presence"), 229 presence: pdb.C("presence"),
229 cleanups: db.C("cleanups"), 230 cleanups: db.C("cleanups"),
230 annotations: db.C("annotations"), 231 annotations: db.C("annotations"),
231 statuses: db.C("statuses"), 232 statuses: db.C("statuses"),
232 } 233 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 297 }
297 st.mu.Unlock() 298 st.mu.Unlock()
298 st.db.Session.Close() 299 st.db.Session.Close()
299 for _, err := range []error{err1, err2, err3} { 300 for _, err := range []error{err1, err2, err3} {
300 if err != nil { 301 if err != nil {
301 return err 302 return err
302 } 303 }
303 } 304 }
304 return nil 305 return nil
305 } 306 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b