Merge lp:~hduran-8/juju-core/add_network_check_on_specified_machine into lp:~go-bot/juju-core/trunk
- add_network_check_on_specified_machine
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~hduran-8/juju-core/add_network_check_on_specified_machine |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
301 lines (+147/-2) 13 files modified
cmd/juju/deploy.go (+2/-1) environs/interface.go (+4/-0) juju/deploy.go (+21/-0) provider/azure/environ.go (+5/-0) provider/dummy/environs.go (+5/-0) provider/ec2/ec2.go (+5/-0) provider/joyent/environ.go (+5/-0) provider/local/environ.go (+5/-0) provider/maas/environ.go (+44/-1) provider/maas/environ_whitebox_test.go (+21/-0) provider/manual/environ.go (+5/-0) provider/openstack/provider.go (+5/-0) state/apiserver/client/client.go (+20/-0) |
To merge this branch: | bzr merge lp:~hduran-8/juju-core/add_network_check_on_specified_machine |
Related bugs: | |
Related blueprints: |
Support MaaS VLANs in Juju
(Essential)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+214463@code.launchpad.net |
Commit message
Description of the change
Added --not/network compat verification for --to
I added ValidateNetwork
This method checks if te requested networks are
available in the instance selected with --to
and if the excluded networks are not in conflict
with already existing ones.
I added this to the Environ interface and mocked
the method in all the available providers.
This method is only required when SupportNetworks
from EnvironCapability is true
Dimiter Naydenov (dimitern) wrote : | # |
Good direction, but I have some concerns and suggestions to make it
better.
https:/
File cmd/juju/deploy.go (right):
https:/
cmd/juju/
d
https:/
File environs/
https:/
environs/
the networks are
// ValidateNetwork
// are not compatible for the given instance id.
s/instance_id string/instanceId instance.Id/
https:/
File juju/deploy.go (right):
https:/
juju/deploy.go:37: func (parms *DeployServiceP
(string, instance.
s/parms/args/ ?
https:/
juju/deploy.go:38: // TODO: Add this to AddUnit and replace wherever
required
// TODO(hduran-8) ...
https:/
File provider/
https:/
provider/
e.instances(
s/maasObj_
https:/
provider/
of instances with the given id")
return fmt.Errorf(
https:/
provider/
logger.Debugf("got networks from MAAS: %v", networks) ?
https:/
provider/
{
s/i_network/
https:/
provider/
logger.Debugf("got networks map from MAAS: %v", netmap)
https:/
provider/
the requested unit", i_network)
Why IP ? We're getting network names in the command and we should check
for that in maas result list, not IPs.
return fmt.Errorf("network %q not found for instance %q in MAAS",
network, instanceId)
https:/
provider/
requested unit and can not be excluded", i_network)
Similarly, return fmt.Errorf("network %q is required for instance %q and
cannot be excluded", network, instanceId)
https:/
File provider/
Dimiter Naydenov (dimitern) wrote : | # |
Also, the kanban card mentioned deploy and add-unit for --to, and I
can't see the changes to the latter (add --(exclude)
check them if --to is given, otherwise return an error if networks are
specified I think). Finally, we need to make sure if the user specifies
networks for both commands, all given networks must be in
include/
add/remove networks from the service when deploying new units, just
restrict what networks will be enabled out of the initially given
networks for the service).
William Reade (fwereade) wrote : | # |
As it stands, this does not lgtm. I think this needs to happen inside
state, based on the contents of state, at unit assignment time, and in a
txn that checks against the current service networks -- doing it that
way should make it possible to correctly handle both deploy and
add-unit.
https:/
File environs/
https:/
environs/
excludedNetworks []string, instance_id string) error
Not 100%sure about this direction -- I'd rather not talk to the provider
if we have the info available in state. Dimitern, what's the status of
the pipeline that sets actual networks on machines?
https:/
File juju/deploy.go (right):
https:/
juju/deploy.go:37: func (parms *DeployServiceP
(string, instance.
Needs documentation, intent is not clear from the name IMO.
https:/
juju/deploy.go:49: if containerType, err =
instance.
You surely didn't have the context to know this, but this is *not* a
container type -- the stuff in --to is a "placement directive", of which
the only one implemented is "lxc".
Haven't looked further; so, if this is consolidating the couple of bits
of code that already do this sort of thing, +1, because it reduces the
number of places we need to fix as we do placement directives properly;
if it's further duplication, -1.
https:/
File provider/
https:/
provider/
This needs to return an error; but I have a pretty serious problem with
the existence of this exported method in the first place. We really
shouldn't be casting Environs like this...
https:/
provider/
!= 1?
but... again, I don't think this should be an environ method anyway.
https:/
File state/apiserver
https:/
state/apiserver
env.ValidateNet
args.ExcludeNet
If I were happy with the environ method, I'd still rather keep this
check inside state, so we can keep ensuring db integrity as networks
become dynamic -- not directly relevant for *deploy*, I guess, but
trying to do the same job in different layers at different times should
generally be avoided ;).
Dimiter Naydenov (dimitern) wrote : | # |
https:/
File environs/
https:/
environs/
excludedNetworks []string, instance_id string) error
On 2014/04/07 09:29:40, fwereade wrote:
> Not 100%sure about this direction -- I'd rather not talk to the
provider if we
> have the info available in state. Dimitern, what's the status of the
pipeline
> that sets actual networks on machines?
We can set networks and NICs on machines in state, but the provisioner
does not do it yet - it will some time later today I hope.
Unmerged revisions
- 2549. By Horacio Durán
-
Ran GoFmt on files
- 2548. By Horacio Durán
-
Fixed ValidateNetwork
sForInstance after testing and added tests - 2547. By Horacio Durán
-
Finished implementing ValidateNetwork
sForInstance in environs, still missing tests - 2546. By Horacio Durán
-
Added most of the required methods to check if requested methods are possible
on the requierd environ - 2545. By Horacio Durán
-
Did a base implementtion for checking netowrk compatibility on --to
Preview Diff
1 | === modified file 'cmd/juju/deploy.go' | |||
2 | --- cmd/juju/deploy.go 2014-04-03 04:46:51 +0000 | |||
3 | +++ cmd/juju/deploy.go 2014-04-07 02:15:57 +0000 | |||
4 | @@ -76,7 +76,7 @@ | |||
5 | 76 | juju deploy mysql --to 23 (Deploy to machine 23) | 76 | juju deploy mysql --to 23 (Deploy to machine 23) |
6 | 77 | juju deploy mysql --to 24/lxc/3 (Deploy to lxc container 3 on host machine 24) | 77 | juju deploy mysql --to 24/lxc/3 (Deploy to lxc container 3 on host machine 24) |
7 | 78 | juju deploy mysql --to lxc:25 (Deploy to a new lxc container on host machine 25) | 78 | juju deploy mysql --to lxc:25 (Deploy to a new lxc container on host machine 25) |
9 | 79 | 79 | ||
10 | 80 | juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each) | 80 | juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each) |
11 | 81 | 81 | ||
12 | 82 | juju deploy mysql --networks=storage,mynet --exclude-networks=logging | 82 | juju deploy mysql --networks=storage,mynet --exclude-networks=logging |
13 | @@ -194,6 +194,7 @@ | |||
14 | 194 | if !env.SupportNetworks() { | 194 | if !env.SupportNetworks() { |
15 | 195 | return errors.New("cannot use --networks/--exclude-networks: not supported by the environment") | 195 | return errors.New("cannot use --networks/--exclude-networks: not supported by the environment") |
16 | 196 | } | 196 | } |
17 | 197 | |||
18 | 197 | } | 198 | } |
19 | 198 | 199 | ||
20 | 199 | charmInfo, err := client.CharmInfo(curl.String()) | 200 | charmInfo, err := client.CharmInfo(curl.String()) |
21 | 200 | 201 | ||
22 | === modified file 'environs/interface.go' | |||
23 | --- environs/interface.go 2014-04-03 03:37:45 +0000 | |||
24 | +++ environs/interface.go 2014-04-07 02:15:57 +0000 | |||
25 | @@ -153,6 +153,10 @@ | |||
26 | 153 | // FwGlobal firewall mode. | 153 | // FwGlobal firewall mode. |
27 | 154 | Ports() ([]instance.Port, error) | 154 | Ports() ([]instance.Port, error) |
28 | 155 | 155 | ||
29 | 156 | // ValidateNetworksForInstance returns nil if the networks are | ||
30 | 157 | // compatible with the given insance or error in case they arent | ||
31 | 158 | ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error | ||
32 | 159 | |||
33 | 156 | // Provider returns the EnvironProvider that created this Environ. | 160 | // Provider returns the EnvironProvider that created this Environ. |
34 | 157 | Provider() EnvironProvider | 161 | Provider() EnvironProvider |
35 | 158 | 162 | ||
36 | 159 | 163 | ||
37 | === modified file 'juju/deploy.go' | |||
38 | --- juju/deploy.go 2014-04-03 09:10:10 +0000 | |||
39 | +++ juju/deploy.go 2014-04-07 02:15:57 +0000 | |||
40 | @@ -34,6 +34,27 @@ | |||
41 | 34 | ExcludeNetworks []string | 34 | ExcludeNetworks []string |
42 | 35 | } | 35 | } |
43 | 36 | 36 | ||
44 | 37 | func (parms *DeployServiceParams) ClearMachineSpecs() (string, instance.ContainerType) { | ||
45 | 38 | // TODO: Add this to AddUnit and replace wherever required | ||
46 | 39 | // machineIdSpec may be an existing machine or container, eg 3/lxc/2 | ||
47 | 40 | // or a new container on a machine, eg lxc:3 | ||
48 | 41 | |||
49 | 42 | mid := parms.ToMachineSpec | ||
50 | 43 | var containerType instance.ContainerType | ||
51 | 44 | specParts := strings.SplitN(mid, ":", 2) | ||
52 | 45 | if len(specParts) > 1 { | ||
53 | 46 | firstPart := specParts[0] | ||
54 | 47 | var err error | ||
55 | 48 | // If the type is present in the first part, the seccond is the id | ||
56 | 49 | if containerType, err = instance.ParseContainerType(firstPart); err == nil { | ||
57 | 50 | mid = specParts[1] | ||
58 | 51 | } else { | ||
59 | 52 | mid = parms.ToMachineSpec | ||
60 | 53 | } | ||
61 | 54 | } | ||
62 | 55 | return mid, containerType | ||
63 | 56 | } | ||
64 | 57 | |||
65 | 37 | // DeployService takes a charm and various parameters and deploys it. | 58 | // DeployService takes a charm and various parameters and deploys it. |
66 | 38 | func DeployService(st *state.State, args DeployServiceParams) (*state.Service, error) { | 59 | func DeployService(st *state.State, args DeployServiceParams) (*state.Service, error) { |
67 | 39 | if args.NumUnits > 1 && args.ToMachineSpec != "" { | 60 | if args.NumUnits > 1 && args.ToMachineSpec != "" { |
68 | 40 | 61 | ||
69 | === modified file 'provider/azure/environ.go' | |||
70 | --- provider/azure/environ.go 2014-04-03 09:07:57 +0000 | |||
71 | +++ provider/azure/environ.go 2014-04-07 02:15:57 +0000 | |||
72 | @@ -387,6 +387,11 @@ | |||
73 | 387 | return env.supportedArchitectures, err | 387 | return env.supportedArchitectures, err |
74 | 388 | } | 388 | } |
75 | 389 | 389 | ||
76 | 390 | func (e *azureEnviron) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
77 | 391 | // If SupportNetworks is true, this should be implemented | ||
78 | 392 | return nil | ||
79 | 393 | } | ||
80 | 394 | |||
81 | 390 | // SupportNetworks is specified on the EnvironCapability interface. | 395 | // SupportNetworks is specified on the EnvironCapability interface. |
82 | 391 | func (env *azureEnviron) SupportNetworks() bool { | 396 | func (env *azureEnviron) SupportNetworks() bool { |
83 | 392 | return false | 397 | return false |
84 | 393 | 398 | ||
85 | === modified file 'provider/dummy/environs.go' | |||
86 | --- provider/dummy/environs.go 2014-04-04 16:52:41 +0000 | |||
87 | +++ provider/dummy/environs.go 2014-04-07 02:15:57 +0000 | |||
88 | @@ -536,6 +536,11 @@ | |||
89 | 536 | return []string{arch.AMD64, arch.PPC64}, nil | 536 | return []string{arch.AMD64, arch.PPC64}, nil |
90 | 537 | } | 537 | } |
91 | 538 | 538 | ||
92 | 539 | func (e *environ) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
93 | 540 | // TODO: Actually check if networks are compatible with the instace | ||
94 | 541 | return nil | ||
95 | 542 | } | ||
96 | 543 | |||
97 | 539 | // SupportNetworks is specified on the EnvironCapability interface. | 544 | // SupportNetworks is specified on the EnvironCapability interface. |
98 | 540 | func (*environ) SupportNetworks() bool { | 545 | func (*environ) SupportNetworks() bool { |
99 | 541 | return true | 546 | return true |
100 | 542 | 547 | ||
101 | === modified file 'provider/ec2/ec2.go' | |||
102 | --- provider/ec2/ec2.go 2014-04-03 04:46:51 +0000 | |||
103 | +++ provider/ec2/ec2.go 2014-04-07 02:15:57 +0000 | |||
104 | @@ -350,6 +350,11 @@ | |||
105 | 350 | return e.supportedArchitectures, err | 350 | return e.supportedArchitectures, err |
106 | 351 | } | 351 | } |
107 | 352 | 352 | ||
108 | 353 | func (e *environ) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
109 | 354 | // If SupportNetworks is true, this should be implemented | ||
110 | 355 | return nil | ||
111 | 356 | } | ||
112 | 357 | |||
113 | 353 | // SupportNetworks is specified on the EnvironCapability interface. | 358 | // SupportNetworks is specified on the EnvironCapability interface. |
114 | 354 | func (e *environ) SupportNetworks() bool { | 359 | func (e *environ) SupportNetworks() bool { |
115 | 355 | // TODO(dimitern) Once we have support for VPCs and advanced | 360 | // TODO(dimitern) Once we have support for VPCs and advanced |
116 | 356 | 361 | ||
117 | === modified file 'provider/joyent/environ.go' | |||
118 | --- provider/joyent/environ.go 2014-04-03 20:05:38 +0000 | |||
119 | +++ provider/joyent/environ.go 2014-04-07 02:15:57 +0000 | |||
120 | @@ -96,6 +96,11 @@ | |||
121 | 96 | return env.supportedArchitectures, err | 96 | return env.supportedArchitectures, err |
122 | 97 | } | 97 | } |
123 | 98 | 98 | ||
124 | 99 | func (e *joyentEnviron) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
125 | 100 | // If SupportNetworks is true, this should be implemented | ||
126 | 101 | return nil | ||
127 | 102 | } | ||
128 | 103 | |||
129 | 99 | // SupportNetworks is specified on the EnvironCapability interface. | 104 | // SupportNetworks is specified on the EnvironCapability interface. |
130 | 100 | func (e *joyentEnviron) SupportNetworks() bool { | 105 | func (e *joyentEnviron) SupportNetworks() bool { |
131 | 101 | return false | 106 | return false |
132 | 102 | 107 | ||
133 | === modified file 'provider/local/environ.go' | |||
134 | --- provider/local/environ.go 2014-04-03 03:37:45 +0000 | |||
135 | +++ provider/local/environ.go 2014-04-07 02:15:57 +0000 | |||
136 | @@ -81,6 +81,11 @@ | |||
137 | 81 | return []string{localArch}, nil | 81 | return []string{localArch}, nil |
138 | 82 | } | 82 | } |
139 | 83 | 83 | ||
140 | 84 | func (e *localEnviron) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
141 | 85 | // If SupportNetworks is true, this should be implemented | ||
142 | 86 | return nil | ||
143 | 87 | } | ||
144 | 88 | |||
145 | 84 | // SupportNetworks is specified on the EnvironCapability interface. | 89 | // SupportNetworks is specified on the EnvironCapability interface. |
146 | 85 | func (*localEnviron) SupportNetworks() bool { | 90 | func (*localEnviron) SupportNetworks() bool { |
147 | 86 | return false | 91 | return false |
148 | 87 | 92 | ||
149 | === modified file 'provider/maas/environ.go' | |||
150 | --- provider/maas/environ.go 2014-04-03 03:37:45 +0000 | |||
151 | +++ provider/maas/environ.go 2014-04-07 02:15:57 +0000 | |||
152 | @@ -81,6 +81,15 @@ | |||
153 | 81 | return env, nil | 81 | return env, nil |
154 | 82 | } | 82 | } |
155 | 83 | 83 | ||
156 | 84 | func GetFromEnvironInterface(interfaceEnv environs.Environ) *maasEnviron { | ||
157 | 85 | maasEnv, ok := interfaceEnv.(*maasEnviron) | ||
158 | 86 | |||
159 | 87 | if !ok { | ||
160 | 88 | return nil | ||
161 | 89 | } | ||
162 | 90 | return maasEnv | ||
163 | 91 | } | ||
164 | 92 | |||
165 | 84 | // Name is specified in the Environ interface. | 93 | // Name is specified in the Environ interface. |
166 | 85 | func (env *maasEnviron) Name() string { | 94 | func (env *maasEnviron) Name() string { |
167 | 86 | return env.name | 95 | return env.name |
168 | @@ -558,7 +567,41 @@ | |||
169 | 558 | Description string | 567 | Description string |
170 | 559 | } | 568 | } |
171 | 560 | 569 | ||
173 | 561 | // GetNetworksList returns a list of strings which contain networks for a gien maas node instance. | 570 | func (e *maasEnviron) ValidateNetworksForInstance(includedNetworks, ExcludeNetworks []string, instance_id string) error { |
174 | 571 | maasObj_list, err := e.instances([]instance.Id{instance.Id(instance_id)}) | ||
175 | 572 | if err != nil { | ||
176 | 573 | return err | ||
177 | 574 | } | ||
178 | 575 | if len(maasObj_list) == 0 { | ||
179 | 576 | //XXX: I am not sure this can actually happen | ||
180 | 577 | return fmt.Errorf("Found unexpected amunt of instances with the given id") | ||
181 | 578 | } | ||
182 | 579 | maasObj := maasObj_list[0] | ||
183 | 580 | |||
184 | 581 | networks, _ := e.GetNetworksList(maasObj) | ||
185 | 582 | netmap := make(map[string]string) | ||
186 | 583 | fmt.Print(networks) | ||
187 | 584 | |||
188 | 585 | for _, value := range networks { | ||
189 | 586 | netmap[value.Ip] = "" | ||
190 | 587 | } | ||
191 | 588 | |||
192 | 589 | for _, i_network := range includedNetworks { | ||
193 | 590 | if _, ok := netmap[i_network]; !ok { | ||
194 | 591 | fmt.Print(netmap) | ||
195 | 592 | return fmt.Errorf("Ip %q is not present in the requested unit", i_network) | ||
196 | 593 | } | ||
197 | 594 | } | ||
198 | 595 | |||
199 | 596 | for _, i_network := range ExcludeNetworks { | ||
200 | 597 | if _, ok := netmap[i_network]; ok { | ||
201 | 598 | return fmt.Errorf("Ip %q is set up in the requested unit and can not be excluded", i_network) | ||
202 | 599 | } | ||
203 | 600 | } | ||
204 | 601 | return nil | ||
205 | 602 | } | ||
206 | 603 | |||
207 | 604 | // GetNetworksList returns a list of strings which contain networks for a given maas node instance. | ||
208 | 562 | func (e *maasEnviron) GetNetworksList(inst instance.Instance) ([]MAASNetworkDetails, error) { | 605 | func (e *maasEnviron) GetNetworksList(inst instance.Instance) ([]MAASNetworkDetails, error) { |
209 | 563 | maasInst := inst.(*maasInstance) | 606 | maasInst := inst.(*maasInstance) |
210 | 564 | maasObj := maasInst.maasObject | 607 | maasObj := maasInst.maasObject |
211 | 565 | 608 | ||
212 | === modified file 'provider/maas/environ_whitebox_test.go' | |||
213 | --- provider/maas/environ_whitebox_test.go 2014-04-02 07:50:15 +0000 | |||
214 | +++ provider/maas/environ_whitebox_test.go 2014-04-07 02:15:57 +0000 | |||
215 | @@ -542,3 +542,24 @@ | |||
216 | 542 | // once gomaasapi testing server supports networks. | 542 | // once gomaasapi testing server supports networks. |
217 | 543 | c.Assert(env.SupportNetworks(), jc.IsFalse) | 543 | c.Assert(env.SupportNetworks(), jc.IsFalse) |
218 | 544 | } | 544 | } |
219 | 545 | |||
220 | 546 | func (suite *environSuite) TestValidateNetworksForNode(c *gc.C) { | ||
221 | 547 | test_environ := suite.makeEnviron() | ||
222 | 548 | suite.getNetwork("test_network") | ||
223 | 549 | suite.getInstance("instance_for_network") | ||
224 | 550 | suite.testMAASObject.TestServer.ConnectNodeToNetwork("instance_for_network", "test_network") | ||
225 | 551 | |||
226 | 552 | err := test_environ.ValidateNetworksForInstance([]string{"127.0.0.1"}, []string{}, "instance_for_network") | ||
227 | 553 | c.Assert(err, gc.IsNil) | ||
228 | 554 | |||
229 | 555 | err = test_environ.ValidateNetworksForInstance([]string{}, []string{"127.0.0.2"}, "instance_for_network") | ||
230 | 556 | c.Assert(err, gc.IsNil) | ||
231 | 557 | |||
232 | 558 | expected_err := fmt.Errorf("Ip %q is set up in the requested unit and can not be excluded", "127.0.0.1") | ||
233 | 559 | err = test_environ.ValidateNetworksForInstance([]string{}, []string{"127.0.0.1"}, "instance_for_network") | ||
234 | 560 | c.Check(err, gc.DeepEquals, expected_err) | ||
235 | 561 | |||
236 | 562 | expected_err = fmt.Errorf("Ip %q is not present in the requested unit", "127.0.0.2") | ||
237 | 563 | err = test_environ.ValidateNetworksForInstance([]string{"127.0.0.2"}, []string{}, "instance_for_network") | ||
238 | 564 | c.Check(err, gc.DeepEquals, expected_err) | ||
239 | 565 | } | ||
240 | 545 | 566 | ||
241 | === modified file 'provider/manual/environ.go' | |||
242 | --- provider/manual/environ.go 2014-04-03 04:03:00 +0000 | |||
243 | +++ provider/manual/environ.go 2014-04-07 02:15:57 +0000 | |||
244 | @@ -96,6 +96,11 @@ | |||
245 | 96 | return arch.AllSupportedArches, nil | 96 | return arch.AllSupportedArches, nil |
246 | 97 | } | 97 | } |
247 | 98 | 98 | ||
248 | 99 | func (e *manualEnviron) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
249 | 100 | // If SupportNetworks is true, this should be implemented | ||
250 | 101 | return nil | ||
251 | 102 | } | ||
252 | 103 | |||
253 | 99 | // SupportNetworks is specified on the EnvironCapability interface. | 104 | // SupportNetworks is specified on the EnvironCapability interface. |
254 | 100 | func (e *manualEnviron) SupportNetworks() bool { | 105 | func (e *manualEnviron) SupportNetworks() bool { |
255 | 101 | return false | 106 | return false |
256 | 102 | 107 | ||
257 | === modified file 'provider/openstack/provider.go' | |||
258 | --- provider/openstack/provider.go 2014-04-03 04:46:51 +0000 | |||
259 | +++ provider/openstack/provider.go 2014-04-07 02:15:57 +0000 | |||
260 | @@ -515,6 +515,11 @@ | |||
261 | 515 | return e.supportedArchitectures, err | 515 | return e.supportedArchitectures, err |
262 | 516 | } | 516 | } |
263 | 517 | 517 | ||
264 | 518 | func (e *environ) ValidateNetworksForInstance(includedNetworks, excludedNetworks []string, instance_id string) error { | ||
265 | 519 | // If SupportNetworks is true, this should be implemented | ||
266 | 520 | return nil | ||
267 | 521 | } | ||
268 | 522 | |||
269 | 518 | // SupportNetworks is specified on the EnvironCapability interface. | 523 | // SupportNetworks is specified on the EnvironCapability interface. |
270 | 519 | func (e *environ) SupportNetworks() bool { | 524 | func (e *environ) SupportNetworks() bool { |
271 | 520 | // TODO(dimitern) Once we have support for networking, inquire | 525 | // TODO(dimitern) Once we have support for networking, inquire |
272 | 521 | 526 | ||
273 | === modified file 'state/apiserver/client/client.go' | |||
274 | --- state/apiserver/client/client.go 2014-04-04 10:00:45 +0000 | |||
275 | +++ state/apiserver/client/client.go 2014-04-07 02:15:57 +0000 | |||
276 | @@ -298,6 +298,26 @@ | |||
277 | 298 | // allows specifying networks to include or exclude on the machine | 298 | // allows specifying networks to include or exclude on the machine |
278 | 299 | // where the charm gets deployed. | 299 | // where the charm gets deployed. |
279 | 300 | func (c *Client) ServiceDeployWithNetworks(args params.ServiceDeploy) error { | 300 | func (c *Client) ServiceDeployWithNetworks(args params.ServiceDeploy) error { |
280 | 301 | // XXX Get the actual node | ||
281 | 302 | parms := juju.DeployServiceParams{ | ||
282 | 303 | ToMachineSpec: args.ToMachineSpec, | ||
283 | 304 | IncludeNetworks: args.IncludeNetworks, | ||
284 | 305 | ExcludeNetworks: args.ExcludeNetworks} | ||
285 | 306 | |||
286 | 307 | mid, _ := parms.ClearMachineSpecs() | ||
287 | 308 | |||
288 | 309 | conn, err := juju.NewConnFromState(c.api.state) | ||
289 | 310 | env := conn.Environ | ||
290 | 311 | if env == nil { | ||
291 | 312 | return err | ||
292 | 313 | } | ||
293 | 314 | |||
294 | 315 | err = env.ValidateNetworksForInstance(args.IncludeNetworks, args.ExcludeNetworks, mid) | ||
295 | 316 | |||
296 | 317 | if err != nil { | ||
297 | 318 | return err | ||
298 | 319 | } | ||
299 | 320 | |||
300 | 301 | return c.ServiceDeploy(args) | 321 | return c.ServiceDeploy(args) |
301 | 302 | } | 322 | } |
302 | 303 | 323 |
Reviewers: mp+214463_ code.launchpad. net,
Message:
Please take a look.
Description:
Added --not/network compat verification for --to
I added ValidateNetwork sForInstance to Environ
This method checks if te requested networks are
available in the instance selected with --to
and if the excluded networks are not in conflict
with already existing ones.
I added this to the Environ interface and mocked
the method in all the available providers.
This method is only required when SupportNetworks
from EnvironCapability is true
https:/ /code.launchpad .net/~hduran- 8/juju- core/add_ network_ check_on_ specified_ machine/ +merge/ 214463
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/84880045/
Affected files (+149, -2 lines): interface. go azure/environ. go dummy/environs. go joyent/ environ. go local/environ. go maas/environ. go maas/environ_ whitebox_ test.go manual/ environ. go openstack/ provider. go /client/ client. go
A [revision details]
M cmd/juju/deploy.go
M environs/
M juju/deploy.go
M provider/
M provider/
M provider/ec2/ec2.go
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M state/apiserver