Merge lp:~axwalk/juju-core/lp1167441-report-instance-state into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 1629
Proposed branch: lp:~axwalk/juju-core/lp1167441-report-instance-state
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 299 lines (+96/-7)
15 files modified
cmd/juju/status.go (+1/-0)
container/lxc/instance.go (+10/-0)
container/lxc/lxc.go (+2/-2)
container/lxc/lxc_test.go (+15/-0)
environs/azure/instance.go (+5/-0)
environs/azure/instance_test.go (+8/-0)
environs/dummy/environs.go (+4/-0)
environs/ec2/ec2.go (+4/-0)
environs/ec2/local_test.go (+15/-0)
environs/local/instance.go (+5/-0)
environs/maas/instance.go (+9/-0)
environs/openstack/local_test.go (+8/-0)
environs/openstack/provider.go (+4/-0)
environs/polling_test.go (+3/-5)
instance/instance.go (+3/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/lp1167441-report-instance-state
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+178222@code.launchpad.net

Commit message

Add Instance.Status method, use in juju status

Add Status() method to Instance interface, and
implementations for azure, ec2, openstack and lxc.
Local and MAAS always return "".

There will be a followup to bubble LXC status
up through the local provider.

Fixes bug #1167441

https://codereview.appspot.com/12333043/

Description of the change

Add Instance.Status method, use in juju status

Add Status() method to Instance interface, and
implementations for azure, ec2, openstack and lxc.
Local and MAAS always return "".

There will be a followup to bubble LXC status
up through the local provider.

Fixes bug #1167441

https://codereview.appspot.com/12333043/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+178222_code.launchpad.net,

Message:
Please take a look.

Description:
Add Instance.State method, use in juju status

Add State() method to Instance interface, and
implementations for azure, ec2, openstack and lxc.
Local and MAAS always return "".

https://code.launchpad.net/~axwalk/juju-core/lp1167441-report-instance-state/+merge/178222

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/12333043/

Affected files:
   A [revision details]
   M cmd/juju/status.go
   M container/lxc/instance.go
   M container/lxc/lxc.go
   M container/lxc/lxc_test.go
   M environs/azure/instance.go
   M environs/azure/instance_test.go
   M environs/dummy/environs.go
   M environs/ec2/ec2.go
   M environs/ec2/local_test.go
   M environs/local/instance.go
   M environs/maas/instance.go
   M environs/openstack/local_test.go
   M environs/openstack/provider.go
   M environs/polling_test.go
   M instance/instance.go

Revision history for this message
William Reade (fwereade) wrote :

LGTM, this is great. I'd love to see a followup for the local provider,
that should be quick and easy.

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go
File container/lxc/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go#newcode30
container/lxc/instance.go:30: return string(state)
I see this, and it looks good, but I'm a bit confused as to why it
doesn't work with the local provider. (Well, I can see why, but I can't
understand the motivation -- can anyone think of a drawback to putting
the lxc.Instances into the local.Instances so that we can access this
method? I can understand differences in address handling, but I don't
think the same forces apply here.)

https://codereview.appspot.com/12333043/diff/1/environs/local/instance.go
File environs/local/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/environs/local/instance.go#newcode27
environs/local/instance.go:27: return ""
I'd like to do what I suggested earlier and expose the lxc instance
state here. But please do it in a followup, and run it by thumper first,
because if there's a reason not to do it he'll know what it is.

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go
File environs/maas/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go#newcode26
environs/maas/instance.go:26: // TODO determine MAAS instance state
Add a bug in LP and note the number here please; and ping bigjools, or
someone else who knows maas, to find out what'll be needed to implement
it, and note that in the bug.

https://codereview.appspot.com/12333043/diff/1/environs/polling_test.go
File environs/polling_test.go (left):

