OLD | NEW |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 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 local | 4 package local |
5 | 5 |
6 import ( | 6 import ( |
7 "errors" | 7 "errors" |
8 "fmt" | 8 "fmt" |
9 "os/exec" | 9 "os/exec" |
10 "regexp" | 10 "regexp" |
11 "runtime" | 11 "runtime" |
12 | 12 |
| 13 "launchpad.net/juju-core/agent/mongo" |
13 "launchpad.net/juju-core/container/kvm" | 14 "launchpad.net/juju-core/container/kvm" |
14 "launchpad.net/juju-core/instance" | 15 "launchpad.net/juju-core/instance" |
15 "launchpad.net/juju-core/upstart" | |
16 "launchpad.net/juju-core/utils" | 16 "launchpad.net/juju-core/utils" |
17 "launchpad.net/juju-core/version" | 17 "launchpad.net/juju-core/version" |
18 ) | 18 ) |
19 | 19 |
20 var notLinuxError = errors.New("The local provider is currently only available f
or Linux") | 20 var notLinuxError = errors.New("The local provider is currently only available f
or Linux") |
21 | 21 |
22 const installMongodUbuntu = "MongoDB server must be installed to enable the loca
l provider:" | 22 const installMongodUbuntu = "MongoDB server must be installed to enable the loca
l provider:" |
23 const aptAddRepositoryJujuStable = ` | 23 const aptAddRepositoryJujuStable = ` |
24 sudo apt-add-repository ppa:juju/stable # required for MongoDB SSL support | 24 sudo apt-add-repository ppa:juju/stable # required for MongoDB SSL support |
25 sudo apt-get update` | 25 sudo apt-get update` |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 switch containerType { | 76 switch containerType { |
77 case instance.LXC: | 77 case instance.LXC: |
78 return verifyLxc() | 78 return verifyLxc() |
79 case instance.KVM: | 79 case instance.KVM: |
80 return kvm.VerifyKVMEnabled() | 80 return kvm.VerifyKVMEnabled() |
81 } | 81 } |
82 return fmt.Errorf("Unknown container type specified in the config.") | 82 return fmt.Errorf("Unknown container type specified in the config.") |
83 } | 83 } |
84 | 84 |
85 func verifyMongod() error { | 85 func verifyMongod() error { |
86 » path := upstart.MongodPath() | 86 » path := mongo.MongodPath() |
87 | 87 |
88 ver, err := mongodVersion(path) | 88 ver, err := mongodVersion(path) |
89 if err != nil { | 89 if err != nil { |
90 return err | 90 return err |
91 } | 91 } |
92 if ver.Compare(lowestMongoVersion) < 0 { | 92 if ver.Compare(lowestMongoVersion) < 0 { |
93 return fmt.Errorf("installed version of mongod (%v) is not suppo
rted by Juju. "+ | 93 return fmt.Errorf("installed version of mongod (%v) is not suppo
rted by Juju. "+ |
94 "Juju requires version %v or greater.", | 94 "Juju requires version %v or greater.", |
95 ver, | 95 ver, |
96 lowestMongoVersion) | 96 lowestMongoVersion) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 return fmt.Errorf("%v\n%s", err, installMongodGeneric) | 138 return fmt.Errorf("%v\n%s", err, installMongodGeneric) |
139 } | 139 } |
140 | 140 |
141 func wrapLxcNotFound(err error) error { | 141 func wrapLxcNotFound(err error) error { |
142 if utils.IsUbuntu() { | 142 if utils.IsUbuntu() { |
143 return fmt.Errorf("%v\n%s", err, installLxcUbuntu) | 143 return fmt.Errorf("%v\n%s", err, installLxcUbuntu) |
144 } | 144 } |
145 return fmt.Errorf("%v\n%s", err, installLxcGeneric) | 145 return fmt.Errorf("%v\n%s", err, installLxcGeneric) |
146 } | 146 } |
OLD | NEW |