Code review comment for lp:~allenap/gwacl/add-virtual-network

Raphaƫl Badin (rvb) wrote :

Looks generally good but I've got a question (see [0]).


76 + for _, existingSite := range *networkConfig.VirtualNetworkSites {
77 + if existingSite.Name == site.Name {
78 + // Network already defined.
79 + return nil
80 + }

That's a weird behavior don't you think? Say I try adding a network with the same name but a different affinity group; the method will return with a nil error so I'll think that everything is ok and it will be a lie :). I /think/ returning an error (maybe only if the network you're trying to add has exactly the same characteristics as the one with the same name which already exists) is more appropriate here. What do you think?


102 + for _, existingSite := range *networkConfig.VirtualNetworkSites {
103 + if existingSite.Name != siteName {
104 + virtualNetworkSites = append(virtualNetworkSites, existingSite)
105 + }

We cannot just remove the network in question from networkConfig.VirtualNetworkSites can we :/


208 + virtualNetwork := &VirtualNetworkSite{Name: MakeRandomVirtualNetworkName("test-")}
209 + err := api.AddVirtualNetworkSite(virtualNetwork)
210 + c.Assert(err, IsNil)
211 + c.Check(record, HasLen, 2)

It's a detail but that's something Jeroen and I have tried to do in tests, especially when the tests are long: put a empty line between the initialization code and the method you're testing, and another after that. This way, we have 3 visually well-separated blocks: initialization, method call, checks.


You could add a check in example/management/run.go to make sure that the created machine effectively has an IP in the virtual network.

review: Needs Information

« Back to merge proposal