Modify ofagent docker build to use protos image

This mimics the behavior of other python based containers
and allows ofagent to start from just a "make build" in
voltha-go/python

Also add the cli image build to the default list

Also add a combined system-test docker-compose that brings up
everything in one shot

Change-Id: I1eeb3fe58eb2841176c999a2729d7331278b1207
diff --git a/compose/system-test.yml b/compose/system-test.yml
new file mode 100644
index 0000000..63e35c9
--- /dev/null
+++ b/compose/system-test.yml
@@ -0,0 +1,155 @@
+---
+# Copyright 2018 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.
+
+version: '2'
+
+networks:
+  default:
+    driver: bridge
+
+services:
+
+  zookeeper:
+    image: "wurstmeister/zookeeper:latest"
+    environment:
+      SERVICE_2181_NAME: "zookeeper"
+    ports:
+    - 2181:2181
+    networks:
+    - default
+
+
+  kafka:
+    image: "wurstmeister/kafka:2.11-2.0.1"
+    environment:
+      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://${DOCKER_HOST_IP}:9092
+      KAFKA_LISTENERS: PLAINTEXT://:9092
+      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
+      SERVICE_9092_NAME: "kafka"
+    volumes:
+      - /var/run/docker.sock:/var/run/docker.sock
+    ports:
+     - 9092:9092
+    networks:
+    - default
+
+
+  etcd:
+    image: "quay.io/coreos/etcd:v3.2.9"
+    command: [
+      "etcd",
+      "--name=etcd0",
+      "--advertise-client-urls=http://${DOCKER_HOST_IP}:2379,http://${DOCKER_HOST_IP}:4001",
+      "--listen-client-urls=http://0.0.0.0:2379,http://0.0.0.0:4001",
+      "--initial-advertise-peer-urls=http://${DOCKER_HOST_IP}:2380",
+      "--listen-peer-urls=http://0.0.0.0:2380",
+      "--initial-cluster-token=etcd-cluster-1",
+      "--initial-cluster=etcd0=http://${DOCKER_HOST_IP}:2380",
+      "--initial-cluster-state=new"
+    ]
+    ports:
+    - "2379:2379"
+    - 2380
+    - 4001
+    networks:
+    - default
+
+
+  rw_core:
+    image: voltha-rw-core
+    entrypoint:
+        - /app/rw_core
+        - -kv_store_type=etcd
+        - -kv_store_host=${DOCKER_HOST_IP}
+        - -kv_store_port=2379
+        - -grpc_port=50057
+        - -banner=true
+        - -kafka_adapter_host=${DOCKER_HOST_IP}
+        - -kafka_adapter_port=9092
+        - -kafka_cluster_host=${DOCKER_HOST_IP}
+        - -kafka_cluster_port=9092
+        - -rw_core_topic=rwcore
+        - -kv_store_data_prefix=service/voltha
+        - -in_competing_mode=false
+        - -log_level=0
+    volumes:
+    - "/var/run/docker.sock:/tmp/docker.sock"
+    ports:
+      - 50057:50057
+    networks:
+    - default
+    restart: unless-stopped
+
+
+  cli:
+    image: "${REGISTRY}${REPOSITORY}voltha-cli:latest"
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "10m"
+        max-file: "3"
+    environment:
+      DOCKER_HOST_IP: "${DOCKER_HOST_IP}"
+    entrypoint:
+    - /voltha/python/cli/setup.sh
+    - -g ${DOCKER_HOST_IP}:50057
+    networks:
+    - default
+    ports:
+    - "5022:22"
+
+
+  ofagent:
+    image: "${REGISTRY}${REPOSITORY}voltha-ofagent:latest"
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "10m"
+        max-file: "3"
+    command: [
+      "/ofagent/ofagent/main.py",
+      "--consul=${DOCKER_HOST_IP}:8500",
+      "--controller=${DOCKER_HOST_IP}:6653",
+      "--grpc-endpoint=${DOCKER_HOST_IP}:50057",
+      "--instance-id-is-container-name",
+      "-v"
+    ]
+    volumes:
+    - "/var/run/docker.sock:/tmp/docker.sock"
+    networks:
+    - default
+    restart: unless-stopped
+
+
+  adapter_openolt:
+    image: "${REGISTRY}${REPOSITORY}voltha-adapter-openolt${TAG}"
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "10m"
+        max-file: "3"
+    command: [
+      "/voltha/python/adapters/openolt/main.py",
+      "-v",
+      "--name=openolt",
+      "--kafka_adapter=${DOCKER_HOST_IP}:9092",
+      "--kafka_cluster=${DOCKER_HOST_IP}:9092",
+      "--core_topic=rwcore"
+    ]
+    networks:
+    - default
+    restart: unless-stopped
+
diff --git a/python/Makefile b/python/Makefile
index 737ae89..0276a91 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -111,7 +111,7 @@
 	@echo "adapter_ponsim_olt       : Build the ponsim olt adapter docker container"
 	@echo "adapter_ponsim_onu       : Build the ponsim olt adapter docker container"
 	@echo "adapter_openolt       : Build the openolt adapter docker container"
-	@echo "ofagent      : Build the openolt adapter docker container"
+	@echo "ofagent      : Build the openflow agent docker container"
 	@echo "tag          : Tag a set of images"
 	@echo "push         : Push the docker images to an external repository"
 	@echo "pull         : Pull the docker images from a repository"
@@ -146,7 +146,7 @@
 
 build: protoc protos containers
 
-containers: base adapter_ponsim_olt adapter_ponsim_onu adapter_openolt ofagent
+containers: base adapter_ponsim_olt adapter_ponsim_onu adapter_openolt ofagent cli
 
 base:
 	docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-base:${TAG} -f docker/Dockerfile.base .
diff --git a/python/docker/Dockerfile.ofagent b/python/docker/Dockerfile.ofagent
index 48b4728..dee28ed 100644
--- a/python/docker/Dockerfile.ofagent
+++ b/python/docker/Dockerfile.ofagent
@@ -15,6 +15,7 @@
 ARG REGISTRY=
 ARG REPOSITORY=
 
+FROM ${REGISTRY}${REPOSITORY}voltha-protos:${TAG} as protos
 FROM ${REGISTRY}${REPOSITORY}voltha-base:${TAG}
 
 MAINTAINER Voltha Community <info@opennetworking.org>
@@ -33,11 +34,16 @@
     rm -f *.deb
 
 # Bundle app source
-RUN mkdir /ofagent && touch /ofagent/__init__.py
+RUN mkdir -p /ofagent/ofagent/protos/third_party/google/api  && \
+        touch   /ofagent/__init__.py \
+                /ofagent/ofagent/protos/third_party/google/__init__.py \
+                /ofagent/ofagent/protos/third_party/google/api/__init__.py
 ENV PYTHONPATH=/ofagent
 COPY common /ofagent/common
 COPY ofagent /ofagent/ofagent
 COPY pki /ofagent/pki
+COPY --from=protos /protos/voltha /ofagent/ofagent/protos
+COPY --from=protos /protos/google/api /ofagent/ofagent/protos/third_party/google/api
 
 ENTRYPOINT ["/usr/bin/dumb-init", "--"]