OLD | NEW |
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 cloudinit | 4 package cloudinit |
5 | 5 |
6 import ( | 6 import ( |
7 "encoding/base64" | 7 "encoding/base64" |
8 "encoding/json" | 8 "encoding/json" |
9 "fmt" | 9 "fmt" |
10 "path" | 10 "path" |
11 "strings" | 11 "strings" |
12 | 12 |
13 "github.com/errgo/errgo" | 13 "github.com/errgo/errgo" |
14 "launchpad.net/goyaml" | 14 "launchpad.net/goyaml" |
15 | 15 |
16 "launchpad.net/juju-core/agent" | 16 "launchpad.net/juju-core/agent" |
| 17 "launchpad.net/juju-core/agent/mongo" |
17 agenttools "launchpad.net/juju-core/agent/tools" | 18 agenttools "launchpad.net/juju-core/agent/tools" |
18 "launchpad.net/juju-core/cloudinit" | 19 "launchpad.net/juju-core/cloudinit" |
19 "launchpad.net/juju-core/constraints" | 20 "launchpad.net/juju-core/constraints" |
20 "launchpad.net/juju-core/environs/config" | 21 "launchpad.net/juju-core/environs/config" |
21 "launchpad.net/juju-core/instance" | 22 "launchpad.net/juju-core/instance" |
22 "launchpad.net/juju-core/juju/osenv" | 23 "launchpad.net/juju-core/juju/osenv" |
23 "launchpad.net/juju-core/log/syslog" | 24 "launchpad.net/juju-core/log/syslog" |
24 "launchpad.net/juju-core/names" | 25 "launchpad.net/juju-core/names" |
25 "launchpad.net/juju-core/state" | 26 "launchpad.net/juju-core/state" |
26 "launchpad.net/juju-core/state/api" | 27 "launchpad.net/juju-core/state/api" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 c.AddScripts( | 502 c.AddScripts( |
502 "mkdir -p "+dbDir+"/journal", | 503 "mkdir -p "+dbDir+"/journal", |
503 "chmod 0700 "+dbDir, | 504 "chmod 0700 "+dbDir, |
504 // Otherwise we get three files with 100M+ each, which takes tim
e. | 505 // Otherwise we get three files with 100M+ each, which takes tim
e. |
505 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.0", | 506 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.0", |
506 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.1", | 507 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.1", |
507 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.2", | 508 "dd bs=1M count=1 if=/dev/zero of="+dbDir+"/journal/prealloc.2", |
508 ) | 509 ) |
509 | 510 |
510 name := cfg.MongoServiceName | 511 name := cfg.MongoServiceName |
511 » conf := upstart.MongoUpstartService(name, cfg.DataDir, dbDir, cfg.StateP
ort) | 512 » conf, err := mongo.MongoUpstartService(name, cfg.DataDir, cfg.StatePort) |
| 513 » if err != nil { |
| 514 » » return err |
| 515 » } |
512 cmds, err := conf.InstallCommands() | 516 cmds, err := conf.InstallCommands() |
513 if err != nil { | 517 if err != nil { |
514 return errgo.Annotate(err, "cannot make cloud-init upstart scrip
t for the state database") | 518 return errgo.Annotate(err, "cannot make cloud-init upstart scrip
t for the state database") |
515 } | 519 } |
516 c.AddRunCmd(cloudinit.LogProgressCmd("Starting MongoDB server (%s)", nam
e)) | 520 c.AddRunCmd(cloudinit.LogProgressCmd("Starting MongoDB server (%s)", nam
e)) |
517 c.AddScripts(cmds...) | 521 c.AddScripts(cmds...) |
518 return nil | 522 return nil |
519 } | 523 } |
520 | 524 |
521 // versionDir converts a tools URL into a name | 525 // versionDir converts a tools URL into a name |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 727 } |
724 if cfg.APIInfo.Tag != names.MachineTag(cfg.MachineId) { | 728 if cfg.APIInfo.Tag != names.MachineTag(cfg.MachineId) { |
725 return fmt.Errorf("entity tag must match started machine
") | 729 return fmt.Errorf("entity tag must match started machine
") |
726 } | 730 } |
727 } | 731 } |
728 if cfg.MachineNonce == "" { | 732 if cfg.MachineNonce == "" { |
729 return fmt.Errorf("missing machine nonce") | 733 return fmt.Errorf("missing machine nonce") |
730 } | 734 } |
731 return nil | 735 return nil |
732 } | 736 } |
OLD | NEW |