Merge lp:~axwalk/juju-core/lp1211147-machine-isstateserver 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: | 1664 |
Proposed branch: | lp:~axwalk/juju-core/lp1211147-machine-isstateserver |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
52 lines (+31/-0) 2 files modified
state/machine.go (+10/-0) state/machine_test.go (+21/-0) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1211147-machine-isstateserver |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+180277@code.launchpad.net |
Commit message
Add convenience method Machine.
Description of the change
Add convenience method Machine.
To post a comment you must log in.
Reviewers: mp+180277_ code.launchpad. net,
Message:
Please take a look.
Description: IsStateServer
Add convenience method Machine.
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1211147- machine- isstateserver/ +merge/ 180277
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/12745044/
Affected files: test.go
A [revision details]
M state/machine.go
M state/machine_
Index: [revision details] 20130809021225- 6c5p05y8zs5j83o 3
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: state/machine.go
=== modified file 'state/machine.go'
--- state/machine.go 2013-08-07 18:02:26 +0000
+++ state/machine.go 2013-08-15 02:03:55 +0000
@@ -167,6 +167,16 @@
return m.doc.Jobs
}
+// IsStateServer returns true if the machine has a JobManageState job.
+func (m *Machine) IsStateServer() bool {
+ for _, job := range m.doc.Jobs {
+ if job == JobManageState {
+ return true
+ }
+ }
+ return false
+}
+
// AgentTools returns the tools that the agent is currently running.
// It returns an error that satisfies IsNotFound if the tools have not yet
been set.
func (m *Machine) AgentTools() (*tools.Tools, error) {
Index: state/machine_ test.go machine_ test.go' test.go 2013-08-08 17:56:28 +0000 test.go 2013-08-15 02:03:55 +0000
=== modified file 'state/
--- state/machine_
+++ state/machine_
@@ -58,6 +58,27 @@
c.Assert(ok, Equals, true)
}
+func (s *MachineSuite) TestMachineIsSt ateServer( c *C) { MachineJob{ state.JobHostUn its}}, MachineJob{ state.JobHostUn its, state.JobManage Environ} }, MachineJob{ state.JobHostUn its, state.JobManage State, Environ} }, MachineJob{ state.JobManage State}} , eParams{ AddMachineWithC onstraints( ¶ms) m.IsStateServer (), Equals, test.isStateServer) geEnviron( c *C) { AddMachine( "series" , state.JobManage Environ)
+ tests := []struct {
+ isStateServer bool
+ jobs []state.MachineJob
+ }{
+ {false, []state.
+ {false, []state.
+ {true, []state.
state.JobManage
+ {true, []state.
+ }
+ for _, test := range tests {
+ params := state.AddMachin
+ Series: "series",
+ Jobs: test.jobs,
+ }
+ m, err := s.State.
+ c.Assert(err, IsNil)
+ c.Assert(
+ }
+}
+
func (s *MachineSuite) TestLifeJobMana
// A JobManageEnviron machine must never advance lifecycle.
m, err := s.State.