OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "fmt" | 5 "fmt" |
6 . "launchpad.net/gocheck" | 6 . "launchpad.net/gocheck" |
7 "launchpad.net/juju-core/charm" | 7 "launchpad.net/juju-core/charm" |
8 "launchpad.net/juju-core/cmd" | 8 "launchpad.net/juju-core/cmd" |
9 "launchpad.net/juju-core/constraints" | |
10 "launchpad.net/juju-core/juju/testing" | 9 "launchpad.net/juju-core/juju/testing" |
11 "launchpad.net/juju-core/state" | 10 "launchpad.net/juju-core/state" |
12 coretesting "launchpad.net/juju-core/testing" | 11 coretesting "launchpad.net/juju-core/testing" |
13 "net/url" | 12 "net/url" |
14 "os" | 13 "os" |
15 "path/filepath" | 14 "path/filepath" |
16 ) | 15 ) |
17 | 16 |
18 var _ = Suite(&SSHSuite{}) | 17 var _ = Suite(&SSHSuite{}) |
19 | 18 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 } | 115 } |
117 | 116 |
118 func (s *SSHCommonSuite) makeMachines(n int, c *C) []*state.Machine { | 117 func (s *SSHCommonSuite) makeMachines(n int, c *C) []*state.Machine { |
119 var machines = make([]*state.Machine, n) | 118 var machines = make([]*state.Machine, n) |
120 for i := 0; i < n; i++ { | 119 for i := 0; i < n; i++ { |
121 m, err := s.State.AddMachine("series", state.JobHostUnits) | 120 m, err := s.State.AddMachine("series", state.JobHostUnits) |
122 c.Assert(err, IsNil) | 121 c.Assert(err, IsNil) |
123 // must set an instance id as the ssh command uses that as a sig
nal the machine | 122 // must set an instance id as the ssh command uses that as a sig
nal the machine |
124 // has been provisioned | 123 // has been provisioned |
125 » » inst, err := s.Conn.Environ.StartInstance(m.Id(), constraints.Va
lue{}, testing.InvalidStateInfo(m.Id()), testing.InvalidAPIInfo(m.Id()), nil) | 124 » » inst := testing.StartInstance(c, s.Conn.Environ, m.Id()) |
126 » » c.Assert(err, IsNil) | |
127 c.Assert(m.SetInstanceId(inst.Id()), IsNil) | 125 c.Assert(m.SetInstanceId(inst.Id()), IsNil) |
128 machines[i] = m | 126 machines[i] = m |
129 } | 127 } |
130 return machines | 128 return machines |
131 } | 129 } |
132 | 130 |
133 func (s *SSHCommonSuite) addUnit(srv *state.Service, m *state.Machine, c *C) { | 131 func (s *SSHCommonSuite) addUnit(srv *state.Service, m *state.Machine, c *C) { |
134 u, err := srv.AddUnit() | 132 u, err := srv.AddUnit() |
135 c.Assert(err, IsNil) | 133 c.Assert(err, IsNil) |
136 err = u.AssignToMachine(m) | 134 err = u.AssignToMachine(m) |
137 c.Assert(err, IsNil) | 135 c.Assert(err, IsNil) |
138 // fudge unit.SetPublicAddress | 136 // fudge unit.SetPublicAddress |
139 id, ok := m.InstanceId() | 137 id, ok := m.InstanceId() |
140 c.Assert(ok, Equals, true) | 138 c.Assert(ok, Equals, true) |
141 insts, err := s.Conn.Environ.Instances([]state.InstanceId{id}) | 139 insts, err := s.Conn.Environ.Instances([]state.InstanceId{id}) |
142 c.Assert(err, IsNil) | 140 c.Assert(err, IsNil) |
143 addr, err := insts[0].WaitDNSName() | 141 addr, err := insts[0].WaitDNSName() |
144 c.Assert(err, IsNil) | 142 c.Assert(err, IsNil) |
145 err = u.SetPublicAddress(addr) | 143 err = u.SetPublicAddress(addr) |
146 c.Assert(err, IsNil) | 144 c.Assert(err, IsNil) |
147 } | 145 } |
OLD | NEW |