You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/08/21 22:35:08 UTC
[trafficcontrol] branch master updated (eed18c9 -> 1b8c166)
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.
from eed18c9 Fix Docs cdn dnssec generate missing date
new 4f61314 updated TM to use TO client v13
new 492d918 updated TO client v13 for TM
new 9182958 update TO client to v13 in TM tools
new 1b8c166 Added CHANGELOG.md entry for updating TM to use TO client v13
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGELOG.md | 1 +
traffic_monitor/manager/opsconfig.go | 4 +--
traffic_monitor/tmcheck/dsstats.go | 4 +--
traffic_monitor/tmcheck/offlinestates.go | 4 +--
traffic_monitor/tmcheck/peerpoller.go | 2 +-
traffic_monitor/tmcheck/queryinterval.go | 2 +-
traffic_monitor/tmcheck/tmcheck.go | 15 ++++-----
.../nagios-validate-deliveryservices.go | 2 +-
.../nagios-validate-offline.go | 2 +-
.../nagios-validate-peerpoller.go | 2 +-
.../nagios-validate-queryinterval.go | 2 +-
.../tools/validator-service/validator-service.go | 2 +-
traffic_monitor/towrap/towrap.go | 36 +++++++++++++---------
traffic_ops/client/{ => v13}/crconfig.go | 8 +----
traffic_ops/client/v13/parameter.go | 17 ++++++++++
traffic_ops/client/v13/server.go | 18 +++++++++++
traffic_ops/client/v13/session.go | 4 +--
traffic_ops/client/{ => v13}/traffic_monitor.go | 21 ++-----------
traffic_ops/client/v13/user.go | 2 +-
19 files changed, 85 insertions(+), 63 deletions(-)
copy traffic_ops/client/{ => v13}/crconfig.go (82%)
copy traffic_ops/client/{ => v13}/traffic_monitor.go (73%)
[trafficcontrol] 02/04: updated TO client v13 for TM
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 492d9183fd733114db74a33838323d94b1129fa1
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Tue Aug 14 13:20:58 2018 -0600
updated TO client v13 for TM
---
traffic_ops/client/v13/crconfig.go | 24 ++++++++++++++
traffic_ops/client/v13/parameter.go | 17 ++++++++++
traffic_ops/client/v13/server.go | 18 ++++++++++
traffic_ops/client/v13/session.go | 4 +--
traffic_ops/client/v13/traffic_monitor.go | 55 +++++++++++++++++++++++++++++++
traffic_ops/client/v13/user.go | 2 +-
6 files changed, 117 insertions(+), 3 deletions(-)
diff --git a/traffic_ops/client/v13/crconfig.go b/traffic_ops/client/v13/crconfig.go
new file mode 100644
index 0000000..ef8356a
--- /dev/null
+++ b/traffic_ops/client/v13/crconfig.go
@@ -0,0 +1,24 @@
+/*
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package v13
+
+import "fmt"
+
+// GetCRConfig returns the raw JSON bytes of the CRConfig from Traffic Ops, and whether the bytes were from the client's internal cache.
+func (to *Session) GetCRConfig(cdn string) ([]byte, ReqInf, error) {
+ url := fmt.Sprintf("/CRConfig-Snapshots/%s/CRConfig.json", cdn)
+ return to.getBytesWithTTL(url, tmPollingInterval)
+}
diff --git a/traffic_ops/client/v13/parameter.go b/traffic_ops/client/v13/parameter.go
index ec76076..34e94ab 100644
--- a/traffic_ops/client/v13/parameter.go
+++ b/traffic_ops/client/v13/parameter.go
@@ -82,6 +82,23 @@ func (to *Session) GetParameters() ([]tc.Parameter, ReqInf, error) {
return data.Response, reqInf, nil
}
+func (to *Session) GetParametersByProfileName(profileName string) ([]tc.Parameter, ReqInf, error) {
+ url := fmt.Sprintf(API_v13_Parameters + "/profile/%s.json", profileName)
+ resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
+ reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
+ if err != nil {
+ return nil, reqInf, err
+ }
+ defer resp.Body.Close()
+
+ var data tc.ParametersResponse
+ if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+ return nil, reqInf, err
+ }
+
+ return data.Response, reqInf, nil
+}
+
// GET a Parameter by the Parameter ID
func (to *Session) GetParameterByID(id int) ([]tc.Parameter, ReqInf, error) {
route := fmt.Sprintf("%s/%d", API_v13_Parameters, id)
diff --git a/traffic_ops/client/v13/server.go b/traffic_ops/client/v13/server.go
index 89864f0..b54cd55 100644
--- a/traffic_ops/client/v13/server.go
+++ b/traffic_ops/client/v13/server.go
@@ -23,6 +23,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-tc/v13"
+ "net/url"
)
const (
@@ -131,3 +132,20 @@ func (to *Session) DeleteServerByID(id int) (tc.Alerts, ReqInf, error) {
err = json.NewDecoder(resp.Body).Decode(&alerts)
return alerts, reqInf, nil
}
+
+func (to *Session) GetServersByType(qparams url.Values) ([]v13.Server, ReqInf, error) {
+ url := fmt.Sprintf("%s.json?%s", API_v13_Servers, qparams.Encode())
+ resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
+ reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
+ if err != nil {
+ return nil, reqInf, err
+ }
+ defer resp.Body.Close()
+
+ var data v13.ServersResponse
+ if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+ return nil, reqInf, err
+ }
+
+ return data.Response, reqInf, nil
+}
\ No newline at end of file
diff --git a/traffic_ops/client/v13/session.go b/traffic_ops/client/v13/session.go
index c409ac0..7634941 100644
--- a/traffic_ops/client/v13/session.go
+++ b/traffic_ops/client/v13/session.go
@@ -114,7 +114,7 @@ func (to *Session) login() (net.Addr, error) {
return nil, errors.New("creating login credentials: " + err.Error())
}
- path := "/api/1.2/user/login"
+ path := apiBase + "/user/login"
resp, remoteAddr, err := to.rawRequest("POST", path, credentials)
resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
if err != nil {
@@ -149,7 +149,7 @@ func (to *Session) logout() (net.Addr, error) {
return nil, errors.New("creating login credentials: " + err.Error())
}
- path := "/api/1.2/user/logout"
+ path := apiBase + "/user/logout"
resp, remoteAddr, err := to.rawRequest("POST", path, credentials)
resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
if err != nil {
diff --git a/traffic_ops/client/v13/traffic_monitor.go b/traffic_ops/client/v13/traffic_monitor.go
new file mode 100644
index 0000000..dc97a44
--- /dev/null
+++ b/traffic_ops/client/v13/traffic_monitor.go
@@ -0,0 +1,55 @@
+package v13
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/trafficcontrol/lib/go-tc"
+)
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+func (to *Session) GetTrafficMonitorConfigMap(cdn string) (*tc.TrafficMonitorConfigMap, ReqInf, error) {
+ tmConfig, reqInf, err := to.GetTrafficMonitorConfig(cdn)
+ if err != nil {
+ return nil, reqInf, err
+ }
+ tmConfigMap, err := tc.TrafficMonitorTransformToMap(tmConfig)
+ if err != nil {
+ return nil, reqInf, err
+ }
+ return tmConfigMap, reqInf, nil
+}
+
+func (to *Session) GetTrafficMonitorConfig(cdn string) (*tc.TrafficMonitorConfig, ReqInf, error) {
+ url := fmt.Sprintf("/api/1.3/cdns/%s/configs/monitoring.json", cdn)
+ resp, remoteAddr, err := to.request("GET", url, nil)
+ reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
+ if err != nil {
+ return nil, reqInf, err
+ }
+ defer resp.Body.Close()
+
+ var data tc.TMConfigResponse
+ if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+ return nil, reqInf, err
+ }
+
+ return &data.Response, reqInf, nil
+}
diff --git a/traffic_ops/client/v13/user.go b/traffic_ops/client/v13/user.go
index 0102498..3309524 100644
--- a/traffic_ops/client/v13/user.go
+++ b/traffic_ops/client/v13/user.go
@@ -29,7 +29,7 @@ func (to *Session) Users() ([]tc.User, error) {
}
func (to *Session) GetUsers() ([]tc.User, ReqInf, error) {
- url := "/api/1.2/users.json"
+ url := apiBase + "/users.json"
resp, remoteAddr, err := to.request("GET", url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
[trafficcontrol] 03/04: update TO client to v13 in TM tools
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 9182958530b649fddd674ac11cf0477cc7385275
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Tue Aug 14 13:29:57 2018 -0600
update TO client to v13 in TM tools
---
.../nagios-validate-deliveryservices.go | 2 +-
.../tools/nagios-validate-offline/nagios-validate-offline.go | 2 +-
.../tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go | 2 +-
.../nagios-validate-queryinterval/nagios-validate-queryinterval.go | 2 +-
traffic_monitor/tools/validator-service/validator-service.go | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go b/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
index 5d61aa8..164cd1f 100644
--- a/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
+++ b/traffic_monitor/tools/nagios-validate-deliveryservices/nagios-validate-deliveryservices.go
@@ -25,7 +25,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-nagios"
"github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const UserAgent = "tm-offline-validator/0.1"
diff --git a/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go b/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
index afe1cbe..a4fd2be 100644
--- a/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
+++ b/traffic_monitor/tools/nagios-validate-offline/nagios-validate-offline.go
@@ -25,7 +25,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-nagios"
"github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const UserAgent = "tm-offline-validator/0.1"
diff --git a/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go b/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
index c52e946..4a67164 100644
--- a/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
+++ b/traffic_monitor/tools/nagios-validate-peerpoller/nagios-validate-peerpoller.go
@@ -24,7 +24,7 @@ import (
"fmt"
"github.com/apache/trafficcontrol/lib/go-nagios"
"github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const UserAgent = "tm-peerpoller-validator/0.1"
diff --git a/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go b/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
index 90bf3ec..178a885 100644
--- a/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
+++ b/traffic_monitor/tools/nagios-validate-queryinterval/nagios-validate-queryinterval.go
@@ -24,7 +24,7 @@ import (
"fmt"
"github.com/apache/trafficcontrol/lib/go-nagios"
"github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const UserAgent = "tm-queryinterval-validator/0.1"
diff --git a/traffic_monitor/tools/validator-service/validator-service.go b/traffic_monitor/tools/validator-service/validator-service.go
index 584f200..a20f849 100644
--- a/traffic_monitor/tools/validator-service/validator-service.go
+++ b/traffic_monitor/tools/validator-service/validator-service.go
@@ -26,7 +26,7 @@ import (
"fmt"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_monitor/tmcheck"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
"io"
"net/http"
"sort"
[trafficcontrol] 01/04: updated TM to use TO client v13
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 4f61314bbc226a614e2493115bd7cbac9da1ac85
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Tue Aug 14 13:18:50 2018 -0600
updated TM to use TO client v13
---
traffic_monitor/manager/opsconfig.go | 4 ++--
traffic_monitor/peer/peer_test.go | 1 -
traffic_monitor/tmcheck/dsstats.go | 4 ++--
traffic_monitor/tmcheck/offlinestates.go | 4 ++--
traffic_monitor/tmcheck/peerpoller.go | 2 +-
traffic_monitor/tmcheck/queryinterval.go | 2 +-
traffic_monitor/tmcheck/tmcheck.go | 15 ++++++-------
traffic_monitor/towrap/towrap.go | 36 +++++++++++++++++++-------------
8 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/traffic_monitor/manager/opsconfig.go b/traffic_monitor/manager/opsconfig.go
index 80578c6..4674c6c 100644
--- a/traffic_monitor/manager/opsconfig.go
+++ b/traffic_monitor/manager/opsconfig.go
@@ -37,7 +37,7 @@ import (
"github.com/apache/trafficcontrol/traffic_monitor/threadsafe"
"github.com/apache/trafficcontrol/traffic_monitor/todata"
"github.com/apache/trafficcontrol/traffic_monitor/towrap"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
// StartOpsConfigManager starts the ops config manager goroutine, returning the (threadsafe) variables which it sets.
@@ -178,7 +178,7 @@ func StartOpsConfigManager(
// getMonitorCDN returns the CDN of a given Traffic Monitor.
// TODO change to get by name, when Traffic Ops supports querying a single server.
func getMonitorCDN(toc *to.Session, monitorHostname string) (string, error) {
- servers, err := toc.Servers()
+ servers, _, err := toc.GetServers()
if err != nil {
return "", fmt.Errorf("getting monitor %s CDN: %v", monitorHostname, err)
}
diff --git a/traffic_monitor/peer/peer_test.go b/traffic_monitor/peer/peer_test.go
index 995493a..ca3a42f 100644
--- a/traffic_monitor/peer/peer_test.go
+++ b/traffic_monitor/peer/peer_test.go
@@ -23,7 +23,6 @@ import (
"fmt"
"io/ioutil"
"testing"
-
"github.com/apache/trafficcontrol/lib/go-tc"
)
diff --git a/traffic_monitor/tmcheck/dsstats.go b/traffic_monitor/tmcheck/dsstats.go
index 8241f69..b914f36 100644
--- a/traffic_monitor/tmcheck/dsstats.go
+++ b/traffic_monitor/tmcheck/dsstats.go
@@ -26,7 +26,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_monitor/dsdata"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
// ValidateDSStates validates that all Delivery Services in the CRConfig exist in given Traffic Monitor's DSStats.
@@ -41,7 +41,7 @@ func ValidateDSStats(tmURI string, toClient *to.Session) error {
// ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves an additional query if the Traffic Monitor's CDN is known.
func ValidateDSStatsWithCDN(tmURI string, tmCDN string, toClient *to.Session) error {
- crConfigBytes, err := toClient.CRConfigRaw(tmCDN)
+ crConfigBytes, _, err := toClient.GetCRConfig(tmCDN)
if err != nil {
return fmt.Errorf("getting CRConfig: %v", err)
}
diff --git a/traffic_monitor/tmcheck/offlinestates.go b/traffic_monitor/tmcheck/offlinestates.go
index c1f1ae8..95a1ed9 100644
--- a/traffic_monitor/tmcheck/offlinestates.go
+++ b/traffic_monitor/tmcheck/offlinestates.go
@@ -25,7 +25,7 @@ import (
"time"
"github.com/apache/trafficcontrol/lib/go-tc"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
// ValidateOfflineStates validates that no OFFLINE or ADMIN_DOWN caches in the given Traffic Ops' CRConfig are marked Available in the given Traffic Monitor's CRStates.
@@ -39,7 +39,7 @@ func ValidateOfflineStates(tmURI string, toClient *to.Session) error {
// ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves an additional query if the Traffic Monitor's CDN is known.
func ValidateOfflineStatesWithCDN(tmURI string, tmCDN string, toClient *to.Session) error {
- crConfigBytes, err := toClient.CRConfigRaw(tmCDN)
+ crConfigBytes, _, err := toClient.GetCRConfig(tmCDN)
if err != nil {
return fmt.Errorf("getting CRConfig: %v", err)
}
diff --git a/traffic_monitor/tmcheck/peerpoller.go b/traffic_monitor/tmcheck/peerpoller.go
index 5cad707..54927d4 100644
--- a/traffic_monitor/tmcheck/peerpoller.go
+++ b/traffic_monitor/tmcheck/peerpoller.go
@@ -22,7 +22,7 @@ package tmcheck
import (
"fmt"
"github.com/apache/trafficcontrol/lib/go-tc"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
"time"
)
diff --git a/traffic_monitor/tmcheck/queryinterval.go b/traffic_monitor/tmcheck/queryinterval.go
index bdcf678..f2c06ca 100644
--- a/traffic_monitor/tmcheck/queryinterval.go
+++ b/traffic_monitor/tmcheck/queryinterval.go
@@ -24,7 +24,7 @@ import (
"time"
"github.com/apache/trafficcontrol/lib/go-tc"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const QueryIntervalMax = time.Duration(10) * time.Second
diff --git a/traffic_monitor/tmcheck/tmcheck.go b/traffic_monitor/tmcheck/tmcheck.go
index 45c02d2..d703651 100644
--- a/traffic_monitor/tmcheck/tmcheck.go
+++ b/traffic_monitor/tmcheck/tmcheck.go
@@ -29,9 +29,10 @@ import (
"time"
"github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/lib/go-tc/v13"
"github.com/apache/trafficcontrol/traffic_monitor/datareq"
"github.com/apache/trafficcontrol/traffic_monitor/dsdata"
- to "github.com/apache/trafficcontrol/traffic_ops/client"
+ to "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
const RequestTimeout = time.Second * time.Duration(30)
@@ -194,10 +195,10 @@ type CRConfigOrError struct {
Err error
}
-func GetMonitors(toClient *to.Session, includeOffline bool) ([]tc.Server, error) {
+func GetMonitors(toClient *to.Session, includeOffline bool) ([]v13.Server, error) {
trafficMonitorType := "RASCAL"
monitorTypeQuery := map[string][]string{"type": []string{trafficMonitorType}}
- servers, err := toClient.ServersByType(monitorTypeQuery)
+ servers, _, err := toClient.GetServersByType(monitorTypeQuery)
if err != nil {
return nil, fmt.Errorf("getting monitors from Traffic Ops: %v", err)
}
@@ -260,8 +261,8 @@ func AllValidator(
}
// FilterOfflines returns only servers which are REPORTED or ONLINE
-func FilterOfflines(servers []tc.Server) []tc.Server {
- onlineServers := []tc.Server{}
+func FilterOfflines(servers []v13.Server) []v13.Server {
+ onlineServers := []v13.Server{}
for _, server := range servers {
status := tc.CacheStatusFromString(server.Status)
if status != tc.CacheStatusOnline && status != tc.CacheStatusReported {
@@ -272,7 +273,7 @@ func FilterOfflines(servers []tc.Server) []tc.Server {
return onlineServers
}
-func GetCDNs(servers []tc.Server) map[tc.CDNName]struct{} {
+func GetCDNs(servers []v13.Server) map[tc.CDNName]struct{} {
cdns := map[tc.CDNName]struct{}{}
for _, server := range servers {
cdns[tc.CDNName(server.CDNName)] = struct{}{}
@@ -283,7 +284,7 @@ func GetCDNs(servers []tc.Server) map[tc.CDNName]struct{} {
func GetCRConfigs(cdns map[tc.CDNName]struct{}, toClient *to.Session) map[tc.CDNName]CRConfigOrError {
crConfigs := map[tc.CDNName]CRConfigOrError{}
for cdn, _ := range cdns {
- crConfigBytes, err := toClient.CRConfigRaw(string(cdn))
+ crConfigBytes, _, err := toClient.GetCRConfig(string(cdn))
if err != nil {
crConfigs[cdn] = CRConfigOrError{Err: fmt.Errorf("getting CRConfig: %v", err)}
continue
diff --git a/traffic_monitor/towrap/towrap.go b/traffic_monitor/towrap/towrap.go
index c93fc50..e047f4f 100644
--- a/traffic_monitor/towrap/towrap.go
+++ b/traffic_monitor/towrap/towrap.go
@@ -30,7 +30,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-log"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-tc/v13"
- "github.com/apache/trafficcontrol/traffic_ops/client"
+ client "github.com/apache/trafficcontrol/traffic_ops/client/v13"
)
// ITrafficOpsSession provides an interface to the Traffic Ops client, so it may be wrapped or mocked.
@@ -41,11 +41,11 @@ type ITrafficOpsSession interface {
Set(session *client.Session)
URL() (string, error)
User() (string, error)
- Servers() ([]tc.Server, error)
- Profiles() ([]tc.Profile, error)
+ Servers() ([]v13.Server, error)
+ Profiles() ([]v13.Profile, error)
Parameters(profileName string) ([]tc.Parameter, error)
- DeliveryServices() ([]tc.DeliveryService, error)
- CacheGroups() ([]v13.CacheGroup, error)
+ DeliveryServices() ([]tc.DeliveryServiceV13, error)
+ CacheGroups() ([]v13.CacheGroupNullable, error)
CRConfigHistory() []CRConfigStat
}
@@ -267,7 +267,8 @@ func (s TrafficOpsSessionThreadsafe) trafficMonitorConfigMapRaw(cdn string) (*tc
if ss == nil {
return nil, ErrNilSession
}
- return ss.TrafficMonitorConfigMap(cdn)
+ configMap, _, error := ss.GetTrafficMonitorConfigMap(cdn)
+ return configMap, error
}
// TrafficMonitorConfigMap returns the Traffic Monitor config map from the Traffic Ops. This is safe for multiple goroutines.
@@ -418,20 +419,22 @@ func CreateMonitorConfig(crConfig tc.CRConfig, mc *tc.TrafficMonitorConfigMap) (
return mc, nil
}
-func (s TrafficOpsSessionThreadsafe) Servers() ([]tc.Server, error) {
+func (s TrafficOpsSessionThreadsafe) Servers() ([]v13.Server, error) {
ss := s.get()
if ss == nil {
return nil, ErrNilSession
}
- return ss.Servers()
+ servers, _, error := ss.GetServers()
+ return servers, error
}
-func (s TrafficOpsSessionThreadsafe) Profiles() ([]tc.Profile, error) {
+func (s TrafficOpsSessionThreadsafe) Profiles() ([]v13.Profile, error) {
ss := s.get()
if ss == nil {
return nil, ErrNilSession
}
- return ss.Profiles()
+ profiles, _, error := ss.GetProfiles()
+ return profiles, error
}
func (s TrafficOpsSessionThreadsafe) Parameters(profileName string) ([]tc.Parameter, error) {
@@ -439,21 +442,24 @@ func (s TrafficOpsSessionThreadsafe) Parameters(profileName string) ([]tc.Parame
if ss == nil {
return nil, ErrNilSession
}
- return ss.Parameters(profileName)
+ parameters, _, error := ss.GetParametersByProfileName(profileName)
+ return parameters, error
}
-func (s TrafficOpsSessionThreadsafe) DeliveryServices() ([]tc.DeliveryService, error) {
+func (s TrafficOpsSessionThreadsafe) DeliveryServices() ([]tc.DeliveryServiceV13, error) {
ss := s.get()
if ss == nil {
return nil, ErrNilSession
}
- return ss.DeliveryServices()
+ deliveryServices, _, error := ss.GetDeliveryServices()
+ return deliveryServices, error
}
-func (s TrafficOpsSessionThreadsafe) CacheGroups() ([]v13.CacheGroup, error) {
+func (s TrafficOpsSessionThreadsafe) CacheGroups() ([]v13.CacheGroupNullable, error) {
ss := s.get()
if ss == nil {
return nil, ErrNilSession
}
- return ss.CacheGroups()
+ cacheGroups, _, error := ss.GetCacheGroupsNullable()
+ return cacheGroups, error
}
[trafficcontrol] 04/04: Added CHANGELOG.md entry for updating TM to
use TO client v13
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 1b8c1664e77c5bbb92c7dc1ed9c0fc90911e8dfc
Author: Jesse Rivas <je...@comcast.com>
AuthorDate: Tue Aug 21 12:50:27 2018 -0600
Added CHANGELOG.md entry for updating TM to use TO client v13
---
CHANGELOG.md | 1 +
traffic_monitor/peer/peer_test.go | 1 +
traffic_ops/client/v13/server.go | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 123734c..b5022ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Cachegroup-Coordinate Refactor: The Cachegroup API now creates/updates a Coordinate entity on Cachegroup creates/updates, and the `latitude` and `longitude` columns in the `cachegroup` table have been replaced with `coordinate` (a foreign key to Coordinate). Coordinates created from Cachegroups are given the name `from_cachegroup_\<cachegroup name\>`.
- Geolocation-based Client Steering: two new steering target types are available to use for `CLIENT_STEERING` delivery services: `STEERING_GEO_ORDER` and `STEERING_GEO_WEIGHT`. When targets of these types have an Origin with a Coordinate, Traffic Router will order and prioritize them based upon the shortest total distance from client -> edge -> origin. Co-located targets are grouped together and can be weighted or ordered within the same location using `STEERING_GEO_WEIGHT` or `STEERING_ [...]
- Tenancy is now the default behavior in Traffic Ops. All database entries that reference a tenant now have a default of the root tenant. This eliminates the need for the `use_tenancy` global parameter and will allow for code to be simplified as a result. If all user and delivery services reference the root tenant, then there will be no difference from having `use_tenancy` set to 0.
+- Traffic Monitor Client Update: Traffic Monitor is updated to use the Traffic Ops v13 client.
## [2.2.0] - 2018-06-07
### Added
diff --git a/traffic_monitor/peer/peer_test.go b/traffic_monitor/peer/peer_test.go
index ca3a42f..995493a 100644
--- a/traffic_monitor/peer/peer_test.go
+++ b/traffic_monitor/peer/peer_test.go
@@ -23,6 +23,7 @@ import (
"fmt"
"io/ioutil"
"testing"
+
"github.com/apache/trafficcontrol/lib/go-tc"
)
diff --git a/traffic_ops/client/v13/server.go b/traffic_ops/client/v13/server.go
index b54cd55..74b0f5a 100644
--- a/traffic_ops/client/v13/server.go
+++ b/traffic_ops/client/v13/server.go
@@ -148,4 +148,4 @@ func (to *Session) GetServersByType(qparams url.Values) ([]v13.Server, ReqInf, e
}
return data.Response, reqInf, nil
-}
\ No newline at end of file
+}