https://codereview.appspot.com/12333043/diff/1/environs/polling_test.go#oldcode63
environs/polling_test.go:63: func (*dnsNameFakeInstance) Ports(string)
([]instance.Port, error) { return nil, nil }
Complete side note: would it be useful for dnsNameFakeInstance to just
embed an instance.Instance, and thus panic on use of unwanted methods?
Feels a bit saner than just returning nonsense without error...

https://codereview.appspot.com/12333043/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go
File container/lxc/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go#newcode30
container/lxc/instance.go:30: return string(state)
On 2013/08/02 17:30:32, fwereade wrote:
> I see this, and it looks good, but I'm a bit confused as to why it
doesn't work
> with the local provider. (Well, I can see why, but I can't understand
the
> motivation -- can anyone think of a drawback to putting the
lxc.Instances into
> the local.Instances so that we can access this method? I can
understand
> differences in address handling, but I don't think the same forces
apply here.)

Are you referring to the lxc.Instance being converted to local.Instance?
I don't understand the reason behind this. I think I'll have to have a
chat with thumper after IOM to understand this better.

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go
File environs/maas/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go#newcode26
environs/maas/instance.go:26: // TODO determine MAAS instance state
On 2013/08/02 17:30:32, fwereade wrote:
> Add a bug in LP and note the number here please; and ping bigjools, or
someone
> else who knows maas, to find out what'll be needed to implement it,
and note
> that in the bug.

I had a chat with bigjools on IRC about this. He tells me that the MAAS
server does not track the status of nodes after they're allocated, and
so any node that juju knows about will always show up as "allocated".

The TODO should probably be replaced with a note explaining that status
isn't available. Sound reasonable?

https://codereview.appspot.com/12333043/diff/1/environs/polling_test.go
File environs/polling_test.go (left):

https://codereview.appspot.com/12333043/diff/1/environs/polling_test.go#oldcode63
environs/polling_test.go:63: func (*dnsNameFakeInstance) Ports(string)
([]instance.Port, error) { return nil, nil }
On 2013/08/02 17:30:32, fwereade wrote:
> Complete side note: would it be useful for dnsNameFakeInstance to just
embed an
> instance.Instance, and thus panic on use of unwanted methods? Feels a
bit saner
> than just returning nonsense without error...

SGTM, done

https://codereview.appspot.com/12333043/

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

LGTM with a couple of suggestions.

https://codereview.appspot.com/12333043/diff/1/container/lxc/lxc_test.go
File container/lxc/lxc_test.go (right):

https://codereview.appspot.com/12333043/diff/1/container/lxc/lxc_test.go#newcode130
container/lxc/lxc_test.go:130: c.Assert(instance.State(), gc.Equals,
string(golxc.StateUnknown))
This is a bit confusing.. should it be "stopped" or something instead?

https://codereview.appspot.com/12333043/diff/1/environs/azure/instance_test.go
File environs/azure/instance_test.go (right):

