PlugIt

General


Secció

...


dir
file
Simple Flask server NewProject
start
access
PlugIt
Simple Flask server
(return JSON object)
.
actions.py coxDB = sqlite3.connect('poll.db'...)

@action(route="/", template="home.html")
def home(request)
...

@action(route="/show/<int:pollId>", template="show.html")
def show(request, pollId)
...
(create new ones, maybe organised in directories)

config.py
  • # PlugIt client API (e.g. Django client)
    API_URL='http://127.0.0.1:8000/plugIt/ebuio_api/'
  • # own database
    SQLALCHEMY_URL=''
  • DEBUG=True
  • PI_BASE_URL='/toto_base/'
  • PI_ALLOWED_NETWORKS=['127.0.0.1/32']
  • API_URL=
  • SQLALCHEMY_URL = 'mysql://myuser:mypasswd@localhost/mydatabase'
  • # SQLALCHEMY_URL = 'sqlite:///mydatabase.sq3'
  • DEBUG=True
  • PI_BASE_URL='/toto_base/'
  • PI_ALLOWED_NETWORKS=['0.0.0.0/0']


models.py - from utils import db

server.py

python server.py
utils.py
# Database: This loads the DB differently depending on what we are
# running (plugit/flask server or standalone)
if 'plugit' in sys.modules:
 # For sqlachemy
