blob: 10897bbc814d69c3a951a04d2d24a5678cb55f3f [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traffic Ops &mdash; Traffic Control 1.1.3 documentation </title>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/theme_overrides.css" type="text/css" />
<link rel="top" title="Traffic Control 1.1.3 documentation" href="../index.html"/>
<link rel="up" title="Developer’s Guide" href="index.html"/>
<link rel="next" title="ASN" href="traffic_ops_rest/asn.html"/>
<link rel="prev" title="Developer’s Guide" href="index.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search">
<a href="/" class="icon icon-home"> Traffic Control
<img src="../_static/tc_logo.png" class="logo" />
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../basics/index.html">CDN Basics</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../basics/content_delivery_networks.html">Content Delivery Networks</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/http_11.html">HTTP 1.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/caching_proxies.html">Caching Proxies</a></li>
<li class="toctree-l2"><a class="reference internal" href="../basics/cache_revalidation.html">Cache Control Headers and Revalidation</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">Traffic Control Overview</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../overview/introduction.html">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_ops.html">Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_router.html">Traffic Router</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_monitor.html">Traffic Monitor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_stats.html">Traffic Stats</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_portal.html">Traffic Portal</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_server.html">Traffic Server</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/traffic_vault.html">Traffic Vault</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../admin/index.html">Administrator&#8217;s Guide</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops_install.html">Installing Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops_config.html">Configuring Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops_using.html">Using Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_ops_extensions.html">Managing Traffic Ops Extensions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_monitor.html">Traffic Monitor Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_router.html">Traffic Router Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_stats.html">Traffic Stats Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_server.html">Traffic Server Administration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/traffic_vault.html">Traffic Vault Administration</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Developer&#8217;s Guide</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="">Traffic Ops</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_router.html">Traffic Router</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_monitor.html">Traffic Monitor</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_stats.html">Traffic Stats</a></li>
<li class="toctree-l2"><a class="reference internal" href="traffic_server.html">Traffic Server</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../faq/general.html">General</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/development.html">Development</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/administration.html">Running a Traffic Control CDN</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
</div>
&nbsp;
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Traffic Control</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Traffic Control 1.1.3</a> &raquo;</li>
<li><a href="index.html">Developer&#8217;s Guide</a> &raquo;</li>
<li>Traffic Ops</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/development/traffic_ops.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="traffic_ops_rest/asn.html" class="btn btn-neutral float-right" title="ASN">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="index.html" class="btn btn-neutral" title="Developer’s Guide"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<div role="main" class="document">
<div class="section" id="traffic-ops">
<h1>Traffic Ops<a class="headerlink" href="#traffic-ops" title="Permalink to this headline"></a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>Traffic Ops uses a MySql or Postgres database to store the configuration information, and the <a class="reference external" href="http://mojolicio.us/">Mojolicious framework</a> to generate the user interface and REST APIs.</p>
</div>
<div class="section" id="software-requirements">
<h2>Software Requirements<a class="headerlink" href="#software-requirements" title="Permalink to this headline"></a></h2>
<p>To work on Traffic Ops you need a *nix (MacOS and Linux are most commonly used) environment that has the following installed:</p>
<ul class="simple">
<li><a class="reference external" href="http://search.cpan.org/~miyagawa/Carton-v1.0.12/lib/Carton.pm">Carton 1.0.12</a></li>
<li><a class="reference external" href="http://golang.org/doc/install">Go 1.4</a></li>
<li>Perl 5.10.1</li>
<li>Git</li>
<li>MySQL 5.1.52</li>
</ul>
</div>
<div class="section" id="traffic-ops-project-tree-overview">
<h2>Traffic Ops Project Tree Overview<a class="headerlink" href="#traffic-ops-project-tree-overview" title="Permalink to this headline"></a></h2>
<p><strong>/opt/traffic_ops/app</strong></p>
<ul class="simple">
<li>bin/ - Directory for scripts, cronjobs, etc.</li>
<li>conf/<ul>
<li>/development - Development (local) specific config files.</li>
<li>/misc - Miscellaneous config files.</li>
<li>/production - Production specific config files.</li>
<li>/test - Test (unit test) specific config files.</li>
</ul>
</li>
<li>db/ - Database related area.<ul>
<li>/migrations - Database Migration files.</li>
</ul>
</li>
<li>lib/<ul>
<li>/API - Mojo Controllers for the /API area of the application.</li>
<li>/Common - Common Code between both the API and UI areas.</li>
<li>/Extensions</li>
<li>Fixtures/ - Test Case fixture data for the ‘to_test’ database.
* /Integration - Integration Tests.</li>
<li>/MojoPlugins - Mojolicious Plugins for Common Controller Code.</li>
<li>Schema/ - Database Schema area.
* /Result - DBIx ORM related files.</li>
<li>/Test - Common Test.</li>
<li>/UI - Mojo Controllers for the Traffic Ops UI itself.</li>
<li>Utils/
* /Helper - Common utilities for the Traffic Ops application.</li>
</ul>
</li>
<li>log/ - Log directory where the development and test files are written by the app.</li>
<li>public/</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>css/ - Stylesheets.</li>
<li>images/ - Images.</li>
<li>js/ - Javascripts</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>script/ - Mojo Bootstrap scripts.</li>
<li>t/ - Unit Tests for the UI.</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>api/ - Unit Tests for the API.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>t_integration/ - High level tests for Integration level testing.</li>
<li>templates/ - Mojo Embedded Perl (.ep) files for the UI.</li>
</ul>
</div>
<div class="section" id="perl-formatting-conventions">
<h2>Perl Formatting Conventions<a class="headerlink" href="#perl-formatting-conventions" title="Permalink to this headline"></a></h2>
<p>Perl tidy is for use in code formatting. See the following config file for formatting conventions.</p>
<div class="highlight-python"><div class="highlight"><pre>edit a file called $HOME/.perltidyrc
l = 156
et=4
t
ci=4
st
se
vt=0
cti=0
pt=1
bt=1
sbt=1
bbt=1
nsfs
nolq
otr
aws
wls=&quot;= + - / * .&quot;
wrs=\&quot;= + - / * .\&quot;
wbb =% + - * / x != == &gt;= &lt;= =~ &lt; &gt; | &amp; **= += *= &amp;= &lt;&lt;= &amp;&amp;= -= /= |= + &gt;&gt;= ||= .= %= ^= x=
</pre></div>
</div>
</div>
<div class="section" id="database-management">
<h2>Database Management<a class="headerlink" href="#database-management" title="Permalink to this headline"></a></h2>
<p>The admin.pl script is for use in managing the Traffic Ops database tables. Below is an example of its usage.</p>
<p><code class="docutils literal"><span class="pre">$</span> <span class="pre">db/admin.pl</span></code></p>
<p>Usage: db/admin.pl [&#8211;env (development|test|production)] [arguments]</p>
<p>Example: <code class="docutils literal"><span class="pre">db/admin.pl</span> <span class="pre">--env=test</span> <span class="pre">reset</span></code></p>
<p>Purpose: This script is used to manage the database. The environments are defined in the dbconf.yml, as well as the database names.</p>
<table border="1" class="docutils">
<colgroup>
<col width="14%" />
<col width="86%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Arguments</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>create</td>
<td>Execute db &#8216;create&#8217; the database for the current environment.</td>
</tr>
<tr class="row-odd"><td>down</td>
<td>Roll back a single migration from the current version.</td>
</tr>
<tr class="row-even"><td>drop</td>
<td>Execute db &#8216;drop&#8217; on the database for the current environment.</td>
</tr>
<tr class="row-odd"><td>redo</td>
<td>Roll back the most recently applied migration, then run it again.</td>
</tr>
<tr class="row-even"><td>reset</td>
<td>Execute db drop, create, load_schema, migrate on the database for
the current environment.</td>
</tr>
<tr class="row-odd"><td>seed</td>
<td>Execute SQL from db/seeds.sql for loading static data.</td>
</tr>
<tr class="row-even"><td>setup</td>
<td>Execute db drop, create, load_schema, migrate, seed on the
database for the current environment.</td>
</tr>
<tr class="row-odd"><td>status</td>
<td>Print the status of all migrations.</td>
</tr>
<tr class="row-even"><td>upgrade</td>
<td>Execute migrate then seed on the database for the current
environment.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="installing-the-developer-environment">
<h2>Installing The Developer Environment<a class="headerlink" href="#installing-the-developer-environment" title="Permalink to this headline"></a></h2>
<p>To install the Traffic Ops Developer environment:</p>
<ol class="arabic simple">
<li>Clone the traffic_control repository from <a class="reference external" href="https://github.com/Comcast/traffic_control">github.com</a>.</li>
<li>Install the local dependencies using Carton (cpanfile).</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>$ cd traffic_ops/app
$ carton
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="3">
<li>Set up a user in MySQL.</li>
</ol>
<blockquote>
<div><p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre>master $ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 305
Server version: 5.6.19 Homebrew
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement.
mysql&gt; create user ‘to_user’@’localhost’;
mysql&gt; grant all on to_development.* to &#39;to_user&#39;@&#39;localhost&#39; identified by &#39;twelve&#39;;
mysql&gt; grant all on to_test.* to &#39;to_user&#39;@&#39;localhost&#39; identified by &#39;twelve&#39;;
mysql&gt; grant all on to_integration.* to &#39;to_user&#39;@&#39;localhost&#39; identified by &#39;twelve&#39;;
</pre></div>
</div>
</div></blockquote>
<ol class="arabic" start="4">
<li><p class="first">Enter <code class="docutils literal"><span class="pre">db/admin.pl</span> <span class="pre">--env=&lt;enviroment</span> <span class="pre">name&gt;</span> <span class="pre">setup</span></code> to set up the traffic_ops database(s).</p>
<ul class="simple">
<li>Unit test database: <code class="docutils literal"><span class="pre">$</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=test</span> <span class="pre">setup</span></code></li>
<li>Development database: <code class="docutils literal"><span class="pre">$</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=development</span> <span class="pre">setup</span></code></li>
<li>Integration database: <code class="docutils literal"><span class="pre">$</span> <span class="pre">db</span> <span class="pre">use</span> <span class="pre">db/admin.pl</span> <span class="pre">--env=integration</span> <span class="pre">setup</span></code></li>
</ul>
<p>The database schema should look like this:</p>
</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>master $ db/admin.pl --env=development setup
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Using database.conf: conf/development/database.conf
Executing &#39;drop database to_development&#39;
Executing &#39;create database to_development&#39;
Creating database tables...
Warning: Using a password on the command line interface can be insecure.
Migrating database...
goose: migrating db environment &#39;development&#39;, current version: 0, target: 20150210100000
OK 20141222103718_extension.sql
OK 20150108100000_add_job_deliveryservice.sql
OK 20150205100000_cg_location.sql
OK 20150209100000_cran_to_asn.sql
OK 20150210100000_ds_keyinfo.sql
Seeding database...
Warning: Using a password on the command line interface can be insecure.
</pre></div>
</div>
</div></blockquote>
<ol class="arabic" start="5">
<li><p class="first">(Optional) To load temporary data into the tables: <code class="docutils literal"><span class="pre">$</span> <span class="pre">perl</span> <span class="pre">bin/db/setup_kabletown.pl</span></code></p>
</li>
<li><p class="first">To start Traffic Ops, enter <code class="docutils literal"><span class="pre">$</span> <span class="pre">bin/start.sh</span></code></p>
<p>The local Traffic Ops instance uses an open source framework called morbo, starting following the start command execution.</p>
<p>Start up success includes the following:</p>
</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>[2015-02-24 10:44:34,991] [INFO] Listening at &quot;http://*:3000&quot;.
Server available at http://127.0.0.1:3000.
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="7">
<li>Using a browser, navigate to the given address: <code class="docutils literal"><span class="pre">http://127.0.0.1:3000</span></code></li>
<li>For the initial log in:</li>
</ol>
<blockquote>
<div><ul class="simple">
<li>User name: admin</li>
<li>Password: password</li>
</ul>
</div></blockquote>
<ol class="arabic simple" start="9">
<li>Change the log in information.</li>
</ol>
</div>
<div class="section" id="test-cases">
<h2>Test Cases<a class="headerlink" href="#test-cases" title="Permalink to this headline"></a></h2>
<p>Use prove to execute test cases. Execute after a carton install:</p>
<ul class="simple">
<li>To run the Unit Tests: <code class="docutils literal"><span class="pre">$</span> <span class="pre">local/bin/prove</span> <span class="pre">-qrp</span>&nbsp; <span class="pre">t/</span></code></li>
<li>To run the Integration Tests: <code class="docutils literal"><span class="pre">$</span> <span class="pre">local/bin/prove</span> <span class="pre">-qrp</span> <span class="pre">t_integration/</span></code></li>
</ul>
<div class="section" id="the-kabletown-cdn-example">
<h3>The KableTown CDN example<a class="headerlink" href="#the-kabletown-cdn-example" title="Permalink to this headline"></a></h3>
<p>The integration tests will load an example CDN with most of the features of Traffic Control being used. This is mostly for testing purposes, but can also be used as an example of how to configure certain features. To load the KableTown CDN example and access it:</p>
<ol class="arabic simple">
<li>Run the integration tests</li>
<li>Start morbo against the integration database: <code class="docutils literal"><span class="pre">export</span> <span class="pre">MOJO_MODE=integration;</span> <span class="pre">./bin/start.sh</span></code></li>
<li>Using a browser, navigate to the given address: <code class="docutils literal"><span class="pre">http://127.0.0.1:3000</span></code></li>
<li>For the initial log in:</li>
</ol>
<blockquote>
<div><ul class="simple">
<li>User name: admin</li>
<li>Password: password</li>
</ul>
</div></blockquote>
</div>
</div>
<div class="section" id="extensions">
<h2>Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h2>
<p>Traffic Ops Extensions are a way to enhance the basic functionality of Traffic Ops in a custom manner. There are three types of extensions:</p>
<ol class="arabic simple">
<li>Check Extensions</li>
</ol>
<blockquote>
<div>These allow you to add custom checks to the &#8220;Health-&gt;Server Checks&#8221; view.</div></blockquote>
<ol class="arabic simple" start="2">
<li>Configuration Extensions</li>
</ol>
<blockquote>
<div>These allow you to add custom configuration file generators.</div></blockquote>
<ol class="arabic simple" start="3">
<li>Data source Extensions</li>
</ol>
<blockquote>
<div>These allow you to add statistic sources for the graph views and APIs.</div></blockquote>
<p>Extensions are managed using the $TO_HOME/bin/extensions command line script. For more information see <a class="reference internal" href="../admin/traffic_ops_extensions.html#admin-to-ext-script"><span>Managing Traffic Ops Extensions</span></a>.</p>
<div class="section" id="check-extensions">
<h3>Check Extensions<a class="headerlink" href="#check-extensions" title="Permalink to this headline"></a></h3>
<p>In other words, check extensions are scripts that, after registering with Traffic Ops, have a column reserved in the &#8220;Health-&gt;Server Checks&#8221; view and that usually run periodically out of cron.</p>
<p>It is the responsibility of the check extension script to iterate over the servers it wants to check and post the results. A check extension can have a column of <img alt="checkmark" src="../_images/good1.png" />&#8216;s and <img alt="X" src="../_images/bad1.png" />&#8216;s (CHECK_EXTENSION_BOOL) or a column that shows a number (CHECK_EXTENSION_NUM). A simple example of a check extension of type CHECK_EXTENSION_NUM that will show 99.33 for all servers of type EDGE is shown below:</p>
<div class="highlight-python"><div class="highlight"><pre>Script here.
</pre></div>
</div>
<p>Check Extension scripts are located in the $TO_HOME/bin/checks directory.</p>
<p>Currently, the following Check Extensions are available and installed by default:</p>
<dl class="docutils">
<dt><strong>Cache Disk Usage Check - CDU</strong></dt>
<dd>This check shows how much of the available total cache disk is in use. A &#8220;warm&#8221; cache should show 100.00.</dd>
<dt><strong>Cache Hit Ratio Check - CHR</strong></dt>
<dd>The cache hit ratio for the cache in the last 15 minutes (the interval is determined by the cron entry).</dd>
<dt><strong>DiffServe CodePoint Check - DSCP</strong></dt>
<dd>Checks if the returning traffic from the cache has the correct DSCP value as assigned in the delivery service. (Some routers will overwrite DSCP)</dd>
<dt><strong>Maximum Transmission Check - MTU</strong></dt>
<dd>Checks if the Traffic Ops host (if that is the one running the check) can send and receive 8192 size packets to the <code class="docutils literal"><span class="pre">ip_address</span></code> of the server in the server table.</dd>
<dt><strong>Operational Readiness Check - ORT</strong></dt>
<dd>See <a class="reference internal" href="../admin/traffic_server.html#reference-traffic-ops-ort"><span>Configuring Traffic Server</span></a> for more information on the ort script. The ORT column shows how many changes the traffic_ops_ort.pl script would apply if it was run. The number in this column should be 0.</dd>
<dt><strong>Ping Check - 10G, ILO, 10G6, FQDN</strong></dt>
<dd><p class="first">The bin/checks/ToPingCheck.pl is to check basic IP connectivity, and in the default setup it checks IP connectivity to the following:</p>
<dl class="last docutils">
<dt>10G</dt>
<dd>Is the <code class="docutils literal"><span class="pre">ip_address</span></code> (the main IPv4 address) from the server table pingable?</dd>
<dt>ILO</dt>
<dd>Is the <code class="docutils literal"><span class="pre">ilo_ip_address</span></code> (the lights-out-mangement IPv4 address) from the server table pingable?</dd>
<dt>10G6</dt>
<dd>Is the <code class="docutils literal"><span class="pre">ip6_address</span></code> (the main IPv6 address) from the server table pingable?</dd>
<dt>FQDN</dt>
<dd>Is the Fully Qualified Domain name (the concatenation of <code class="docutils literal"><span class="pre">host_name</span></code> and <code class="docutils literal"><span class="pre">.</span></code> and <code class="docutils literal"><span class="pre">domain_name</span></code> from the server table) pingable?</dd>
</dl>
</dd>
</dl>
<p><strong>Traffic Router Check - RTR</strong></p>
</div>
<div class="section" id="configuration-extensions">
<h3>Configuration Extensions<a class="headerlink" href="#configuration-extensions" title="Permalink to this headline"></a></h3>
<p>NOTE: Config Extensions are Beta at this time.</p>
</div>
<div class="section" id="data-source-extensions">
<h3>Data source Extensions<a class="headerlink" href="#data-source-extensions" title="Permalink to this headline"></a></h3>
<p>NOTE: Data source Extensions are Beta at this time.</p>
</div>
</div>
<div class="section" id="api">
<h2>API<a class="headerlink" href="#api" title="Permalink to this headline"></a></h2>
<p>The Traffic Ops API provides programmatic access to read and write CDN data providing authorized API consumers with the ability to monitor CDN performance and configure CDN settings and parameters.</p>
<div class="section" id="response-structure">
<h3>Response Structure<a class="headerlink" href="#response-structure" title="Permalink to this headline"></a></h3>
<p>All successful responses have the following structure:</p>
<div class="highlight-python"><div class="highlight"><pre>{
&quot;response&quot;: &lt;JSON object with main response&gt;,
&quot;version&quot;: &quot;1.1&quot;
}
</pre></div>
</div>
<p>To make the documentation easier to read, only the <code class="docutils literal"><span class="pre">&lt;JSON</span> <span class="pre">object</span> <span class="pre">with</span> <span class="pre">main</span> <span class="pre">response&gt;</span></code> is documented, even though the response and version fields are always present.</p>
</div>
<div class="section" id="using-api-endpoints">
<h3>Using API Endpoints<a class="headerlink" href="#using-api-endpoints" title="Permalink to this headline"></a></h3>
<ol class="arabic simple">
<li>Authenticate with your Traffic Portal or Traffic Ops user account credentials.</li>
<li>Upon successful user authentication, note the mojolicious cookie value in the response headers.</li>
<li>Pass the mojolicious cookie value, along with any subsequent calls to an authenticated API endpoint.</li>
</ol>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre>[jvd@laika ~]$ curl -H &quot;Accept: application/json&quot; http://localhost:3000/api/1.1/usage/asns.json
{&quot;version&quot;:&quot;1.1&quot;,&quot;alerts&quot;:[{&quot;level&quot;:&quot;error&quot;,&quot;text&quot;:&quot;Unauthorized, please log in.&quot;}]}
[jvd@laika ~]$
[jvd@laika ~]$ curl -v -H &quot;Accept: application/json&quot; -v -X POST --data &#39;{ &quot;u&quot;:&quot;admin&quot;, &quot;p&quot;:&quot;secret_passwd&quot; }&#39; http://localhost:3000/api/1.1/user/login
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
&gt; POST /api/1.1/user/login HTTP/1.1
&gt; User-Agent: curl/7.37.1
&gt; Host: localhost:3000
&gt; Accept: application/json
&gt; Content-Length: 32
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
* upload completely sent off: 32 out of 32 bytes
&lt; HTTP/1.1 200 OK
&lt; Connection: keep-alive
&lt; Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
&lt; Access-Control-Allow-Origin: http://localhost:8080
&lt; Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
&lt; Set-Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862; expires=Sun, 19 Apr 2015 00:10:01 GMT; path=/; HttpOnly
&lt; Content-Type: application/json
&lt; Date: Sat, 18 Apr 2015 20:10:01 GMT
&lt; Access-Control-Allow-Credentials: true
&lt; Content-Length: 81
&lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate
* Server Mojolicious (Perl) is not blacklisted
&lt; Server: Mojolicious (Perl)
&lt;
* Connection #0 to host localhost left intact
{&quot;alerts&quot;:[{&quot;level&quot;:&quot;success&quot;,&quot;text&quot;:&quot;Successfully logged in.&quot;}],&quot;version&quot;:&quot;1.1&quot;}
[jvd@laika ~]$
[jvd@laika ~]$ curl -H&#39;Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862;&#39; -H &quot;Accept: application/json&quot; http://localhost:3000/api/1.1/asns.json
{&quot;response&quot;:{&quot;asns&quot;:[{&quot;lastUpdated&quot;:&quot;2012-09-17 15:41:22&quot;, .. asn data deleted .. ,&quot;version&quot;:&quot;1.1&quot;}
[jvd@laika ~]$
</pre></div>
</div>
</div>
<div class="section" id="api-errors">
<h3>API Errors<a class="headerlink" href="#api-errors" title="Permalink to this headline"></a></h3>
<p><strong>Response Properties</strong></p>
<table border="1" class="docutils">
<colgroup>
<col width="28%" />
<col width="10%" />
<col width="62%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Parameter</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">alerts</span></code></td>
<td>array</td>
<td>A collection of alert messages.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">&gt;level</span></code></td>
<td>string</td>
<td>Success, info, warning or error.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">&gt;text</span></code></td>
<td>string</td>
<td>Alert message.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">version</span></code></td>
<td>string</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The 3 most common errors returned by Traffic Ops are:</p>
<dl class="docutils">
<dt>401 Unauthorized</dt>
<dd><p class="first">When you don&#8217;t supply the right cookie, this is the response.</p>
<div class="last highlight-python"><div class="highlight"><pre>[jvd@laika ~]$ curl -v -H &quot;Accept: application/json&quot; http://localhost:3000/api/1.1/usage/asns.json
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
&gt; GET /api/1.1/usage/asns.json HTTP/1.1
&gt; User-Agent: curl/7.37.1
&gt; Host: localhost:3000
&gt; Accept: application/json
&gt;
&lt; HTTP/1.1 401 Unauthorized
&lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate
&lt; Content-Length: 84
* Server Mojolicious (Perl) is not blacklisted
&lt; Server: Mojolicious (Perl)
&lt; Connection: keep-alive
&lt; Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
&lt; Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
&lt; Access-Control-Allow-Origin: http://localhost:8080
&lt; Date: Sat, 18 Apr 2015 20:36:12 GMT
&lt; Content-Type: application/json
&lt; Access-Control-Allow-Credentials: true
&lt;
* Connection #0 to host localhost left intact
{&quot;version&quot;:&quot;1.1&quot;,&quot;alerts&quot;:[{&quot;level&quot;:&quot;error&quot;,&quot;text&quot;:&quot;Unauthorized, please log in.&quot;}]}
[jvd@laika ~]$
</pre></div>
</div>
</dd>
<dt>404 Not Found</dt>
<dd><p class="first">When the resource (path) is non existant Traffic Ops returns a 404:</p>
<div class="last highlight-python"><div class="highlight"><pre>[jvd@laika ~]$ curl -v -H&#39;Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862;&#39; -H &quot;Accept: application/json&quot; http://localhost:3000/api/1.1/asnsjj.json
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
&gt; GET /api/1.1/asnsjj.json HTTP/1.1
&gt; User-Agent: curl/7.37.1
&gt; Host: localhost:3000
&gt; Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862;
&gt; Accept: application/json
&gt;
&lt; HTTP/1.1 404 Not Found
* Server Mojolicious (Perl) is not blacklisted
&lt; Server: Mojolicious (Perl)
&lt; Content-Length: 75
&lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate
&lt; Content-Type: application/json
&lt; Date: Sat, 18 Apr 2015 20:37:43 GMT
&lt; Access-Control-Allow-Credentials: true
&lt; Set-Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAzODYzLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--8a5a61b91473bc785d4073fe711de8d2c63f02dd; expires=Sun, 19 Apr 2015 00:37:43 GMT; path=/; HttpOnly
&lt; Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
&lt; Connection: keep-alive
&lt; Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
&lt; Access-Control-Allow-Origin: http://localhost:8080
&lt;
* Connection #0 to host localhost left intact
{&quot;version&quot;:&quot;1.1&quot;,&quot;alerts&quot;:[{&quot;text&quot;:&quot;Resource not found.&quot;,&quot;level&quot;:&quot;error&quot;}]}
[jvd@laika ~]$
</pre></div>
</div>
</dd>
<dt>500 Internal Server Error</dt>
<dd><p class="first">When you are asking for a correct path, but the database doesn&#8217;t match, it returns a 500:</p>
<div class="highlight-python"><div class="highlight"><pre>[jvd@laika ~]$ curl -v -H&#39;Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862;&#39; -H &quot;Accept: application/json&quot; http://localhost:3000/api/1.1/servers/hostname/jj/details.json
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
&gt; GET /api/1.1/servers/hostname/jj/details.json HTTP/1.1
&gt; User-Agent: curl/7.37.1
&gt; Host: localhost:3000
&gt; Cookie: mojolicious=eyJleHBpcmVzIjoxNDI5NDAyMjAxLCJhdXRoX2RhdGEiOiJhZG1pbiJ9--f990d03b7180b1ece97c3bb5ca69803cd6a79862;
&gt; Accept: application/json
&gt;
&lt; HTTP/1.1 500 Internal Server Error
* Server Mojolicious (Perl) is not blacklisted
&lt; Server: Mojolicious (Perl)
&lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate
&lt; Content-Length: 93
&lt; Set-Cookie: mojolicious=eyJhdXRoX2RhdGEiOiJhZG1pbiIsImV4cGlyZXMiOjE0Mjk0MDQzMDZ9--1b08977e91f8f68b0ff5d5e5f6481c76ddfd0853; expires=Sun, 19 Apr 2015 00:45:06 GMT; path=/; HttpOnly
&lt; Content-Type: application/json
&lt; Date: Sat, 18 Apr 2015 20:45:06 GMT
&lt; Access-Control-Allow-Credentials: true
&lt; Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
&lt; Connection: keep-alive
&lt; Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
&lt; Access-Control-Allow-Origin: http://localhost:8080
&lt;
* Connection #0 to host localhost left intact
{&quot;alerts&quot;:[{&quot;level&quot;:&quot;error&quot;,&quot;text&quot;:&quot;An error occurred. Please contact your administrator.&quot;}]}
[jvd@laika ~]$
</pre></div>
</div>
<p class="last">The rest of the API documentation will only document the <code class="docutils literal"><span class="pre">200</span> <span class="pre">OK</span></code> case, where no errors have occured.</p>
</dd>
</dl>
</div>
<div class="section" id="api-1-1-reference">
<h3>API 1.1 Reference<a class="headerlink" href="#api-1-1-reference" title="Permalink to this headline"></a></h3>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/asn.html">ASN</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/cachegroup.html">Cache Group</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/cdn.html">CDN</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/changelog.html">Change Logs</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/deliveryservice.html">Delivery Service</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/hwinfo.html">hwinfo</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/parameter.html">Parameter</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/phys_location.html">Physical Location</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/profile.html">Profiles</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/redis.html">Redis</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/region.html">Regions</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/role.html">Roles</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/server.html">Server</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/static_dns.html">Static DNS Entries</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/status.html">Status</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/system.html">System</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/to_extension.html">TO Extensions</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/type.html">Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="traffic_ops_rest/user.html">Users</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="traffic_ops_rest/asn.html" class="btn btn-neutral float-right" title="ASN">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="index.html" class="btn btn-neutral" title="Developer’s Guide"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.1.3',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>