VOL-594 remove unused containers
Change-Id: I82403f68969691516c8b500e876440f3f3c0e559
diff --git a/Makefile b/Makefile
index 4675b73..a699518 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@
VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
-.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 docker-base voltha ofagent podder netconf shovel onos dashd vcli portainer grafana nginx consul registrator envoy golang envoyd tools opennms logstash unum
+.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 docker-base voltha ofagent netconf shovel onos dashd vcli portainer grafana nginx consul envoy golang envoyd tools opennms logstash unum
# This should to be the first and default target in this Makefile
help:
@@ -60,7 +60,6 @@
@echo "docker-base : Build the base docker container used by all other dockers"
@echo "voltha : Build the voltha docker container"
@echo "ofagent : Build the ofagent docker container"
- @echo "podder : Build the podder docker container"
@echo "netconf : Build the netconf docker container"
@echo "shovel : Build the shovel docker container"
@echo "onos : Build the onos docker container"
@@ -110,11 +109,11 @@
jenkins : protos jenkins-containers
-jenkins-containers: docker-base voltha ofagent netconf consul registrator unum
+jenkins-containers: docker-base voltha ofagent netconf consul unum
prod-containers: docker-base voltha ofagent netconf shovel dashd vcli grafana consul tools golang envoyd envoy fluentd unum
-containers: docker-base voltha ofagent podder netconf shovel onos tester config-push dashd vcli portainer grafana nginx consul registrator tools golang envoyd envoy fluentd unum
+containers: docker-base voltha ofagent netconf shovel onos tester config-push dashd vcli portainer grafana nginx consul tools golang envoyd envoy fluentd unum
docker-base:
docker build $(DOCKER_BUILD_ARGS) -t cord/voltha-base -f docker/Dockerfile.base .
@@ -128,9 +127,6 @@
ofagent:
docker build $(DOCKER_BUILD_ARGS) -t cord/ofagent -f docker/Dockerfile.ofagent .
-podder:
- docker build $(DOCKER_BUILD_ARGS) -t cord/podder -f docker/Dockerfile.podder .
-
tools:
docker build $(DOCKER_BUILD_ARGS) -t voltha/tools -f docker/Dockerfile.tools .
@@ -171,9 +167,6 @@
consul:
docker build $(DOCKER_BUILD_ARGS) -t voltha/consul -f docker/Dockerfile.consul .
-registrator:
- docker build $(DOCKER_BUILD_ARGS) -t voltha/registrator -f docker/Dockerfile.registrator .
-
grafana:
docker build $(DOCKER_BUILD_ARGS) -t voltha/grafana -f docker/Dockerfile.grafana .
@@ -216,9 +209,6 @@
docker pull ubuntu:xenial
docker pull wurstmeister/kafka:1.0.0
docker pull zookeeper:3.4.11
- # These images are depricated and should be removed in subsequent commits.
- docker pull gliderlabs/registrator:v7
- docker pull wurstmeister/zookeeper:3.4.6
fetch:
docker pull consul:0.9.2
docker pull fluent/fluentd:v0.14.23.rc1
@@ -229,11 +219,6 @@
docker pull lyft/envoy:29361deae91575a1d46c7a21e913f19e75622ebe
docker pull registry:2
docker pull kamon/grafana_graphite:3.0
- # These images are depricated and should be removed in subsequent commits.
- docker pull gliderlabs/registrator:v7
- docker pull wurstmeister/zookeeper:3.4.6
- docker pull nginx:1.13.6
-
purge-venv:
rm -fr ${VENVDIR}
diff --git a/common/utils/dockerhelpers.py b/common/utils/dockerhelpers.py
index 89acab6..4620aef 100644
--- a/common/utils/dockerhelpers.py
+++ b/common/utils/dockerhelpers.py
@@ -30,18 +30,6 @@
docker_socket = os.environ.get('DOCKER_SOCK', 'unix://tmp/docker.sock')
log = get_logger()
-
-def remove_container(id, force=True):
- try:
- docker_cli = Client(base_url=docker_socket)
- containers = docker_cli.remove_container(id, force=force)
-
- except Exception, e:
- log.exception('failed', e=e)
- raise
-
- return containers
-
def get_my_containers_name():
"""
Return the docker containers name in which this process is running.
@@ -85,168 +73,3 @@
return info
-
-def create_host_config(volumes, ports):
- try:
- port_bindings = ports
- binds = ['{0}:{1}'.format(k, v) for k, v in volumes.iteritems()]
- docker_cli = Client(base_url=docker_socket)
- host_config = docker_cli.create_host_config(binds=binds,
- port_bindings=port_bindings)
- except Exception, e:
- log.exception('failed-host-config-creation', volumes, ports, e=e)
- raise
-
- return host_config
-
-def connect_container_to_network(container, net_id, links):
- try:
- docker_cli = Client(base_url=docker_socket)
- docker_cli.connect_container_to_network(container, net_id, links=links)
- except Exception, e:
- log.exception('failed-connection-to-network',
- container=container, net_id=net_id, e=e)
- raise
-
-def create_networking_config(name, links):
- """
- Creates a container networks based on a set of containers.
- :param name: the network name
- :param links: the set of containers to link
- :return: a network configuration
- """
- try:
- docker_cli = Client(base_url=docker_socket)
- networking_config = docker_cli.create_networking_config({
- name : docker_cli.create_endpoint_config(links=links)
- })
- except Exception, e:
- log.exception('failed-network-creation', name, e=e)
- raise
-
- return networking_config
-
-def stop_container(container, timeout=10):
- try:
- docker_cli = Client(base_url=docker_socket)
- docker_cli.stop(container, timeout=timeout)
- except Exception, e:
- log.exception('failed', e=e)
- raise
-
-def create_container(args):
- try:
- docker_cli = Client(base_url=docker_socket)
- container = docker_cli.create_container(**args)
- except Exception, e:
- log.exception('failed', e=e)
- raise
- return container
-
-def start_container(container):
- """
- Starts a requested container with the appropriate configuration.
- :param args: contains arguments for container creation
- (see https://docker-py.readthedocs.io/en/stable/api/#create_container)
- :return: the containers name
- """
- try:
- docker_cli = Client(base_url=docker_socket)
- response = docker_cli.start(container=container.get('Id'))
- except Exception, e:
- log.exception('failed', e=e)
- raise
- return response
-
-class EventProcessor(object):
- """
- This class handles the api session and allows for it to
- be terminated.
- """
- def __init__(self, threads=1):
- self.client = CustomClient(base_url=docker_socket)
- self.events = self.client.events(decode=True)
- log.info("starting", threads=threads)
- self.exec_service = ThreadPoolExecutor(max_workers=threads)
-
- def stop_listening(self):
- """
- Shuts down the socket.
- :return: None
- """
- if self.events is not None:
- sock = self.client._get_raw_response_socket(self.events.response)
- sock.shutdown(socket.SHUT_RDWR)
-
-
- def listen_for_events(self, handlers):
- """
- Listens to the docker event stream and applies the functions
- in the passed handler to each event.
-
- docker containers can report the following events:
-
- attach, commit, copy, create, destroy, detach, die,
- exec_create, exec_detach, exec_start, export,
- health_status, kill, oom, pause, rename, resize,
- restart, start, stop, top, unpause, update
-
- :param handlers: a dict of functions
- :return: None
- """
- if not handlers or len(handlers) == 0:
- raise ValueError("Handlers cannot be empty")
-
- for event in self.events:
- for k in ['time', 'Time']:
- if k in event:
- event[k] = datetime.fromtimestamp(event[k])
- log.debug('docker-event', event=event)
-
- data = {}
- i = get_id(event)
- if i is not None:
- try:
- if 'from' in event or 'From' in event:
- data = self.client.inspect_container(i)
- else:
- data = self.client.inspect_image(i)
- data[i] = data
- except errors.NotFound:
- log.debug('no-data-for-container', container=i)
-
- status = get_status(event)
- if status in handlers:
- self.exec_service.submit(handlers[get_status(event)], event,
- data, handlers['podder_config'])
- else:
- log.debug('no-handler', handler=status)
-
-class CustomGenerator(object):
- """
- This is a custom ugly class that allows for the generator
- to be (kind of) cleanly closed.
- """
- def __init__(self, stream, response, decode):
- self.stream = stream
- self.response = response
- self.decode = decode
-
- def __iter__(self):
- for item in super(CustomClient, self.stream).\
- _stream_helper(self.response, self.decode):
- yield item
-
-class CustomClient(Client):
- def _stream_helper(self, response, decode=False):
- return CustomGenerator(self, response, decode)
-
-def get_status(event):
- for k in ['status', 'Status']:
- if k in event:
- return event[k]
-
-def get_id(event):
- for k in ['id', 'ID', 'Id']:
- if k in event:
- return event[k]
diff --git a/compose/docker-compose-system-test-with-podder.yml b/compose/docker-compose-system-test-with-podder.yml
deleted file mode 100644
index 2295848..0000000
--- a/compose/docker-compose-system-test-with-podder.yml
+++ /dev/null
@@ -1,160 +0,0 @@
-version: '2'
-services:
- #
- # Single-node zookeeper service
- #
- zookeeper:
- image: wurstmeister/zookeeper
- ports:
- - 2181
- environment:
- SERVICE_2181_NAME: "zookeeper"
- #
- # Single-node kafka service
- #
- kafka:
- image: wurstmeister/kafka
- ports:
- - 9092
- environment:
- KAFKA_ADVERTISED_HOST_NAME: ${DOCKER_HOST_IP}
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
- KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
- KAFKA_HEAP_OPTS: "-Xmx256M -Xms128M"
- SERVICE_9092_NAME: "kafka"
- depends_on:
- - consul
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- #
- # Single-node consul agent
- #
- consul:
- image: consul:latest
- command: agent -server -bootstrap -client 0.0.0.0 -ui
- ports:
- - "8300:8300"
- - "8400:8400"
- - "8500:8500"
- - "8600:8600/udp"
- environment:
- #SERVICE_53_IGNORE: "yes"
- SERVICE_8300_IGNORE: "yes"
- SERVICE_8400_IGNORE: "yes"
- SERVICE_8500_NAME: "consul-rest"
- #
- # Registrator
- #
- registrator:
- image: gliderlabs/registrator:latest
- command: [
- "-ip=${DOCKER_HOST_IP}",
- "-retry-attempts", "100",
- # "-internal",
- "consul://consul:8500"
- ]
- links:
- - consul
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
- # Fluentd log server
- #
- fluentd:
- image: fluent/fluentd
- ports:
- - "24224:24224"
- volumes:
- - "/tmp/fluentd:/fluentd/log"
- environment:
- SERVICE_24224_NAME: "fluentd-intake"
-
- #
- # Podder service instance
- #
- podder:
- image: cord/podder
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- restart: unless-stopped
-
- #
- # Graphite-Grafana-statsd service instance
- # (demo place-holder for external KPI system)
- #
- grafana:
- image: kamon/grafana_graphite
- ports:
- - "8882:80"
- - "2003:2003"
- - "2004:2004"
- - "8126:8126"
- - "8125:8125/udp"
- environment:
- SERVICE_80_NAME: "grafana-web-ui"
- SERVICE_2003_NAME: "carbon-plain-text-intake"
- SERVICE_2004_NAME: "carbon-pickle-intake"
- SERVICE_8126_NAME: "statsd-tcp-intake"
- SERVICE_8125_NAME: "statsd-udp-intake"
-
- #
- # Shovel (Kafka-graphite-gateway)
- #
- shovel:
- image: cord/shovel
- command: [
- "/shovel/shovel/main.py",
- "--kafka=@kafka",
- "--consul=${DOCKER_HOST_IP}:8500",
- "--topic=voltha.kpis",
- "--host=${DOCKER_HOST_IP}"
- ]
- depends_on:
- - consul
- - kafka
- - grafana
-
- #
- # Voltha server instance(s)
- #
- voltha:
- image: cord/voltha
- command: [
- "/voltha/voltha/main.py",
- "-v",
- "--consul=${DOCKER_HOST_IP}:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8880",
- "--grpc-port=50555",
- "--kafka=@kafka",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8880
- - 50555
- - 18880
- depends_on:
- - consul
- - podder
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8880_NAME: "voltha-health"
- SERVICE_8880_CHECK_HTTP: "/health"
- SERVICE_8880_CHECK_INTERVAL: "5s"
- SERVICE_8880_CHECK_TIMEOUT: "1s"
- SERVICE_50555_NAME: "voltha-grpc"
- SERVICE_18880_NAME: "voltha-sim-rest"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- networks:
- - default
- - ponmgmt
-
-networks:
- default:
- driver: bridge
- ponmgmt:
- driver: bridge
diff --git a/docker/Dockerfile.podder b/docker/Dockerfile.podder
deleted file mode 100644
index 30857cd..0000000
--- a/docker/Dockerfile.podder
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed 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.
-#
-
-FROM cord/voltha-base
-
-MAINTAINER Zsolt Haraszti <zharaszt@ciena.com>
-MAINTAINER Ali Al-Shabibi <ali.al-shabibi@onlab.us>
-MAINTAINER Nathan Knuth <nathan.knuth@tibitcom.com>
-
-RUN mkdir /podder && touch /podder/__init__.py
-ENV PYTHONPATH=/podder
-COPY common /podder/common
-COPY podder /podder/podder
-
-# Exposing process and default entry point
-CMD ["python", "podder/podder/main.py"]
diff --git a/docs/manuals/user/labtests/V01_voltha_bringup_deploy.md b/docs/manuals/user/labtests/V01_voltha_bringup_deploy.md
index f198ba0..2667d56 100644
--- a/docs/manuals/user/labtests/V01_voltha_bringup_deploy.md
+++ b/docs/manuals/user/labtests/V01_voltha_bringup_deploy.md
@@ -58,7 +58,6 @@
Creating compose_chameleon_1
Creating compose_netconf_1
Creating compose_zookeeper_1
- Creating compose_podder_1
Creating compose_kafka_1
Creating compose_grafana_1
Creating compose_shovel_1
@@ -93,7 +92,6 @@
compose_kafka_1 start-kafka.sh Up 0.0.0.0:...
compose_netconf_1 /netconf/netconf/main.py - ... Up 0.0.0.0:...
compose_ofagent_1 /ofagent/ofagent/main.py - ... Up
- compose_podder_1 python podder/podder/main.py Up
compose_registrator_1 /bin/registrator -ip=10.0. ... Up
compose_shovel_1 /shovel/shovel/main.py --k ... Up
compose_voltha_1 /voltha/voltha/main.py -v ... Up 0.0.0.0:...
diff --git a/podder/handlers.py b/podder/handlers.py
deleted file mode 100644
index 825cd60..0000000
--- a/podder/handlers.py
+++ /dev/null
@@ -1,148 +0,0 @@
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed 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.
-#
-from common.utils.dockerhelpers import create_host_config, create_container, start_container, create_networking_config, \
- get_all_running_containers, inspect_container, remove_container
-from docker import errors
-
-from structlog import get_logger
-import yaml
-
-log = get_logger()
-
-INSTANCE_ID_KEY = 'com.docker.compose.container-number'
-INSTANCE_NAME_KEY = 'name'
-
-
-def check(event):
- return ('from' in event) and\
- ('Actor' in event and 'Attributes' in event['Actor'] and\
- INSTANCE_ID_KEY in event['Actor']['Attributes']) and\
- ('Actor' in event and 'Attributes' in event['Actor'] and\
- INSTANCE_NAME_KEY in event['Actor']['Attributes'])
-
-def get_entry(key, dico, mandatory = False, noneval=None):
- if key in dico:
- return dico[key]
- if mandatory:
- raise Exception('Key {} must be in container config'.format(key))
- return noneval
-
-def obtain_network_name(data):
- return data['NetworkSettings']['Networks'].keys()
-
-
-def create_network_config(network, links):
- if links is None:
- return None
- # Assuming only one network exists....
- return create_networking_config(network[0], { l : l for l in links})
-
-def process_value(value):
- if value is None:
- return None
- if isinstance(value, dict):
- return value
- if isinstance(value, list):
- retval = {}
- for item in value:
- if not isinstance(item, int) and ':' in item:
- item_split = item.split(':')
- retval[item_split[0]] = item_split[1]
- else:
- retval[item] = None
- return retval
- raise Exception('Cannot handle {}'.format(value))
-
-def construct_container_spec(config):
- container_spec = {}
- container_spec['image'] = get_entry('image', config, mandatory=True)
- container_spec['command'] = get_entry('command', config, mandatory=True)
- container_spec['environment'] = get_entry('environment', config, noneval={})
- container_spec['ports'] = get_entry('ports', config)
- container_spec['volumes'] = get_entry('volumes', config)
- return container_spec
-
-def service_shutdown(service, instance_name, config):
- containers = get_all_running_containers()
- for container in containers:
- try:
- info = inspect_container(container['Id'])
- except errors.NotFound, e:
- continue
- envs = info['Config']['Env']
- for env in envs:
- for name in env.split('='):
- if name == instance_name:
- log.info('Removing container {}'.format(container['Names']))
- remove_container(container['Id'])
-
-def start_slaves(service, instance_name, instance_id, data, conf):
- network = obtain_network_name(data)
- # still assuming a single network
- config = yaml.load(conf.render(data=data, network=network[0]))
-
- if service not in config['services']:
- log.debug('Unknown service {}'.format(service))
- return
- for slave in config['services'][service]['slaves']:
- if slave not in config['slaves']:
- log.debug('Unknown slave service {}'.format(slave))
- continue
-
- netcfg = create_network_config(network, get_entry('links', config['slaves'][slave]))
- container_spec = construct_container_spec(config['slaves'][slave])
- container_spec['networking_config'] = netcfg
- if 'volumes' in container_spec:
- container_spec['host_config'] = create_host_config(
- process_value(container_spec['volumes']),
- process_value(container_spec['ports']))
- container_spec['name'] = 'podder_%s_%s' % (slave, instance_id)
-
- container_spec['environment']['PODDER_MASTER'] = instance_name
-
- container = create_container(container_spec)
- log.info('Starting slaves for {}'.format(instance_name))
- start_container(container)
-
-
-def stop_slaves(service, instance_name, instance_id, data, conf):
- log.info('Stopping slaves for {}'.format(instance_name))
- config = yaml.load(conf.render())
- if service in config['services']:
- service_shutdown(service, instance_name, config)
- else:
- # handle slave shutdown; restart him
- pass
-
-
-def handler_start(event, data, config):
- if not check(event):
- log.debug('event {} is invalid'.format(event) )
- return
- service = event['from']
- instance_name = event['Actor']['Attributes'][INSTANCE_NAME_KEY]
- instance_id = event['Actor']['Attributes'][INSTANCE_ID_KEY]
- start_slaves(service, instance_name, instance_id, data, config)
-
-def handler_stop(event, data, config):
- if not check(event):
- log.debug('event {} is invalid'.format(event) )
- return
- service = event['from']
- instance_name = event['Actor']['Attributes'][INSTANCE_NAME_KEY]
- instance_id = event['Actor']['Attributes'][INSTANCE_ID_KEY]
- stop_slaves(service, instance_name, instance_id, data, config)
-
diff --git a/podder/main.py b/podder/main.py
deleted file mode 100755
index 412ae58..0000000
--- a/podder/main.py
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed 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.
-#
-
-import argparse
-import os
-
-import yaml
-from podder import Podder
-
-from common.structlog_setup import setup_logging
-from common.utils.nethelpers import get_my_primary_local_ipv4
-
-defs = dict(
- slaves=os.environ.get('SLAVES', './slaves.yml.j2'),
- config=os.environ.get('CONFIG', './podder.yml'),
- consul=os.environ.get('CONSUL', 'localhost:8500'),
- external_host_address=os.environ.get('EXTERNAL_HOST_ADDRESS',
- get_my_primary_local_ipv4()),
- grpc_endpoint=os.environ.get('GRPC_ENDPOINT', 'localhost:50055'),
- fluentd=os.environ.get('FLUENTD', None),
- instance_id=os.environ.get('INSTANCE_ID', os.environ.get('HOSTNAME', '1')),
- internal_host_address=os.environ.get('INTERNAL_HOST_ADDRESS',
- get_my_primary_local_ipv4()),
- work_dir=os.environ.get('WORK_DIR', '/tmp/podder'),
- threads=os.environ.get('PODDER_THREADS', 5)
-)
-
-def parse_args():
-
- parser = argparse.ArgumentParser()
-
- _help = ('Path to podder.yml config file (default: %s). '
- 'If relative, it is relative to main.py of podder.'
- % defs['config'])
- parser.add_argument('-c', '--config',
- dest='config',
- action='store',
- default=defs['config'],
- help=_help)
-
- _help = ('Path to slaves configuration file (default %s).'
- 'If relative, it is relative to main.py of podder.'
- % defs['slaves'])
- parser.add_argument('-s', '--slaves',
- dest='slaves',
- action='store',
- default=defs['slaves'],
- help=_help)
-
- _help = '<hostname>:<port> to consul agent (default: %s)' % defs['consul']
- parser.add_argument(
- '-C', '--consul', dest='consul', action='store',
- default=defs['consul'],
- help=_help)
-
-
- _help = ('<hostname>:<port> to fluentd server (default: %s). (If not '
- 'specified (None), the address from the config file is used'
- % defs['fluentd'])
- parser.add_argument('-F', '--fluentd',
- dest='fluentd',
- action='store',
- default=defs['fluentd'],
- help=_help)
-
- _help = ('unique string id of this ofagent instance (default: %s)'
- % defs['instance_id'])
- parser.add_argument('-i', '--instance-id',
- dest='instance_id',
- action='store',
- default=defs['instance_id'],
- help=_help)
-
- _help = 'omit startup banner log lines'
- parser.add_argument('-n', '--no-banner',
- dest='no_banner',
- action='store_true',
- default=False,
- help=_help)
-
- _help = "suppress debug and info logs"
- parser.add_argument('-q', '--quiet',
- dest='quiet',
- action='count',
- help=_help)
-
- _help = 'enable verbose logging'
- parser.add_argument('-v', '--verbose',
- dest='verbose',
- action='count',
- help=_help)
-
- _help = 'Number of events to handle in parallel'
- parser.add_argument('-e', '--events-in-parallel',
- dest='threads',
- type=int,
- default=defs['threads'],
- action='store',
- help=_help)
-
-
- args = parser.parse_args()
-
- # post-processing
-
- return args
-
-def load_file(file):
- path = file
- if path.startswith('.'):
- dir = os.path.dirname(os.path.abspath(__file__))
- path = os.path.join(dir, path)
- path = os.path.abspath(path)
- with open(path) as fd:
- contents = fd.read()
- return contents
-
-def load_config(config):
- contents = load_file(config)
- return yaml.load(contents)
-
-
-banner = r'''
- _____
-| | | |
-| | | |
-|_____|_____ ____|____| ___ _
-| | | | |/ _ \ /
-| |_____|____|____|\____|
-'''
-
-def print_banner(log):
- for line in banner.strip('\n').splitlines():
- log.info(line)
- log.info('(to stop: press Ctrl-C)')
-
-class Main(object):
-
- def __init__(self):
- self.args = args = parse_args()
- self.config = load_config(args.config)
- self.slave_config = load_file(args.slaves)
-
- verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
- self.log = setup_logging(self.config.get('logging', {}),
- args.instance_id,
- verbosity_adjust=verbosity_adjust,
- fluentd=args.fluentd)
-
- self.consul_manager = None
-
- if not args.no_banner:
- print_banner(self.log)
-
- def start(self):
- self.startup_components()
-
- def startup_components(self):
- self.log.info('starting-internal-components')
- args = self.args
- self.podder = Podder(args, self.slave_config)
- self.log.info('started-internal-components')
- self.podder.run()
-
-
-if __name__ == '__main__':
- Main().start()
diff --git a/podder/podder.py b/podder/podder.py
deleted file mode 100644
index e3a2fe4..0000000
--- a/podder/podder.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed 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.
-#
-
-from handlers import handler_start, handler_stop
-from structlog import get_logger
-from jinja2 import Template
-
-from common.utils.dockerhelpers import EventProcessor
-
-class Podder(object):
-
- log = get_logger()
-
- def __init__(self, args, slave_config):
- self.log.info('Initializing Podder')
- self.running = False
- self.events = EventProcessor(threads=args.threads)
- self.handlers = { 'podder_config' : Template(slave_config) }
-
- def run(self):
- if self.running:
- return
- self.running = True
-
- self.initialize()
-
- def shutdown(self):
- try:
- self.events.stop_listening()
- except:
- self.log.info('Shutting down')
-
- def initialize(self):
- self.define_handlers()
- while True:
- try:
- self.events.listen_for_events(self.handlers)
- except KeyboardInterrupt:
- self.shutdown()
- break
- except Exception, e:
- self.log.info('Handler exception', e)
-
- def define_handlers(self):
- self.handlers['start'] = handler_start
- self.handlers['stop'] = handler_stop
-
diff --git a/podder/podder.yml b/podder/podder.yml
deleted file mode 100644
index 9a43048..0000000
--- a/podder/podder.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-logging:
- version: 1
-
- formatters:
- brief:
- format: '%(message)s'
- default:
- format: '%(asctime)s.%(msecs)03d %(levelname)-8s %(module)s.%(funcName)s %(message)s'
- datefmt: '%Y%m%dT%H%M%S'
- fluent_fmt:
- '()': fluent.handler.FluentRecordFormatter
- format:
- level: '%(levelname)s'
- hostname: '%(hostname)s'
- where: '%(module)s.%(funcName)s'
-
- handlers:
- console:
- class : logging.StreamHandler
- level: DEBUG
- formatter: default
- stream: ext://sys.stdout
- fluent:
- class: fluent.handler.FluentHandler
- host: localhost
- port: 24224
- tag: voltha.logging
- formatter: fluent_fmt
- level: DEBUG
- null:
- class: logging.NullHandler
-
- loggers:
- amqp:
- handlers: [null]
- propagate: False
- conf:
- handlers: [null]
- propagate: False
- '': # root logger
- handlers: [console, fluent]
- level: INFO # this can be bumped up/down by -q and -v command line
- # options
- propagate: False
\ No newline at end of file
diff --git a/podder/slaves.yml.j2 b/podder/slaves.yml.j2
deleted file mode 100644
index d72bae9..0000000
--- a/podder/slaves.yml.j2
+++ /dev/null
@@ -1,59 +0,0 @@
-{% macro address(data, network) -%}
- {% if data is defined and network is defined -%}
- {{ data['NetworkSettings']['Networks'][network]['IPAddress'] }}:50555 }}
- {%- else -%}
- None:None
- {%- endif %}
-{%- endmacro %}
-
-services:
- cord/voltha:
- slaves: ["chameleon", "ofagent"]
-
-
-slaves:
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint={{ address(data, network) }}",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
-
- ofagent:
- image: cord/ofagent
- command: [
- "/ofagent/ofagent/main.py",
- "-v",
- "--consul=${DOCKER_HOST_IP}:8500",
- "--fluentd=fluentd:24224",
- "--controller=${DOCKER_HOST_IP}:6633",
- "--grpc-endpoint={{ address(data, network) }}",
- "--instance-id-is-container-name",
- "-v"
- ]
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"