https://codereview.appspot.com/12333043/diff/1/environs/azure/instance_test.go#newcode28
environs/azure/instance_test.go:28: func (*InstanceSuite) TestId(c *C) {
Thanks for fixing this. Maybe while you're at it, make it instanceState
instead - no need to be exported.

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go
File environs/maas/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/environs/maas/instance.go#newcode26
environs/maas/instance.go:26: // TODO determine MAAS instance state
On 2013/08/05 07:09:06, axw1 wrote:
> On 2013/08/02 17:30:32, fwereade wrote:
> > Add a bug in LP and note the number here please; and ping bigjools,
or someone
> > else who knows maas, to find out what'll be needed to implement it,
and note
> > that in the bug.

> I had a chat with bigjools on IRC about this. He tells me that the
MAAS server
> does not track the status of nodes after they're allocated, and so any
node that
> juju knows about will always show up as "allocated".

> The TODO should probably be replaced with a note explaining that
status isn't
> available. Sound reasonable?

+1

https://codereview.appspot.com/12333043/

Revision history for this message
John A Meinel (jameinel) wrote :

Is it possible to call the function "Instance.Status()"? We have a bit
of an overload of State things, and it would be one case less.

I think the reasoning might be that the status command outputs 'state:
pending' but avoiding the word State() in an interface seems useful to
me.

https://codereview.appspot.com/12333043/

Revision history for this message
Roger Peppe (rogpeppe) wrote :

+1 to Status, good call.

On 8 August 2013 18:27, John A Meinel <email address hidden> wrote:
> Is it possible to call the function "Instance.Status()"? We have a bit
> of an overload of State things, and it would be one case less.
>
> I think the reasoning might be that the status command outputs 'state:
> pending' but avoiding the word State() in an interface seems useful to
> me.
>
>
> https://codereview.appspot.com/12333043/
>
> --
> https://code.launchpad.net/~axwalk/juju-core/lp1167441-report-instance-state/+merge/178222
> Your team juju hackers is requested to review the proposed merge of lp:~axwalk/juju-core/lp1167441-report-instance-state into lp:juju-core.

Revision history for this message
John A Meinel (jameinel) wrote :

Another small thing, if you can mention "bug #1167441" somewhere in your
proposal, it makes it obvious that there is a bug thread on Launchpad
that can be read to find more context.

It is true that the LP merge proposal does give the link to related
bugs, but it is a helpful reminder when reading the proposal (CL) that
there is more context available.

https://codereview.appspot.com/12333043/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2013/08/08 17:27:01, jameinel wrote:
> Is it possible to call the function "Instance.Status()"? We have a bit
of an
> overload of State things, and it would be one case less.

> I think the reasoning might be that the status command outputs 'state:
pending'
> but avoiding the word State() in an interface seems useful to me.

Hah, I had it as Status originally, and changed it to State to match
"instance-state". I'll change it back.

https://codereview.appspot.com/12333043/

Revision history for this message
Andrew Wilkins (axwalk) wrote :
Revision history for this message
Go Bot (go-bot) wrote :
Download full text (8.1 KiB)

The attempt to merge lp:~axwalk/juju-core/lp1167441-report-instance-state into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 1.667s
ok launchpad.net/juju-core/agent/tools 26.411s
ok launchpad.net/juju-core/bzr 6.795s
ok launchpad.net/juju-core/cert 2.645s
ok launchpad.net/juju-core/charm 0.518s
? launchpad.net/juju-core/charm/hooks [no test files]
ok launchpad.net/juju-core/cloudinit 0.019s
ok launchpad.net/juju-core/cmd 0.248s
? launchpad.net/juju-core/cmd/builddb [no test files]
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]
ok launchpad.net/juju-core/cmd/juju 105.948s
ok launchpad.net/juju-core/cmd/jujud 51.162s
ok launchpad.net/juju-core/cmd/plugins/juju-metadata 0.859s
ok launchpad.net/juju-core/constraints 0.024s
ok launchpad.net/juju-core/container/lxc 0.433s
? launchpad.net/juju-core/container/lxc/mock [no test files]
ok launchpad.net/juju-core/downloader 5.308s
ok launchpad.net/juju-core/environs 1.305s
? launchpad.net/juju-core/environs/all [no test files]
ok launchpad.net/juju-core/environs/azure 4.000s
ok launchpad.net/juju-core/environs/cloudinit 0.443s
ok launchpad.net/juju-core/environs/config 0.745s
ok launchpad.net/juju-core/environs/dummy 16.007s
2013-08-09 02:50:55 WARNING juju.environs.config config.go:429 unknown config field "future"
2013-08-09 02:50:55 WARNING juju.environs.config config.go:429 unknown config field "future"
2013-08-09 02:50:55 WARNING juju.environs.config config.go:429 unknown config field "future"

----------------------------------------------------------------------
FAIL: local_test.go:306: localServerSuite.TestInstanceStatus

