You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/05/29 21:53:24 UTC
[GitHub] dangogh closed pull request #2345: Fix for issue #2342 - host_name
blanking when xmpp_id is sent
dangogh closed pull request #2345: Fix for issue #2342 - host_name blanking when xmpp_id is sent
URL: https://github.com/apache/incubator-trafficcontrol/pull/2345
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/lib/go-tc/v13/servers.go b/lib/go-tc/v13/servers.go
index b71adb1e1..e7e9c5325 100644
--- a/lib/go-tc/v13/servers.go
+++ b/lib/go-tc/v13/servers.go
@@ -78,6 +78,7 @@ type Server struct {
TCPPort int `json:"tcpPort" db:"tcp_port"`
Type string `json:"type" db:"server_type"`
TypeID int `json:"typeId" db:"server_type_id"`
+ TypeName string `json:"typeName" db:"server_type_name"`
UpdPending bool `json:"updPending" db:"upd_pending"`
XMPPID string `json:"xmppId" db:"xmpp_id"`
XMPPPasswd string `json:"xmppPasswd" db:"xmpp_passwd"`
diff --git a/traffic_ops/testing/api/v13/servers_test.go b/traffic_ops/testing/api/v13/servers_test.go
index cb305d37b..9e848f2fd 100644
--- a/traffic_ops/testing/api/v13/servers_test.go
+++ b/traffic_ops/testing/api/v13/servers_test.go
@@ -16,9 +16,10 @@ package v13
*/
import (
+ "testing"
+
"github.com/apache/incubator-trafficcontrol/lib/go-log"
"github.com/apache/incubator-trafficcontrol/lib/go-tc"
- "testing"
)
func TestServers(t *testing.T) {
@@ -55,13 +56,6 @@ func CreateTestServers(t *testing.T) {
}
respProfile := respProfiles[0]
- // GET EDGE type
- respTypes, _, err := TOSession.GetTypeByName("EDGE")
- if err != nil {
- t.Errorf("cannot GET Division by name: EDGE - %v\n", err)
- }
- respType := respTypes[0]
-
// GET ONLINE status
respStatuses, _, err := TOSession.GetStatusByName("ONLINE")
if err != nil {
@@ -85,6 +79,13 @@ func CreateTestServers(t *testing.T) {
// loop through servers, assign FKs and create
for _, server := range testData.Servers {
+ // GET EDGE type
+ respTypes, _, err := TOSession.GetTypeByName(server.TypeName)
+ if err != nil {
+ t.Errorf("cannot GET Division by name: EDGE - %v\n", err)
+ }
+ respType := respTypes[0]
+
server.CDNID = respProfile.CDNID
server.ProfileID = respProfile.ID
server.TypeID = respType.ID
@@ -114,8 +115,10 @@ func GetTestServers(t *testing.T) {
func UpdateTestServers(t *testing.T) {
firstServer := testData.Servers[0]
+ hostName := firstServer.HostName
// Retrieve the server by hostname so we can get the id for the Update
- resp, _, err := TOSession.GetServerByHostName(firstServer.HostName)
+ resp, _, err := TOSession.GetServerByHostName(hostName)
+
if err != nil {
t.Errorf("cannot GET Server by hostname: %v - %v\n", firstServer.HostName, err)
}
diff --git a/traffic_ops/testing/api/v13/tc-fixtures.json b/traffic_ops/testing/api/v13/tc-fixtures.json
index cc5d9b606..5fa7ac6c4 100644
--- a/traffic_ops/testing/api/v13/tc-fixtures.json
+++ b/traffic_ops/testing/api/v13/tc-fixtures.json
@@ -152,7 +152,7 @@
"deliveryService": {
"active": false,
"ccrDnsTtl": 30,
- "deepCachingType": "ALWAYS",
+ "deepCachingType": "NEVER",
"displayName": "Testing transitions",
"dscp": 3,
"geoLimit": 1,
@@ -520,8 +520,8 @@
"interfaceName": "bond0",
"ip6Address": "2345:1234:12:8::1/64",
"ip6Gateway": "2345:1234:12:8::1",
- "ipAddress": "127.0.0.1",
- "ipGateway": "127.0.0.1",
+ "ipAddress": "127.0.0.21",
+ "ipGateway": "127.0.0.21",
"ipNetmask": "255.255.255.252",
"lastUpdated": "2018-03-28T17:30:00.220351+00:00",
"mgmtIpAddress": "",
@@ -533,6 +533,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-edge-01\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -564,6 +565,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 8086,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "",
"xmppPasswd": ""
@@ -595,6 +597,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-router-01\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -626,6 +629,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-edge-03\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -657,6 +661,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-edge-14\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -688,6 +693,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-edge-15\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -719,6 +725,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "MID",
"updPending": true,
"xmppId": "atlanta-mid-16\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -750,6 +757,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-org-1\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -781,6 +789,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "EDGE",
"updPending": true,
"xmppId": "atlanta-org-1\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -812,6 +821,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 80,
+ "typeName": "MID",
"updPending": true,
"xmppId": "atlanta-mid-01\\\\@ocdn.kabletown.net",
"xmppPasswd": "X"
@@ -843,15 +853,16 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 81,
+ "typeName": "TRAFFIC_MONITOR",
"updPending": true,
- "xmppId": "rascal\\\\@kabletown.net",
+ "xmppId": "",
"xmppPasswd": "X"
},
{
- "domainName": "kabletown.net",
+ "domainName": "local",
"guid": null,
- "hostName": "riak01",
- "httpsPort": null,
+ "hostName": "riak",
+ "httpsPort": 8088,
"iloIpAddress": "",
"iloIpGateway": "",
"iloIpNetmask": "",
@@ -861,8 +872,8 @@
"interfaceName": "eth1",
"ip6Address": "2345:1234:12:b::12/64",
"ip6Gateway": "2345:1234:12:b::12",
- "ipAddress": "127.0.0.5",
- "ipGateway": "127.0.0.5",
+ "ipAddress": "127.0.0.1",
+ "ipGateway": "127.0.0.1",
"ipNetmask": "255.255.252.0",
"lastUpdated": "2018-03-28T17:30:00.220351+00:00",
"mgmtIpAddress": "",
@@ -874,6 +885,7 @@
"routerHostName": "",
"routerPortName": "",
"tcpPort": 8088,
+ "typeName": "RIAK",
"updPending": true,
"xmppId": "",
"xmppPasswd": ""
@@ -1108,6 +1120,12 @@
"lastUpdated": "2018-03-02T19:13:46.832327+00:00",
"name": "MID",
"useInTable": "server"
+ },
+ {
+ "description": "Traffic Monitor (Rascal)",
+ "lastUpdated": "2018-03-02T19:13:46.832327+00:00",
+ "name": "TRAFFIC_MONITOR",
+ "useInTable": "server"
}
]
}
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go
index 60a46826d..8fbcb71c7 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -413,7 +413,9 @@ router_port_name=:router_port_name,
status=:status_id,
tcp_port=:tcp_port,
type=:server_type_id,
-upd_pending=:upd_pending
+upd_pending=:upd_pending,
+xmpp_id=:xmpp_id,
+xmpp_passwd=:xmpp_passwd
WHERE id=:id RETURNING last_updated`
return query
}
@@ -442,8 +444,10 @@ func (server *TOServer) Create(db *sqlx.DB, user auth.CurrentUser) (error, tc.Ap
log.Error.Printf("could not begin transaction: %v", err)
return tc.DBError, tc.SystemError
}
+
if server.XMPPID == nil || *server.XMPPID == "" {
- server.XMPPID = server.HostName
+ hostName := *server.HostName
+ server.XMPPID = &hostName
}
resultRows, err := tx.NamedQuery(insertQuery(), server)
@@ -522,7 +526,10 @@ router_port_name,
status,
tcp_port,
type,
-upd_pending) VALUES (
+upd_pending,
+xmpp_id,
+xmpp_passwd
+) VALUES (
:cachegroup_id,
:cdn_id,
:domain_name,
@@ -552,7 +559,10 @@ upd_pending) VALUES (
:status_id,
:tcp_port,
:server_type_id,
-:upd_pending) RETURNING id,last_updated`
+:upd_pending,
+:xmpp_id,
+:xmpp_passwd
+) RETURNING id,last_updated`
return query
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services