This is an automated email from the ASF dual-hosted git repository.
mattjackson 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 02a1286 Servers fixes (#4794)
02a1286 is described below
commit 02a1286ea91f923444b21a679975599352d98603
Author: ocket8888 <[email protected]>
AuthorDate: Mon Jun 15 15:53:46 2020 -0600
Servers fixes (#4794)
* Fixed changed status codes and response alerts
* Fixed TO Python client treating success responses as failures
---
traffic_control/clients/python/trafficops/restapi.py | 2 +-
traffic_ops/traffic_ops_golang/server/servers.go | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/traffic_control/clients/python/trafficops/restapi.py
b/traffic_control/clients/python/trafficops/restapi.py
index f52fc89..0a6241e 100644
--- a/traffic_control/clients/python/trafficops/restapi.py
+++ b/traffic_control/clients/python/trafficops/restapi.py
@@ -358,7 +358,7 @@ class RestApiSession(object):
def _do_operation(self,
operation, api_path, query_params=None,
munchify=True, debug_response=False,
- expected_status_codes=(200, 204,), *unused_args,
**kwargs):
+ expected_status_codes=range(200, 300), *unused_args,
**kwargs):
"""
Helper method to perform HTTP operation requests - This is a
boilerplate process for HTTP
operations.
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go
b/traffic_ops/traffic_ops_golang/server/servers.go
index 8d72737..509423d 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -598,7 +598,7 @@ func getServers(params map[string]string, tx *sqlx.Tx, user
*auth.CurrentUser) (
}
userErr, sysErr, _ := tenant.CheckID(tx.Tx, user, dsID)
if userErr != nil || sysErr != nil {
- return nil, 0, errors.New("forbidden"), sysErr,
http.StatusForbidden
+ return nil, 0, errors.New("Forbidden"), sysErr,
http.StatusForbidden
}
// only if dsId is part of params: add join on
deliveryservice_server table
queryAddition = `
@@ -1092,8 +1092,8 @@ func createV1(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
return
}
- alerts := tc.CreateAlerts(tc.SuccessLevel, "Server created")
- api.WriteAlertsObj(w, r, http.StatusCreated, alerts, server)
+ alerts := tc.CreateAlerts(tc.SuccessLevel, "server was created.")
+ api.WriteAlertsObj(w, r, http.StatusOK, alerts, server)
changeLogMsg := fmt.Sprintf("SERVER: %s.%s, ID: %d, ACTION: created",
*server.HostName, *server.DomainName, *server.ID)
api.CreateChangeLogRawTx(api.ApiChange, changeLogMsg, inf.User, tx)
@@ -1147,8 +1147,8 @@ func createV2(inf *api.APIInfo, w http.ResponseWriter, r
*http.Request) {
return
}
- alerts := tc.CreateAlerts(tc.SuccessLevel, "Server created")
- api.WriteAlertsObj(w, r, http.StatusCreated, alerts, server)
+ alerts := tc.CreateAlerts(tc.SuccessLevel, "server was created.")
+ api.WriteAlertsObj(w, r, http.StatusOK, alerts, server)
changeLogMsg := fmt.Sprintf("SERVER: %s.%s, ID: %d, ACTION: created",
*server.HostName, *server.DomainName, *server.ID)
api.CreateChangeLogRawTx(api.ApiChange, changeLogMsg, inf.User, tx)
@@ -1292,9 +1292,9 @@ func Delete(w http.ResponseWriter, r *http.Request) {
}
if inf.Version.Major <= 1 {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
deleted", serverV2.ServerNullableV11)
+ api.WriteRespAlertObj(w, r, tc.SuccessLevel, "server
was deleted.", serverV2.ServerNullableV11)
} else {
- api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server
deleted", serverV2)
+ api.WriteRespAlertObj(w, r, tc.SuccessLevel, "server
was deleted.", serverV2)
}
}
changeLogMsg := fmt.Sprintf("SERVER: %s.%s, ID: %d, ACTION: deleted",
*server.HostName, *server.DomainName, *server.ID)