Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chantra committed Dec 31, 2014
0 parents commit 5fee47f
Show file tree
Hide file tree
Showing 107 changed files with 13,475 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
@@ -0,0 +1,9 @@
[run]
branch = True
omit =
atc/atcd/tests/*
# files generated by thrift
atc/atc_thrift/atc_thrift/*
# chef files
chef/*/*

36 changes: 36 additions & 0 deletions .gitignore
@@ -0,0 +1,36 @@
*.log
*.pot
*.pyc
*.sqlite3
local_settings.py
*.swp
*.swo
external/
collected_static/
.vagrant
.DS_Store
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
build-aux/
config.h
config.h.in
config.status
configure
libtool
m4/
.deps/
.libs/
*.egg-info
*.lo
*.o
*.la
stamp-h1
check_atc
check_atc.trs
*.cap
*.har
pcap2har/
internal
.coverage
2 changes: 2 additions & 0 deletions .pep8
@@ -0,0 +1,2 @@
[pep8]
exclude = migrations, */atc_thrift/atc_thrift
44 changes: 44 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,44 @@
# Contributing to Air Traffic Control
We want to make contributing to this project as easy and transparent as
possible.

## Our Development Process

Air Traffic Control is maintained and developed on github. It is designed to be
easily extensible and contain API that can be reused by external
services/frontends.

Send us your pull requests, and we'd be happy to provide feedback and merge
as appropriate.

## Pull Requests
We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints (e.g., pyflakes, PEP8, etc).
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")
In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Facebook's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues
We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## Coding Style
* PEP-8 compliant
* 80 character line length
* General pyFlakes compliance (e.g., no * imports)

## License
By contributing to Air Traffic Control, you agree that your contributions will be licensed
under its BSD license.
9 changes: 9 additions & 0 deletions CONTRIBUTORS.md
@@ -0,0 +1,9 @@
* Alessandro Salvatori
* Ameesh Goyal
* Andrew Pope
* Anthony Gargiulo
* Chris Vander Mey
* Emmanuel Bretelle
* Gus Luxton
* John Morrow
* Patrick Shuff
30 changes: 30 additions & 0 deletions LICENSE
@@ -0,0 +1,30 @@
BSD License

For Air Traffic Control software

Copyright (c) 2014, Facebook, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 23 additions & 0 deletions PATENTS
@@ -0,0 +1,23 @@
Additional Grant of Patent Rights

"Software" means the Air Traffic Control software distributed by Facebook, Inc.

Facebook hereby grants you a perpetual, worldwide, royalty-free, non-exclusive,
irrevocable (subject to the termination provision below) license under any
rights in any patent claims owned by Facebook, to make, have made, use, sell,
offer to sell, import, and otherwise transfer the Software. For avoidance of
doubt, no license is granted under Facebook’s rights in any patent claims that
are infringed by (i) modifications to the Software made by you or a third party,
or (ii) the Software in combination with any software or other technology
provided by you or a third party.

The license granted hereunder will terminate, automatically and without notice,
for anyone that makes any claim (including by filing any lawsuit, assertion or
other action) alleging (a) direct, indirect, or contributory infringement or
inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or
affiliates, whether or not such claim is related to the Software, (ii) by any
party if such claim arises in whole or in part from any software, product or
service of Facebook or any of its subsidiaries or affiliates, whether or not
such claim is related to the Software, or (iii) by any party relating to the
Software; or (b) that any right in any patent claim of Facebook is invalid or
unenforceable.
4 changes: 4 additions & 0 deletions atc/atc_thrift/README.md
@@ -0,0 +1,4 @@
ATC Thrift
==========

ATC Thrift is `Air Traffic Control` (ATC) Thrift Library
180 changes: 180 additions & 0 deletions atc/atc_thrift/atc_thrift/Atcd-remote
@@ -0,0 +1,180 @@
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
# @generated

import sys
import pprint
from urlparse import urlparse
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.transport import THttpClient
from thrift.protocol import TBinaryProtocol

import Atcd
from ttypes import *

