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 2019/03/27 23:26:11 UTC
[trafficcontrol] branch master updated: CIAB: Add CDN_NAME
environment variable (#3413)
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
The following commit(s) were added to refs/heads/master by this push:
new fe08b29 CIAB: Add CDN_NAME environment variable (#3413)
fe08b29 is described below
commit fe08b296828ae257fcfa0a3daff4901b31a2681f
Author: Shihta Kuan <Sh...@users.noreply.github.com>
AuthorDate: Thu Mar 28 07:26:05 2019 +0800
CIAB: Add CDN_NAME environment variable (#3413)
---
infrastructure/cdn-in-a-box/edge/run.sh | 8 +++-----
infrastructure/cdn-in-a-box/mid/run.sh | 6 ++----
infrastructure/cdn-in-a-box/traffic_monitor/run.sh | 7 +++----
infrastructure/cdn-in-a-box/traffic_ops/run-go.sh | 14 +++++++-------
infrastructure/cdn-in-a-box/traffic_ops/to-access.sh | 2 +-
.../traffic_ops_data/cdns/010-CDN-in-a-Box.json | 2 +-
.../traffic_ops_data/deliveryservices/010-ciab.json | 2 +-
.../traffic_ops_data/profiles/010-ATS_EDGE_TIER_CACHE.json | 2 +-
.../traffic_ops_data/profiles/020-ATS_MID_TIER_CACHE.json | 2 +-
.../traffic_ops_data/profiles/040-CCR_CIAB.json | 2 +-
.../profiles/070-RASCAL-Traffic_Monitor.json | 2 +-
infrastructure/cdn-in-a-box/variables.env | 1 +
12 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/edge/run.sh b/infrastructure/cdn-in-a-box/edge/run.sh
index a5da036..93e5646 100755
--- a/infrastructure/cdn-in-a-box/edge/run.sh
+++ b/infrastructure/cdn-in-a-box/edge/run.sh
@@ -45,8 +45,6 @@ while ! to-ping 2>/dev/null; do
sleep 5
done
-CDN=CDN-in-a-Box
-
export TO_USER=$TO_ADMIN_USER
export TO_PASSWORD=$TO_ADMIN_PASSWORD
@@ -55,10 +53,10 @@ found=
while [[ -z $found ]]; do
echo 'waiting for enroller setup'
sleep 3
- found=$(to-get "api/1.3/cdns?name=$CDN" | jq -r '.response[].name')
+ found=$(to-get "api/1.3/cdns?name=$CDN_NAME" | jq -r '.response[].name')
done
-to-enroll edge $CDN || (while true; do echo "enroll failed."; sleep 3 ; done)
+to-enroll edge $CDN_NAME || (while true; do echo "enroll failed."; sleep 3 ; done)
while [[ -z "$(testenrolled)" ]]; do
echo "waiting on enrollment"
@@ -66,7 +64,7 @@ while [[ -z "$(testenrolled)" ]]; do
done
# Wait for SSL keys to exist
-until to-get "api/1.3/cdns/name/$CDN/sslkeys" && [[ "$(to-get api/1.3/cdns/name/$CDN/sslkeys)" != '{"response":[]}' ]]; do
+until to-get "api/1.3/cdns/name/$CDN_NAME/sslkeys" && [[ "$(to-get api/1.3/cdns/name/$CDN_NAME/sslkeys)" != '{"response":[]}' ]]; do
echo 'waiting for SSL keys to exist'
sleep 3
done
diff --git a/infrastructure/cdn-in-a-box/mid/run.sh b/infrastructure/cdn-in-a-box/mid/run.sh
index 2d256b8..9e5915c 100755
--- a/infrastructure/cdn-in-a-box/mid/run.sh
+++ b/infrastructure/cdn-in-a-box/mid/run.sh
@@ -45,8 +45,6 @@ while ! to-ping 2>/dev/null; do
sleep 5
done
-CDN=CDN-in-a-Box
-
export TO_USER=$TO_ADMIN_USER
export TO_PASSWORD=$TO_ADMIN_PASSWORD
@@ -55,10 +53,10 @@ found=
while [[ -z $found ]]; do
echo 'waiting for enroller setup'
sleep 3
- found=$(to-get api/1.3/cdns?name="$CDN" | jq -r '.response[].name')
+ found=$(to-get api/1.3/cdns?name="$CDN_NAME" | jq -r '.response[].name')
done
-to-enroll mid $CDN "CDN_in_a_Box_Mid" || (while true; do echo "enroll failed."; sleep 3 ; done)
+to-enroll mid $CDN_NAME "CDN_in_a_Box_Mid" || (while true; do echo "enroll failed."; sleep 3 ; done)
while [[ -z "$(testenrolled)" ]]; do
echo "waiting on enrollment"
diff --git a/infrastructure/cdn-in-a-box/traffic_monitor/run.sh b/infrastructure/cdn-in-a-box/traffic_monitor/run.sh
index 81ecbc3..b2ad4dd 100755
--- a/infrastructure/cdn-in-a-box/traffic_monitor/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_monitor/run.sh
@@ -58,9 +58,8 @@ cp $X509_CA_CERT_FULL_CHAIN_FILE /etc/pki/ca-trust/source/anchors
update-ca-trust extract
# Enroll with traffic ops
-CDN=CDN-in-a-Box
TO_URL="https://$TO_FQDN:$TO_PORT"
-to-enroll tm $CDN || (while true; do echo "enroll failed."; sleep 3 ; done)
+to-enroll tm $CDN_NAME || (while true; do echo "enroll failed."; sleep 3 ; done)
# Configure Traffic Monitor
cat > /opt/traffic_monitor/conf/traffic_ops.cfg <<- ENDOFMESSAGE
@@ -69,7 +68,7 @@ cat > /opt/traffic_monitor/conf/traffic_ops.cfg <<- ENDOFMESSAGE
"password": "$TM_PASSWORD",
"url": "$TO_URL",
"insecure": true,
- "cdnName": "$CDN",
+ "cdnName": "$CDN_NAME",
"httpListener": ":$TM_PORT"
}
ENDOFMESSAGE
@@ -100,7 +99,7 @@ export TO_PASSWORD=$TO_ADMIN_PASSWORD
touch /opt/traffic_monitor/var/log/traffic_monitor.log
# Do not start until there is a valid CRConfig available
-until [ $(to-get '/CRConfig-Snapshots/CDN-in-a-Box/CRConfig.json' 2>/dev/null | jq -c -e '.config|length') -gt 0 ] ; do
+until [ $(to-get "/CRConfig-Snapshots/$CDN_NAME/CRConfig.json" 2>/dev/null | jq -c -e '.config|length') -gt 0 ] ; do
echo "Waiting on valid CRConfig...";
sleep 3;
done
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 da8be3c..4ba9de1 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
@@ -82,8 +82,8 @@ while true; do
echo "Verifying that edge was associated to delivery service..."
edge_name="$(to-get 'api/1.3/servers/hostname/edge/details' 2>/dev/null | jq -r -c '.response|.hostName')"
- ds_name="$(to-get 'api/1.3/deliveryservices' 2>/dev/null | jq -r -c '.response[].xmlId')"
- ds_id="$(to-get 'api/1.3/deliveryservices' 2>/dev/null | jq -r -c '.response[].id')"
+ ds_name=$(to-get 'api/1.3/deliveryservices' 2>/dev/null | jq -r -c '.response[] | select(.cdnName == "'"$CDN_NAME"'").xmlId')
+ ds_id=$(to-get 'api/1.3/deliveryservices' 2>/dev/null | jq -r -c '.response[] | select(.cdnName == "'"$CDN_NAME"'").id')
edge_verify=$(to-get "/api/1.2/deliveryservices/$ds_id/servers" | jq -r '.response[]|.hostName')
if [[ $edge_verify = $edge_name ]] ; then
@@ -108,7 +108,7 @@ while [[ "$demo1_sslkeys_verified" = false ]]; do
demo1_csr="$(sed -n -e '/-----BEGIN CERTIFICATE REQUEST-----/,$p' $X509_DEMO1_REQUEST_FILE | jq -s -R '.')"
demo1_key="$(sed -n -e '/-----BEGIN PRIVATE KEY-----/,$p' $X509_DEMO1_KEY_FILE | jq -s -R '.')"
demo1_json_request=$(jq -n \
- --arg cdn "CDN-in-a-Box" \
+ --arg cdn "$CDN_NAME" \
--arg hostname "*.demo1.mycdn.ciab.test" \
--arg dsname "$ds_name" \
--argjson crt "$demo1_crt" \
@@ -131,7 +131,7 @@ while [[ "$demo1_sslkeys_verified" = false ]]; do
if [[ -n "$demo1_json_response" ]] ; then
sleep 2
- cdn_sslkeys_response=$(to-get 'api/1.3/cdns/name/CDN-in-a-Box/sslkeys.json' | jq '.response[] | length')
+ cdn_sslkeys_response=$(to-get "api/1.3/cdns/name/$CDN_NAME/sslkeys.json" | jq '.response[] | length')
echo "cdn_sslkeys_response=$cdn_sslkeys_response"
if [ -n "$cdn_sslkeys_response" ] ; then
@@ -162,11 +162,11 @@ while [[ "$AUTO_SNAPQUEUE_ENABLED" = true ]] ; do
[ -z "$current_servers_json" ] && current_servers_json='[]'
current_servers_list=$(jq -r -n --argjson current "$current_servers_json" '$current|join(",")')
current_servers_total=$(jq -r -n --argjson current "$current_servers_json" '$current|length')
-
+
remain_servers_json=$(jq -n --argjson expected "$expected_servers_json" --argjson current "$current_servers_json" '$expected-$current')
remain_servers_list=$(jq -r -n --argjson remain "$remain_servers_json" '$remain|join(",")')
remain_servers_total=$(jq -r -n --argjson remain "$remain_servers_json" '$remain|length')
-
+
echo "AUTO-SNAPQUEUE - Expected Servers ($expected_servers_total): $expected_servers_list"
echo "AUTO-SNAPQUEUE - Current Servers ($current_servers_total): $current_servers_list"
echo "AUTO-SNAPQUEUE - Remain Servers ($remain_servers_total): $remain_servers_list"
@@ -180,7 +180,7 @@ while [[ "$AUTO_SNAPQUEUE_ENABLED" = true ]] ; do
echo "AUTO-SNAPQUEUE - Do queue updates..."
to-post 'api/1.3/cdns/2/queue_update' '{"action":"queue"}'
break
- fi
+ fi
sleep $AUTO_SNAPQUEUE_POLL_INTERVAL
done
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 79d1a16..e98e085 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh
@@ -170,7 +170,7 @@ to-enroll() {
if [[ ! -z "$2" ]]; then
export MY_CDN="$2"
else
- export MY_CDN="CDN-in-a-Box"
+ export MY_CDN="$CDN_NAME"
fi
if [[ ! -z "$3" ]]; then
export MY_CACHE_GROUP="$3"
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/cdns/010-CDN-in-a-Box.json b/infrastructure/cdn-in-a-box/traffic_ops_data/cdns/010-CDN-in-a-Box.json
index 549df92..c066060 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/cdns/010-CDN-in-a-Box.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/cdns/010-CDN-in-a-Box.json
@@ -1,5 +1,5 @@
{
"dnssecEnabled": false,
"domainName": "mycdn.ciab.test",
- "name": "CDN-in-a-Box"
+ "name": "$CDN_NAME"
}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/010-ciab.json b/infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/010-ciab.json
index 2fa0fb0..5b1b5d7 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/010-ciab.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/deliveryservices/010-ciab.json
@@ -4,7 +4,7 @@
"tenant": "root",
"protocol": 2,
"orgServerFqdn": "http://origin.infra.ciab.test",
- "cdnName": "CDN-in-a-Box",
+ "cdnName": "$CDN_NAME",
"type": "HTTP",
"active": true,
"dscp": 0,
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/010-ATS_EDGE_TIER_CACHE.json b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/010-ATS_EDGE_TIER_CACHE.json
index 7d56915..66a3405 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/010-ATS_EDGE_TIER_CACHE.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/010-ATS_EDGE_TIER_CACHE.json
@@ -1,5 +1,5 @@
{
- "cdnName": "CDN-in-a-Box",
+ "cdnName": "$CDN_NAME",
"description": "Edge Cache - Apache Traffic Server",
"name": "ATS_EDGE_TIER_CACHE",
"routingDisabled": false,
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/020-ATS_MID_TIER_CACHE.json b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/020-ATS_MID_TIER_CACHE.json
index 29f6377..8fd4de2 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/020-ATS_MID_TIER_CACHE.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/020-ATS_MID_TIER_CACHE.json
@@ -1,5 +1,5 @@
{
- "cdnName": "CDN-in-a-Box",
+ "cdnName": "$CDN_NAME",
"description": "Mid Cache - Apache Traffic Server",
"name": "ATS_MID_TIER_CACHE",
"routingDisabled": false,
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/040-CCR_CIAB.json b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/040-CCR_CIAB.json
index 1eb77bc..e4836fc 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/040-CCR_CIAB.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/040-CCR_CIAB.json
@@ -1,5 +1,5 @@
{
- "cdnName": "CDN-in-a-Box",
+ "cdnName": "$CDN_NAME",
"description": "Traffic Router for CDN-In-A-Box",
"name": "CCR_CIAB",
"routingDisabled": false,
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/070-RASCAL-Traffic_Monitor.json b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/070-RASCAL-Traffic_Monitor.json
index 0fc5483..4ab828f 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/070-RASCAL-Traffic_Monitor.json
+++ b/infrastructure/cdn-in-a-box/traffic_ops_data/profiles/070-RASCAL-Traffic_Monitor.json
@@ -1,5 +1,5 @@
{
- "cdnName": "CDN-in-a-Box",
+ "cdnName": "$CDN_NAME",
"description": "Traffic Monitor for CDN-in-a-Box",
"name": "RASCAL-Traffic_Monitor",
"type": "TM_PROFILE",
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env
index 9c20baf..cca9308 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/variables.env
@@ -16,6 +16,7 @@
# under the License.
TLD_DOMAIN=ciab.test
INFRA_SUBDOMAIN=infra
+CDN_NAME=CDN-in-a-Box
CDN_SUBDOMAIN=mycdn
DS_HOSTS=demo1 demo2 demo3
X509_CA_NAME=CIAB-CA