[LOG] 68.93735 INFO juju environs/testing: uploading FAKE tools 1.13.1-precise-amd64
[LOG] 68.95787 INFO juju environs/ec2: opening environment "sample"
[LOG] 73.78884 INFO juju environs/ec2: bootstrapping environment "sample"
[LOG] 73.78886 INFO juju environs: reading tools with major version 1
[LOG] 73.78888 DEBUG juju.agent.tools reading v1.* tools
[LOG] 73.78932 INFO juju environs: falling back to public bucket
[LOG] 73.78933 DEBUG juju.agent.tools reading v1.* tools
[LOG] 73.78992 DEBUG juju.agent.tools found 1.13.1-precise-amd64
[LOG] 73.78998 INFO juju environs: filtering tools by series: precise
[LOG] 73.79000 INFO juju environs: picked newest version: 1.13.1
[LOG] 73.82766 WARNING juju.environs.imagemetadata cannot load index "test:"/"streams/v1/index.sjson": cannot find URL "test:/streams/v1/index.sjson" not found
[LOG] 73.82778 DEBUG juju.environs.imagemetadata candidate matches for products ["com.ubuntu.cloud:server:12.04:amd64"] are [0xc20021da00]
[LOG] 73.99677 DEBUG juju environs/ec2: ec2 user data; 7410 bytes
[LOG] 74.00157 INFO juju environs/ec2: started instance "i-3"
[LOG] 74.00251 DEBUG juju waiting for DNS name(s) of state server instances [i-3]
[LOG] 74.00499 INFO juju environs: reading tools with major version 1
[LOG] 74.00500 DEBUG juju.agent.tools reading v1.* tools
[LOG] 74.00549 INFO juju environs: falling back to public bucket
[LOG] 74.00550 DEBUG juju.agent.tools reading v1.* tools
[L...

Read more...

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Bot needs an updated goamz. I take it that it's not using dependencies.tsv yet...

Revision history for this message
Tim Penhey (thumper) wrote :

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go
File container/lxc/instance.go (right):

https://codereview.appspot.com/12333043/diff/1/container/lxc/instance.go#newcode30
container/lxc/instance.go:30: return string(state)
On 2013/08/05 07:09:06, axw1 wrote:
> On 2013/08/02 17:30:32, fwereade wrote:
> > I see this, and it looks good, but I'm a bit confused as to why it
doesn't
> work
> > with the local provider. (Well, I can see why, but I can't
understand the
> > motivation -- can anyone think of a drawback to putting the
lxc.Instances into
> > the local.Instances so that we can access this method? I can
understand
> > differences in address handling, but I don't think the same forces
apply
> here.)

> Are you referring to the lxc.Instance being converted to
local.Instance? I don't
> understand the reason behind this. I think I'll have to have a chat
with thumper
> after IOM to understand this better.

I think the comment is more to have local.Instance use lxc.Instance not
the other way around. I've not looked at the differences yet, so for
now would prefer to keep them separate.

Perhaps, we have local.Instance be composed of an lxc.Instance so it can
defer to the lxc commands and just override what is different. Take
this with a grain of salt as I haven't looked at the code right now.

https://codereview.appspot.com/12333043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/status.go'
2--- cmd/juju/status.go 2013-08-08 15:34:49 +0000
3+++ cmd/juju/status.go 2013-08-09 02:41:46 +0000
4@@ -357,6 +357,7 @@
5 inst, ok := context.instances[instid]
6 if ok {
7 status.DNSName, _ = inst.DNSName()
8+ status.InstanceState = inst.Status()
9 } else {
10 // Double plus ungood. There is an instance id recorded
11 // for this machine in the state, yet the environ cannot
12
13=== modified file 'container/lxc/instance.go'
14--- container/lxc/instance.go 2013-07-19 01:18:26 +0000
15+++ container/lxc/instance.go 2013-08-09 02:41:46 +0000
16@@ -6,10 +6,13 @@
17 import (
18 "fmt"
19
20+ "launchpad.net/golxc"
21+
22 "launchpad.net/juju-core/instance"
23 )
24
25 type lxcInstance struct {
26+ golxc.Container
27 id string
28 }
29
30@@ -20,6 +23,13 @@
31 return instance.Id(lxc.id)
32 }
33
34+// Status implements instance.Instance.Status.
35+func (lxc *lxcInstance) Status() string {
36+ // On error, the state will be "unknown".
37+ state, _, _ := lxc.Info()
38+ return string(state)
39+}
40+
41 func (lxc *lxcInstance) Addresses() ([]instance.Address, error) {
42 logger.Errorf("lxcInstance.Addresses not implemented")
43 return nil, nil
44
45=== modified file 'container/lxc/lxc.go'
46--- container/lxc/lxc.go 2013-08-06 07:40:45 +0000
47+++ container/lxc/lxc.go 2013-08-09 02:41:46 +0000
48@@ -188,7 +188,7 @@
49 return nil, err
50 }
51 logger.Tracef("container started")
52- return &lxcInstance{name}, nil
53+ return &lxcInstance{container, name}, nil
54 }
55
56 func (manager *containerManager) StopContainer(instance instance.Instance) error {
57@@ -240,7 +240,7 @@
58 continue
59 }
60 if container.IsRunning() {
61- result = append(result, &lxcInstance{name})
62+ result = append(result, &lxcInstance{container, name})
63 }
64 }
65 return
66
67=== modified file 'container/lxc/lxc_test.go'
68--- container/lxc/lxc_test.go 2013-08-06 07:40:45 +0000
69+++ container/lxc/lxc_test.go 2013-08-09 02:41:46 +0000
70@@ -11,6 +11,7 @@
71 stdtesting "testing"
72
73 gc "launchpad.net/gocheck"
74+ "launchpad.net/golxc"
75 "launchpad.net/goyaml"
76 "launchpad.net/loggo"
77
78@@ -142,6 +143,20 @@
79 c.Assert(location, gc.Equals, expectedTarget)
80 }
81
82+func (s *LxcSuite) TestContainerState(c *gc.C) {
83+ manager := lxc.NewContainerManager(lxc.ManagerConfig{})
84+ instance := StartContainer(c, manager, "1/lxc/0")
85+
86+ // The mock container will be immediately "running".
87+ c.Assert(instance.Status(), gc.Equals, string(golxc.StateRunning))
88+
89+ // StopContainer stops and then destroys the container, putting it
90+ // into "unknown" state.
91+ err := manager.StopContainer(instance)
92+ c.Assert(err, gc.IsNil)
93+ c.Assert(instance.Status(), gc.Equals, string(golxc.StateUnknown))
94+}
95+
96 func (s *LxcSuite) TestStopContainer(c *gc.C) {
97 manager := lxc.NewContainerManager(lxc.ManagerConfig{})
98 instance := StartContainer(c, manager, "1/lxc/0")
99
100=== modified file 'environs/azure/instance.go'
101--- environs/azure/instance.go 2013-08-07 10:23:50 +0000
102+++ environs/azure/instance.go 2013-08-09 02:41:46 +0000
103@@ -29,6 +29,11 @@
104 return instance.Id(azInstance.ServiceName)
105 }
106
107+// Status is specified in the Instance interface.
108+func (azInstance *azureInstance) Status() string {
109+ return azInstance.HostedServiceDescriptor.Status
110+}
111+
112 var AZURE_DOMAIN_NAME = "cloudapp.net"
113
114 // Addresses is specified in the Instance interface.
115
116=== modified file 'environs/azure/instance_test.go'
117--- environs/azure/instance_test.go 2013-08-08 11:22:08 +0000
118+++ environs/azure/instance_test.go 2013-08-09 02:41:46 +0000
119@@ -32,6 +32,14 @@
120 c.Check(azInstance.Id(), Equals, instance.Id(serviceName))
121 }
122
123+func (*instanceSuite) TestStatus(c *C) {
124+ serviceName := "test-name"
125+ testService := makeHostedServiceDescriptor(serviceName)
126+ testService.Status = "something"
127+ azInstance := azureInstance{*testService, nil}
128+ c.Check(azInstance.Status(), Equals, testService.Status)
129+}
130+
131 func (*instanceSuite) TestDNSName(c *C) {
132 // An instance's DNS name is computed from its hosted-service name.
133 host := "hostname"
134
135=== modified file 'environs/dummy/environs.go'
136--- environs/dummy/environs.go 2013-07-30 16:39:37 +0000
137+++ environs/dummy/environs.go 2013-08-09 02:41:46 +0000
138@@ -726,6 +726,10 @@
139 return inst.id
140 }
141
142+func (inst *dummyInstance) Status() string {
143+ return ""
144+}
145+
146 func (inst *dummyInstance) DNSName() (string, error) {
147 defer delay()
148 return string(inst.id) + ".dns", nil
149
150=== modified file 'environs/ec2/ec2.go'
151--- environs/ec2/ec2.go 2013-07-30 23:46:30 +0000
152+++ environs/ec2/ec2.go 2013-08-09 02:41:46 +0000
153@@ -72,6 +72,10 @@
154 return instance.Id(inst.InstanceId)
155 }
156
157+func (inst *ec2Instance) Status() string {
158+ return inst.State.Name
159+}
160+
161 func (inst *ec2Instance) hardwareCharacteristics() *instance.HardwareCharacteristics {
162 hc := &instance.HardwareCharacteristics{Arch: inst.arch}
163 if inst.instType != nil {
164
165=== modified file 'environs/ec2/local_test.go'
166--- environs/ec2/local_test.go 2013-07-30 23:46:30 +0000
167+++ environs/ec2/local_test.go 2013-08-09 02:41:46 +0000
168@@ -303,6 +303,21 @@
169 c.Assert(err, NotNil)
170 }
171
172+func (t *localServerSuite) TestInstanceStatus(c *C) {
173+ err := environs.Bootstrap(t.env, constraints.Value{})
174+ c.Assert(err, IsNil)
175+ series := t.env.Config().DefaultSeries()
176+ info, apiInfo, err := t.env.StateInfo()
177+ c.Assert(err, IsNil)
178+ c.Assert(info, NotNil)
179+ info.Tag = "machine-1"
180+ apiInfo.Tag = "machine-1"
181+ t.srv.ec2srv.SetInitialInstanceState(ec2test.Terminated)
182+ inst, _, err := t.env.StartInstance("1", "fake_nonce", series, constraints.Value{}, info, apiInfo)
183+ c.Assert(err, IsNil)
184+ c.Assert(inst.Status(), Equals, "terminated")
185+}
186+
187 func (t *localServerSuite) TestStartInstanceHardwareCharacteristics(c *C) {
188 err := environs.Bootstrap(t.env, constraints.Value{})
189 c.Assert(err, IsNil)
190
191=== modified file 'environs/local/instance.go'
192--- environs/local/instance.go 2013-07-19 01:18:26 +0000
193+++ environs/local/instance.go 2013-08-09 02:41:46 +0000
194@@ -22,6 +22,11 @@
195 return inst.id
196 }
197
198+// Status implements instance.Instance.Status.
199+func (inst *localInstance) Status() string {
200+ return ""
201+}
202+
203 func (inst *localInstance) Addresses() ([]instance.Address, error) {
204 logger.Errorf("localInstance.Addresses not implemented")
205 return nil, nil
206
207=== modified file 'environs/maas/instance.go'
208--- environs/maas/instance.go 2013-07-19 01:18:26 +0000
209+++ environs/maas/instance.go 2013-08-09 02:41:46 +0000
210@@ -22,6 +22,15 @@
211 return instance.Id((*mi.maasObject).URI().String())
212 }
213
214+func (mi *maasInstance) Status() string {
215+ // MAAS does not track node status once they're allocated.
216+ // Since any instance that juju knows about will be an
217+ // allocated one, it doesn't make sense to report any
218+ // state unless we obtain it through some means other than
219+ // through the MAAS API.
220+ return ""
221+}
222+
223 // refreshInstance refreshes the instance with the most up-to-date information
224 // from the MAAS server.
225 func (mi *maasInstance) refreshInstance() error {
226
227=== modified file 'environs/openstack/local_test.go'
228--- environs/openstack/local_test.go 2013-07-30 23:46:30 +0000
229+++ environs/openstack/local_test.go 2013-08-09 02:41:46 +0000
230@@ -330,6 +330,14 @@
231 },
232 }
233
234+func (s *localServerSuite) TestInstanceStatus(c *C) {
235+ // goose's test service always returns ACTIVE state.
236+ inst, _ := testing.StartInstance(c, s.Env, "100")
237+ c.Assert(inst.Status(), Equals, nova.StatusActive)
238+ err := s.Env.StopInstances([]instance.Instance{inst})
239+ c.Assert(err, IsNil)
240+}
241+
242 func (s *localServerSuite) TestInstancesGathering(c *C) {
243 inst0, _ := testing.StartInstance(c, s.Env, "100")
244 id0 := inst0.Id()
245
246=== modified file 'environs/openstack/provider.go'
247--- environs/openstack/provider.go 2013-07-30 23:46:30 +0000
248+++ environs/openstack/provider.go 2013-08-09 02:41:46 +0000
249@@ -242,6 +242,10 @@
250 return instance.Id(inst.ServerDetail.Id)
251 }
252
253+func (inst *openstackInstance) Status() string {
254+ return inst.ServerDetail.Status
255+}
256+
257 func (inst *openstackInstance) hardwareCharacteristics() *instance.HardwareCharacteristics {
258 hc := &instance.HardwareCharacteristics{Arch: inst.arch}
259 if inst.instType != nil {
260
261=== modified file 'environs/polling_test.go'
262--- environs/polling_test.go 2013-07-24 14:37:17 +0000
263+++ environs/polling_test.go 2013-08-09 02:41:46 +0000
264@@ -42,6 +42,8 @@
265 // DNSName returns whatever you tell it to, and WaitDNSName delegates to the
266 // shared WaitDNSName implementation. All the other methods are empty stubs.
267 type dnsNameFakeInstance struct {
268+ // embed a nil Instance to panic on unimplemented method
269+ instance.Instance
270 name string
271 err error
272 }
273@@ -56,11 +58,7 @@
274 return environs.WaitDNSName(inst)
275 }
276
277-func (*dnsNameFakeInstance) Addresses() ([]instance.Address, error) { return nil, nil }
278-func (*dnsNameFakeInstance) Id() instance.Id { return "" }
279-func (*dnsNameFakeInstance) OpenPorts(string, []instance.Port) error { return nil }
280-func (*dnsNameFakeInstance) ClosePorts(string, []instance.Port) error { return nil }
281-func (*dnsNameFakeInstance) Ports(string) ([]instance.Port, error) { return nil, nil }
282+func (*dnsNameFakeInstance) Id() instance.Id { return "" }
283
284 func (pollingSuite) TestWaitDNSNameReturnsDNSNameIfAvailable(c *C) {
285 inst := dnsNameFakeInstance{name: "anansi"}
286
287=== modified file 'instance/instance.go'
288--- instance/instance.go 2013-07-24 13:07:02 +0000
289+++ instance/instance.go 2013-08-09 02:41:46 +0000
290@@ -32,6 +32,9 @@
291 // Id returns a provider-generated identifier for the Instance.
292 Id() Id
293
294+ // Status returns the provider-specific status for the instance.
295+ Status() string
296+
297 // Addresses returns a list of hostnames or ip addresses
298 // associated with the instance. This will supercede DNSName
299 // which can be implemented by selecting a preferred address.

Subscribers

People subscribed via source and target branches

to status/vote changes: