OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "launchpad.net/juju-core/charm" | 5 "launchpad.net/juju-core/charm" |
6 "launchpad.net/juju-core/environs" | 6 "launchpad.net/juju-core/environs" |
7 "launchpad.net/juju-core/juju" | 7 "launchpad.net/juju-core/juju" |
8 "launchpad.net/juju-core/log" | 8 "launchpad.net/juju-core/log" |
9 "launchpad.net/juju-core/state" | 9 "launchpad.net/juju-core/state" |
| 10 "launchpad.net/juju-core/state/api/params" |
10 stdlog "log" | 11 stdlog "log" |
11 "os" | 12 "os" |
12 "path/filepath" | 13 "path/filepath" |
13 "time" | 14 "time" |
14 | 15 |
15 // Register the provider | 16 // Register the provider |
16 _ "launchpad.net/juju-core/environs/ec2" | 17 _ "launchpad.net/juju-core/environs/ec2" |
17 ) | 18 ) |
18 | 19 |
19 func main() { | 20 func main() { |
(...skipping 24 matching lines...) Expand all Loading... |
44 return err | 45 return err |
45 } | 46 } |
46 if err := service.SetExposed(); err != nil { | 47 if err := service.SetExposed(); err != nil { |
47 return err | 48 return err |
48 } | 49 } |
49 units, err := conn.AddUnits(service, 1) | 50 units, err := conn.AddUnits(service, 1) |
50 if err != nil { | 51 if err != nil { |
51 return err | 52 return err |
52 } | 53 } |
53 | 54 |
54 » log.Infof("builddb: Waiting for unit to reach %q status...", state.UnitS
tarted) | 55 » log.Infof("builddb: Waiting for unit to reach %q status...", params.Unit
Started) |
55 unit := units[0] | 56 unit := units[0] |
56 last, info := unit.Status() | 57 last, info := unit.Status() |
57 logStatus(last, info) | 58 logStatus(last, info) |
58 » for last != state.UnitStarted { | 59 » for last != params.UnitStarted { |
59 time.Sleep(2 * time.Second) | 60 time.Sleep(2 * time.Second) |
60 if err := unit.Refresh(); err != nil { | 61 if err := unit.Refresh(); err != nil { |
61 return err | 62 return err |
62 } | 63 } |
63 status, info := unit.Status() | 64 status, info := unit.Status() |
64 if status != last { | 65 if status != last { |
65 logStatus(status, info) | 66 logStatus(status, info) |
66 last = status | 67 last = status |
67 } | 68 } |
68 } | 69 } |
69 addr, ok := unit.PublicAddress() | 70 addr, ok := unit.PublicAddress() |
70 if !ok { | 71 if !ok { |
71 return fmt.Errorf("cannot retrieve files: build unit lacks a pub
lic-address") | 72 return fmt.Errorf("cannot retrieve files: build unit lacks a pub
lic-address") |
72 } | 73 } |
73 log.Noticef("builddb: Built files published at http://%s", addr) | 74 log.Noticef("builddb: Built files published at http://%s", addr) |
74 log.Noticef("builddb: Remember to destroy the environment when you're do
ne...") | 75 log.Noticef("builddb: Remember to destroy the environment when you're do
ne...") |
75 return nil | 76 return nil |
76 } | 77 } |
77 | 78 |
78 func logStatus(status state.UnitStatus, info string) { | 79 func logStatus(status params.UnitStatus, info string) { |
79 if info == "" { | 80 if info == "" { |
80 log.Infof("builddb: Unit status is %q", status) | 81 log.Infof("builddb: Unit status is %q", status) |
81 } else { | 82 } else { |
82 log.Infof("builddb: Unit status is %q: %s", status, info) | 83 log.Infof("builddb: Unit status is %q: %s", status, info) |
83 } | 84 } |
84 } | 85 } |
OLD | NEW |