from plugit import db
else:
# Create db here
# For sqlachemy
#from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask
app = Flask(__name__)
# For sqlachemy
#app.config['SQLALCHEMY_DATABASE_URI'] = config.SQLALCHEMY_URL
#db = SQLAlchemy(app)
(uncomment 3 lines under # For SqlAlchemy)


plugit
__init__.py

(uncomment 3 lines under # For SqlAlchemy)

api.py




params.py




routes.py
def ping
def version
def mail
for ...
  app.add_url_rule(MetaView...)
  app.add_url_rule(TemplateView...) 
  app.add_url_rule(ActionView...)


http://127.0.0.1:5000/toto_base/ping
http://127.0.0.1:5000/toto_base/version
http://127.0.0.1:5000/toto_base/mail
http://127.0.0.1:5000/toto_base/meta/<action>
http://127.0.0.1:5000/toto_base/template/<action>
http://127.0.0.1:5000/toto_base/action/<action>
http://127.0.0.1:5000/toto_base/media/<action>
http://127.0.0.1:5000/toto_base/meta/
http://127.0.0.1:5000/toto_base/template/
http://127.0.0.1:5000/toto_base/action/
views.py
class MetaView
class TemplateView
class ActionView


utils.py



media




templates




Simple Flask server (ProxyMode)
(return HTML)






Simple Django client
.
manage.py


python manage.py runserver
app
settings.py
  • PIAPI_STANDALONE=True
  • # PlugIt server
    PIAPI_STANDALONE_URI='http://127.0.0.1:5000/toto_base'
  • PIAPI_BASEURI='/plugIt/'
  • PIAPI_USERDATA=['username','id',...]
  • # orga mode
    PIAPI_ORGAMODE=True
  • PIAPI_PROXYMODE=False
  • # False: fake users. True: from database
    PIAPI_REALUSERS=False



urls.py




wsgi.py




plugIt plugIt.py
class PlugIt():
    def __init__
        """Instance a new plugIt instance. Need the base URI of the server"""
        self.baseURI = baseURI
    def doQuery(self, url, method='GET', getParmeters=None, postParameters=None, files=None, extraHeaders={}, session={}):

    def ping
    def checkVersion
    def getMedia(self, uri):
        r = self.doQuery('media/' + uri)
    def getMeta
    def getTemplate
    def doAction(self, uri, method='GET', getParmeters=None, postParameters=None, files=None, extraHeaders={}, proxyMode=False, session={}):
        base_url = 'action/' if not proxyMode else ''
        r = self.doQuery(base_url + uri, method=method, getParmeters=getParmeters, postParameters=postParameters, files=files, extraHeaders=extraHeaders, session=session)




models.py
(empty)



urls.py
url(r'^media/...
url(r'^ebuio_setUser$', 'setUser'),
url(r'^ebuio_setOrga$', 'setOrga'),

url(r'^ebuio_api/$','api_home')
url(r'^ebuio_api/user/...', 'api_user'),
url(r'^ebuio_api/orgas/$', 'api_orgas'),
url(r'^ebuio_api/orga/...', 'api_orga'),
url(r'^ebuio_api/members/$', 'api_get_project_members'),
url(r'^ebuio_api/mail/$', 'api_send_mail'),

url(r'^(?P<query>.*)$', 'main'),

...


http://127.0.0.1:8000/
http://127.0.0.1:8000/plugIt/ebuio_api/
http://127.0.0.1:8000/plugIt/ebuio_api/user/...
http://127.0.0.1:8000/plugIt/ebuio_api/orgas/
http://127.0.0.1:8000/plugIt/ebuio_api/orga/...
http://127.0.0.1:8000/plugIt/ebuio_api/members/
http://127.0.0.1:8000/plugIt/ebuio_api/mail/
views.py
# Standalone mode: Load the main plugit interface
if settings.PIAPI_STANDALONE:
    plugIt = PlugIt(settings.PIAPI_STANDALONE_URI)
    baseURI = settings.PIAPI_BASEURI

def getPlugItObject
def generate_user
dropdown (base.html)
generate_user / main (views.py)
etiqueta
mode
username
ebuio_member
ebuio_admin
ebuio_orga_member ebuio_orga_admin



user.is_staff
user.is_superuser
user.isMember
user.isOwner
Anonymous user
ano
AnonymousUser()
False
False
False
False
Logged in user
log
Logged
False False False False
Project member
mem
Member
True
False
True False
Admin user
adm
Admin
True True True True

class SimpleOrga
class SimpleUser
def gen404
def gen403
def get_cache_key
def check_rights
def find_in_cache
def build_base_parameters
def build_user_requested_parameters
def build_orga_parameters
def build_parameters
def build_extra_headers
def handle_special_cases
def build_final_response
def render_data
def cache_if_needed
def build_context
def get_template
def get_current_orga
def update_session
def get_current_session
def main(request, query, hproPk=None):
    if not settings.PIAPI_STANDALONE:
        (plugIt, baseURI, hproject) = getPlugItObject(hproPk)
    else:
        global plugIt, baseURI
    ...
    # Check access rights
    error = check_rights(request, meta)
    ...
    # Do the action
    (data, session_to_set) = plugIt.doAction(query, request.method, getParameters, postParameters, files, things_to_add, proxyMode=proxyMode, session=current_session)
    ...
    # Get template
    (templateContent, templateError) = get_template(request, query, meta, proxyMode)
    ...
    # Return the final response
    return build_final_response(request, meta, result, hproject, proxyMode, context)

def media
def setUser(...)
def setOrga(...)
def set_api_key
    if settings.PIAPI_STANDALONE:
        return True
    ...
def home(...)

def api_home(request, key=None,hproPk=None)
def api_user(...)
def api_orga(...)
orga
pk
name
codops
-1
EBU

-2
RTS

-3
BBC

-4
CNN


def api_get_project_members(...)
def api_send_mail(...)
...










columns
radiodns-plugit
RadioDns-PlugIt
.
__init__.py
#if config.SENTRY_DSN:
if hasattr(config, 'SENTRY_DSN'):



actions.py



alembic.ini




config.py.dist
develop
new-dnsstructure
API_URL = ""
SQLALCHEMY_URL = ""
API_SECRET = ""

DEBUG = True

PI_BASE_URL = '/'
PI_ALLOWED_NETWORKS = ['127.0.0.1/32']

# Flask Log
FLASK_LOG_PATH = '/home/ubuntu/logs/flask.log'
FLASK_LOG_SIZE = 1024 * 1024 # 1MB

SENTRY_DSN = ''
DEBUG = True

# the URL to call the PlugIt client ("https://github.com/ebu/PlugIt/tree/master/Simple Django client"):
# e.g. Django client: 'http://127.0.0.1:8000/plugIt/ebuio_api/'
API_URL = '{{PLUGIT_API_URL}}'

# the connection string to MySQL for SqlAlchemy
# e.g.: 'mysql://plugit_user:plugit_password@localhost/plugit_db'
SQLALCHEMY_URL = '{{SQLALCHEMY_URL}}'

# a secret, shared with the RadioVisServer to access special calls:
# e.g.: 'my_api_secret'
API_SECRET = '{{API_SECRET}}'

# Amazon AWS
AWS_ACCESS_KEY = '{{AWS_ACCESS_KEY}}'
AWS_SECRET_KEY = '{{AWS_SECRET_KEY}}'

# Domain Name base for all services
# e.g.: 'radio.mydomain.org.'
DOMAIN = 'radio.ebu.io.'

# XSI
XSISERVING_ENABLED = True
# e.g.: 'epg.radio.local.mydomain.org':
XSISERVING_DOMAIN = 'epg.radio.local.ebu.io'


# Default Service URLs for RadioDNS Services
# e.g.: 'vis.radio.mydomain.org:61613':
RADIOVIS_SERVICE_DEFAULT = 'vis.radio.ebu.io:61613'
# e.g.: 'epg.radio.mydomain.org:80':
RADIOEPG_SERVICE_DEFAULT = 'epg.radio.ebu.io:80'
# e.g.: 'tag.radio.mydomain.org:80':
RADIOTAG_SERVICE_DEFAULT = 'tag.radio.ebu.io:80'
RADIOTAG_ENABLED = False
RADIODNS_REQUIRED_IMAGESIZES = [(32, 32), (112, 32), (128, 128), (320, 240), (600, 600)]

# the base url for the PlugIt API:
# e.g.: '/toto_base/'
# e.g.: '/'
PI_BASE_URL = '{{PI_BASE_URL}}'
# clients allowed to use the PlugIt API
# e.g.: ['0.0.0.0/0']
PI_ALLOWED_NETWORKS = {{PI_ALLOWED_NETWORKS}}

# Flask Log
FLASK_LOG_PATH = '/home/ubuntu/logs/flask.log'
FLASK_LOG_SIZE = 1024 * 1024 # 1MB

# Sentry
# e.g.: 'http://public:secret@example.com/1'
SENTRY_DSN = '{{SENTRY_DSN}}'

# AWS Route53
RADIOVIS_DNS = 'radiovis_dns'
RADIOEPG_DNS = 'radioepg_dns'
RADIOTAG_DNS = 'radiotag_dns'
RADIOVIS_A = 'radiovis_a'
RADIOEPG_A = 'radioepg_a'
RADIOTAG_A = 'radiotag_a'

DEBUG = True

# the URL to call the PlugIt client ("https://github.com/ebu/PlugIt/tree/master/Simple Django client"):
# e.g. Django client: 'http://127.0.0.1:8000/plugIt/ebuio_api/'
API_URL = '{{PLUGIT_API_URL}}'

# the connection string to MySQL for SqlAlchemy
# e.g.: 'mysql://plugit_user:plugit_password@localhost/plugit_db'
SQLALCHEMY_URL = '{{SQLALCHEMY_URL}}'

# a secret, shared with the RadioVisServer to access special calls:
# e.g.: 'my_api_secret'
API_SECRET = '{{API_SECRET}}'

# the base url for the PlugIt API:
# e.g.: '/toto_base/'
# e.g.: '/'
PI_BASE_URL = '{{PI_BASE_URL}}'
# clients allowed to use the PlugIt API
# e.g.: ['0.0.0.0/0']
PI_ALLOWED_NETWORKS = {{PI_ALLOWED_NETWORKS}}

# Flask Log
FLASK_LOG_PATH = '/home/ubuntu/logs/flask.log'
FLASK_LOG_SIZE = 1024 * 1024 # 1MB

# Sentry
# e.g.: 'http://public:secret@example.com/1'
SENTRY_DSN = '{{SENTRY_DSN}}'






config.py
  • directly from config.py.dist
  • or indirectly from Deployment/plugit/configFiles/config.py



models.py def to_json
class ServiceProvider
class Station
class Ecc
class Channel
class Picture
class LogEntry
class Show
class Schedule
class GenericServiceFollowingEntry
class PictureForEPG
class LogoImage



server.py




utils.py




wsgi.py




channels actions.py @action(route="/channels/", template="channels/home.html")
@only_orga_member_user()
def channels_home(request):
    plugitapi = PlugItAPI(config.API_URL)
    orga = plugitapi.get_orga(request.args.get('ebuio_orgapk'))

...
@action(route="/channels/edit/<id>", template="channels/edit.html", methods=['POST', 'GET'])
@only_orga_admin_user()
def channels_edit(request, id):
...


    #if orga.codops:
    if hasattr(orga,'codops'):

http://radiodns.nuvolet.eu/toto_base/action/channels/?ebuio_orgapk=0
http://ebu.io/radiodns/channels/
http://ebu.io/radiodns/channels/edit/<id>
http://ebu.io/radiodns/channels/delete/<id>
http://ebu.io/radiodns/channels/check/<id>
http://ebu.io/radiodns/channels/export/
  • Station
  • Name
  • RadioDNS entry
  • DNS Authoritative FQDN
  • VIS server
  • EPG server
main
actions.py

http://ebu.io/radiodns/
radioepg actions.py

http://ebu.io/radiodns/radioepg/shows/



http://ebu.io/radiodns/radioepg/schedule/


http://ebu.io/radiodns/radioepg/servicefollowing/


http://ebu.io/radiodns/radioepg/gallery/


http://ebu.io/radiodns/radioepg/logos/
radiovis
actions.py
@action(route="/radiovis/gallery/", template="radiovis/gallery/home.html")
@only_orga_member_user()
def radiovis_gallery_home(request):

http://ebu.io/radiodns/radiovis/gallery/
  • Name
  • Text
  • URL
  • Image
@action(route="/radiovis/channels/", template="radiovis/channels/home.html")
@only_orga_member_user()
def radiovis_channels_home(request):
...

http://ebu.io/radiodns/radiovis/channels/
  • Station
  • Name
  • Topic
  • Default value
@action(route="/radiovis/api/<secret>/get_channels")
@only_orga_admin_user() # To prevent call from IO
@json_only()
def radiovis_api_get_channels(request, secret):

http://ebu.io/radiodns/radiovis/api/<secret>/get_channels?station_id=... (from RadioVisServer/radiodns.py)
serviceprovider actions.py



stations
actions.py
...
    #if orga.codops:
    if hasattr(orga,'codops'):

http://ebu.io/radiodns/stations/
  • Name
  • Stomp username
  • Stomp password
  • Allowed IPs
serviceprovider
actions.py



system
actions.py



aws
awsutils.py




plugit
api.py
class PlugItAPI(object):
    def __init__(self, url):
        """Create a new PlugItAPI instance, need url as the main endpoint for the API"""
        self.url = url

    def get_orga(self, orgaPk):




params.py
 



routes.py




views.py




utils.py




media





templates
main/home.html
    {% block pageheader %}
    {% plugitInclude "menubar" %}




...




RadioVisServer

.
config.py.dist
develop
new-dnsstructure
import logging

# General
LOG_LEVEL = logging.DEBUG
STOMP_IP = '0.0.0.0'
STOMP_PORT = 61613

# PlugIt server (url of PlugIt server api for RadioVis)
# e.g.: 'http://127.0.0.1:5000/toto_base/action/radiovis/api/my_api_secret/'
# e.g.: 'http://127.0.0.1:5000{{RADIODNS_API_BASE_URL}}action/radiovis/api/{{RADIODNS_API_SECRET}}/'
API_URL = {{RADIOVIS_API_URL}}
# RabbitMQ
RABBITMQ_LOOPBACK = False # If set to true, don't use rabbitmq but just send messages back !
# e.g.: RABBITMQ_HOST = '127.0.0.1'
RABBITMQ_HOST = {{RADIOVIS_RABBITMQ_HOST}}
RABBITMQ_PORT = 5672
RABBITMQ_USER = 'rabbitmq_user'
RABBITMQ_PASSWORD = 'rabbitmq_password'
RABBITMQ_VHOST = '/'
RABBITMQ_DEBUG = True
RABBITMQ_EXCHANGE = 'amq.fanout'

#http://beaker.readthedocs.org/en/latest/configuration.html#configuration
CACHE_OPTS = {
'cache.type': 'memory',
}

# Fallback server
FB_CHANNEL_CACHE = 60 # 1 minute
FB_QUEUE = 'fallbacklogs'
FB_FALLBACK_CHECK = 15 # The time when we check for timeouted channels. (Each FB_FALLBACK_CHECK seconds)
FB_FALLBACK_TIME = 60 # The time before a channel is consided dead
FB_IMAGE_LOCATIONS = '' # Should be the public url of plugit
FB_LOGS_MAX_AGE = 60 * 60 * 24 # Cleanup logs if > 24h
FB_LOGS_CLEANUP = 60 * 60 # Cleanup logs each 1h

# Testing
TEST_TOPICS = ['/topic/id/tests._ebu.nowhere/topic1/', '/topic/id/tests._ebu.nowhere/topic2/']
TEST_ECC = {'ch': '4e1'}
TEST_ECC_TOPIC_GCC = '/topic/fm/4e1/ffff/99999/'
TEST_ECC_TOPIC_CC = '/topic/fm/ch/ffff/99999/'
TEST_WATCHDOG_TOPIC = [('/topic/id/tests._ebu.nowhere/topicwatchdogeg/',1), ('/topic/id/tests._ebu.nowhere/topicwatchdogegnoinfo/',2)]
TEST_FB_FALLBACK_CHECK = 2
TEST_FB_FALLBACK_TIME = 10
TEST_FB_QUEUE = FB_QUEUE + '_testMode'
TEST_FB_LOGS_CLEANUP = 5
TEST_CHANNEL_DEFAULT = {'id': '1', 'orga': '', 'name': 'test', 'filename': 'testfilename', 'radiotext': 'testdefaultext', 'radiolink': 'testdefaultlink', 'clean_filename': 'testfilename'}

STATS_GAUGE_APPNAME = 'radiovis.app'
STATS_GAUGE_NB_CLIENTS = 'nb_tcp_cox'
STATS_COUNTER_NBMESSAGE_SENT = 'radiovis.app.msg_sent'
STATS_COUNTER_NBMESSAGE_RECV = 'radiovis.app.msg_recv'
STATS_COUNTER_NBMESSAGE_SEND_BY_WATCHDOG = 'radiovis.app.msg_watchdog'






config.py
  • directly taken from config.py.dist
  • or indirectly taken from Deployment/radiovis/configFiles/config.py





supervisord-radiovis.conf





rabbitmq.py





radiodns.py
def do_query
  return requests.get(config.API_URL + url, data=params).json()

def get_channels()
  result = self.do_query('get_channels', {'station_id': station_id})




server.py





stomp.py
allowed_channels = radioDns.get_channels(self.station_id)



Deployment

config.py.dist.py
develop
new-dnsstructure
SSH_USER = ''
SSH_PRIVKEY = ''
USE_SSH_CONFIG = False
RABBITMQ_USER = ''
RABBITMQ_PASS = ''
RADIOVIS_RABBITMQ_HOST = ''
RADIOVIS_RABBITMQ_QUEUE = ''
RADIOVIS_API_URL = ''
RADIOVIS_LOG_LEVEL = ''
GIT_REPO = ''
GIT_BRANCH = ''
GIT_PRIV_KEY = ''
GIT_RADIOVISDIR = ''
CONFIG_DIR = ''
MYSQL_DATABSE = ''
MYSQL_PASSWORD = ''
PLUGIT_PUBLIC_ACCESS = ''
AWS_VM_TAG = 'io-radiodns'
AWS_REGION = ''
AWS_ACCESS_KEY = ''
AWS_SECRET_KEY = ''
SSH_USER = ''
SSH_PRIVKEY = ''
USE_SSH_CONFIG = False
RABBITMQ_USER = ''
RABBITMQ_PASS = ''
RADIOVIS_RABBITMQ_HOST = ''
RADIOVIS_RABBITMQ_QUEUE = ''
RADIOVIS_API_URL = ''
RADIOVIS_LOG_LEVEL = ''
GIT_REPO = ''
GIT_BRANCH = ''
GIT_PRIV_KEY = ''
GIT_RADIOVISDIR = ''
CONFIG_DIR = ''
MYSQL_DATABASE = ''
MYSQL_PASSWORD = ''
PLUGIT_PUBLIC_ACCESS = ''
AWS_VM_TAG = 'io-radiodns'
AWS_REGION = ''
AWS_ACCESS_KEY = ''
AWS_SECRET_KEY = ''
## 1) Deployment
CONFIG_DIR='configFiles'


## 2) SSH (AWS) (used by fabfile.py)
SSH_USER='ubuntu'
SSH_PRIVKEY='/home/user/.ssh/keys/toto.pem'
USE_SSH_CONFIG = False
AWS_VM_TAG = 'io-radiodns'
RADIOVIS_AWS_TAG = 'io-radiovis'
AWS_REGION = 'eu-west-1'
# with permissions to get_list
AWS_ACCESS_KEY = '...'
AWS_SECRET_KEY = '...'


## 3) RadioDns-PlugIt (to complete RadioDns-Plugit/config.py)

# 3.1) RadioDns Git (used by "fab plugit_server.git_init")
GIT_PRIV_KEY = '...'
GIT_BRANCH = 'develop'
GIT_REPO = 'https://github.com/ebu/radiodns-plugit.git'
GIT_PLUGITDIR = 'RadioDns-PlugIt/'

# 3.2) PlugIt (used by "fab plugit_server.configure")
#PLUGIT_PUBLIC_ACCESS
PLUGIT_API_URL = 'http://127.0.0.1:8000/plugIt/ebuio_api/'
SQLALCHEMY_URL = 'mysql://plugit_user:plugit_password@localhost/plugit_db'
API_SECRET = 'my_api_secret'
API_BASE_URL = '/toto_base/'
API_ALLOWD_IPS = ['0.0.0.0/0']
#RADIODNS_SENTRY_DSN = 'http://public:secret@example.com/1'
#RADIODNS_AWS_ACCESS_KEY = '...'
#RADIODNS_AWS_SECRET_KEY = '...'

# 3.3) MySQL (used by "fab plugit_server.create_database", "fab plugit_server.create_user")
MYSQL_DATABSE = 'plugit_db'
MYSQL_USER = 'plugit_user'
MYSQL_PASSWORD = 'plugit_password'

# 3.4) Alembic (fab plugit_server.update_database)
PI_ALLOWED_NETWORKS = ['0.0.0.0/0']

# 3.5) Sentry
SENTRY_DSN = 'http://public:secret@example.com/1'


## 4) RadioVisServer (to complete RadioVisServer/config.py)

# 4.1) RabbitMQ (fab rabbitmq_server.setup_auth)
RABBITMQ_USER = 'rabbitmq_user'
RABBITMQ_PASS = 'rabbitmq_password'

# 4.2) RadioVis Git (fab radiovis_server.git_init)
GIT_RADIOVISDIR = 'RadioVisServer'

# 4.3) RadioVis
RADIOVIS_RABBITMQ_HOST = '127.0.0.1'
RADIOVIS_RABBITMQ_QUEUE = ''
RADIOVIS_API_URL = 'http://127.0.0.1:5000{{RADIODNS_API_BASE_URL}}action/radiovis/api/{{RADIODNS_API_SECRET}}/'
RADIOVIS_LOG_LEVEL = ''
## 1) Deployment
CONFIG_DIR=''


## 2) SSH (AWS) (used by fabfile.py)
SSH_USER='ubuntu'
#SSH_PRIVKEY='/home/user/.ssh/keys/toto.pem'
SSH_CERT='/home/user/.ssh/keys/toto.pem'
USE_SSH_CONFIG = False
RADIODNS_AWS_TAG = 'io-radiodns'
RADIOVIS_AWS_TAG = 'io-radiovis'
AWS_REGION = 'eu-west-1'
# with permissions to get_list
AWS_ACCESS_KEY = '...'
AWS_SECRET_KEY = '...'


## 3) RadioDns-PlugIt (to complete RadioDns-Plugit/config.py)

# 3.1) RadioDns Git (used by "fab plugit_server.git_init")
GIT_PRIV_KEY = '...'
RADIODNS_BRANCH = 'new-dnsstructure'
RADIODNS_REPO = 'https://github.com/ebu/radiodns-plugit.git'
RADIODNS_FOLDER = 'RadioDns-PlugIt'

# 3.2) PlugIt (used by "fab plugit_server.configure")
#PLUGIT_PUBLIC_ACCESS
RADIODNS_PLUGIT_API_URL = 'http://127.0.0.1:8000/plugIt/ebuio_api/'
RADIODNS_SQLALCHEMY_URL = 'mysql://plugit_user:plugit_password@localhost/plugit_db'
RADIODNS_API_SECRET = 'my_api_secret'
RADIODNS_API_BASE_URL = '/toto_base/'
RADIODNS_API_ALLOWED_IPS = ['0.0.0.0/0']
RADIODNS_SENTRY_DSN = 'http://public:secret@example.com/1'
RADIODNS_AWS_ACCESS_KEY = '...'
RADIODNS_AWS_SECRET_KEY = '...'

# 3.3) MySQL (used by "fab plugit_server.create_database", "fab plugit_server.create_user")
MYSQL_DATABASE = 'plugit_db'
MYSQL_USER = 'plugit_user'
MYSQL_PASSWORD = 'plugit_password'

# 3.4) Sentry
SENTRY_DSN = 'http://public:secret@example.com/1'


## 4) RadioVisServer (to complete RadioVisServer/config.py)

# 4.1) RabbitMQ (fab rabbitmq_server.setup_auth)
RABBITMQ_USER = 'rabbitmq_user'
RABBITMQ_PASS = 'rabbitmq_password'

# 4.2) RadioVis Git (fab radiovis_server.git_init)
GIT_REPO = 'https://github.com/ebu/radiodns-plugit.git'
GIT_RADIOVISDIR = 'RadioVisServer'
GIT_BRANCH = 'new-dnsstructure'

# 4.3) RadioVis
RADIOVIS_RABBITMQ_HOST = '127.0.0.1'
RADIOVIS_RABBITMQ_QUEUE = ''
RADIOVIS_API_URL = 'http://127.0.0.1:5000{{RADIODNS_API_BASE_URL}}action/radiovis/api/{{RADIODNS_API_SECRET}}/'
RADIOVIS_LOG_LEVEL = ''




config.py <- config.py.dist.py



plugit
plugit_server.py
@task
def configure():
    """Configure apache and the flask server"""

    upload_template('plugit/configFiles/config.py', '~/gitrepo-plugit/' + config.GIT_PLUGITDIR + 'config.py', context={
        'PLUGIT_API_URL': config.PLUGIT_API_URL,
        'SQLALCHEMY_URL': config.SQLALCHEMY_URL,
        'API_SECRET': config.API_SECRET,
        'PI_BASE_URL': config.API_BASE_URL,
        'API_ALLOWD_IPS': config.API_ALLOWD_IPS,
        'PI_ALLOWED_NETWORKS': config.PI_ALLOWED_NETWORKS,
    }, use_jinja=True)

    # Disable default site
    sudo('a2dissite 000-default', pty=True)

    # Put our config and enable it
    put(conf('apache.conf'), 'apache.conf')
    sudo('mv apache.conf /etc/apache2/sites-available/')
    sudo('a2ensite apache.conf', pty=True)





plugit/configFiles config.py <- RadioDns-Plugit/config.py.dist




apache.conf
<VirtualHost *:80>
  ServerName radiodns.nuvolet.eu
  ErrorLog "/home/ubuntu/logs/error.log"
  WSGIScriptAlias / /home/ubuntu/gitrepo-plugit/RadioDns-PlugIt/wsgi.py
  ...
    <Directory /home/ubuntu/gitrepo-plugit/RadioDns-PlugIt/>
        #Order Allow,Deny
        #Allow from All
        Require all granted
    </Directory>
</VirtualHost>



radiovis/configFiles config.py <- RadioVisServer/config.py.dist





proxyMode

orgaMode
PIAPI_STANDALONE=True
settings.PIAPI_PROXYMODE PIAPI_REALUSERS=True
(must be settings.PIAPI_ORGAMODE=False)
PIAPI_REALUSERS=False settings.PIAPI_ORGAMODE
PIAPI_STANDALONE=False hproject.plugItProxyMode

hproject.plugItOrgaMode

Deployment:
  • local dependencies (computer that will execute fab...)
    • Ubuntu
      • sudo apt-get install git
        sudo apt-get install fabric
        sudo apt-get install pyhton-pip
        sudo pip install boto jinja2
    • Mageia
      • virtualenv /opt/p27_plugit/bin/activate
      • source source /opt/p27_plugit/bin/activate
      • pip install fabric
      • pip install boto jinja2
  • PlugIt server
    • fab plugit_server.deploy
      • fab plugit_server.upgrade
      • fab plugit_server.install_dependencies
      • fab plugit_server.install_pip_dependencies
      • fab plugit_server.create_logs
      • fab plugit_server.git_init
      • fab plugit_server.configure
        • configure apache and the flask server
      • fab plugit_server.create_database
      • fab plugit_server.create_user
      • fab plugit_server.update_database
      • fab plugit_server.restart_apache
  • RabbitMQ server
    • fab rabbitmq_server.deploy
      • fab rabbitmq_server.upgrade
      • fab rabbitmq_server.install_dependencies
      • fab rabbitmq_server.setup_auth
      • fab rabbitmq_server.activate_management
      • fab rabbitmq_server.stop
      • fab rabbitmq_server.start
  • RadioVis server
    • fab radiovis_server.deploy
      • fab radiovis_server.upgrade
      • fab radiovis_server.install_dependencies
      • fab radiovis_server.install_pip_dependencies
      • fab radiovis_server.create_logs
      • fab radiovis_server.git_init
      • fab radiovis_server.configure
        • configure radiovisserver and supervisord
      • fab radiovis_server.start_radiovis
      • fab radiovis_server.setup_startup_cronjobs
Local:
  • PlugIt server
    • original fab
      Ubuntu
      Mageia
      plugit_server.upgrade sudo apt-get update
      sudo apt-get upgrade -y

      plugit_server.install_dependencies
      • apt-get install -y python-gevent python-setuptools debconf-utils python-mysqldb apache2 libapache2-mod-wsgi git python-imaging
      • sudo easy_install pip
      • sudo apt-get install -y mysql-server
      • urpmi python-gevent
      • urpmi mariadb-server
      plugit_server.install_pip_dependencies sudo pip install flask sqlalchemy Flask-SQLAlchemy alembic dnspython haigha requests beaker blinker raven Pillow boto
      (new-dnsstructure): sudo pip install Flask-Cache
      • virtualenv /opt/p27_plugit
      • source /opt/p27_plugit/bin/activate
      • pip install flask sqlalchemy Flask-SQLAlchemy alembic dnspython haigha requests beaker blinker raven Pillow boto MySQL-python
      • deactivate
      plugit_server.create_logs
      • mkdir /home/ubuntu/logs
      • chmod 777 /home/ubuntu/logs
      • mkdir ~/logs
      • chmod 777 ~/logs
      plugit_server.git_init
      • rm -rf ~/gitrepo-plugit
      • git init ~/gitrepo-plugit
      • cd ~/gitrepo-plugit
      • git remote add -m new-dnsstructure origin https://github.com/ebu/radiodns-plugit.git
      • git config core.sparsecheckout true
      • echo RadioVisServer >> .git/info/sparse-checkout
      • git pull origin new-dnsstructure

      plugit_server.configure
      • cd RadioDns-PlugIt
      • cp config.py.dist config.py
      • edit config.py
      • cd plugit; ln -s ../config.py .

      • sudo a2dissite 000-default.conf
      • cp apache.conf /etc/apache2/sites-available/
      • a2ensite apache.conf
      • cd ~/gitrepo-plugit/RadioDns-PlugIt
      • chmod -R 777 media/uploads

      plugit_server.create_database mysql -u root -p
      • CREATE DATABASE IF NOT EXISTS plugit_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

      plugit_server.create_user mysql -u root -p
      • CREATE USER 'plugit_user'@'localhost' IDENTIFIED BY 'plugit_password';
      • GRANT ALL ON plugit_db.* TO 'plugit_user'@'localhost'; FLUSH PRIVILEGES;

      plugit_server.update_database
      • cd ~/gitrepo-plugit/RadioDns-PlugIt
      • alembic upgrade head

      plugit_server.restart_apache sudo service apache2 restart



      python server.py
      • http://127.0.0.1:5000/toto_base/

  • PlugIt client (Django)

    • Ubuntu
      Mageia
      install_pip_dependencies
      pip install django==1.5 python-dateutil poster


      pip install django requests python-dateutil poster
      configure
      app/settings.py
      • PIAPI_STANDALONE = True
        PIAPI_STANDALONE_URI = 'http://127.0.0.1:5000/toto_base'
        PIAPI_BASEURI = '/plugIt/'



      python manage.py runserver


      mysql -u root -p
      • CREATE DATABASE IF NOT EXISTS djclient_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
      • CREATE USER 'djclient_user'@'localhost' IDENTIFIED BY 'plugit_password';
      • GRANT ALL ON djclient_db.* TO 'djclient_user'@'localhost'; FLUSH PRIVILEGES;


  • RabbitMQ server
    • original fab
      Ubuntu
      Mageia
      rabbitmq_server.install_dependencies sudo apt-get install rabbitmq-server urpmi rabbitmq-server
      rabbitmq_server.setup_auth
      • sudo rabbitmqctl list_users
      • sudo rabbitmqctl add_user rabbitmq_user rabbitmq_password
      • sudo rabbitmqctl set_permissions -p / rabbitmq_user ".*" ".*" ".*"
      • sudo rabbitmqctl set_user_tags rabbitmq_user administrator
      • sudo rabbitmqctl set_permissions -p / guest "^amq.gen.*$" "^amq.gen.*$" ".*"
      • sudo rabbitmqctl set_user_tags guest
      • rabbitmqctl list_users
      • rabbitmqctl add_user rabbitmq_user rabbitmq_password
      • rabbitmqctl set_permissions -p / rabbitmq_user ".*" ".*" ".*"
      • rabbitmqctl set_user_tags rabbitmq_user administrator
      • rabbitmqctl set_permissions -p / guest "^amq.gen.*$" "^amq.gen.*$" ".*"
      • rabbitmqctl set_user_tags guest
      rabbitmq_server.activate_management sudo rabbitmq-plugins enable rabbitmq_management /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management
      rabbitmq_server.start sudo /etc/init.d/rabbitmq-server start service rabbitmq-server start
      rabbitmq_server.stop sudo /etc/init.d/rabbitmq-server stop service rabbitmq-server stop

  • RadioVis server
    • original fab
      Ubuntu
      Mageia
      radiovis_server.install_dependencies
      • sudo apt-get install python-gevent python-setuptools supervisor git
      • sudo easy_install pip
      • urpmi python-gevent
      radiovis_server.install_pip_dependencies sudo pip install flask sqlalchemy Flask-SQLAlchemy alembic dnspython haigha requests beaker python-statsd
      sudo pip install -y beaker haigha python-statsd
      • virtualenv /opt/p27
      • source /opt/p27/bin/activate
      • pip install flask sqlalchemy Flask-SQLAlchemy alembic dnspython haigha requests beaker python-statsd
      • deactivate
      radiovis_server.create_logs
      • sudo mkdir /home/ubuntu/logs
      • sudo chmod 777 /home/ubuntu/logs
      • mkdir ~/logs_radiodns/
      • chmod 777 ~/logs_radiodns/
      radiovis_server.git_init
      • git init ~/gitrepo-radiovis
      • cd ~/gitrepo-radiovis
      • git remote add -m new-dnsstructure origin https://github.com/ebu/radiodns-plugit.git
      • git config core.sparsecheckout true
      • echo RadioVisServer >> .git/info/sparse-checkout
      • git pull origin new-dnsstructure

      radiovis_server.configure
      • cd RadioVisServer
      • cp config.py.dist config.py
      • edit config.py
      • edit Deployment/radiovis/configFiles/supervisor-*.conf
        • ... /home/<your_user>/logs/...
      • cp Deployment/radiovis/configFiles/supervisord-*.conf ~/gitrepo-radiovis/RadioVisServer/
      radiovis_server.start_radiovis
      • cd ~/gitrepo-radiovis/RadioVisServer
      • supervisord -c supervisord-radiovis.conf
      • supervisord -c supervisord-fallback.conf
      • cd RadioVisServer
      • source /opt/p27/bin/activate
      • python server.py
      status supervisorctl -c supervisord-radiovis.conf status
      supervisorctl -c supervisord-fallback.conf status

      stop
      supervisorctl -c supervisord-radiovis.conf stop radiovisserver
      supervisorctl -c supervisord-fallback.conf stop fallbackserver

      restart supervisorctl -c supervisord-radiovis.conf restart radiovisserver
      supervisorctl -c supervisord-fallback.conf restart fallbackserver

      shutdown supervisorctl -c supervisord-radiovis.conf shutdown
      supervisorctl -c supervisord-fallback.conf shutdown

      radiovis_server.setup_startup_cronjobs
      • touch /tmp/crondump
      • echo "@reboot cd ~/gitrepo-radiovis/RadioVisServer && supervisord -c supervisord-radiovis.conf" >> /tmp/crondump
      • echo "@reboot cd ~/gitrepo-radiovis/RadioVisServer && supervisord -c supervisord-fallback.conf" >> /tmp/crondump
      • crontab /tmp/crondump


EBU RadioDNS

  • ROCK FM / Barcelona 89.8MHz
    • telnet radiovis.ebu.io 61613
      • CONNECT

        ^@
      • SUBSCRIBE
        destination:/topic/fm/ee2/e2cf/08980/image
        id: 22
        ack: auto

        ^@
      • MESSAGE
        ...
      • UNSUBSCRIBE
        id: 22

        ^@
      • SUBSCRIBE
        destination:/topic/fm/ee2/e2cf/08980/text
        id: 23
        ack: auto

        ^@

      • UNSUBSCRIBE
        id: 23

        ^@

      • DISCONNECT

        ^@

    • telnet radiovis.nuvolet.eu 61613
      • CONNECT
        login: my_login
        passcode: my_passcode

        ^@
      • SEND
        destination:/topic/fm/ee2/e2cf/08980/image
        ack: auto
        trigger-time:NOW

        SHOW http://toto.org/image.jpg^@
      • SEND
        destination:/topic/fm/ee2/e2cf/08980/image
        ack: auto
        trigger-time:NOW

        SHOW http://toto.org/image.jpg
        ^@
      • SEND
        destination:/topic/fm/ee2/e2cf/08980/text
        ack: auto

        TEXT This is a sample text^@
      • DISCONNECT

        ^@

  • CADENA 100 / Cadena 100 All
    • telnet radiovis.ebu.io 61613
      • CONNECT

        ^@
      • CONNECTED
        session:d0...

      • SUBSCRIBE
        id:0
        destination:/topic/fm/ee2/e2ce/*/image
        ack: auto

        ^@
         
      • MESSAGE
        destination:/topic/fm/ee2/e2ce/*/image
        trigger-time:NOW
        timestamp:1419957721445
        expires:0
        when:1419957721
        priority:0
        link:http://www.cadena100.es/
        message-id:189048157414971483072549662185219455156

        SHOW http://ebu.io/plugit/1/media/uploads/radiovis/gallery/CAD100_PRG_V01.jpg
      • SUBSCRIBE
        id:1
        destination:/topic/fm/ee2/e2ce/*/text
        ack: auto

        ^@
      • MESSAGE
        destination:/topic/fm/ee2/e2ce/*/text
        trigger-time:NOW
        timestamp:1419957793210
        expires:0
        when:1419957793
        priority:0
        link:http://www.cadena100.es/
        message-id:85784137625358472670752196321189123133

        TEXT La mejor variedad musical

http://www.francescpinyol.cat/plugit.html
Primera versió: / First version:
Darrera modificació: 24 de febrer de 2015 / Last update: 24th February 2015

Valid HTML 4.01!

Cap a casa / Back home