diff --git a/api/agent/uniter/uniter.go b/api/agent/uniter/uniter.go index 7fed50ef7de0..adb262357c6c 100644 --- a/api/agent/uniter/uniter.go +++ b/api/agent/uniter/uniter.go @@ -434,35 +434,6 @@ func (st *State) OpenedPortRangesByEndpoint() (map[names.UnitTag]network.Grouped return processOpenPortRangesByEndpointResults(results, st.unitTag) } -// OpenedApplicationPortRangesByEndpoint returns all port ranges currently open for the given -// application, grouped by application endpoint. -func (st *State) OpenedApplicationPortRangesByEndpoint(appTag names.ApplicationTag) (network.GroupedPortRanges, error) { - if st.BestAPIVersion() < 18 { - // OpenedApplicationPortRangesByEndpoint() was introduced in UniterAPIV18. - return nil, errors.NotImplementedf("OpenedApplicationPortRangesByEndpoint() (need V18+)") - } - arg := params.Entity{Tag: appTag.String()} - var result params.ApplicationOpenedPortsResults - if err := st.facade.FacadeCall("OpenedApplicationPortRangesByEndpoint", arg, &result); err != nil { - return nil, errors.Trace(err) - } - if len(result.Results) != 1 { - return nil, errors.Errorf("expected 1 result, got %d", len(result.Results)) - } - res := result.Results[0] - if res.Error != nil { - err := apiservererrors.RestoreError(res.Error) - return nil, errors.Annotatef(err, "unable to fetch opened ports for %s", appTag) - } - out := make(network.GroupedPortRanges) - for _, pgs := range res.ApplicationPortRanges { - for _, pg := range pgs.PortRanges { - out[pgs.Endpoint] = append(out[pgs.Endpoint], pg.NetworkPortRange()) - } - } - return out, nil -} - // WatchRelationUnits returns a watcher that notifies of changes to the // counterpart units in the relation for the given unit. func (st *State) WatchRelationUnits( diff --git a/api/agent/uniter/uniter_test.go b/api/agent/uniter/uniter_test.go index 10197c3b38fd..b34986054d74 100644 --- a/api/agent/uniter/uniter_test.go +++ b/api/agent/uniter/uniter_test.go @@ -135,55 +135,6 @@ func (s *uniterSuite) TestOpenedPortRangesByEndpoint(c *gc.C) { }) } -func (s *uniterSuite) TestOpenedApplicationPortRangesByEndpoint(c *gc.C) { - apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error { - c.Assert(objType, gc.Equals, "Uniter") - c.Assert(request, gc.Equals, "OpenedApplicationPortRangesByEndpoint") - c.Assert(arg, gc.DeepEquals, params.Entity{Tag: "application-gitlab"}) - c.Assert(result, gc.FitsTypeOf, ¶ms.ApplicationOpenedPortsResults{}) - *(result.(*params.ApplicationOpenedPortsResults)) = params.ApplicationOpenedPortsResults{ - Results: []params.ApplicationOpenedPortsResult{ - { - ApplicationPortRanges: []params.ApplicationOpenedPorts{ - { - Endpoint: "", - PortRanges: []params.PortRange{{100, 200, "tcp"}}, - }, - { - Endpoint: "server", - PortRanges: []params.PortRange{{3306, 3306, "tcp"}}, - }, - }, - }, - }, - } - return nil - }) - caller := testing.BestVersionCaller{apiCaller, 18} - client := uniter.NewState(caller, names.NewUnitTag("gitlab/0")) - - result, err := client.OpenedApplicationPortRangesByEndpoint(names.NewApplicationTag("gitlab")) - c.Assert(err, jc.ErrorIsNil) - c.Assert(result, jc.DeepEquals, network.GroupedPortRanges{ - "": []network.PortRange{network.MustParsePortRange("100-200/tcp")}, - "server": []network.PortRange{network.MustParsePortRange("3306/tcp")}, - }) -} - -func (s *uniterSuite) TestOpenedApplicationPortRangesByEndpointOldAPINotSupported(c *gc.C) { - apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error { - c.Assert(objType, gc.Equals, "Uniter") - c.Assert(request, gc.Equals, "OpenedApplicationPortRangesByEndpoint") - c.Assert(arg, gc.DeepEquals, params.Entities{Entities: []params.Entity{{Tag: "unit-gitlab-0"}}}) - return nil - }) - caller := testing.BestVersionCaller{apiCaller, 17} - client := uniter.NewState(caller, names.NewUnitTag("gitlab/0")) - - _, err := client.OpenedApplicationPortRangesByEndpoint(names.NewApplicationTag("gitlab")) - c.Assert(err, gc.ErrorMatches, `OpenedApplicationPortRangesByEndpoint\(\) \(need V18\+\) not implemented`) -} - func (s *uniterSuite) TestOpenedPortRangesByEndpointOldAPINotSupported(c *gc.C) { apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error { c.Assert(objType, gc.Equals, "Uniter") diff --git a/api/facadeversions.go b/api/facadeversions.go index 102a09c4689a..35cc5422f978 100644 --- a/api/facadeversions.go +++ b/api/facadeversions.go @@ -125,7 +125,7 @@ var facadeVersions = map[string][]int{ "Subnets": {5}, "Undertaker": {1}, "UnitAssigner": {1}, - "Uniter": {18, 19}, + "Uniter": {19}, "Upgrader": {1}, "UpgradeSeries": {3}, "UpgradeSteps": {2},