if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ''
print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
print ''
print 'Functions:'
print ' TrafficControlRc startShaping(TrafficControl tc)'
print ' TrafficControlRc stopShaping(TrafficControlledDevice device)'
print ' TrafficControl getCurrentShaping(TrafficControlledDevice device)'
print ' bool isShaped(TrafficControlledDevice device)'
print ' PacketCapture startPacketCapture(TrafficControlledDevice device, i32 timeout)'
print ' PacketCapture stopPacketCapture(TrafficControlledDevice device)'
print ' void stopAllPacketCaptures()'
print ' listPacketCaptures(TrafficControlledDevice device)'
print ' listRunningPacketCaptures()'
print ' i32 getShapedDeviceCount()'
print ' AccessToken requestToken(string ip, i32 duration)'
print ' bool requestRemoteControl(TrafficControlledDevice device, AccessToken accessToken)'
print ' getDevicesControlledBy(string ip)'
print ' getDevicesControlling(string ip)'
print ''
sys.exit(0)

pp = pprint.PrettyPrinter(indent = 2)
host = 'localhost'
port = 9090
uri = ''
framed = False
http = False
argi = 1

if sys.argv[argi] == '-h':
parts = sys.argv[argi+1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
argi += 2

if sys.argv[argi] == '-u':
url = urlparse(sys.argv[argi+1])
parts = url[1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
else:
port = 80
uri = url[2]
if url[4]:
uri += '?%s' % url[4]
http = True
argi += 2

if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
framed = True
argi += 1

cmd = sys.argv[argi]
args = sys.argv[argi+1:]

if http:
transport = THttpClient.THttpClient(host, port, uri)
else:
socket = TSocket.TSocket(host, port)
if framed:
transport = TTransport.TFramedTransport(socket)
else:
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Atcd.Client(protocol)
transport.open()

if cmd == 'startShaping':
if len(args) != 1:
print 'startShaping requires 1 args'
sys.exit(1)
pp.pprint(client.startShaping(eval(args[0]),))

elif cmd == 'stopShaping':
if len(args) != 1:
print 'stopShaping requires 1 args'
sys.exit(1)
pp.pprint(client.stopShaping(eval(args[0]),))

elif cmd == 'getCurrentShaping':
if len(args) != 1:
print 'getCurrentShaping requires 1 args'
sys.exit(1)
pp.pprint(client.getCurrentShaping(eval(args[0]),))

elif cmd == 'isShaped':
if len(args) != 1:
print 'isShaped requires 1 args'
sys.exit(1)
pp.pprint(client.isShaped(eval(args[0]),))

elif cmd == 'startPacketCapture':
if len(args) != 2:
print 'startPacketCapture requires 2 args'
sys.exit(1)
pp.pprint(client.startPacketCapture(eval(args[0]),eval(args[1]),))

elif cmd == 'stopPacketCapture':
if len(args) != 1:
print 'stopPacketCapture requires 1 args'
sys.exit(1)
pp.pprint(client.stopPacketCapture(eval(args[0]),))

elif cmd == 'stopAllPacketCaptures':
if len(args) != 0:
print 'stopAllPacketCaptures requires 0 args'
sys.exit(1)
pp.pprint(client.stopAllPacketCaptures())

elif cmd == 'listPacketCaptures':
if len(args) != 1:
print 'listPacketCaptures requires 1 args'
sys.exit(1)
pp.pprint(client.listPacketCaptures(eval(args[0]),))

elif cmd == 'listRunningPacketCaptures':
if len(args) != 0:
print 'listRunningPacketCaptures requires 0 args'
sys.exit(1)
pp.pprint(client.listRunningPacketCaptures())

elif cmd == 'getShapedDeviceCount':
if len(args) != 0:
print 'getShapedDeviceCount requires 0 args'
sys.exit(1)
pp.pprint(client.getShapedDeviceCount())

elif cmd == 'requestToken':
if len(args) != 2:
print 'requestToken requires 2 args'
sys.exit(1)
pp.pprint(client.requestToken(args[0],eval(args[1]),))

elif cmd == 'requestRemoteControl':
if len(args) != 2:
print 'requestRemoteControl requires 2 args'
sys.exit(1)
pp.pprint(client.requestRemoteControl(eval(args[0]),eval(args[1]),))

elif cmd == 'getDevicesControlledBy':
if len(args) != 1:
print 'getDevicesControlledBy requires 1 args'
sys.exit(1)
pp.pprint(client.getDevicesControlledBy(args[0],))

elif cmd == 'getDevicesControlling':
if len(args) != 1:
print 'getDevicesControlling requires 1 args'
sys.exit(1)
pp.pprint(client.getDevicesControlling(args[0],))

else:
print 'Unrecognized method %s' % cmd
sys.exit(1)

transport.close()

0 comments on commit 5fee47f

Please sign in to comment.