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/07/03 15:19:52 UTC
[trafficcontrol] branch master updated (a5a8685 -> a8c364c)
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 a5a8685 calls dbdump endpoint via TP instead of TO directly (as it should have always been)
new 1be6e7d provide a way to bypass carton
new a8d6761 add trafficmonitor
new f188ca9 trafficmonitor works
new 1e1dcce add init for trafficops
new 4dcedd7 add support for TM in TO
new a8c364c use yum-installed go
The 6 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/docker-compose.yml | 29 ++++++++++
.../traffic_monitor/Dockerfile} | 31 +++++++----
.../traffic_monitor/run.sh | 0
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 26 ++++++---
.../cdn-in-a-box/traffic_ops/Dockerfile-go | 3 +-
.../traffic_ops/Dockerfile-init} | 18 +++----
.../traffic_ops/init/trafficops-init.sh | 61 ++++++++++++++++++++++
.../traffic_ops/init/users/tmonitor.json | 13 +++++
infrastructure/cdn-in-a-box/traffic_ops/run.sh | 1 +
infrastructure/cdn-in-a-box/variables.env | 10 ++--
10 files changed, 157 insertions(+), 35 deletions(-)
copy infrastructure/{docker/traffic_ops/dbInit.sh => cdn-in-a-box/traffic_monitor/Dockerfile} (67%)
mode change 100755 => 100644
copy infrastructure/{docker => cdn-in-a-box}/traffic_monitor/run.sh (100%)
copy infrastructure/{test/integration/docker-integration-tests/single-traffic-ops-query.sh => cdn-in-a-box/traffic_ops/Dockerfile-init} (76%)
mode change 100755 => 100644
create mode 100755 infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
create mode 100644 infrastructure/cdn-in-a-box/traffic_ops/init/users/tmonitor.json
[trafficcontrol] 06/06: use yum-installed go
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 a8c364c6d8acfe256cf8442f858a2ee4a3aa1fdf
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jun 28 13:54:46 2018 -0600
use yum-installed go
---
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 12 ++++++------
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go | 3 +--
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 797b4f6..38f0990 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -40,10 +40,11 @@ RUN yum install -y perl-DBIx-Connector
# Override TRAFFIC_OPS_RPM arg to use a different one using --build-arg TRAFFIC_OPS_RPM=... Can be local file or http://...
ARG TRAFFIC_OPS_RPM=traffic_ops.rpm
ADD $TRAFFIC_OPS_RPM /
-RUN yum install -y /$(basename $TRAFFIC_OPS_RPM)
-
-# once installed, remove rpm to lower image size
-RUN rm /$(basename $TRAFFIC_OPS_RPM) && \
+RUN yum install -y \
+ /$(basename $TRAFFIC_OPS_RPM) \
+ git \
+ golang && \
+ rm /$(basename $TRAFFIC_OPS_RPM) && \
yum clean all
# if local.tar.gz exists, untar to .../app/local to keep carton from reinstalling the Perl universe
@@ -57,8 +58,7 @@ RUN [ -f /tmp/local.tar.gz ] && \
POSTGRES_HOME=/usr/pgsql-9.6 carton && \
rm -rf $HOME/.cpan* /tmp/Dockerfile /tmp/local.tar.gz
-RUN /opt/traffic_ops/install/bin/install_go.sh && \
- /opt/traffic_ops/install/bin/install_goose.sh
+RUN /opt/traffic_ops/install/bin/install_goose.sh
RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
&& export TERM=xterm \
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index 96e73a5..2b838b9 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -24,9 +24,8 @@
FROM centos:7
RUN yum -y install nmap-ncat openssl
-RUN mkdir -p /opt/traffic_ops/app/bin /opt/traffic_ops/app/conf/production
+RUN mkdir -p /opt/traffic_ops/app/bin /opt/traffic_ops/app/conf/production /opt/traffic_ops/app/db
COPY --from=trafficops-perl /opt/traffic_ops/app/bin/traffic_ops_golang /opt/traffic_ops/app/bin/traffic_ops_golang
-COPY --from=trafficops-perl /usr/local/go /usr/local/go
EXPOSE 6443
WORKDIR /opt/traffic_ops/app
[trafficcontrol] 04/06: add init for trafficops
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 1e1dcce602fb7714a306b6a1641a4920742c4046
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Tue Jun 26 13:00:37 2018 -0600
add init for trafficops
---
infrastructure/cdn-in-a-box/docker-compose.yml | 14 +++++
.../{variables.env => traffic_ops/Dockerfile-init} | 33 ++++--------
.../traffic_ops/init/trafficops-init.sh | 60 ++++++++++++++++++++++
.../cdn-in-a-box/traffic_ops/init/users.json | 15 ++++++
infrastructure/cdn-in-a-box/traffic_ops/run.sh | 1 +
infrastructure/cdn-in-a-box/variables.env | 10 ++--
6 files changed, 105 insertions(+), 28 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/docker-compose.yml b/infrastructure/cdn-in-a-box/docker-compose.yml
index edcfdba..1038539 100644
--- a/infrastructure/cdn-in-a-box/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/docker-compose.yml
@@ -98,6 +98,20 @@ services:
- db
- trafficops-perl
+ # trafficops-init is a small container that uses admin credentials to add needed data to trafficops
+ # after it has successfully started
+ trafficops-init:
+ build:
+ context: traffic_ops
+ dockerfile: Dockerfile-init
+ depends_on:
+ - trafficops
+ domainname: cdn.local
+ env_file:
+ - variables.env
+ networks:
+ - tcnet
+
trafficportal:
build:
context: traffic_portal
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-init
similarity index 64%
copy from infrastructure/cdn-in-a-box/variables.env
copy to infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-init
index 2d6a463..a24d78d 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-init
@@ -14,26 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-DOMAIN=cdn.local
-CERT_CITY=Denver
-CERT_COMPANY=NotComcast
-CERT_COUNTRY=US
-CERT_STATE=CO
-DB_NAME=traffic_ops
-DB_ROOT_PASS=twelve
-DB_USER_PASS=twelve
-DB_PORT=5432
-DB_SERVER=db
-DB_USER=traffic_ops
-POSTGRES_PASSWORD=twelve
-PGPASSWORD=twelve
-TM_USER=tmonitor
-TM_PASSWORD=twelve
-TO_ADMIN_PASSWORD=twelve
-TO_ADMIN_USER=admin
-TO_EMAIL=cdnadmin@example.com
-TO_HOST=trafficops
-TO_PORT=6443
-TO_SECRET=blahblah
-TP_EMAIL=none
-TP_HOST=trafficportal
+
+############################################################
+# Dockerfile to initialize Traffic Ops
+############################################################
+
+FROM alpine
+
+RUN apk add --no-cache curl bash
+ADD init /
+CMD /trafficops-init.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh b/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
new file mode 100755
index 0000000..b8825d2
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
@@ -0,0 +1,60 @@
+#!/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.
+
+# Required env vars
+# Check that env vars are set
+set -x
+for v in TO_HOST TO_PORT TO_ADMIN_USER TO_ADMIN_PASSWORD; do
+ [[ -z $(eval echo \$$v) ]] || continue
+ echo "$v is unset"
+ exit 1
+done
+
+TO_URL="https://$TO_HOST:$TO_PORT"
+# wait until the ping endpoint succeeds
+while ! curl -k $TO_URL/api/1.3/ping; do
+ echo waiting for trafficops
+ sleep 3
+done
+
+export COOKIEJAR=/tmp/cookiejar.$(echo $TO_URL $TO_ADMIN_USER | md5sum | awk '{print $1}')
+
+login() {
+ local datadir=$(mktemp -d)
+ local login="$datadir/login.json"
+ local url=$TO_URL/api/1.3/user/login
+ local datatype='Accept: application/json'
+ cat > "$login" <<-CREDS
+ { "u" : "$TO_ADMIN_USER", "p" : "$TO_ADMIN_PASSWORD" }
+CREDS
+
+ res=$(curl -k -H "$datatype" --cookie "$COOKIEJAR" --cookie-jar "$COOKIEJAR" -X POST --data @"$login" "$url")
+ rm -rf "$datadir"
+ if [[ $res != *"Successfully logged in."* ]]; then
+ echo $res
+ return -1
+ fi
+}
+
+login
+
+for f in *.json; do
+ ep=$(basename $f .json)
+ curl -k -s --cookie "$COOKIEJAR" -X POST --data @"$f" "$TO_URL/api/1.3/$ep"
+done
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/init/users.json b/infrastructure/cdn-in-a-box/traffic_ops/init/users.json
new file mode 100644
index 0000000..c3c38e4
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/init/users.json
@@ -0,0 +1,15 @@
+[
+ {
+ "email": "tmonitor@cdn.example.com",
+ "fullName": "Traffic Monitor",
+ "gid": 0,
+ "localPasswd": "jhdslvhdfsuklvfhsuvlhs",
+ "confirmLocalPasswd": "jhdslvhdfsuklvfhsuvlhs",
+ "role": 4,
+ "rolename": "admin",
+ "tenant": "root",
+ "tenantId": 1,
+ "uid": 0,
+ "username": "tmon"
+ }
+]
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index f5fd76d..aa7a832 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -68,6 +68,7 @@ cd $TO_DIR && \
./db/admin.pl --env=production reset && \
./db/admin.pl --env=production seed || echo "db setup failed!"
+# Add admin user -- all other users should be created using API
/adduser.pl $TO_ADMIN_USER $TO_ADMIN_PASSWORD admin | psql -U$DB_USER -h$DB_SERVER $DB_NAME || echo "adding traffic_ops admin user failed!"
cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env
index 2d6a463..7a8d24f 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/variables.env
@@ -14,21 +14,21 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-DOMAIN=cdn.local
CERT_CITY=Denver
CERT_COMPANY=NotComcast
CERT_COUNTRY=US
CERT_STATE=CO
DB_NAME=traffic_ops
-DB_ROOT_PASS=twelve
-DB_USER_PASS=twelve
DB_PORT=5432
+DB_ROOT_PASS=twelve
DB_SERVER=db
DB_USER=traffic_ops
-POSTGRES_PASSWORD=twelve
+DB_USER_PASS=twelve
+DOMAIN=cdn.local
PGPASSWORD=twelve
-TM_USER=tmonitor
+POSTGRES_PASSWORD=twelve
TM_PASSWORD=twelve
+TM_USER=tmonitor
TO_ADMIN_PASSWORD=twelve
TO_ADMIN_USER=admin
TO_EMAIL=cdnadmin@example.com
[trafficcontrol] 01/06: provide a way to bypass carton
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 1be6e7dbd6d40e55fd4a9435e5090264c569c67b
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jun 25 09:24:40 2018 -0600
provide a way to bypass carton
---
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 50ad18d..797b4f6 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -46,7 +46,16 @@ RUN yum install -y /$(basename $TRAFFIC_OPS_RPM)
RUN rm /$(basename $TRAFFIC_OPS_RPM) && \
yum clean all
-RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton && rm -rf $HOME/.cpan*
+# if local.tar.gz exists, untar to .../app/local to keep carton from reinstalling the Perl universe
+# NOTE: copying Dockerfile so the COPY succeeds whether or not local.tar.gz exists
+WORKDIR /opt/traffic_ops/app
+COPY Dockerfile local.tar.gz /tmp/
+
+# run carton whether or not local dir was installed
+RUN [ -f /tmp/local.tar.gz ] && \
+ tar xzvf /tmp/local.tar.gz || true && \
+ POSTGRES_HOME=/usr/pgsql-9.6 carton && \
+ rm -rf $HOME/.cpan* /tmp/Dockerfile /tmp/local.tar.gz
RUN /opt/traffic_ops/install/bin/install_go.sh && \
/opt/traffic_ops/install/bin/install_goose.sh
@@ -54,7 +63,8 @@ RUN /opt/traffic_ops/install/bin/install_go.sh && \
RUN export PERL5LIB=/opt/traffic_ops/app/local/lib/perl5/:/opt/traffic_ops/install/lib/ \
&& export TERM=xterm \
&& export USER=root \
- && /opt/traffic_ops/install/bin/download_web_deps -i
+ && /opt/traffic_ops/install/bin/download_web_deps -i || \
+ true # keep a failure here from failing all..
# \todo add Drive Letters to postinstall input
# RUN sed -i -- 's/"value": "b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"/"value": "0"/g' /opt/traffic_ops/install/data/profiles/profile.trafficserver_edge.traffic_ops
[trafficcontrol] 03/06: trafficmonitor works
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 f188ca91fb52db452821152df22d840c65010e81
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jun 25 13:21:58 2018 -0600
trafficmonitor works
---
infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile b/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
index 04ba0db..ad9c88d 100644
--- a/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
@@ -26,9 +26,11 @@ ARG RPM=traffic_monitor.rpm
ADD $RPM /
RUN yum install -y \
- initscripts \
- jq \
- /$(basename $RPM) && \
+ epel-release \
+ initscripts && \
+ yum install -y \
+ jq \
+ /$(basename $RPM) && \
rm /$(basename $RPM) && \
yum clean all
[trafficcontrol] 02/06: add trafficmonitor
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 a8d6761119d9cf86e8845d445ef97d238a812f91
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jun 25 10:22:26 2018 -0600
add trafficmonitor
---
infrastructure/cdn-in-a-box/docker-compose.yml | 15 ++
.../{variables.env => traffic_monitor/Dockerfile} | 42 +++---
infrastructure/cdn-in-a-box/traffic_monitor/run.sh | 151 +++++++++++++++++++++
infrastructure/cdn-in-a-box/variables.env | 4 +-
4 files changed, 190 insertions(+), 22 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/docker-compose.yml b/infrastructure/cdn-in-a-box/docker-compose.yml
index d7a95a2..edcfdba 100644
--- a/infrastructure/cdn-in-a-box/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/docker-compose.yml
@@ -112,3 +112,18 @@ services:
- tcnet
ports:
- "443:443"
+
+ trafficmonitor:
+ build:
+ context: traffic_monitor
+ args:
+ TRAFFIC_PORTAL_RPM: traffic_monitor.rpm
+ domainname: cdn.local
+ env_file:
+ - variables.env
+ hostname: trafficmonitor
+ image: trafficmonitor
+ networks:
+ - tcnet
+ ports:
+ - "80:80"
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
similarity index 61%
copy from infrastructure/cdn-in-a-box/variables.env
copy to infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
index aa2e5ca..04ba0db 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/traffic_monitor/Dockerfile
@@ -14,24 +14,24 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-DOMAIN=domain
-CERT_CITY=Denver
-CERT_COMPANY=NotComcast
-CERT_COUNTRY=US
-CERT_STATE=CO
-DB_NAME=traffic_ops
-DB_ROOT_PASS=twelve
-DB_USER_PASS=twelve
-DB_PORT=5432
-DB_SERVER=db
-DB_USER=traffic_ops
-POSTGRES_PASSWORD=twelve
-PGPASSWORD=twelve
-TO_ADMIN_PASSWORD=twelve
-TO_ADMIN_USER=admin
-TO_EMAIL=cdnadmin@example.com
-TO_HOST=trafficops
-TO_PORT=6443
-TO_SECRET=blahblah
-TP_EMAIL=none
-TP_HOST=trafficportal
+############################################################
+# Dockerfile to build Traffic Monitor container images
+# Based on CentOS
+############################################################
+
+FROM centos/systemd
+
+# Default values for RPM -- override with `docker build --build-arg RPM=...'
+ARG RPM=traffic_monitor.rpm
+ADD $RPM /
+
+RUN yum install -y \
+ initscripts \
+ jq \
+ /$(basename $RPM) && \
+ rm /$(basename $RPM) && \
+ yum clean all
+
+EXPOSE 80
+ADD run.sh /
+ENTRYPOINT /run.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_monitor/run.sh b/infrastructure/cdn-in-a-box/traffic_monitor/run.sh
new file mode 100755
index 0000000..f936b45
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_monitor/run.sh
@@ -0,0 +1,151 @@
+#!/usr/bin/env 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.
+
+# Script for running the Dockerfile for Traffic Monitor.
+# The Dockerfile sets up a Docker image which can be used for any new container;
+# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container.
+#
+# The following environment variables must be set (ordinarily by `docker run -e` arguments):
+# TRAFFIC_OPS_URI
+# TRAFFIC_OPS_USER
+# TRAFFIC_OPS_PASS
+
+# Check that env vars are set
+envvars=( TRAFFIC_OPS_URI TRAFFIC_OPS_USER TRAFFIC_OPS_PASS )
+for v in $envvars
+do
+ if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
+done
+
+start() {
+ service traffic_monitor start
+ touch /opt/traffic_monitor/var/log/traffic_monitor.log
+ exec tail -f /opt/traffic_monitor/var/log/traffic_monitor.log
+}
+
+init() {
+ [ ! -z $IP ] || IP=$(ip addr | grep 'global' | awk '{print $2}' | cut -f1 -d'/')
+ [ ! -z $DOMAIN ] || DOMAIN="localdomain"
+ [ ! -z $CACHEGROUP ] || CACHEGROUP="mid-east"
+ [ ! -z $TYPE ] || TYPE="RASCAL"
+ [ ! -z $PROFILE ] || PROFILE="RASCAL_CDN1"
+ [ ! -z $PHYS_LOCATION ] || PHYS_LOCATION="plocation-nyc-1"
+ [ ! -z $INTERFACE ] || INTERFACE="eth0"
+ [ ! -z $NETMASK ] || NETMASK="255.255.0.0"
+ [ ! -z $MTU ] || MTU="9000"
+ [ ! -z $PORT ] || PORT="80"
+ [ ! -z $GATEWAY ] || GATEWAY="$(ip route | grep default | awk '{print $3}')"
+ [ ! -z $CDN ] || CDN="cdn"
+ echo "IP: $IP"
+ echo "Domain: $DOMAIN"
+ echo "Cachegroup: $CACHEGROUP"
+ echo "Type: $TYPE"
+ echo "Profile: $PROFILE"
+ echo "PhysLocation: $PHYS_LOCATION"
+ echo "Interface: $INTERFACE"
+ echo "NetMask: $NETMASK"
+ echo "MTU: $MTU"
+ echo "Port: $PORT"
+ echo "Gateway: $GATEWAY"
+ echo "CDN: $CDN"
+ echo "Create Server: $CREATE_TO_SERVER"
+
+ mkdir -p /opt/traffic_monitor/conf
+ cat > /opt/traffic_monitor/conf/traffic_monitor.cfg <<- ENDOFMESSAGE
+ {
+ "cache_health_polling_interval_ms": 6000,
+ "cache_stat_polling_interval_ms": 6000,
+ "monitor_config_polling_interval_ms": 15000,
+ "http_timeout_ms": 2000,
+ "peer_polling_interval_ms": 5000,
+ "peer_optimistic": true,
+ "max_events": 200,
+ "max_stat_history": 5,
+ "max_health_history": 5,
+ "health_flush_interval_ms": 20,
+ "stat_flush_interval_ms": 20,
+ "log_location_event": "/opt/traffic_monitor/var/log/event.log",
+ "log_location_error": "/opt/traffic_monitor/var/log/traffic_monitor.log",
+ "log_location_warning": "/opt/traffic_monitor/var/log/traffic_monitor.log",
+ "log_location_info": "null",
+ "log_location_debug": "null",
+ "serve_read_timeout_ms": 10000,
+ "serve_write_timeout_ms": 10000,
+ "http_poll_no_sleep": false,
+ "static_file_dir": "/opt/traffic_monitor/static/"
+ }
+ENDOFMESSAGE
+
+ cat > /opt/traffic_monitor/conf/traffic_ops.cfg <<- ENDOFMESSAGE
+ {
+ "username": "$TRAFFIC_OPS_USER",
+ "password": "$TRAFFIC_OPS_PASS",
+ "url": "$TRAFFIC_OPS_URI",
+ "insecure": true,
+ "cdnName": "$CDN",
+ "httpListener": ":$PORT"
+ }
+ ENDOFMESSAGE
+
+ TO_COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$TRAFFIC_OPS_USER"'", "p":"'"$TRAFFIC_OPS_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
+ echo "Got Cookie: $TO_COOKIE"
+
+ if [ ! -z "$CREATE_TO_SERVER" ] ; then
+ echo "Creating Server in Traffic Ops!"
+ # curl -v -k -X POST -H "Cookie: mojolicious=$TO_COOKIE" -F "filename=Traffic_Monitor_Dockerfile_profile.traffic_ops" -F "profile_to_import=@/Traffic_Monitor_Dockerfile_profile.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
+
+ CACHEGROUP_ID="$( curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | jq '.response | .[] | select(.name=='"\"$CACHEGROUP\""') | .id')"
+ echo "Got cachegroup ID: $CACHEGROUP_ID"
+
+ SERVER_TYPE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | jq '.response | .[] | select(.name=='"\"$TYPE\""') | .id')"
+ echo "Got server type ID: $SERVER_TYPE_ID"
+
+ SERVER_PROFILE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/profiles.json | jq '.response | .[] | select(.name=='"\"$PROFILE\""') | .id')"
+ echo "Got server profile ID: $SERVER_PROFILE_ID"
+
+ PHYS_LOCATION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/phys_locations.json | jq '.response | .[] | select(.shortName=='"\"$PHYS_LOCATION\""') | .id')"
+ echo "Got phys location ID: $PHYS_LOCATION_ID"
+
+ CDN_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cdns.json | jq '.response | .[] | select(.name=='"\"$CDN\""') | .id')"
+ echo "Got cdn ID: $CDN_ID"
+
+ # Create Server in Traffic Ops
+ curl -v -k -X POST -H "Cookie: mojolicious=$TO_COOKIE" --data-urlencode "host_name=$HOSTNAME" --data-urlencode "domain_name=$DOMAIN" --data-urlencode "interface_name=$INTERFACE" --data-urlencode "ip_address=$IP" --data-urlencode "ip_netmask=$NETMASK" --data-urlencode "ip_gateway=$GATEWAY" --data-urlencode "interface_mtu=$MTU" --data-urlencode "cdn=$CDN_ID" --data-urlencode "cachegroup=$CACHEGROUP_ID" --data-urlencode "phys_location=$PHYS_LOCATION_ID" --data-urlencode "type=$SERVER_TYPE [...]
+
+ # Add Monitor IP to `allow_ip` Parameters
+ IP_ALLOW_PARAMS=$(curl -Lsk --cookie "mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/parameters?name=allow_ip | jq '.response | .[] | .id, .value')
+ while IFS= read -r id; do
+ IFS= read -r ipallow
+ ipallow=$(echo ${ipallow} | sed -e 's/^"//' -e 's/"$//')
+ IPALLOW_UPDATE_JSON="{\"id\": ${id}, \"value\": \"${ipallow},${IP}\"}"
+ curl -Lsk --cookie "mojolicious=$TO_COOKIE" -H 'Content-Type: application/json' -X PUT -d "$IPALLOW_UPDATE_JSON" $TRAFFIC_OPS_URI/api/1.2/parameters/${id}
+ done <<< "$IP_ALLOW_PARAMS"
+ fi
+
+ SERVER_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/servers.json | jq '.response | .[] | select(.hostName=='"\"$HOSTNAME\""') | .id')"
+ echo "Got server ID: $SERVER_ID"
+
+ # Set Server to Online in Traffic Ops
+ curl -v -k -H "Content-Type: application/x-www-form-urlencoded" -H "Cookie: mojolicious=$TO_COOKIE" -X POST --data-urlencode "id=$SERVER_ID" --data-urlencode "status=ONLINE" $TRAFFIC_OPS_URI/server/updatestatus
+
+ echo "INITIALIZED=1" >> /etc/environment
+}
+
+source /etc/environment
+if [ -z "$INITIALIZED" ]; then init; fi
+start
diff --git a/infrastructure/cdn-in-a-box/variables.env b/infrastructure/cdn-in-a-box/variables.env
index aa2e5ca..2d6a463 100644
--- a/infrastructure/cdn-in-a-box/variables.env
+++ b/infrastructure/cdn-in-a-box/variables.env
@@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-DOMAIN=domain
+DOMAIN=cdn.local
CERT_CITY=Denver
CERT_COMPANY=NotComcast
CERT_COUNTRY=US
@@ -27,6 +27,8 @@ DB_SERVER=db
DB_USER=traffic_ops
POSTGRES_PASSWORD=twelve
PGPASSWORD=twelve
+TM_USER=tmonitor
+TM_PASSWORD=twelve
TO_ADMIN_PASSWORD=twelve
TO_ADMIN_USER=admin
TO_EMAIL=cdnadmin@example.com
[trafficcontrol] 05/06: add support for TM in TO
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 4dcedd73228a10c822210d10c78625c95ae8dfe6
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Tue Jun 26 14:02:37 2018 -0600
add support for TM in TO
---
.../cdn-in-a-box/traffic_ops/init/trafficops-init.sh | 5 +++--
infrastructure/cdn-in-a-box/traffic_ops/init/users.json | 15 ---------------
.../cdn-in-a-box/traffic_ops/init/users/tmonitor.json | 13 +++++++++++++
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh b/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
index b8825d2..320fced 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/init/trafficops-init.sh
@@ -54,7 +54,8 @@ CREDS
login
-for f in *.json; do
- ep=$(basename $f .json)
+# load json files using the API
+for f in */*.json; do
+ ep=$(dirname $f)
curl -k -s --cookie "$COOKIEJAR" -X POST --data @"$f" "$TO_URL/api/1.3/$ep"
done
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/init/users.json b/infrastructure/cdn-in-a-box/traffic_ops/init/users.json
deleted file mode 100644
index c3c38e4..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/init/users.json
+++ /dev/null
@@ -1,15 +0,0 @@
-[
- {
- "email": "tmonitor@cdn.example.com",
- "fullName": "Traffic Monitor",
- "gid": 0,
- "localPasswd": "jhdslvhdfsuklvfhsuvlhs",
- "confirmLocalPasswd": "jhdslvhdfsuklvfhsuvlhs",
- "role": 4,
- "rolename": "admin",
- "tenant": "root",
- "tenantId": 1,
- "uid": 0,
- "username": "tmon"
- }
-]
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/init/users/tmonitor.json b/infrastructure/cdn-in-a-box/traffic_ops/init/users/tmonitor.json
new file mode 100644
index 0000000..c9a966d
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/init/users/tmonitor.json
@@ -0,0 +1,13 @@
+{
+ "email": "tmonitor@cdn.example.com",
+ "fullName": "Traffic Monitor",
+ "gid": 0,
+ "localPasswd": "jhdslvhdfsuklvfhsuvlhs",
+ "confirmLocalPasswd": "jhdslvhdfsuklvfhsuvlhs",
+ "role": 4,
+ "rolename": "admin",
+ "tenant": "root",
+ "tenantId": 1,
+ "uid": 0,
+ "username": "tmon"
+}