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/06/14 18:05:13 UTC
[trafficcontrol] 01/20: start with docker
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 a95758d66c4d2f63c20f94be3b3c431fe961a85e
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Tue May 29 23:15:41 2018 +0000
start with docker
---
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 78 ++++++
.../cdn-in-a-box/traffic_ops/Dockerfile_psql | 42 +++
infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh | 30 +++
.../cdn-in-a-box/traffic_ops/docker-compose.yml | 86 ++++++
.../traffic_ops/profile.origin.traffic_ops | 18 ++
infrastructure/cdn-in-a-box/traffic_ops/run.sh | 292 +++++++++++++++++++++
6 files changed, 546 insertions(+)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
new file mode 100644
index 0000000..9c94e24
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -0,0 +1,78 @@
+# 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.
+
+############################################################
+# Dockerfile to build Traffic Ops container images
+# Based on CentOS 7.2
+############################################################
+
+# Example Build and Run:
+# docker network create cdnet
+# docker build --rm --tag traffic_ops:1.7.0 --build-arg=RPM=http://traffic-control-cdn.net/downloads/1.7.0/RELEASE-1.7.0/traffic_ops-1.7.0-3908.5b77f60f.x86_64.rpm traffic_ops
+#
+# docker run --name my-traffic-ops-mysql --hostname my-traffic-ops-mysql --net cdnet --env MYSQL_ROOT_PASSWORD=secretrootpass --detach mysql:5.5
+#
+# docker run --name my-traffic-ops --hostname my-traffic-ops --net cdnet --publish 443:443 --env MYSQL_IP=my-traffic-ops-mysql --env MYSQL_PORT=3306 --env MYSQL_ROOT_PASS=secretrootpass --env MYSQL_TRAFFIC_OPS_PASS=supersecretpassword --env ADMIN_USER=superroot --env ADMIN_PASS=supersecreterpassward --env CERT_COUNTRY=US --env CERT_STATE=Colorado --env CERT_CITY=Denver --env CERT_COMPANY=NotComcast --env TRAFFIC_VAULT_PASS=marginallylesssecret --env DOMAIN=cdnet --detach traffic_ops:1.5.1
+
+FROM centos/systemd
+MAINTAINER Dan Kirkwood
+
+RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
+RUN yum install -y initscripts # needed for service command
+RUN yum install -y epel-release # needed for perl-Crypt-ScryptKDF
+RUN yum install -y perl-Crypt-ScryptKDF
+RUN yum install -y perl cpanminus perl-Test-CPAN-Meta
+RUN cpanm Carton
+RUN yum install -y perl-DBIx-Connector
+
+# Override RPM arg to use a different one using --build-arg RPM=... Can be local file or http://...
+ARG RPM=traffic_ops.rpm
+ADD $RPM /
+RUN yum install -y /$(basename $RPM)
+
+# once installed, remove rpm to lower image size
+RUN rm /$(basename $RPM)
+
+RUN POSTGRES_HOME=/usr/pgsql-9.6 cd /opt/traffic_ops/app && carton
+
+RUN /opt/traffic_ops/install/bin/install_go.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 \
+# && export USER=root \
+# && yes | /opt/traffic_ops/install/bin/build_trafficops_perl_library -i
+
+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
+
+# \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
+# 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_mid.traffic_ops
+
+RUN echo "{\"user\": \"riakuser\",\"password\": \"$TRAFFIC_VAULT_PASS\"}" > /opt/traffic_ops/app/conf/production/riak.conf
+
+RUN cp /opt/traffic_ops/app/bin/traffic_ops_golang{,.new} && mv /opt/traffic_ops/app/bin/traffic_ops_golang{.new,} # fixes an 'Invalid Argument' bug; TODO diagnose, fix, & remove
+
+EXPOSE 443
+WORKDIR /opt/traffic_ops/app
+ENV MOJO_MODE production
+ADD profile.origin.traffic_ops /
+ADD run.sh /
+CMD /run.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql
new file mode 100644
index 0000000..9704aaa
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile_psql
@@ -0,0 +1,42 @@
+# 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.
+
+############################################################
+# Dockerfile to initialized Traffic Ops Database container
+# Based on CentOS 7.2
+############################################################
+
+FROM centos/systemd
+
+RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
+
+RUN yum -y install \
+ postgresql96 \
+ nmap-ncat \
+ cpanminus && \
+ yum clean all
+
+ENV POSTGRES_HOME $POSTGRES_HOME
+ENV PGPASSWORD $PGPASSWORD
+ENV DB_USERNAME $DB_USERNAME
+ENV DB_NAME $DB_NAME
+ENV DB_USER_PASS $DB_USER_PASS
+ENV DB_SERVER $DB_SERVER
+ENV DB_PORT $DB_PORT
+
+ADD dbInit.sh /
+CMD /dbInit.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
new file mode 100755
index 0000000..80156f5
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
@@ -0,0 +1,30 @@
+#!/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 creating the database user account for traffic
+# ops.
+# Used while the Docker Image is initializing itself
+############################################################
+
+while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
+ echo "waiting for $DB_SERVER:$DB_PORT"
+ sleep 3
+done
+psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USERNAME WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
+createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USERNAME
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
new file mode 100644
index 0000000..8451aae
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -0,0 +1,86 @@
+# 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.
+#
+# To use this compose you should first build Traffic Ops and then copy the RPM to :
+#
+# incubator-trafficcontrol/infrastructure/docker/traffic_ops/traffic_ops.rpm
+#
+# You should then just be able to go to the directory incubator-trafficcontrol/infrastructure/docker/traffic_ops/
+# and type 'docker-compose up -d'
+#
+# You should then be able to go to https://localhost and test Traffic Ops or the go api.
+# if you make code changes to the Go proxy then you just need to rebuild it and then
+# restart Traffic Ops:
+#
+# bash -c "clear && docker exec trafficops_to_server_1 /bin/bash /etc/init.d/traffic_ops /bin/bash /etc/init.d/traffic_ops start; sleep 5"
+#
+
+---
+version: '2'
+
+volumes:
+ incubator-trafficcontrol:
+ traffic_ops:
+ conf:
+
+services:
+ db:
+ image: postgres:9.6.6
+ ports:
+ - "5432:5432"
+
+ db_init:
+ environment:
+ POSTGRES_HOME: /usr/pgsql-9.6
+ PGPASSWORD: secretrootpass
+ DB_USERNAME: traffic_ops
+ DB_NAME: traffic_ops
+ DB_USER_PASS: twelve
+ DB_SERVER: db
+ DB_PORT: 5432
+ build:
+ context: .
+ dockerfile: Dockerfile_psql
+ depends_on:
+ - db
+
+ to_server:
+ environment:
+ DB_SERVER: db
+ DB_PORT: 5432
+ DB_NAME: traffic_ops
+ DB_ROOT_PASS: null
+ DB_USER_PASS: twelve
+ DB_USER: traffic_ops
+ ADMIN_USER: superroot
+ ADMIN_PASS: passward
+ CERT_COUNTRY: US
+ CERT_STATE: Colorado
+ CERT_CITY: Denver
+ CERT_COMPANY: NotComcast
+ TRAFFIC_VAULT_PASS: tvsecret
+ DOMAIN: trafficops_default
+ ports:
+ - "443:443"
+ build:
+ context: .
+ args:
+ RPM: traffic_ops.rpm
+ volumes:
+ - ../../../traffic_ops/traffic_ops_golang/traffic_ops_golang:/opt/traffic_ops/app/bin/traffic_ops_golang
+ depends_on:
+ - db_init
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops b/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
new file mode 100644
index 0000000..f655f89
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/profile.origin.traffic_ops
@@ -0,0 +1,18 @@
+{
+ "parameters": [
+ {
+ "config_file": "CRConfig.json",
+ "name": "domain_name",
+ "value": "{{.Domain}}"
+ },
+ {
+ "config_file": "parent.config",
+ "name": "weight",
+ "value": "1.0"
+ }
+ ],
+ "profile": {
+ "description": "Multi site origin profile 1",
+ "name": "ORG1_CDN1"
+ }
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
new file mode 100755
index 0000000..5aed968
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -0,0 +1,292 @@
+#!/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 Ops.
+# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops 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:
+# DB_SERVER
+# DB_PORT
+# DB_ROOT_PASS
+# DB_USER
+# DB_USER_PASS
+# DB_NAME
+# ADMIN_USER
+# ADMIN_PASS
+# CERT_COUNTRY
+# CERT_STATE
+# CERT_CITY
+# CERT_COMPANY
+# DOMAIN
+
+# TODO: Unused -- should be removed? TRAFFIC_VAULT_PASS
+
+# Check that env vars are set
+envvars=( DB_SERVER DB_PORT DB_ROOT_PASS DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
+for v in $envvars
+do
+ if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
+done
+
+start() {
+ service traffic_ops start
+ exec tail -f /var/log/traffic_ops/traffic_ops.log
+}
+
+init() {
+ local postinstall_input_file="postinstall-input.json"
+ cat > "$postinstall_input_file" <<- ENDOFMESSAGE
+{
+ "/opt/traffic_ops/app/conf/production/database.conf":[
+ {
+ "Database type":"Pg",
+ "config_var":"type"
+ },
+ {
+ "Database name":"$DB_NAME",
+ "config_var":"dbname"
+ },
+ {
+ "Database server hostname IP or FQDN":"$DB_SERVER",
+ "config_var":"hostname"
+ },
+ {
+ "Database port number":"$DB_PORT",
+ "config_var":"port"
+ },
+ {
+ "Traffic Ops database user":"$DB_USER",
+ "config_var":"user"
+ },
+ {
+ "Traffic Ops database password":"$DB_USER_PASS",
+ "config_var":"password",
+ "hidden":"1"
+ }
+ ],
+ "/opt/traffic_ops/app/db/dbconf.yml":[
+ {
+ "Database server root (admin) user":"postgres",
+ "config_var":"pgUser"
+ },
+ {
+ "Database server admin password":"$DB_ROOT_PASS",
+ "config_var":"pgPassword",
+ "hidden":"1"
+ },
+ {
+ "Download Maxmind Database?":"yes",
+ "config_var":"maxmind"
+ }
+ ],
+ "/opt/traffic_ops/app/conf/cdn.conf":[
+ {
+ "Generate a new secret?":"yes",
+ "config_var":"genSecret"
+ },
+ {
+ "Port to serve on?": "443",
+ "config_var": "port"
+ },
+ {
+ "Number of workers?": "12",
+ "config_var":"workers"
+ },
+ {
+ "Traffic Ops url?": "https://$HOSTNAME",
+ "config_var": "base_url"
+ },
+ {
+ "Number of secrets to keep?":"1",
+ "config_var":"keepSecrets"
+ }
+ ],
+ "/opt/traffic_ops/app/conf/ldap.conf":[
+ {
+ "Do you want to set up LDAP?":"no",
+ "config_var":"setupLdap"
+ },
+ {
+ "LDAP server hostname":"",
+ "config_var":"host"
+ },
+ {
+ "LDAP Admin DN":"",
+ "config_var":"admin_dn"
+ },
+ {
+ "LDAP Admin Password":"",
+ "config_var":"admin_pass",
+ "hidden":"1"
+ },
+ {
+ "LDAP Search Base":"",
+ "config_var":"search_base"
+ }
+ ],
+ "/opt/traffic_ops/install/data/json/users.json":[
+ {
+ "Administration username for Traffic Ops":"$ADMIN_USER",
+ "config_var":"tmAdminUser"
+ },
+ {
+ "Password for the admin user":"$ADMIN_PASS",
+ "config_var":"tmAdminPw",
+ "hidden":"1"
+ }
+ ],
+ "/opt/traffic_ops/install/data/profiles/":[
+ {
+ "Add custom profiles?":"no",
+ "config_var":"custom_profiles"
+ }
+ ],
+ "/opt/traffic_ops/install/data/json/openssl_configuration.json":[
+ {
+ "Do you want to generate a certificate?":"yes",
+ "config_var":"genCert"
+ },
+ {
+ "Country Name (2 letter code)":"$CERT_COUNTRY",
+ "config_var":"country"
+ },
+ {
+ "State or Province Name (full name)":"$CERT_STATE",
+ "config_var":"state"
+ },
+ {
+ "Locality Name (eg, city)":"$CERT_CITY",
+ "config_var":"locality"
+ },
+ {
+ "Organization Name (eg, company)":"$CERT_COMPANY",
+ "config_var":"company"
+ },
+ {
+ "Organizational Unit Name (eg, section)":"",
+ "config_var":"org_unit"
+ },
+ {
+ "Common Name (eg, your name or your server's hostname)":"$HOSTNAME",
+ "config_var":"common_name"
+ },
+ {
+ "RSA Passphrase":"passphrase",
+ "config_var":"rsaPassword",
+ "hidden":"1"
+ }
+ ],
+ "/opt/traffic_ops/install/data/json/profiles.json":[
+ {
+ "Traffic Ops url":"https://$HOSTNAME",
+ "config_var":"tm.url"
+ },
+ {
+ "Human-readable CDN Name. (No whitespace, please)":"cdn",
+ "config_var":"cdn_name"
+ },
+ {
+ "Health Polling Interval (milliseconds)":"8000",
+ "config_var":"health_polling_int"
+ },
+ {
+ "DNS sub-domain for which your CDN is authoritative":"$HOSTNAME.$DOMAIN",
+ "config_var":"dns_subdomain"
+ },
+ {
+ "TLD SOA admin":"traffic_ops",
+ "config_var":"soa_admin"
+ },
+ {
+ "TrafficServer Drive Prefix":"/dev/ram",
+ "config_var":"driver_prefix"
+ },
+ {
+ "TrafficServer RAM Drive Prefix":"/dev/ram",
+ "config_var":"ram_drive_prefix"
+ },
+ {
+ "TrafficServer RAM Drive Letters (comma separated)":"1",
+ "config_var":"ram_drive_letters"
+ },
+ {
+ "Health Threshold Load Average":"25",
+ "config_var":"health_thresh_load_avg"
+ },
+ {
+ "Health Threshold Available Bandwidth in Kbps":"1750000",
+ "config_var":"health_thresh_kbps"
+ },
+ {
+ "Traffic Server Health Connection Timeout (milliseconds)":"2000",
+ "config_var":"health_connect_timeout"
+ }
+ ]
+}
+ ENDOFMESSAGE
+
+ # TODO determine if term, user are necessary
+ export TERM=xterm && export USER=root && /opt/traffic_ops/install/bin/postinstall -cfile "$postinstall_input_file"
+
+ # Only listen on IPv4, not IPv6, because Docker doesn't provide a v6 interface by default. See http://mojolicious.org/perldoc/Mojo/Server/Daemon#listen
+ sed -i -e 's#https://\[::\]#https://127\.0\.0\.1#' /opt/traffic_ops/app/conf/cdn.conf
+ service traffic_ops restart
+
+ TRAFFIC_OPS_URI="https://localhost"
+
+ TMP_TO_COOKIE="$(curl -v -s -k -X POST --data '{ "u":"'"$ADMIN_USER"'", "p":"'"$ADMIN_PASS"'" }' $TRAFFIC_OPS_URI/api/1.2/user/login 2>&1 | grep 'Set-Cookie' | sed -e 's/.*mojolicious=\(.*\); expires.*/\1/')"
+ echo "Got cookie: $TMP_TO_COOKIE"
+
+ TMP_DOMAIN=$DOMAIN
+ sed -i -- "s/{{.Domain}}/$TMP_DOMAIN/g" /profile.origin.traffic_ops
+ echo "Got domain: $TMP_DOMAIN"
+
+ echo "Importing origin"
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" -F "filename=profile.origin.traffic_ops" -F "profile_to_import=@/profile.origin.traffic_ops" $TRAFFIC_OPS_URI/profile/doImport
+
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "division.name=East" $TRAFFIC_OPS_URI/division/create
+ TMP_DIVISION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/region/add | grep --color=never -oE "<option value=\"[0-9]+\">East</option>" | grep --color=never -oE "[0-9]+")"
+ echo "Got division ID: $TMP_DIVISION_ID"
+
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "region.name=Eastish" --data-urlencode "region.division_id=$TMP_DIVISION_ID" $TRAFFIC_OPS_URI/region/create
+ TMP_REGION_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/regions.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="Eastish"]; print match[0]')"
+ echo "Got region ID: $TMP_REGION_ID"
+
+ TMP_CACHEGROUP_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="MID_LOC"]; print match[0]')"
+ echo "Got cachegroup type ID: $TMP_CACHEGROUP_TYPE"
+
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=mid-east" --data-urlencode "cg_data.short_name=east" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=-1" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+ TMP_CACHEGROUP_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="mid-east"]; print match[0]')"
+ echo "Got cachegroup ID: $TMP_CACHEGROUP_ID"
+
+ TMP_CACHEGROUP_EDGE_TYPE="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/types.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="EDGE_LOC"]; print match[0]')"
+ echo "Got cachegroup type ID: $TMP_CACHEGROUP_EDGE_TYPE"
+
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "cg_data.name=edge-east" --data-urlencode "cg_data.short_name=eeast" --data-urlencode "cg_data.latitude=0" --data-urlencode "cg_data.longitude=0" --data-urlencode "cg_data.parent_cachegroup_id=$TMP_CACHEGROUP_ID" --data-urlencode "cg_data.type=$TMP_CACHEGROUP_EDGE_TYPE" $TRAFFIC_OPS_URI/cachegroup/create
+ TMP_CACHEGROUP_EDGE_ID="$(curl -s -k -X GET -H "Cookie: mojolicious=$TMP_TO_COOKIE" $TRAFFIC_OPS_URI/api/1.2/cachegroups.json | python -c 'import json,sys;obj=json.load(sys.stdin);match=[x["id"] for x in obj["response"] if x["name"]=="edge-east"]; print match[0]')"
+ echo "Got cachegroup edge ID: $TMP_CACHEGROUP_EDGE_ID"
+
+ curl -v -k -X POST -H "Cookie: mojolicious=$TMP_TO_COOKIE" --data-urlencode "location.name=plocation-nyc-1" --data-urlencode "location.short_name=nyc" --data-urlencode "location.address=1 Main Street" --data-urlencode "location.city=nyc" --data-urlencode "location.state=NY" --data-urlencode "location.zip=12345" --data-urlencode "location.poc=" --data-urlencode "location.phone=" --data-urlencode "location.email=no@no.no" --data-urlencode "location.comments=" --data-urlencode "location.re [...]
+
+ echo "INITIALIZED=1" >> /etc/environment
+}
+
+source /etc/environment
+if [ -z "$INITIALIZED" ]; then init; fi
+start
--
To stop receiving notification emails like this one, please contact
dewrich@apache.org.