You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/08/21 15:25:55 UTC
[trafficcontrol] branch master updated (e4f2f20 -> 8247f2d)
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.
from e4f2f20 Add TO Go JSONNumAsStr unmarshal unit test
new 763bcb8 redo initial data loading from dir structure
new 8247f2d compress CURLOPTS to work in both bash and zsh
The 2 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:
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 2 +-
.../cdn-in-a-box/traffic_ops/Dockerfile-go | 6 ---
infrastructure/cdn-in-a-box/traffic_ops/run-go.sh | 16 ++-----
infrastructure/cdn-in-a-box/traffic_ops/setup.sh | 54 ----------------------
.../cdn-in-a-box/traffic_ops/to-access.sh | 12 ++---
.../{ => traffic_ops}/trafficops-init.sh | 12 ++++-
.../cachegroups}/edge_cachegroup.json | 2 +-
.../cachegroups}/mid_cachegroup.json | 2 +-
.../cdns}/cdns.json | 0
.../deliveryservices}/deliveryservices.json | 0
.../traffic_ops_data/divisions/north.json | 3 ++
.../traffic_ops_data/divisions/usa.json | 3 ++
.../traffic_ops_data/phys_locations/apachecon.json | 9 ++++
.../phys_locations}/phys_location.json | 3 +-
.../cdn-in-a-box/traffic_ops_data/regions/dc.json | 4 ++
.../traffic_ops_data/regions/montreal.json | 4 ++
16 files changed, 47 insertions(+), 85 deletions(-)
delete mode 100755 infrastructure/cdn-in-a-box/traffic_ops/setup.sh
rename infrastructure/cdn-in-a-box/{ => traffic_ops}/trafficops-init.sh (87%)
rename infrastructure/cdn-in-a-box/{traffic_ops => traffic_ops_data/cachegroups}/edge_cachegroup.json (82%)
rename infrastructure/cdn-in-a-box/{traffic_ops => traffic_ops_data/cachegroups}/mid_cachegroup.json (83%)
rename infrastructure/cdn-in-a-box/{traffic_ops => traffic_ops_data/cdns}/cdns.json (100%)
rename infrastructure/cdn-in-a-box/{traffic_ops => traffic_ops_data/deliveryservices}/deliveryservices.json (100%)
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops_data/divisions/north.json
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops_data/divisions/usa.json
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/apachecon.json
rename infrastructure/cdn-in-a-box/{traffic_ops => traffic_ops_data/phys_locations}/phys_location.json (80%)
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops_data/regions/dc.json
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops_data/regions/montreal.json
[trafficcontrol] 02/02: compress CURLOPTS to work in both bash and
zsh
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 8247f2dafa7cba31401560edd2377b4046e48af3
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Aug 20 14:53:34 2018 -0600
compress CURLOPTS to work in both bash and zsh
---
infrastructure/cdn-in-a-box/traffic_ops/to-access.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
index 4154a7d..be91d10 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
@@ -21,7 +21,7 @@
export TO_URL TO_ADMIN_USER TO_ADMIN_PASSWORD
-export CURLOPTS=${CURLOPTS:--L -f -s -S}
+export CURLOPTS=${CURLOPTS:--LfsS}
export CURLAUTH=${CURLAUTH:--k}
export COOKIEJAR=$(mktemp -t XXXX.cookie)
[trafficcontrol] 01/02: redo initial data loading from dir structure
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 763bcb8dc29df605333063d2a9d310747184957b
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Aug 16 16:40:37 2018 -0600
redo initial data loading from dir structure
---
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 2 +-
.../cdn-in-a-box/traffic_ops/Dockerfile-go | 6 ---
infrastructure/cdn-in-a-box/traffic_ops/run-go.sh | 16 ++-----
infrastructure/cdn-in-a-box/traffic_ops/setup.sh | 54 ----------------------
.../cdn-in-a-box/traffic_ops/to-access.sh | 12 ++---
.../{ => traffic_ops}/trafficops-init.sh | 12 ++++-
.../cachegroups}/edge_cachegroup.json | 2 +-
.../cachegroups}/mid_cachegroup.json | 2 +-
.../cdns}/cdns.json | 0
.../deliveryservices}/deliveryservices.json | 0
.../traffic_ops_data/divisions/north.json | 3 ++
.../traffic_ops_data/divisions/usa.json | 3 ++
.../traffic_ops_data/phys_locations/apachecon.json | 9 ++++
.../phys_locations}/phys_location.json | 3 +-
.../cdn-in-a-box/traffic_ops_data/regions/dc.json | 4 ++
.../traffic_ops_data/regions/montreal.json | 4 ++
16 files changed, 47 insertions(+), 85 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 0637164..0b19e43 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -80,7 +80,7 @@ ADD traffic_ops/run.sh \
traffic_ops/config.sh \
traffic_ops/adduser.pl \
traffic_ops/to-access.sh \
- trafficops-init.sh \
+ traffic_ops/trafficops-init.sh \
/
ADD traffic_ops_data /traffic_ops_data
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index 5acf20c..edd47b2 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -33,11 +33,5 @@ WORKDIR /opt/traffic_ops/app
ADD traffic_ops/config.sh \
traffic_ops/run-go.sh \
- traffic_ops/setup.sh \
- traffic_ops/cdns.json \
- traffic_ops/deliveryservices.json \
- traffic_ops/mid_cachegroup.json \
- traffic_ops/edge_cachegroup.json \
- traffic_ops/phys_location.json \
/
CMD /run-go.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
index 27ce0c7..821c062 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
@@ -57,19 +57,9 @@ while ! nc trafficops-perl 60443 </dev/null 2>/dev/null; do
done
cd /opt/traffic_ops/app
-ls -l bin
+
CDNCONF=/opt/traffic_ops/app/conf/cdn.conf
DBCONF=/opt/traffic_ops/app/conf/production/database.conf
mkdir -p /var/log/traffic_ops
-touch /var/log/traffic_ops.log
-./bin/traffic_ops_golang -cfg $CDNCONF -dbcfg $DBCONF >>/var/log/traffic_ops.log 2>>/var/log/traffic_ops.log &
-
-while ! nc localhost 6443 </dev/null; do
- echo "waiting for traffic_ops_golang:6443"
- sleep 3
-done
-
-/setup.sh
-
-cat /var/log/traffic_ops/*
-exec tail -f /var/log/traffic_ops.log
+touch /var/log/traffic_ops/traffic_ops.log
+./bin/traffic_ops_golang -cfg $CDNCONF -dbcfg $DBCONF
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/setup.sh b/infrastructure/cdn-in-a-box/traffic_ops/setup.sh
deleted file mode 100755
index b465ee1..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/setup.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/bash
-# 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.
-
-set -x
-set -e
-
-# First, we need to authenticate
-curl -skc cookie.jar -d "{\"u\":\"$TO_ADMIN_USER\",\"p\":\"$TO_ADMIN_PASSWORD\"}" https://localhost:$TO_PORT/api/1.3/user/login
-echo
-# Now set up a new CDN...
-curl -skb cookie.jar -d @/cdns.json https://localhost:$TO_PORT/api/1.3/cdns
-echo
-#... and a delivery service
-curl -skb cookie.jar -d @/deliveryservices.json https://localhost:$TO_PORT/api/1.3/deliveryservices
-echo
-#... and two cachegroup
-MID_LOC_ID=$(curl -skb cookie.jar https://localhost:$TO_PORT/api/1.3/types | jq '.response|.[]|select(.name=="MID_LOC")|.id')
-EDGE_LOC_ID=$(curl -skb cookie.jar https://localhost:$TO_PORT/api/1.3/types | jq '.response|.[]|select(.name=="EDGE_LOC")|.id')
-
-
-sed -ie "s/MID_LOC_ID/${MID_LOC_ID}/g" /mid_cachegroup.json
-sed -ie "s/EDGE_LOC_ID/${EDGE_LOC_ID}/g" /edge_cachegroup.json
-curl -skb cookie.jar -d @/mid_cachegroup.json https://localhost:$TO_PORT/api/1.3/cachegroups
-echo
-curl -skb cookie.jar -d @/edge_cachegroup.json https://localhost:$TO_PORT/api/1.3/cachegroups
-echo
-#... and a division
-curl -skb cookie.jar -d '{"name":"CDN_in_a_Box"}' https://localhost:$TO_PORT/api/1.3/divisions
-echo
-#... and a region
-curl -skb cookie.jar -d '{"name":"CDN_in_a_Box"}' https://localhost:$TO_PORT/api/1.3/divisions/CDN_in_a_Box/regions
-echo
-#... and a physical location
-curl -skb cookie.jar -d @/phys_location.json https://localhost:$TO_PORT/api/1.3/regions/CDN_in_a_Box/phys_locations
-echo
-
-
-#cleanup at exit
-rm cookie.jar
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
index 6c2f877..4154a7d 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
@@ -21,7 +21,7 @@
export TO_URL TO_ADMIN_USER TO_ADMIN_PASSWORD
-export CURLOPTS=${CURLOPTS:--L}
+export CURLOPTS=${CURLOPTS:--L -f -s -S}
export CURLAUTH=${CURLAUTH:--k}
export COOKIEJAR=$(mktemp -t XXXX.cookie)
@@ -71,12 +71,12 @@ CREDS
to-ping() {
# ping endpoint does not require authentication
- curl $CURLAUTH $CURLOPTS -s -X GET "$TO_URL/api/1.3/ping"
+ curl $CURLAUTH $CURLOPTS -X GET "$TO_URL/api/1.3/ping"
}
to-get() {
to-auth && \
- curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X GET "$TO_URL/$1"
+ curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X GET "$TO_URL/$1"
}
to-post() {
@@ -88,7 +88,7 @@ to-post() {
data="--data $2"
fi
to-auth && \
- curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X POST $data "$TO_URL/$1"
+ curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X POST $data "$TO_URL/$1"
}
to-put() {
@@ -100,10 +100,10 @@ to-put() {
data="--data $2"
fi
to-auth && \
- curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X PUT $data "$TO_URL/$1"
+ curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X PUT $data "$TO_URL/$1"
}
to-delete() {
to-auth && \
- curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X DELETE "$TO_URL/$1"
+ curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X DELETE "$TO_URL/$1"
}
diff --git a/infrastructure/cdn-in-a-box/trafficops-init.sh b/infrastructure/cdn-in-a-box/traffic_ops/trafficops-init.sh
similarity index 87%
rename from infrastructure/cdn-in-a-box/trafficops-init.sh
rename to infrastructure/cdn-in-a-box/traffic_ops/trafficops-init.sh
index 89eeedd..ee241c0 100755
--- a/infrastructure/cdn-in-a-box/trafficops-init.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/trafficops-init.sh
@@ -36,7 +36,7 @@ while ! to-get api/1.3/ping 2>/dev/null; do
done
# NOTE: order dependent on foreign key references, e.g. tenants must be defined before users
-endpoints="tenants users cdns servers"
+endpoints="cdns divisions regions phys_locations tenants users cachegroups deliveryservices"
load_data_from() {
local dir="$1"
@@ -52,10 +52,18 @@ load_data_from() {
[[ -r $f ]] || continue
t=$(mktemp --tmpdir $ep-XXX.json)
envsubst <"$f" >"$t"
- to-post api/1.3/"$ep" "$t"
+ if ! to-post api/1.3/"$ep" "$t"; then
+ echo POST api/1.3/"$ep" "$t" failed
+ status=$?
+ fi
rm "$t"
done
done
+ if [ $status -ne 0 ]; then
+ exit $status
+ fi
+
+
}
# First, load required data at the top level
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/edge_cachegroup.json b/infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/edge_cachegroup.json
similarity index 82%
rename from infrastructure/cdn-in-a-box/traffic_ops/edge_cachegroup.json
rename to infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/edge_cachegroup.json
index efc18c4..3f0b0ce 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/edge_cachegroup.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/edge_cachegroup.json
@@ -3,5 +3,5 @@
"shortName": "ciabEdge",
"latitude": 38.897663,
"longitude": -77.036574,
-"typeId": EDGE_LOC_ID
+"typeId": 23
}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/mid_cachegroup.json b/infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/mid_cachegroup.json
similarity index 83%
rename from infrastructure/cdn-in-a-box/traffic_ops/mid_cachegroup.json
rename to infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/mid_cachegroup.json
index 26f6c56..00c9e84 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/mid_cachegroup.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/cachegroups/mid_cachegroup.json
@@ -3,5 +3,5 @@
"shortName": "ciabMid",
"latitude": 38.897663,
"longitude": -77.036574,
-"typeId": MID_LOC_ID
+"typeId": 24
}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/cdns.json b/infrastructure/cdn-in-a-box/traffic_ops_data/cdns/cdns.json
similarity index 100%
rename from infrastructure/cdn-in-a-box/traffic_ops/cdns.json
rename to infrastructure/cdn-in-a-box/traffic_ops_data/cdns/cdns.json
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/deliveryservices.json b/infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/deliveryservices.json
similarity index 100%
rename from infrastructure/cdn-in-a-box/traffic_ops/deliveryservices.json
rename to infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/deliveryservices.json
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/north.json b/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/north.json
new file mode 100644
index 0000000..b13855c
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/north.json
@@ -0,0 +1,3 @@
+{
+ "name": "Quebec"
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/usa.json b/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/usa.json
new file mode 100644
index 0000000..4a6c163
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/divisions/usa.json
@@ -0,0 +1,3 @@
+{
+ "name": "U.S.A"
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/apachecon.json b/infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/apachecon.json
new file mode 100644
index 0000000..23ea340
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/apachecon.json
@@ -0,0 +1,9 @@
+{
+ "name": "Apachecon North America 2018",
+ "shortName": "Apachecon",
+ "address": " 1050 de la Gauchetiere West",
+ "city": "Montreal QC",
+ "state": "Canada",
+ "zip": "H3B 4C9",
+ "regionId": 2
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/phys_location.json b/infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/phys_location.json
similarity index 80%
rename from infrastructure/cdn-in-a-box/traffic_ops/phys_location.json
rename to infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/phys_location.json
index 94b168f..ffa5880 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/phys_location.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/phys_locations/phys_location.json
@@ -4,5 +4,6 @@
"address": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "D.C.",
- "zip": "20500"
+ "zip": "20500",
+ "regionId": 1
}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/regions/dc.json b/infrastructure/cdn-in-a-box/traffic_ops_data/regions/dc.json
new file mode 100644
index 0000000..850d6cb
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/regions/dc.json
@@ -0,0 +1,4 @@
+{
+ "division": 2,
+ "name": "Washington, D.C"
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/regions/montreal.json b/infrastructure/cdn-in-a-box/traffic_ops_data/regions/montreal.json
new file mode 100644
index 0000000..e286381
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/regions/montreal.json
@@ -0,0 +1,4 @@
+{
+ "division": 1,
+ "name": "Montreal"
+}