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

Delta Between Two Patch Sets: environs/cloudinit/cloudinit.go

Issue 6855054: state: add CACert to Info.
Left Patch Set: Created 12 years, 4 months ago
Right Patch Set: state: add CACert to Info. Created 12 years, 4 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:
Right: Side by side diff | Download
« no previous file with change/comment | « environs/bootstrap_test.go ('k') | environs/cloudinit/cloudinit_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package cloudinit 1 package cloudinit
2 2
3 import ( 3 import (
4 "encoding/base64" 4 "encoding/base64"
5 "fmt" 5 "fmt"
6 "launchpad.net/goyaml" 6 "launchpad.net/goyaml"
7 "launchpad.net/juju-core/cloudinit" 7 "launchpad.net/juju-core/cloudinit"
8 "launchpad.net/juju-core/environs" 8 "launchpad.net/juju-core/environs"
9 "launchpad.net/juju-core/environs/config" 9 "launchpad.net/juju-core/environs/config"
10 "launchpad.net/juju-core/log" 10 "launchpad.net/juju-core/log"
(...skipping 11 matching lines...) Expand all
22 var mgoPortSuffix = fmt.Sprintf(":%d", mgoPort) 22 var mgoPortSuffix = fmt.Sprintf(":%d", mgoPort)
23 23
24 // MachineConfig represents initialization information for a new juju machine. 24 // MachineConfig represents initialization information for a new juju machine.
25 // Creation of cloudinit data from this struct is largely provider-independent, 25 // Creation of cloudinit data from this struct is largely provider-independent,
26 // but we'll keep it internal until we need to factor it out. 26 // but we'll keep it internal until we need to factor it out.
27 type MachineConfig struct { 27 type MachineConfig struct {
28 // StateServer specifies whether the new machine will run a ZooKeeper 28 // StateServer specifies whether the new machine will run a ZooKeeper
29 // or MongoDB instance. 29 // or MongoDB instance.
30 StateServer bool 30 StateServer bool
31 31
32 » // StateServerCertPEM and StateServerKeyPEM hold the state server 32 » // StateServerCert and StateServerKey hold the state server
33 // certificate and private key in PEM format; they are required when 33 // certificate and private key in PEM format; they are required when
34 // StateServer is set, and ignored otherwise. 34 // StateServer is set, and ignored otherwise.
35 » StateServerCertPEM []byte 35 » StateServerCert []byte
36 » StateServerKeyPEM []byte 36 » StateServerKey []byte
37 37
38 // InstanceIdAccessor holds bash code that evaluates to the current inst ance id. 38 // InstanceIdAccessor holds bash code that evaluates to the current inst ance id.
39 InstanceIdAccessor string 39 InstanceIdAccessor string
40 40
41 // ProviderType identifies the provider type so the host 41 // ProviderType identifies the provider type so the host
42 // knows which kind of provider to use. 42 // knows which kind of provider to use.
43 ProviderType string 43 ProviderType string
44 44
45 // StateInfo holds the means for the new instance to communicate with th e 45 // StateInfo holds the means for the new instance to communicate with th e
46 // juju state. Unless the new machine is running a state server (StateSe rver is 46 // juju state. Unless the new machine is running a state server (StateSe rver is
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 debugFlag := "" 113 debugFlag := ""
114 // TODO: disable debug mode by default when the system is stable. 114 // TODO: disable debug mode by default when the system is stable.
115 if true || log.Debug { 115 if true || log.Debug {
116 debugFlag = " --debug" 116 debugFlag = " --debug"
117 } 117 }
118 118
119 if cfg.StateServer { 119 if cfg.StateServer {
120 addScripts(c, 120 addScripts(c,
121 fmt.Sprintf("echo %s > %s", 121 fmt.Sprintf("echo %s > %s",
122 » » » » shquote(string(cfg.StateServerCertPEM)+string(cf g.StateServerKeyPEM)), serverPEMPath), 122 » » » » shquote(string(cfg.StateServerCert)+string(cfg.S tateServerKey)), serverPEMPath),
123 "chmod 600 "+serverPEMPath, 123 "chmod 600 "+serverPEMPath,
124 ) 124 )
125 125
126 // TODO The public bucket must come from the environment configu ration. 126 // TODO The public bucket must come from the environment configu ration.
127 b := cfg.Tools.Binary 127 b := cfg.Tools.Binary
128 url := fmt.Sprintf("http://juju-dist.s3.amazonaws.com/tools/mong o-2.2.0-%s-%s.tgz", b.Series, b.Arch) 128 url := fmt.Sprintf("http://juju-dist.s3.amazonaws.com/tools/mong o-2.2.0-%s-%s.tgz", b.Series, b.Arch)
129 addScripts(c, 129 addScripts(c,
130 "mkdir -p /opt", 130 "mkdir -p /opt",
131 fmt.Sprintf("wget --no-verbose -O - %s | tar xz -C /opt" , shquote(url)), 131 fmt.Sprintf("wget --no-verbose -O - %s | tar xz -C /opt" , shquote(url)),
132 ) 132 )
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if cfg.StateServer { 284 if cfg.StateServer {
285 if cfg.InstanceIdAccessor == "" { 285 if cfg.InstanceIdAccessor == "" {
286 return fmt.Errorf("missing instance id accessor") 286 return fmt.Errorf("missing instance id accessor")
287 } 287 }
288 if cfg.Config == nil { 288 if cfg.Config == nil {
289 return fmt.Errorf("missing environment configuration") 289 return fmt.Errorf("missing environment configuration")
290 } 290 }
291 if cfg.StateInfo.EntityName != "" { 291 if cfg.StateInfo.EntityName != "" {
292 return fmt.Errorf("entity name must be blank when starti ng a state server") 292 return fmt.Errorf("entity name must be blank when starti ng a state server")
293 } 293 }
294 » » if len(cfg.StateServerCertPEM) == 0 { 294 » » if len(cfg.StateServerCert) == 0 {
295 return fmt.Errorf("missing state server certificate") 295 return fmt.Errorf("missing state server certificate")
296 } 296 }
297 » » if len(cfg.StateServerKeyPEM) == 0 { 297 » » if len(cfg.StateServerKey) == 0 {
298 return fmt.Errorf("missing state server private key") 298 return fmt.Errorf("missing state server private key")
299 } 299 }
300 } else { 300 } else {
301 if len(cfg.StateInfo.Addrs) == 0 { 301 if len(cfg.StateInfo.Addrs) == 0 {
302 return fmt.Errorf("missing state hosts") 302 return fmt.Errorf("missing state hosts")
303 } 303 }
304 if cfg.StateInfo.EntityName != state.MachineEntityName(cfg.Machi neId) { 304 if cfg.StateInfo.EntityName != state.MachineEntityName(cfg.Machi neId) {
305 return fmt.Errorf("entity name must match started machin e") 305 return fmt.Errorf("entity name must match started machin e")
306 } 306 }
307 } 307 }
308 for _, r := range cfg.StateInfo.Password { 308 for _, r := range cfg.StateInfo.Password {
309 if r == '\'' || r == '\\' || r < 32 { 309 if r == '\'' || r == '\\' || r < 32 {
310 return fmt.Errorf("password has disallowed characters") 310 return fmt.Errorf("password has disallowed characters")
311 } 311 }
312 } 312 }
313 return nil 313 return nil
314 } 314 }
LEFTRIGHT

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