Merge lp:~gz/juju-core/add_startinstance_params into lp:~go-bot/juju-core/trunk

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 2445
Proposed branch: lp:~gz/juju-core/add_startinstance_params
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 134 lines (+43/-6)
4 files modified
environs/broker.go (+11/-0)
juju/testing/instance.go (+26/-0)
provider/common/bootstrap_test.go (+4/-4)
provider/common/mock_test.go (+2/-2)
To merge this branch: bzr merge lp:~gz/juju-core/add_startinstance_params
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+211588@code.launchpad.net

Commit message

environs: Added Networks to StartInstanceParams

Added to StartInstanceParams in environ/broker.go
Networks is a simple struct holding two str lists
defining which networks are to be included/excluded
for the started instance.

https://codereview.appspot.com/77490043/

R=natefinch

Description of the change

environs: Added Networks to StartInstanceParams

Added to StartInstanceParams in environ/broker.go
Networks is a simple struct holding two str lists
defining which networks are to be included/excluded
for the started instance.
Networks was defined in place for the moment.
Even though I added helpers to the ones already in
place (for Starting instances with constraints)
I did not add specific tests for the added struct.

https://codereview.appspot.com/77490043/

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :
Download full text (6.4 KiB)

Reviewers: mp+211588_code.launchpad.net,

Message:
Please take a look.

Description:
environs: Added Networks to StartInstanceParams

Added to StartInstanceParams in environ/broker.go
Networks is a simple struct holding two str lists
defining which networks are to be included/excluded
for the started instance.
Networks was defined in place for the moment.
Even though I added helpers to the ones already in
place (for Starting instances with constraints)
I did not add specific tests for the added struct.

https://code.launchpad.net/~gz/juju-core/add_startinstance_params/+merge/211588

(do not edit description out of merge proposal)

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

Affected files (+45, -6 lines):
   A [revision details]
   M environs/broker.go
   M juju/testing/instance.go
   M provider/common/bootstrap_test.go
   M provider/common/mock_test.go

Index: [revision details]
=== 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-20140318112939-onhi90o40412k44a
+New revision: <email address hidden>

Index: environs/broker.go
=== modified file 'environs/broker.go'
--- environs/broker.go 2014-03-13 05:09:14 +0000
+++ environs/broker.go 2014-03-18 17:18:22 +0000
@@ -10,6 +10,13 @@
   "launchpad.net/juju-core/tools"
  )

+// Networks holds network include/exclude
+// configuration
+type Networks struct {
+ IncludedNetworks []string
+ ExcludedNetworks []string
+}
+
  // StartInstanceParams holds parameters for the
  // InstanceBroker.StartInstace method.
  type StartInstanceParams struct {
@@ -17,6 +24,10 @@
   // the kind of instance to create.
   Constraints constraints.Value

+ // Networks holds 2 string slices indicating
+ // respectively included and excluded Networks
+ Networks Networks
+
   // Tools is a list of tools that may be used
   // to start a Juju agent on the machine.
   Tools tools.List

Index: juju/testing/instance.go
=== modified file 'juju/testing/instance.go'
--- juju/testing/instance.go 2014-03-13 05:09:14 +0000
+++ juju/testing/instance.go 2014-03-18 17:18:22 +0000
@@ -85,6 +85,31 @@
  ) (
   instance.Instance, *instance.HardwareCharacteristics, error,
  ) {
+ return StartInstanceWithConstraintsAndNetworks(env, machineId, cons,
environs.Networks{})
+}
+
+// AssertStartInstanceWithNetworks is a test helper function that starts an
+// instance with the given networks, and a plausible but invalid
+// configuration, and returns the result of Environ.StartInstance.
+func AssertStartInstanceWithNetworks(
+ c *gc.C, env environs.Environ, machineId string, cons constraints.Value,
nets environs.Networks,
+) (
+ instance.Instance, *instance.HardwareCharacteristics,
+) {
+ inst, hc, err := StartInstanceWithConstraintsAndNetworks(env, machineId,
cons, nets)
+ c.Assert(err, gc.IsNil)
+ return inst, hc
+}
+
+// StartInstanceWithNetworks is a test helper function that starts an
instance
+// with the given networks, and a plausible but invalid configuration, and
+// returns the result of Environ.StartInstance.
+func StartInstanceWithConstraintsAndNetwor...

Read more...

