func (api *MachinerAPI) SetProviderNetworkConfig(args params.Entities) (params.ErrorResults, error) { result := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } for i, arg := range args.Entities { m, err := api.getMachineForSettingNetworkConfig(arg.Tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } if m.IsContainer() { continue } providerConfig, err := api.getOneMachineProviderNetworkConfig(m) if err != nil { result.Results[i].Error = common.ServerError(err) continue } else if len(providerConfig) == 0 { continue } sortedProviderConfig := networkingcommon.SortNetworkConfigsByParents(providerConfig) logger.Tracef("sorted provider network config for %q: %+v", m.Id(), sortedProviderConfig) if err := api.setOneMachineNetworkConfig(m, sortedProviderConfig); err != nil { result.Results[i].Error = common.ServerError(err) continue } } return result, nil }
func (s *TypesSuite) checkSortNetworkConfigsByParentsWithAllInputPremutationsMatches(c *gc.C, expectedOutput []params.NetworkConfig) { expectedLength := len(expectedOutput) jsonExpected := s.networkConfigsAsJSON(c, expectedOutput) for i := 0; i < expectedLength; i++ { shuffledInput := shuffleNetworkConfigs(expectedOutput) result := networkingcommon.SortNetworkConfigsByParents(shuffledInput) c.Assert(result, gc.HasLen, expectedLength) jsonResult := s.networkConfigsAsJSON(c, result) c.Check(jsonResult, gc.Equals, jsonExpected) } }