This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new bd6f7ee8a3 Remove ASN from servers (#7118)
bd6f7ee8a3 is described below
commit bd6f7ee8a3af9baaa1d8ac1a429e0b7e43480c8f
Author: Srijeet Chatterjee <[email protected]>
AuthorDate: Thu Oct 20 11:47:22 2022 -0600
Remove ASN from servers (#7118)
* Remove ASN from servers
* remove unneeded file
* remove unneeded commit
* add error detail
---
CHANGELOG.md | 1 -
cache-config/t3cutil/toreq/clientfuncs.go | 2 +-
cache-config/t3cutil/toreq/conversions.go | 4 +-
docs/source/api/v4/deliveryservices_id_servers.rst | 4 -
.../v4/deliveryservices_id_servers_eligible.rst | 4 -
docs/source/api/v4/servers.rst | 11 ---
docs/source/api/v4/servers_id.rst | 8 --
docs/source/api/v5/deliveryservices_id_servers.rst | 2 -
.../v5/deliveryservices_id_servers_eligible.rst | 2 -
docs/source/api/v5/servers_id.rst | 4 -
infrastructure/cdn-in-a-box/enroller/enroller.go | 2 +-
lib/go-tc/deliveryservice_servers.go | 15 +---
lib/go-tc/servers.go | 10 +--
traffic_monitor/towrap/towrap.go | 2 +-
traffic_ops/testing/api/v4/servers_test.go | 64 +++-------------
.../traffic_ops_golang/dbhelpers/db_helpers.go | 2 +-
.../traffic_ops_golang/deliveryservice/eligible.go | 13 +---
.../deliveryservice/eligible_test.go | 5 +-
.../deliveryservice/keys_test.go | 6 +-
.../deliveryservice/servers/servers.go | 13 +---
.../deliveryservice/servers/servers_test.go | 5 +-
traffic_ops/traffic_ops_golang/routing/routes.go | 2 -
traffic_ops/traffic_ops_golang/server/servers.go | 88 +++++++---------------
.../traffic_ops_golang/server/servers_test.go | 26 +++----
.../table/servers/TableServersController.js | 5 --
traffic_router/ultimate-test-harness/http_test.go | 2 +-
26 files changed, 63 insertions(+), 239 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3ba5b55b0..cf73486453 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,6 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7055](https://github.com/apache/trafficcontrol/issues/7055) *Traffic
Portal* Made `Clear Table Filters` option visible to the user.
- [#7024](https://github.com/apache/trafficcontrol/pull/7024) *Traffic
Monitor* Added logging for `ipv4Availability` and `ipv6Availability` in TM.
- [#7063](https://github.com/apache/trafficcontrol/pull/7063) *Traffic Ops*
Added API version 5.0 (IN DEVELOPMENT)
-- [#7023](https://github.com/apache/trafficcontrol/pull/7023) *Traffic Ops*
Added the `ASN` field in TO Server struct, which provides the ability to query
servers by `ASN`.
- [#2101](https://github.com/apache/trafficcontrol/issues/2101) *Traffic
Portal* Added the ability to tell if a Delivery Service is the target of
another steering DS.
- [#6021](https://github.com/apache/trafficcontrol/issues/6021) *Traffic
Portal* Added the ability to view a change logs message in it's entirety by
clicking on it.
- [#6033](https://github.com/apache/trafficcontrol/issues/6033) *Traffic Ops,
Traffic Portal* Added ability to assign multiple server capabilities to a
server.
diff --git a/cache-config/t3cutil/toreq/clientfuncs.go
b/cache-config/t3cutil/toreq/clientfuncs.go
index f7a9ca15af..9c5e335ce5 100644
--- a/cache-config/t3cutil/toreq/clientfuncs.go
+++ b/cache-config/t3cutil/toreq/clientfuncs.go
@@ -169,7 +169,7 @@ func (cl *TOClient) GetServerByHostName(serverHostName
string, reqHdr http.Heade
if len(toServers.Response) < 1 {
return errors.New("getting server name '" +
serverHostName + "' from Traffic Ops '" +
torequtil.MaybeIPStr(reqInf.RemoteAddr) + "': no servers returned")
}
- asv, err :=
serverToLatest(&toServers.Response[0].ServerV40)
+ asv, err := serverToLatest(&toServers.Response[0])
if err != nil {
return errors.New("converting server to latest
version: " + err.Error())
}
diff --git a/cache-config/t3cutil/toreq/conversions.go
b/cache-config/t3cutil/toreq/conversions.go
index f480377fbe..7520a0498f 100644
--- a/cache-config/t3cutil/toreq/conversions.go
+++ b/cache-config/t3cutil/toreq/conversions.go
@@ -36,7 +36,7 @@ import (
func serversToLatest(svs tc.ServersV4Response) ([]atscfg.Server, error) {
serversV40 := make([]tc.ServerV40, 0)
for _, srv := range svs.Response {
- serversV40 = append(serversV40, srv.ServerV40)
+ serversV40 = append(serversV40, srv)
}
return atscfg.ToServers(serversV40), nil
}
@@ -222,7 +222,7 @@ func (cl *TOClient) GetServersCompat(opts
toclient.RequestOptions) (tc.ServersV4
if err != nil {
return tc.ServersV4Response{}, reqInf,
errors.New("converting server from possible legacy format: " + err.Error())
}
- resp.Response = append(resp.Response, tc.ServerV41{ServerV40:
newSv})
+ resp.Response = append(resp.Response, newSv)
}
return resp, reqInf, nil
}
diff --git a/docs/source/api/v4/deliveryservices_id_servers.rst
b/docs/source/api/v4/deliveryservices_id_servers.rst
index bb8c9676fa..69a64377f8 100644
--- a/docs/source/api/v4/deliveryservices_id_servers.rst
+++ b/docs/source/api/v4/deliveryservices_id_servers.rst
@@ -40,9 +40,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
-
- .. versionadded:: 4.1
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: An integral, unique identifier the CDN to which the server
belongs
@@ -145,7 +142,6 @@ Response Structure
"type": "EDGE",
"typeId": 11,
"updPending": false,
- "asns": [1,2],
"interfaces": [{
"ipAddresses": [
{
diff --git a/docs/source/api/v4/deliveryservices_id_servers_eligible.rst
b/docs/source/api/v4/deliveryservices_id_servers_eligible.rst
index 20fdb73511..903b661aba 100644
--- a/docs/source/api/v4/deliveryservices_id_servers_eligible.rst
+++ b/docs/source/api/v4/deliveryservices_id_servers_eligible.rst
@@ -46,9 +46,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
-
- .. versionadded:: 4.1
:cachegroup: A string which is the :ref:`Name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: An integral, unique identifier the CDN to which the server
belongs
@@ -143,7 +140,6 @@ Response Structure
"type": "EDGE",
"typeId": 11,
"updPending": false,
- "asns": [1,2],
"interfaces": [{
"ipAddresses": [
{
diff --git a/docs/source/api/v4/servers.rst b/docs/source/api/v4/servers.rst
index 313a00bf15..9580d3f8b0 100644
--- a/docs/source/api/v4/servers.rst
+++ b/docs/source/api/v4/servers.rst
@@ -69,10 +69,6 @@ Request Structure
| | | the first page is 1. If ``offset`` was
defined, this query parameter has no effect. ``limit`` must be defined to |
| | | make use of ``page``.
|
+----------------+----------+-------------------------------------------------------------------------------------------------------------------+
- | asn | no | Return only the servers that have a
cachegroup matching the provided ASN. |
- | | |
|
- | | | .. versionadded:: 4.1
|
-
+----------------+----------+-------------------------------------------------------------------------------------------------------------------+
.. code-block:: http
@@ -86,9 +82,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
-
- .. versionadded:: 4.1
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: The integral, unique identifier of the CDN to which the
server belongs
@@ -233,10 +226,6 @@ Response Structure
"routerHostName": "",
"routerPortName": ""
}
- ],
- "asns": [
- 1,
- 2
]
}],
"summary": {
diff --git a/docs/source/api/v4/servers_id.rst
b/docs/source/api/v4/servers_id.rst
index df366f36c8..881323b709 100644
--- a/docs/source/api/v4/servers_id.rst
+++ b/docs/source/api/v4/servers_id.rst
@@ -160,9 +160,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
-
- .. versionadded:: 4.1
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: The integral, unique identifier of the CDN to which the
server belongs
@@ -265,7 +262,6 @@ Response Structure
}
],
"response": {
- "asns": [1,2],
"cachegroup": "CDN_in_a_Box_Mid",
"cachegroupId": 6,
"cdnId": 2,
@@ -359,9 +355,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
-
- .. versionadded:: 4.1
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belonged
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belonged
:cdnId: The integral, unique identifier of the CDN to which the
server belonged
@@ -460,7 +453,6 @@ Response Structure
}
],
"response": {
- "asns": [1,2],
"cachegroup": "CDN_in_a_Box_Mid",
"cachegroupId": 6,
"cdnId": 2,
diff --git a/docs/source/api/v5/deliveryservices_id_servers.rst
b/docs/source/api/v5/deliveryservices_id_servers.rst
index a2e82abae5..02e578982a 100644
--- a/docs/source/api/v5/deliveryservices_id_servers.rst
+++ b/docs/source/api/v5/deliveryservices_id_servers.rst
@@ -40,7 +40,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: An integral, unique identifier the CDN to which the server
belongs
@@ -143,7 +142,6 @@ Response Structure
"type": "EDGE",
"typeId": 11,
"updPending": false,
- "asns": [1,2],
"interfaces": [{
"ipAddresses": [
{
diff --git a/docs/source/api/v5/deliveryservices_id_servers_eligible.rst
b/docs/source/api/v5/deliveryservices_id_servers_eligible.rst
index b0c04f0550..f51c34f946 100644
--- a/docs/source/api/v5/deliveryservices_id_servers_eligible.rst
+++ b/docs/source/api/v5/deliveryservices_id_servers_eligible.rst
@@ -46,7 +46,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
:cachegroup: A string which is the :ref:`Name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: An integral, unique identifier the CDN to which the server
belongs
@@ -141,7 +140,6 @@ Response Structure
"type": "EDGE",
"typeId": 11,
"updPending": false,
- "asns": [1,2],
"interfaces": [{
"ipAddresses": [
{
diff --git a/docs/source/api/v5/servers_id.rst
b/docs/source/api/v5/servers_id.rst
index cfd25dd80b..712b1fb209 100644
--- a/docs/source/api/v5/servers_id.rst
+++ b/docs/source/api/v5/servers_id.rst
@@ -160,7 +160,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belongs
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belongs
:cdnId: The integral, unique identifier of the CDN to which the
server belongs
@@ -263,7 +262,6 @@ Response Structure
}
],
"response": {
- "asns": [1,2],
"cachegroup": "CDN_in_a_Box_Mid",
"cachegroupId": 6,
"cdnId": 2,
@@ -357,7 +355,6 @@ Request Structure
Response Structure
------------------
-:asns: The :abbr:`ASN (Autonomous System Number)` associated with
the cachegroups of the current server.
:cachegroup: A string that is the :ref:`name of the Cache Group
<cache-group-name>` to which the server belonged
:cachegroupId: An integer that is the :ref:`ID of the Cache Group
<cache-group-id>` to which the server belonged
:cdnId: The integral, unique identifier of the CDN to which the
server belonged
@@ -456,7 +453,6 @@ Response Structure
}
],
"response": {
- "asns": [1,2],
"cachegroup": "CDN_in_a_Box_Mid",
"cachegroupId": 6,
"cdnId": 2,
diff --git a/infrastructure/cdn-in-a-box/enroller/enroller.go
b/infrastructure/cdn-in-a-box/enroller/enroller.go
index f8b61407ce..0633ab51bb 100644
--- a/infrastructure/cdn-in-a-box/enroller/enroller.go
+++ b/infrastructure/cdn-in-a-box/enroller/enroller.go
@@ -757,7 +757,7 @@ func enrollServer(toSession *session, r io.Reader) error {
return err
}
- alerts, _, err := toSession.CreateServer(tc.ServerV4{ServerV40: s},
client.RequestOptions{})
+ alerts, _, err := toSession.CreateServer(s, client.RequestOptions{})
if err != nil {
err = fmt.Errorf("error creating Server: %v - alerts: %+v",
err, alerts.Alerts)
log.Infoln(err)
diff --git a/lib/go-tc/deliveryservice_servers.go
b/lib/go-tc/deliveryservice_servers.go
index 25b5ce2096..7f1d1a1570 100644
--- a/lib/go-tc/deliveryservice_servers.go
+++ b/lib/go-tc/deliveryservice_servers.go
@@ -189,12 +189,6 @@ type DSServerResponseV30 struct {
// DSServerV4 contains information for a V4.x Delivery Service Server.
type DSServerV4 struct {
- DSServerV40
- ASNs []int64 `json:"asns"`
-}
-
-// DSServerV40 contains information for a V4.0 Delivery Service Server.
-type DSServerV40 struct {
DSServerBaseV4
ServerInterfaces *[]ServerInterfaceInfoV40 `json:"interfaces"
db:"interfaces"`
}
@@ -202,13 +196,6 @@ type DSServerV40 struct {
// DSServerResponseV40 is the type of a response from Traffic Ops to a request
// for servers assigned to a Delivery Service - in API version 4.0.
type DSServerResponseV40 struct {
- Response []DSServerV40 `json:"response"`
- Alerts
-}
-
-// DSServerResponseV41 is the type of a response from Traffic Ops to a request
-// for servers assigned to a Delivery Service - in API version 4.1.
-type DSServerResponseV41 struct {
Response []DSServerV4 `json:"response"`
Alerts
}
@@ -216,7 +203,7 @@ type DSServerResponseV41 struct {
// DSServerResponseV4 is the type of a response from Traffic Ops to a request
// for servers assigned to a Delivery Service - in the latest minor version of
// API version 4.
-type DSServerResponseV4 = DSServerResponseV41
+type DSServerResponseV4 = DSServerResponseV40
// ToDSServerBaseV4 upgrades the DSServerBase to the structure used by the
// latest minor version of version 4 of Traffic Ops's API.
diff --git a/lib/go-tc/servers.go b/lib/go-tc/servers.go
index 8ef5f24e91..2f435cdb3f 100644
--- a/lib/go-tc/servers.go
+++ b/lib/go-tc/servers.go
@@ -34,7 +34,7 @@ import (
// ServersV4Response is the format of a response to a GET request for API v4.x
/servers.
type ServersV4Response struct {
- Response []ServerV41 `json:"response"`
+ Response []ServerV40 `json:"response"`
Summary struct {
Count uint64 `json:"count"`
} `json:"summary"`
@@ -1019,12 +1019,6 @@ func UpdateServerPropertiesV40(profileNames []string,
properties CommonServerPro
}
}
-// ServerV41 is the representation of a Server in version 4.1 of the Traffic
Ops API.
-type ServerV41 struct {
- ServerV40
- ASNs []int64 `json:"asns"`
-}
-
// ServerV40 is the representation of a Server in version 4.0 of the Traffic
Ops API.
type ServerV40 struct {
Cachegroup *string `json:"cachegroup"
db:"cachegroup"`
@@ -1072,7 +1066,7 @@ type ServerV40 struct {
// ServerV4 is the representation of a Server in the latest minor version of
// version 4 of the Traffic Ops API.
-type ServerV4 = ServerV41
+type ServerV4 = ServerV40
// ServerV30 is the representation of a Server in version 3 of the Traffic Ops
API.
type ServerV30 struct {
diff --git a/traffic_monitor/towrap/towrap.go b/traffic_monitor/towrap/towrap.go
index 48f0f66cd3..c24ea22fc3 100644
--- a/traffic_monitor/towrap/towrap.go
+++ b/traffic_monitor/towrap/towrap.go
@@ -587,7 +587,7 @@ func (s TrafficOpsSessionThreadsafe)
fetchServerByHostname(hostName string) (tc.
for i, srv := range resp.Response {
num = i
if srv.CDNName != nil && srv.HostName != nil && *srv.HostName
== hostName {
- server = srv.ServerV40
+ server = srv
found = true
break
}
diff --git a/traffic_ops/testing/api/v4/servers_test.go
b/traffic_ops/testing/api/v4/servers_test.go
index 61857b5ec2..42809430a8 100644
--- a/traffic_ops/testing/api/v4/servers_test.go
+++ b/traffic_ops/testing/api/v4/servers_test.go
@@ -33,12 +33,11 @@ import (
)
func TestServers(t *testing.T) {
- WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments, ASN},
func() {
+ WithObjs(t, []TCObj{CDNs, Types, Tenants, Users, Parameters, Profiles,
Statuses, Divisions, Regions, PhysLocations, CacheGroups, Servers, Topologies,
ServiceCategories, DeliveryServices, DeliveryServiceServerAssignments}, func() {
currentTime := time.Now().UTC().Add(-15 * time.Second)
currentTimeRFC := currentTime.Format(time.RFC1123)
tomorrow := currentTime.AddDate(0, 0, 1).Format(time.RFC1123)
- setupCacheGroupWithASN(t)
methodTests := utils.V4TestCase{
"GET": {
"NOT MODIFIED when NO CHANGES made": {
@@ -46,11 +45,6 @@ func TestServers(t *testing.T) {
RequestOpts:
client.RequestOptions{Header: http.Header{rfc.IfModifiedSince: {tomorrow}}},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
},
- "OK when CORRECT ASN parameter": {
- ClientSession: TOSession,
- RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"asn": {"1111"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseLengthGreaterOrEqual(1)),
- },
"OK when VALID HOSTNAME parameter": {
ClientSession: TOSession,
RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"hostName":
{"atlanta-edge-01"}}},
@@ -63,17 +57,6 @@ func TestServers(t *testing.T) {
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseLengthGreaterOrEqual(1),
validateServerFields(map[string]interface{}{"CachegroupID": GetCacheGroupId(t,
"cachegroup1")()})),
},
- "OK when VALID ASN parameter": {
- ClientSession: TOSession,
- RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"asn": {"1111"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseLengthGreaterOrEqual(1),
-
validateServerFields(map[string]interface{}{"Cachegroup":
"topology-mid-cg-01"})),
- },
- "EMPTY RESPONSE when INVALID ASN parameter": {
- ClientSession: TOSession,
- RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"asn": {"5555"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(0)),
- },
"OK when VALID CACHEGROUPNAME parameter": {
ClientSession: TOSession,
RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"cachegroupName":
{"topology-mid-cg-01"}}},
@@ -400,35 +383,10 @@ func TestServers(t *testing.T) {
})
}
-func setupCacheGroupWithASN(t *testing.T) {
- // Add a new asn for one of the cachegroups
- cgResp, _, err :=
TOSession.GetCacheGroups(client.RequestOptions{QueryParameters:
url.Values{"name": {"topology-mid-cg-01"}}})
- if err != nil {
- t.Fatalf("couldn't get cachegroups: %v", err)
- }
- if len(cgResp.Response) != 1 {
- t.Fatalf("expected 1 cachegroup, but got %d",
len(cgResp.Response))
- }
- if cgResp.Response[0].ID == nil {
- t.Fatalf("ID of cachegroup is nil")
- }
-
- asn := tc.ASN{
- ASN: 1111,
- Cachegroup: "topology-mid-cg-01",
- CachegroupID: *cgResp.Response[0].ID,
- }
-
- _, _, err = TOSession.CreateASN(asn, client.NewRequestOptions())
- if err != nil {
- t.Fatalf("couldn't create ASN: %v", err)
- }
-}
-
func validateServerFields(expectedResp map[string]interface{}) utils.CkReqFunc
{
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected response to not be
nil.")
- serverResp := resp.([]tc.ServerV41)
+ serverResp := resp.([]tc.ServerV40)
for field, expected := range expectedResp {
for _, server := range serverResp {
switch field {
@@ -501,7 +459,7 @@ func validateServerFieldsForUpdate(hostname string,
expectedResp map[string]inte
func validateExpectedServers(expectedHostnames []string) utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected response to not be
nil.")
- serverResp := resp.([]tc.ServerV41)
+ serverResp := resp.([]tc.ServerV40)
var notInResponse []string
serverMap := make(map[string]struct{})
for _, server := range serverResp {
@@ -520,7 +478,7 @@ func validateExpectedServers(expectedHostnames []string)
utils.CkReqFunc {
func validateServerTypeIsNotMid() utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected response to not be
nil.")
- serverResp := resp.([]tc.ServerV41)
+ serverResp := resp.([]tc.ServerV40)
for _, server := range serverResp {
assert.RequireNotNil(t, server.HostName, "Expected
server host name to not be nil.")
assert.NotEqual(t, server.Type,
tc.CacheTypeMid.String(), "Expected to find no %s-typed servers but found
server %s", tc.CacheTypeMid, *server.HostName)
@@ -531,7 +489,7 @@ func validateServerTypeIsNotMid() utils.CkReqFunc {
func validateServerPagination(paginationParam string) utils.CkReqFunc {
return func(t *testing.T, _ toclientlib.ReqInf, resp interface{}, _
tc.Alerts, _ error) {
assert.RequireNotNil(t, resp, "Expected response to not be
nil.")
- paginationResp := resp.([]tc.ServerV41)
+ paginationResp := resp.([]tc.ServerV40)
opts := client.NewRequestOptions()
opts.QueryParameters.Set("orderby", "id")
respBase, _, err := TOSession.GetServers(opts)
@@ -597,16 +555,16 @@ func UpdateTestServerStatusLastUpdated(t *testing.T) {
assert.RequireNoError(t, err, "Cannot get Server by hostname '%s': %v -
alerts %+v", hostName, err, resp.Alerts)
assert.RequireGreaterOrEqual(t, len(resp.Response), 1, "Expected at
least one server to exist by hostname '%s'", hostName)
assert.RequireNotNil(t, resp.Response[0].StatusLastUpdated, "Traffic
Ops returned a representation for a server with null or undefined Status Last
Updated time")
- originalServer := resp.Response[0].ServerV40
+ originalServer := resp.Response[0]
// Perform an update with no changes to status
- alerts, _, err := TOSession.UpdateServer(*originalServer.ID,
tc.ServerV4{ServerV40: originalServer}, client.RequestOptions{})
+ alerts, _, err := TOSession.UpdateServer(*originalServer.ID,
originalServer, client.RequestOptions{})
assert.RequireNoError(t, err, "Cannot UPDATE Server by ID %d (hostname
'%s'): %v - alerts: %+v", *originalServer.ID, hostName, err, alerts)
resp, _, err = TOSession.GetServers(opts)
assert.RequireNoError(t, err, "Cannot get Server by hostname '%s': %v -
alerts %+v", hostName, err, resp.Alerts)
assert.RequireGreaterOrEqual(t, len(resp.Response), 1, "Expected at
least one server to exist by hostname '%s'", hostName)
- respServer := resp.Response[0].ServerV40
+ respServer := resp.Response[0]
assert.RequireNotNil(t, respServer.StatusLastUpdated, "Traffic Ops
returned a representation for a server with null or undefined Status Last
Updated time")
assert.Equal(t, *originalServer.StatusLastUpdated,
*respServer.StatusLastUpdated, "Since status didnt change, no change in
'StatusLastUpdated' time was expected. "+
"old value: %v, new value: %v",
*originalServer.StatusLastUpdated, *respServer.StatusLastUpdated)
@@ -615,13 +573,13 @@ func UpdateTestServerStatusLastUpdated(t *testing.T) {
newStatusID := GetStatusID(t, "ONLINE")()
originalServer.StatusID = &newStatusID
- alerts, _, err = TOSession.UpdateServer(*originalServer.ID,
tc.ServerV4{ServerV40: originalServer}, client.RequestOptions{})
+ alerts, _, err = TOSession.UpdateServer(*originalServer.ID,
originalServer, client.RequestOptions{})
assert.RequireNoError(t, err, "Cannot UPDATE Server by ID %d (hostname
'%s'): %v - alerts: %+v", *originalServer.ID, hostName, err, alerts)
resp, _, err = TOSession.GetServers(opts)
assert.RequireNoError(t, err, "Cannot get Server by hostname '%s': %v -
alerts %+v", hostName, err, resp.Alerts)
assert.RequireGreaterOrEqual(t, len(resp.Response), 1, "Expected at
least one server to exist by hostname '%s'", hostName)
- respServer = resp.Response[0].ServerV40
+ respServer = resp.Response[0]
assert.RequireNotNil(t, respServer.StatusLastUpdated, "Traffic Ops
returned a representation for a server with null or undefined Status Last
Updated time")
assert.NotEqual(t, *originalServer.StatusLastUpdated,
*respServer.StatusLastUpdated, "Since status changed, expected
'StatusLastUpdated' to change. "+
"old value: %v, new value: %v",
*originalServer.StatusLastUpdated, *respServer.StatusLastUpdated)
@@ -669,7 +627,7 @@ func UpdateDSGetServerDSID(t *testing.T) {
func CreateTestServers(t *testing.T) {
for _, server := range testData.Servers {
- resp, _, err := TOSession.CreateServer(tc.ServerV4{ServerV40:
server}, client.RequestOptions{})
+ resp, _, err := TOSession.CreateServer(server,
client.RequestOptions{})
assert.RequireNoError(t, err, "Could not create server '%s': %v
- alerts: %+v", *server.HostName, err, resp.Alerts)
}
}
diff --git a/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
b/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
index 10c5ff7fb0..f93131ab96 100644
--- a/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
+++ b/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
@@ -2029,7 +2029,7 @@ WHERE server.id = $2;`
}
// GetCommonServerPropertiesFromV4 converts ServerV40 to
CommonServerProperties struct.
-func GetCommonServerPropertiesFromV4(s tc.ServerV41, tx *sql.Tx)
(tc.CommonServerProperties, error) {
+func GetCommonServerPropertiesFromV4(s tc.ServerV40, tx *sql.Tx)
(tc.CommonServerProperties, error) {
var id int
var desc string
if len(s.ProfileNames) == 0 {
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
b/traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
index 33e2efb9ab..d863aa423b 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
@@ -96,15 +96,6 @@ func GetServersEligible(w http.ResponseWriter, r
*http.Request) {
api.WriteResp(w, r, v3ServerList)
return
}
- if inf.Version.Major == 4 && inf.Version.Minor < 1 {
- v40ServerList := []tc.DSServerV40{}
- for _, s := range servers {
- sV40 := s.DSServerV40
- v40ServerList = append(v40ServerList, sV40)
- }
- api.WriteResp(w, r, v40ServerList)
- return
- }
api.WriteResp(w, r, servers)
}
@@ -156,8 +147,7 @@ t.name as server_type,
s.type as server_type_id,
s.config_update_time > s.config_apply_time AS upd_pending,
ARRAY(select ssc.server_capability from server_server_capability ssc where
ssc.server = s.id order by ssc.server_capability) as server_capabilities,
-ARRAY(select drc.required_capability from deliveryservices_required_capability
drc where drc.deliveryservice_id = (select v from ds_id) order by
drc.required_capability) as deliveryservice_capabilities,
-(SELECT ARRAY_AGG(asn) AS asns FROM asn a WHERE a.cachegroup = s.cachegroup)
AS asns
+ARRAY(select drc.required_capability from deliveryservices_required_capability
drc where drc.deliveryservice_id = (select v from ds_id) order by
drc.required_capability) as deliveryservice_capabilities
`
idRows, err := tx.Query(fmt.Sprintf(queryFormatString, "",
queryWhereClause), dsID)
if err != nil {
@@ -219,7 +209,6 @@ ARRAY(select drc.required_capability from
deliveryservices_required_capability d
&s.UpdPending,
pq.Array(&s.ServerCapabilities),
pq.Array(&s.DeliveryServiceCapabilities),
- pq.Array(&s.ASNs),
)
if err != nil {
return nil, errors.New("scanning delivery service
eligible servers: " + err.Error())
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/eligible_test.go
b/traffic_ops/traffic_ops_golang/deliveryservice/eligible_test.go
index c0692959df..cda71eae68 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/eligible_test.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/eligible_test.go
@@ -84,9 +84,7 @@ func TestGetEligibleServers(t *testing.T) {
"server_type_id",
"upd_pending",
"server_capabilities",
- "deliveryservice_capabilities",
- "asns",
- }
+ "deliveryservice_capabilities"}
eligbleRows := sqlmock.NewRows(cols)
for _, s := range testServers {
@@ -122,7 +120,6 @@ func TestGetEligibleServers(t *testing.T) {
s.UpdPending,
[]byte(`{""}`),
[]byte(`{""}`),
- []byte(`{1,2}`),
)
}
mock.ExpectQuery("SELECT s.id ,").WillReturnRows(eligbleRows)
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/keys_test.go
b/traffic_ops/traffic_ops_golang/deliveryservice/keys_test.go
index a0678f082c..1c285a1e85 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/keys_test.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/keys_test.go
@@ -2260,7 +2260,7 @@ func TestVerifyAndEncodeCertificateSelfSignedX509v1(t
*testing.T) {
certChain, certPrivateKey, unknownAuth, _, err :=
verifyCertKeyPair(SelfSignedX509v1Certificate, SelfSignedX509v1PrivateKey, "",
true)
if err != nil {
- t.Fatalf("unexpected result: the x509v1 cert/key pair is valid
and should have passed validation")
+ t.Fatalf("unexpected result: the x509v1 cert/key pair is valid
and should have passed validation: %v", err)
}
if !unknownAuth {
@@ -2286,7 +2286,7 @@ func
TestVerifyAndEncodeCertificateSelfSignedNoSkiAkiCertKeyPair(t *testing.T) {
certChain, certPrivateKey, unknownAuth, _, err :=
verifyCertKeyPair(SelfSignedNOSKIAKIRSACertificate,
SelfSignedNOSKIAKIRSAPrivateKey, "", true)
if err != nil {
- t.Fatalf("unexpected result: a certificate verification error
should have occured")
+ t.Fatalf("unexpected result: a certificate verification error
should have occured: %v", err)
}
if !unknownAuth {
@@ -2312,7 +2312,7 @@ func
TestVerifyAndEncodeCertificateSelfSignedCertKeyPair(t *testing.T) {
certChain, certPrivateKey, unknownAuth, _, err :=
verifyCertKeyPair(SelfSignedRSACertificate, SelfSignedRSAPrivateKey, "", true)
if err != nil {
- t.Fatalf("unexpected result, a certificate verification error
should have occured")
+ t.Fatalf("unexpected result, a certificate verification error
should have occured: %v", err)
}
if !unknownAuth {
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
index f7f31fd21d..06720c3f3d 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
@@ -724,15 +724,6 @@ func GetReadAssigned(w http.ResponseWriter, r
*http.Request) {
api.WriteAlertsObj(w, r, http.StatusOK, alerts, v3ServerList)
return
}
- if inf.Version.Major == 4 && inf.Version.Minor < 1 {
- v40ServerList := []tc.DSServerV40{}
- for _, s := range servers {
- sV40 := s.DSServerV40
- v40ServerList = append(v40ServerList, sV40)
- }
- api.WriteAlertsObj(w, r, http.StatusOK, alerts, v40ServerList)
- return
- }
api.WriteAlertsObj(w, r, http.StatusOK, alerts, servers)
}
@@ -766,8 +757,7 @@ s.status as status_id,
s.tcp_port,
t.name as server_type,
s.type as server_type_id,
-s.config_update_time > s.config_apply_time AS upd_pending,
-(SELECT ARRAY_AGG(asn) AS asns FROM asn a WHERE a.cachegroup = s.cachegroup)
AS asns
+s.config_update_time > s.config_apply_time AS upd_pending
`
queryFormatString := `
@@ -842,7 +832,6 @@ WHERE s.id in (select server from deliveryservice_server
where deliveryservice =
&s.Type,
&s.TypeID,
&s.UpdPending,
- pq.Array(&s.ASNs),
)
if err != nil {
return nil, errors.New("error scanning dss rows: " +
err.Error())
diff --git
a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers_test.go
b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers_test.go
index aa6f4ec409..eed56f1613 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers_test.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers_test.go
@@ -115,9 +115,7 @@ func TestReadServers(t *testing.T) {
"tcp_port",
"server_type",
"server_type_id",
- "upd_pending",
- "asns",
- }
+ "upd_pending"}
rows := sqlmock.NewRows(cols)
@@ -152,7 +150,6 @@ func TestReadServers(t *testing.T) {
s.Type,
s.TypeID,
s.UpdPending,
- []byte(`{1,2}`),
)
}
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go
b/traffic_ops/traffic_ops_golang/routing/routes.go
index d70de9e2a9..a19457bd2e 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -531,8 +531,6 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
* 4.x API
*/
- // GET servers
- {Version: api.Version{Major: 4, Minor: 1}, Method:
http.MethodGet, Path: `servers/?$`, Handler: server.Read, RequiredPrivLevel:
auth.PrivLevelReadOnly, RequiredPermissions: []string{"SERVER:READ",
"DELIVERY-SERVICE:READ", "CDN:READ", "PHYSICAL-LOCATION:READ",
"CACHE-GROUP:READ", "TYPE:READ", "PROFILE:READ"}, Authenticated: Authenticated,
Middlewares: nil, ID: 47219592853},
// Assign Multiple Server Capabilities
{Version: api.Version{Major: 4, Minor: 1}, Method:
http.MethodPut, Path: `multiple_server_capabilities/?$`, Handler:
server.AssignMultipleServerCapabilities, RequiredPrivLevel:
auth.PrivLevelOperations, RequiredPermissions: []string{"SERVER:UPDATE",
"SERVER:READ", "SERVER-CAPABILITY:READ"}, Authenticated: Authenticated,
Middlewares: nil, ID: 40792419258},
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go
b/traffic_ops/traffic_ops_golang/server/servers.go
index 4cd372f3d0..f1a827a278 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -152,8 +152,7 @@ SELECT
s.config_apply_time,
s.xmpp_id,
s.xmpp_passwd,
- s.status_last_updated,
- (SELECT ARRAY_AGG(asn) AS asns FROM asn a WHERE a.cachegroup =
s.cachegroup) AS asns
+ s.status_last_updated
` + serversFromAndJoin
const selectIDQuery = `
@@ -689,7 +688,7 @@ func Read(w http.ResponseWriter, r *http.Request) {
return
}
- servers := []tc.ServerV41{}
+ servers := []tc.ServerV40{}
var serverCount uint64
cfg, e := api.GetConfig(r.Context())
useIMS := false
@@ -705,7 +704,7 @@ func Read(w http.ResponseWriter, r *http.Request) {
}
if errCode == http.StatusNotModified {
w.WriteHeader(errCode)
- api.WriteResp(w, r, []tc.ServerV41{})
+ api.WriteResp(w, r, []tc.ServerV40{})
return
}
if userErr != nil || sysErr != nil {
@@ -719,7 +718,7 @@ func Read(w http.ResponseWriter, r *http.Request) {
}
v40Servers := make([]tc.ServerV40, 0)
for _, server := range servers {
- v40Servers = append(v40Servers, server.ServerV40)
+ v40Servers = append(v40Servers, server)
}
api.WriteRespWithSummary(w, r, v40Servers, serverCount)
return
@@ -768,7 +767,7 @@ func getServerCount(tx *sqlx.Tx, query string, queryValues
map[string]interface{
return serverCount, nil
}
-func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user
*auth.CurrentUser, useIMS bool, version api.Version) ([]tc.ServerV41, uint64,
error, error, int, *time.Time) {
+func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user
*auth.CurrentUser, useIMS bool, version api.Version) ([]tc.ServerV40, uint64,
error, error, int, *time.Time) {
var maxTime time.Time
var runSecond bool
// Query Parameters to Database Query column mappings
@@ -795,12 +794,6 @@ func getServers(h http.Header, params map[string]string,
tx *sqlx.Tx, user *auth
}
if version.Major >= 4 {
- if version.Minor >= 1 {
- queryParamsToSQLCols["asn"] = dbhelpers.WhereColumnInfo{
- Column: "a.asn",
- Checker: api.IsInt,
- }
- }
queryParamsToSQLCols["profileName"] = dbhelpers.WhereColumnInfo{
Column: "sp.profile_name",
Checker: nil,
@@ -868,14 +861,6 @@ func getServers(h http.Header, params map[string]string,
tx *sqlx.Tx, user *auth
queryString = selectQuery
countQueryString = serverCountQuery
if version.Major >= 4 {
- if version.Minor >= 1 {
- if _, ok := params["asn"]; ok {
- queryString = selectQuery + `
-JOIN asn a ON s.cachegroup = a.cachegroup`
- countQueryString = serverCountQuery + `
-JOIN asn a ON s.cachegroup = a.cachegroup`
- }
- }
if _, ok := params["profileName"]; ok {
queryString = queryString + `
JOIN server_profile sp ON s.id = sp.server`
@@ -896,7 +881,7 @@ JOIN server_profile sp ON s.id = sp.server`
return nil, 0, nil, fmt.Errorf("failed to get servers count:
%v", err), http.StatusInternalServerError, nil
}
- serversList := []tc.ServerV41{}
+ serversList := []tc.ServerV40{}
if useIMS {
runSecond, maxTime = ims.TryIfModifiedSinceQuery(tx, h,
queryValues, selectMaxLastUpdatedQuery(queryAddition, where))
if !runSecond {
@@ -923,10 +908,10 @@ JOIN server_profile sp ON s.id = sp.server`
HiddenField := "********"
- servers := make(map[int]tc.ServerV41)
+ servers := make(map[int]tc.ServerV40)
ids := []int{}
for rows.Next() {
- s := tc.ServerV41{}
+ s := tc.ServerV40{}
err := rows.Scan(&s.Cachegroup,
&s.CachegroupID,
&s.CDNID,
@@ -963,8 +948,7 @@ JOIN server_profile sp ON s.id = sp.server`
&s.ConfigApplyTime,
&s.XMPPID,
&s.XMPPPasswd,
- &s.StatusLastUpdated,
- pq.Array(&s.ASNs))
+ &s.StatusLastUpdated)
if err != nil {
return nil, serverCount, nil, errors.New("getting
servers: " + err.Error()), http.StatusInternalServerError, nil
}
@@ -997,7 +981,7 @@ JOIN server_profile sp ON s.id = sp.server`
}
if len(ids) < 1 {
- return []tc.ServerV41{}, serverCount, nil, nil, http.StatusOK,
nil
+ return []tc.ServerV40{}, serverCount, nil, nil, http.StatusOK,
nil
}
query, args, err := sqlx.In(`SELECT max_bandwidth, monitor, mtu, name,
server, router_host_name, router_port_name FROM interface WHERE server IN (?)`,
ids)
@@ -1068,7 +1052,7 @@ JOIN server_profile sp ON s.id = sp.server`
}
}
- returnable := make([]tc.ServerV41, 0, len(ids))
+ returnable := make([]tc.ServerV40, 0, len(ids))
for _, id := range ids {
server := servers[id]
@@ -1082,7 +1066,7 @@ JOIN server_profile sp ON s.id = sp.server`
}
// getMidServers gets the mids used by the edges provided with an option to
filter for a given cdn
-func getMidServers(edgeIDs []int, servers map[int]tc.ServerV41, dsID int,
cdnID int, tx *sqlx.Tx, includeCapabilities bool) ([]int, error, error, int) {
+func getMidServers(edgeIDs []int, servers map[int]tc.ServerV40, dsID int,
cdnID int, tx *sqlx.Tx, includeCapabilities bool) ([]int, error, error, int) {
if len(edgeIDs) == 0 {
return nil, nil, nil, http.StatusOK
}
@@ -1150,7 +1134,7 @@ func getMidServers(edgeIDs []int, servers
map[int]tc.ServerV41, dsID int, cdnID
ids := []int{}
for rows.Next() {
- var s tc.ServerV41
+ var s tc.ServerV40
if err := rows.Scan(&s.Cachegroup,
&s.CachegroupID,
&s.CDNID,
@@ -1187,8 +1171,7 @@ func getMidServers(edgeIDs []int, servers
map[int]tc.ServerV41, dsID int, cdnID
&s.ConfigApplyTime,
&s.XMPPID,
&s.XMPPPasswd,
- &s.StatusLastUpdated,
- pq.Array(&s.ASNs)); err != nil {
+ &s.StatusLastUpdated); err != nil {
log.Errorf("could not scan mid servers: %s\n", err)
return nil, nil, err, http.StatusInternalServerError
}
@@ -1349,7 +1332,7 @@ func Update(w http.ResponseWriter, r *http.Request) {
return
}
- original := originals[0].ServerV40
+ original := originals[0]
if original.XMPPID == nil || *original.XMPPID == "" {
log.Warnf("original server %s had no XMPPID\n",
*original.HostName)
}
@@ -1572,7 +1555,7 @@ func Update(w http.ResponseWriter, r *http.Request) {
} else {
selquery = selectQuery + where
}
- var srvr tc.ServerV41
+ var srvr tc.ServerV40
err = inf.Tx.QueryRow(selquery, serverID).Scan(&srvr.Cachegroup,
&srvr.CachegroupID,
&srvr.CDNID,
@@ -1609,8 +1592,7 @@ func Update(w http.ResponseWriter, r *http.Request) {
&srvr.ConfigApplyTime,
&srvr.XMPPID,
&srvr.XMPPPasswd,
- &srvr.StatusLastUpdated,
- pq.Array(&srvr.ASNs))
+ &srvr.StatusLastUpdated)
if err != nil {
api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, err)
return
@@ -1634,18 +1616,14 @@ func Update(w http.ResponseWriter, r *http.Request) {
if inf.Version.Major >= 5 {
api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server updated",
srvr)
} else if inf.Version.Major >= 4 {
- if version.Minor >= 1 {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
updated", srvr)
- } else {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
updated", srvr.ServerV40)
- }
+ api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server updated",
srvr)
} else if inf.Version.Major >= 3 {
csp, err := dbhelpers.GetCommonServerPropertiesFromV4(srvr,
inf.Tx.Tx)
if err != nil {
api.HandleErr(w, r, inf.Tx.Tx,
http.StatusInternalServerError, nil, err)
return
}
- srvrV30, err := srvr.ServerV40.ToServerV3FromV4(csp)
+ srvrV30, err := srvr.ToServerV3FromV4(csp)
if err != nil {
api.HandleErr(w, r, inf.Tx.Tx,
http.StatusInternalServerError, nil, err)
return
@@ -1817,7 +1795,7 @@ func createV3(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
where := `WHERE s.id = $1`
selquery := selectQuery + where
- var s4 tc.ServerV41
+ var s4 tc.ServerV40
err = inf.Tx.QueryRow(selquery, serverID).Scan(&s4.Cachegroup,
&s4.CachegroupID,
&s4.CDNID,
@@ -1854,8 +1832,7 @@ func createV3(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
&s4.ConfigApplyTime,
&s4.XMPPID,
&s4.XMPPPasswd,
- &s4.StatusLastUpdated,
- pq.Array(&s4.ASNs))
+ &s4.StatusLastUpdated)
if err != nil {
api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, err)
return
@@ -1952,7 +1929,7 @@ func createV4(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
where := `WHERE s.id = $1`
selquery := selectQuery + joinProfileV4 + where
- var srvr tc.ServerV41
+ var srvr tc.ServerV40
err = inf.Tx.QueryRow(selquery, serverID).Scan(&srvr.Cachegroup,
&srvr.CachegroupID,
&srvr.CDNID,
@@ -1989,8 +1966,7 @@ func createV4(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
&srvr.ConfigApplyTime,
&srvr.XMPPID,
&srvr.XMPPPasswd,
- &srvr.StatusLastUpdated,
- pq.Array(&srvr.ASNs))
+ &srvr.StatusLastUpdated)
if err != nil {
api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, err)
return
@@ -2000,15 +1976,7 @@ func createV4(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
srvr.Interfaces = server.Interfaces
alerts := tc.CreateAlerts(tc.SuccessLevel, "Server created")
- if inf.Version.Major == 5 {
- api.WriteAlertsObj(w, r, http.StatusCreated, alerts, srvr)
- } else {
- if inf.Version.Minor >= 1 {
- api.WriteAlertsObj(w, r, http.StatusCreated, alerts,
srvr)
- } else {
- api.WriteAlertsObj(w, r, http.StatusCreated, alerts,
srvr.ServerV40)
- }
- }
+ api.WriteAlertsObj(w, r, http.StatusCreated, alerts, srvr)
changeLogMsg := fmt.Sprintf("SERVER: %s.%s, ID: %d, ACTION: created",
*srvr.HostName, *srvr.DomainName, *srvr.ID)
api.CreateChangeLogRawTx(api.ApiChange, changeLogMsg, inf.User,
inf.Tx.Tx)
@@ -2212,7 +2180,7 @@ func Delete(w http.ResponseWriter, r *http.Request) {
return
}
- var servers []tc.ServerV41
+ var servers []tc.ServerV40
servers, _, userErr, sysErr, errCode, _ = getServers(r.Header,
map[string]string{"id": inf.Params["id"]}, inf.Tx, inf.User, false, *version)
if userErr != nil || sysErr != nil {
api.HandleErr(w, r, tx, errCode, userErr, sysErr)
@@ -2271,11 +2239,7 @@ func Delete(w http.ResponseWriter, r *http.Request) {
}
if inf.Version.Major >= 4 {
- if inf.Version.Minor >= 1 || inf.Version.Major == 5 {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
deleted", server)
- } else {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
deleted", server.ServerV40)
- }
+ api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server deleted",
server)
} else {
csp, err := dbhelpers.GetCommonServerPropertiesFromV4(server,
tx)
if err != nil {
diff --git a/traffic_ops/traffic_ops_golang/server/servers_test.go
b/traffic_ops/traffic_ops_golang/server/servers_test.go
index a7243f38c5..25e4f5dda7 100644
--- a/traffic_ops/traffic_ops_golang/server/servers_test.go
+++ b/traffic_ops/traffic_ops_golang/server/servers_test.go
@@ -32,12 +32,11 @@ import (
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
"github.com/jmoiron/sqlx"
- "github.com/lib/pq"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
)
type ServerAndInterfaces struct {
- Server tc.ServerV41
+ Server tc.ServerV40
Interface tc.ServerInterfaceInfoV40
}
@@ -82,10 +81,6 @@ func getTestServers() []ServerAndInterfaces {
RevalUpdateTime: &(time.Time{}),
RevalApplyTime: &(time.Time{}),
}
- testServer := tc.ServerV41{
- ServerV40: testServerV40,
- ASNs: pq.Int64Array{1, 2},
- }
mtu := uint64(9500)
iface := tc.ServerInterfaceInfoV40{
@@ -106,15 +101,15 @@ func getTestServers() []ServerAndInterfaces {
RouterPortName: "routerPortName",
}
- servers = append(servers, ServerAndInterfaces{Server: testServer,
Interface: iface})
+ servers = append(servers, ServerAndInterfaces{Server: testServerV40,
Interface: iface})
- testServer2 := testServer
+ testServer2 := testServerV40
testServer2.Cachegroup = util.StrPtr("cachegroup2")
testServer2.HostName = util.StrPtr("server2")
testServer2.ID = util.IntPtr(2)
servers = append(servers, ServerAndInterfaces{Server: testServer2,
Interface: iface})
- testServer3 := testServer
+ testServer3 := testServerV40
testServer3.Cachegroup = util.StrPtr("cachegroup3")
testServer3.HostName = util.StrPtr("server3")
testServer3.ID = util.IntPtr(3)
@@ -183,7 +178,7 @@ func TestGetServersByCachegroup(t *testing.T) {
"last_updated", "mgmt_ip_address", "mgmt_ip_gateway",
"mgmt_ip_netmask", "offline_reason", "phys_location",
"phys_location_id", "profile_name", "rack", "reval_pending",
"revalidate_update_time", "revalidate_apply_time",
"status", "status_id", "tcp_port", "server_type",
"server_type_id", "upd_pending", "config_update_time",
- "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated", "asns"}
+ "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated"}
interfaceCols := []string{"max_bandwidth", "monitor", "mtu", "name",
"server", "router_host_name", "router_port_name"}
rows := sqlmock.NewRows(cols)
interfaceRows := sqlmock.NewRows(interfaceCols)
@@ -233,7 +228,6 @@ func TestGetServersByCachegroup(t *testing.T) {
*ts.XMPPID,
*ts.XMPPPasswd,
*ts.StatusLastUpdated,
- []byte(`{1,2}`),
)
interfaceRows = interfaceRows.AddRow(
srv.Interface.MaxBandwidth,
@@ -305,7 +299,7 @@ func TestGetMidServers(t *testing.T) {
"last_updated", "mgmt_ip_address", "mgmt_ip_gateway",
"mgmt_ip_netmask", "offline_reason", "phys_location",
"phys_location_id", "profile_name", "rack", "reval_pending",
"revalidate_update_time", "revalidate_apply_time",
"status", "status_id", "tcp_port", "server_type",
"server_type_id", "upd_pending", "config_update_time",
- "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated", "asns"}
+ "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated"}
interfaceCols := []string{"max_bandwidth", "monitor", "mtu", "name",
"server", "router_host_name", "router_port_name"}
rows := sqlmock.NewRows(cols)
interfaceRows := sqlmock.NewRows(interfaceCols)
@@ -353,7 +347,6 @@ func TestGetMidServers(t *testing.T) {
*ts.XMPPID,
*ts.XMPPPasswd,
*ts.StatusLastUpdated,
- []byte(`{1,2}`),
)
interfaceRows = interfaceRows.AddRow(
srv.Interface.MaxBandwidth,
@@ -397,7 +390,7 @@ func TestGetMidServers(t *testing.T) {
"last_updated", "mgmt_ip_address", "mgmt_ip_gateway",
"mgmt_ip_netmask", "offline_reason", "phys_location",
"phys_location_id", "profile_name", "rack", "reval_pending",
"revalidate_update_time", "revalidate_apply_time",
"status", "status_id", "tcp_port", "server_type",
"server_type_id", "upd_pending", "config_update_time",
- "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated", "asns"}
+ "config_apply_time", "xmpp_id", "xmpp_passwd",
"status_last_updated"}
rows2 := sqlmock.NewRows(cols2)
cgs := []tc.CacheGroup{}
@@ -443,7 +436,7 @@ func TestGetMidServers(t *testing.T) {
}
cgs = append(cgs, testCG2)
- serverMap := make(map[int]tc.ServerV41, len(servers))
+ serverMap := make(map[int]tc.ServerV40, len(servers))
serverIDs := make([]int, 0, len(servers))
for _, server := range servers {
if server.ID == nil {
@@ -453,7 +446,7 @@ func TestGetMidServers(t *testing.T) {
serverMap[*server.ID] = server
}
- var ts tc.ServerV41
+ var ts tc.ServerV40
for _, s := range servers {
if s.HostName != nil && *s.HostName == "server2" {
ts = s
@@ -499,7 +492,6 @@ func TestGetMidServers(t *testing.T) {
*ts.XMPPID,
*ts.XMPPPasswd,
*ts.StatusLastUpdated,
- []byte(`{1,2}`),
)
mock.ExpectBegin()
diff --git
a/traffic_portal/app/src/common/modules/table/servers/TableServersController.js
b/traffic_portal/app/src/common/modules/table/servers/TableServersController.js
index e4c22580d3..d475833acb 100644
---
a/traffic_portal/app/src/common/modules/table/servers/TableServersController.js
+++
b/traffic_portal/app/src/common/modules/table/servers/TableServersController.js
@@ -155,11 +155,6 @@ var TableServersController = function(tableName, servers,
filter, $scope, $state
field: "offlineReason",
hide: true
},
- {
- headerName: "ASNs",
- field: "asns",
- hide: true
- },
{
headerName: "Phys Location",
field: "physLocation",
diff --git a/traffic_router/ultimate-test-harness/http_test.go
b/traffic_router/ultimate-test-harness/http_test.go
index ed67bc2262..140a2976c6 100644
--- a/traffic_router/ultimate-test-harness/http_test.go
+++ b/traffic_router/ultimate-test-harness/http_test.go
@@ -339,7 +339,7 @@ func getTrafficRouters(trafficRouterName string, cdnName
tc.CDNName) ([]tc.Serve
trafficRouters := response.Response
trafficRoutersV40 := make([]tc.ServerV40, 0)
for _, tr := range trafficRouters {
- trafficRoutersV40 = append(trafficRoutersV40, tr.ServerV40)
+ trafficRoutersV40 = append(trafficRoutersV40, tr)
}
if len(trafficRouters) < 1 {
return trafficRoutersV40, fmt.Errorf("no Traffic Routers were
found with these criteria: %v", requestOptions.QueryParameters)