This commit updates the grpc server to accept connections on any
container IP and refresh the adapters README.md file.
Change-Id: Ic59c3b07d786499cda0a0a1a6be0ee1f75e869ca
diff --git a/.gitignore b/.gitignore
index bba1e09..e1660b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,5 +55,8 @@
*.log
# Files copied over during make
-adapters/protos/*.proto
+python/protos/*.proto
+
+# voltha cli history
+python/cli/.voltha_cli_history
diff --git a/common/grpc/server.go b/common/grpc/server.go
index 0441fcf..d5685f1 100644
--- a/common/grpc/server.go
+++ b/common/grpc/server.go
@@ -17,12 +17,11 @@
import (
"context"
+ "fmt"
"github.com/opencord/voltha-go/common/log"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"net"
- "strconv"
- "strings"
)
/*
@@ -85,10 +84,8 @@
Start prepares the GRPC server and starts servicing requests
*/
func (s *GrpcServer) Start(ctx context.Context) {
- host := strings.Join([]string{
- s.address,
- strconv.Itoa(int(s.port)),
- }, ":")
+
+ host := fmt.Sprintf("%s:%d", s.address, s.port)
lis, err := net.Listen("tcp", host)
if err != nil {
diff --git a/compose/cli.yml b/compose/cli.yml
index e8ff4ee..2869329 100644
--- a/compose/cli.yml
+++ b/compose/cli.yml
@@ -26,7 +26,7 @@
DOCKER_HOST_IP: "${DOCKER_HOST_IP}"
entrypoint:
- /voltha/python/cli/setup.sh
- - -g 192.168.0.14:50057
+ - -g ${DOCKER_HOST_IP}:50057
networks:
- default
ports:
diff --git a/compose/rw_core.yml b/compose/rw_core.yml
index c5d39ce..8b164db 100644
--- a/compose/rw_core.yml
+++ b/compose/rw_core.yml
@@ -22,7 +22,6 @@
- -kv_store_type=etcd
- -kv_store_host=${DOCKER_HOST_IP}
- -kv_store_port=2379
- - -grpc_host=${DOCKER_HOST_IP}
- -grpc_port=50057
- -banner=true
- -kafka_adapter_host=${DOCKER_HOST_IP}
@@ -32,7 +31,7 @@
- -rw_core_topic=rwcore
- -log_level=0
ports:
- - "50057:50057"
+ - 50057:50057
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
networks:
diff --git a/python/adapters/README.md b/python/adapters/README.md
index 3eda078..1ab1c4f 100644
--- a/python/adapters/README.md
+++ b/python/adapters/README.md
@@ -1,18 +1,20 @@
-# How to Build and Develop a Voltha Adapter
+# How to Build and Run a Voltha Adapter
-The build and development environment of a Voltha Adapter is left to the developer's choice.
+The build and development environment of a Voltha Adapter is left to the developer's choice. The
+environment used below is the macOS.
### Build
-You can build the Voltha Adapter by:
+To build the adapters (so far Ponsim OLT and Ponsim ONU adapters) and dependent containers follow
+the commands below. The base directory is voltha-go.
```
-cd adapters
-. env.sh
-make build
+cd python
+source env.sh
+VOLTHA_BUILD=docker make build
```
-The above has generates a few docker images. An example is below:
+The above build command generates a few docker images. An example is below:
```
$ docker images
@@ -20,14 +22,85 @@
voltha-adapter-ponsim-onu latest 3638b16b5262 36 seconds ago 774MB
voltha-adapter-ponsim-olt latest 9e98a3a8e1aa 58 seconds ago 775MB
voltha-base latest 40ed93942a6a 23 minutes ago 771MB
-voltha-rw-core latest 648be4bc594a About an hour ago 29.1MB
voltha-protos latest d458a391cc81 12 days ago 2.66MB
+voltha-protoc latest a67dda73f695 2 months ago 1.41GB
```
-### Run the ponsim adapters
+Now build the Voltha Core from the voltha-go directory as well as the CLI image (used below for provisioning)
+```
+make rw_core
+```
-The simplest way to run the containerized adapters is using the docker compose command:
+This will create the following images:
+```
+REPOSITORY TAG IMAGE ID CREATED SIZE
+voltha-rw-core latest eab4b288adea 47 seconds ago 36.8MB
+voltha-cli latest a0a4b8f25373 About an hour ago 827MB
+```
+
+### Run the Adapters locally (development environment)
+
+We will use Ponsim as the example. Ponsim has two containers, one being the Ponsim OLT Adapter and
+the other one the Ponsim ONU Adapter. We will use the docker-compose command to run these containers locally
+as it is straight forward.
+
+#### Setup
+Since an adapter communicates with the Voltha Core via the Kafka bus and uses the Etcd KV store then we
+need to have these containers running as well. There is no dependency in the order in which they need to
+start as an adapter must be able to handle this scenario.
+
+First run the dependent containers from the voltha-go directory. In the commands below, replace the IP
+with the IP of the host.
+```
+DOCKER_HOST_IP=<Host IP> docker-compose -f compose/docker-compose-zk-kafka-test.yml up -d
+DOCKER_HOST_IP=<Host IP> docker-compose -f compose/docker-compose-etcd.yml up -d
+DOCKER_HOST_IP=<Host IP> docker-compose -f compose/rw_core.yml up -d
+DOCKER_HOST_IP=<Host IP> docker-compose -f compose/cli.yml up -d
+```
+#### Running the Ponsim Adapters
+
+Start the Ponsim OLT and ONU adapters
+```
+DOCKER_HOST_IP=<Host IP> docker-compose -f compose/adapters-ponsim.yml up -d
+```
+
+Start also the Ponsim OLT and ONU containers. We are using only PonsimV2. You may want to change the
+image names from the yml files below if you are pulling the Ponsim OLT and ONU images from somewhere else.
```
-docker-compose -f ../compose/adapters-ponsim.yml up -d
+docker-compose -f compose/ponsim_olt.yml up -d
+docker-compose -f compose/ponsim_onu.yml up -d
```
+
+#### Provisioning a device
+
+First get the IP address of the Ponsim OLT container by using the docker inspect command.
+
+Now, start the CLI.
+
+```$xslt
+ssh -p 5022 voltha@localhost
+```
+
+Perform the provisioning
+
+```$xslt
+preprovision_olt -t ponsim_olt -H <IP of Ponsim OLT>:50060
+enable <deviceId> // Use the device ID returned in the previous command
+```
+
+At this point you can send flows to the devices using the test option in the CLI.
+```$xslt
+test
+install_eapol_flow <logical_device_id>
+install_dhcp_flows <logical_device_id>
+install_all_controller_bound_flows <logical_device_id>
+install_all_sample_flows <logical_device_id>
+```
+
+You can also see the metrics the Ponsim OLT and ONU adapters are pushing onto the kafka bus.
+
+```$xslt
+kafkacat -b <host IP>:9092 -t voltha.kpis -p 0 -o beginning
+```
+
diff --git a/python/cli/main.py b/python/cli/main.py
index 0348f66..00ea702 100755
--- a/python/cli/main.py
+++ b/python/cli/main.py
@@ -90,8 +90,7 @@
def __init__(self, voltha_grpc, voltha_sim_rest, global_request=False):
- VolthaCli.voltha_grpc = "localhost:50057"
- # VolthaCli.voltha_grpc = voltha_grpc
+ VolthaCli.voltha_grpc = voltha_grpc
VolthaCli.voltha_sim_rest = voltha_sim_rest
VolthaCli.global_request = global_request
Cmd.__init__(self)
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index c363d49..e0d0fe6 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -28,7 +28,7 @@
EtcdStoreName = "etcd"
default_InstanceID = "rwcore001"
default_GrpcPort = 50057
- default_GrpcHost = "127.0.0.1"
+ default_GrpcHost = ""
default_KafkaAdapterHost = "127.0.0.1"
default_KafkaAdapterPort = 9092
default_KafkaClusterHost = "127.0.0.1"