Skip to content

Commit

Permalink
Merge pull request #6 from CloudlyIO/bugfix/mplane-demo-build-docker-…
Browse files Browse the repository at this point in the history
…image

update mplane demo build docker image scripts - first commit from Cloudly team (thank you)
  • Loading branch information
shahrahman-fb authored Feb 13, 2024
2 parents e073a47 + c800043 commit a683ed3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
9 changes: 6 additions & 3 deletions mplane_client/example/demo.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mplane/mpclient-built-tests:latest
FROM mplane/mplane-client-integrated-tester:latest

RUN apt update; \
apt install --yes \
Expand All @@ -9,6 +9,9 @@ RUN python3 -m pip install \
flask \
flask-socketio \
protobuf \
grpcio
grpcio \
grpcio-tools

COPY mplane_demo /mplane_demo
COPY demo /mplane_demo

RUN python3 -m grpc_tools.protoc --experimental_allow_proto3_optional -I/mplane_client/src/if --python_out=/mplane_demo --grpc_python_out=/mplane_demo mpclient.proto
20 changes: 14 additions & 6 deletions mplane_client/example/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ written as a docker container which can be run on an arbitrary host.

## Build

From the directory above `mplane_demo`, i.e. `mplane-rru/mplane/mpclient`, run
`docker build -f demo.Dockerfile --tag mplane/mpclient-demo:latest`. Note that
the image `mplane/mpclient-built-tests:latest` is expected to be available in
your local Docker images. `mplane/mpclient-built-tests:latest` is built during
From the directory above `demo`, i.e. `open-mplane/mplane_client/example`, run
`docker build -f demo.Dockerfile --tag mplane/mpclient-demo:latest .`. Note that
the image `mplane/mplane-client-integrated-tester:latest` is expected to be available in
your local Docker images. `mplane/mplane-client-integrated-tester:latest` is built during
the mpclient dockerized build.

## Run
Expand All @@ -21,11 +21,19 @@ port with `ssh`, e.g.:
ssh -L 9999:localhost:830 <M-Plane server host>
```

Once port 9999 is setup, run `mplane_demo/run_demo.sh`. The console will contain
a log from `mpclient-server` and the webapp running in the docker container, and
Once port 9999 is setup, run `demo/run_demo.sh`. The console will contain
a log from `mpc_client` and the webapp running in the docker container, and
a webpage displaying information fetched from the M-Plane server will be
available at `localhost:80`.

For linux, `run_demo.sh` needs to be modified to add the host-gateway:
```
docker run \
-p 127.0.0.1:10000:830 -p 80:8000/tcp \
-it --add-host host.docker.internal:host-gateway mplane/mpclient-demo:latest \
python3 /mplane_demo/server.py
```

## Files

- `getalarms.xml`: A yin payload for fetching the `active-alarm-list` O-RAN YANG leaf
Expand Down
8 changes: 4 additions & 4 deletions mplane_client/example/demo/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Constants
GRPC_HOST = "localhost"
GRPC_PORT = "50051"
GRPC_CERT = "/mpclient/build/server.crt"
GRPC_CERT = "/mplane_client/build/server.crt"

NETCONF_HOST = "host.docker.internal"
NETCONF_PORT = 9999
Expand All @@ -40,20 +40,20 @@

NETCONF_RPC_TIMEOUT = 3

SERVER_CMD = "/mpclient/build/wrapper.sh /mpclient/build/mpclient-server"
SERVER_CMD = "/mplane_client/build/wrapper.sh /mplane_client/build/mpc_client"

# Alarms RPC payload
ALARMS_YIN = open("/mplane_demo/getalarms.xml", "r").read()


def start_server():
"""Start the mpclient-server application"""
"""Start the mpc_client application"""
subprocess.Popen(SERVER_CMD.split())
time.sleep(1)


def fetch_thread():
"""Periodically send an RPC to mpclient-server to fetch alarms-list"""
"""Periodically send an RPC to mpc_client to fetch alarms-list"""
stub = mpclient.MpclientStub(
grpc.secure_channel(
f"{GRPC_HOST}:{GRPC_PORT}",
Expand Down

0 comments on commit a683ed3

Please sign in to comment.