Revision history for this message
Nate Finch (natefinch) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/broker.go'
2--- environs/broker.go 2014-03-13 05:09:14 +0000
3+++ environs/broker.go 2014-03-18 17:27:01 +0000
4@@ -10,6 +10,13 @@
5 "launchpad.net/juju-core/tools"
6 )
7
8+// Networks holds network include/exclude
9+// configuration
10+type Networks struct {
11+ IncludedNetworks []string
12+ ExcludedNetworks []string
13+}
14+
15 // StartInstanceParams holds parameters for the
16 // InstanceBroker.StartInstace method.
17 type StartInstanceParams struct {
18@@ -17,6 +24,10 @@
19 // the kind of instance to create.
20 Constraints constraints.Value
21
22+ // Networks holds 2 string slices indicating
23+ // respectively included and excluded Networks
24+ Networks Networks
25+
26 // Tools is a list of tools that may be used
27 // to start a Juju agent on the machine.
28 Tools tools.List
29
30=== modified file 'juju/testing/instance.go'
31--- juju/testing/instance.go 2014-03-13 05:09:14 +0000
32+++ juju/testing/instance.go 2014-03-18 17:27:01 +0000
33@@ -85,6 +85,31 @@
34 ) (
35 instance.Instance, *instance.HardwareCharacteristics, error,
36 ) {
37+ return StartInstanceWithConstraintsAndNetworks(env, machineId, cons, environs.Networks{})
38+}
39+
40+// AssertStartInstanceWithNetworks is a test helper function that starts an
41+// instance with the given networks, and a plausible but invalid
42+// configuration, and returns the result of Environ.StartInstance.
43+func AssertStartInstanceWithNetworks(
44+ c *gc.C, env environs.Environ, machineId string, cons constraints.Value, nets environs.Networks,
45+) (
46+ instance.Instance, *instance.HardwareCharacteristics,
47+) {
48+ inst, hc, err := StartInstanceWithConstraintsAndNetworks(env, machineId, cons, nets)
49+ c.Assert(err, gc.IsNil)
50+ return inst, hc
51+}
52+
53+// StartInstanceWithNetworks is a test helper function that starts an instance
54+// with the given networks, and a plausible but invalid configuration, and
55+// returns the result of Environ.StartInstance.
56+func StartInstanceWithConstraintsAndNetworks(
57+ env environs.Environ, machineId string, cons constraints.Value,
58+ nets environs.Networks,
59+) (
60+ instance.Instance, *instance.HardwareCharacteristics, error,
61+) {
62 series := env.Config().DefaultSeries()
63 agentVersion, ok := env.Config().AgentVersion()
64 if !ok {
65@@ -100,6 +125,7 @@
66 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stateInfo, apiInfo)
67 return env.StartInstance(environs.StartInstanceParams{
68 Constraints: cons,
69+ Networks: nets,
70 Tools: possibleTools,
71 MachineConfig: machineConfig,
72 })
73
74=== modified file 'provider/common/bootstrap_test.go'
75--- provider/common/bootstrap_test.go 2014-03-13 07:54:56 +0000
76+++ provider/common/bootstrap_test.go 2014-03-18 17:27:01 +0000
77@@ -93,7 +93,7 @@
78 checkCons := constraints.MustParse("mem=8G")
79
80 startInstance := func(
81- cons constraints.Value, possibleTools tools.List, mcfg *cloudinit.MachineConfig,
82+ cons constraints.Value, _ environs.Networks, possibleTools tools.List, mcfg *cloudinit.MachineConfig,
83 ) (
84 instance.Instance, *instance.HardwareCharacteristics, error,
85 ) {
86@@ -118,7 +118,7 @@
87 stor := &mockStorage{Storage: innerStorage}
88
89 startInstance := func(
90- _ constraints.Value, _ tools.List, _ *cloudinit.MachineConfig,
91+ _ constraints.Value, _ environs.Networks, _ tools.List, _ *cloudinit.MachineConfig,
92 ) (
93 instance.Instance, *instance.HardwareCharacteristics, error,
94 ) {
95@@ -151,7 +151,7 @@
96 stor := &mockStorage{Storage: innerStorage}
97
98 startInstance := func(
99- _ constraints.Value, _ tools.List, _ *cloudinit.MachineConfig,
100+ _ constraints.Value, _ environs.Networks, _ tools.List, _ *cloudinit.MachineConfig,
101 ) (
102 instance.Instance, *instance.HardwareCharacteristics, error,
103 ) {
104@@ -193,7 +193,7 @@
105
106 checkURL := ""
107 startInstance := func(
108- _ constraints.Value, _ tools.List, mcfg *cloudinit.MachineConfig,
109+ _ constraints.Value, _ environs.Networks, _ tools.List, mcfg *cloudinit.MachineConfig,
110 ) (
111 instance.Instance, *instance.HardwareCharacteristics, error,
112 ) {
113
114=== modified file 'provider/common/mock_test.go'
115--- provider/common/mock_test.go 2014-03-13 05:09:14 +0000
116+++ provider/common/mock_test.go 2014-03-18 17:27:01 +0000
117@@ -17,7 +17,7 @@
118 )
119
120 type allInstancesFunc func() ([]instance.Instance, error)
121-type startInstanceFunc func(constraints.Value, tools.List, *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error)
122+type startInstanceFunc func(constraints.Value, environs.Networks, tools.List, *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error)
123 type stopInstancesFunc func([]instance.Instance) error
124 type getToolsSourcesFunc func() ([]simplestreams.DataSource, error)
125 type configFunc func() *config.Config
126@@ -46,7 +46,7 @@
127 return env.allInstances()
128 }
129 func (env *mockEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
130- return env.startInstance(args.Constraints, args.Tools, args.MachineConfig)
131+ return env.startInstance(args.Constraints, args.Networks, args.Tools, args.MachineConfig)
132 }
133
134 func (env *mockEnviron) StopInstances(instances []instance.Instance) error {

Subscribers

People subscribed via source and target branches

to status/vote changes: