mirror of
https://github.com/outbackdingo/xmidt.git
synced 2026-01-27 10:20:52 +00:00
Add the simulator to the docker-compose group plus a few examples.
This commit is contained in:
@@ -12,7 +12,7 @@ brought up for current ease of use. Future releases will deprecate tr1d1um.
|
||||
|
||||
- Build the images locally
|
||||
```bash
|
||||
git clone git@github.com:Comcast/xmidt.git
|
||||
git clone git@github.com:Comcast/xmidt.git
|
||||
git clone git@github.com:Comcast/talaria.git
|
||||
git clone git@github.com:Comcast/scytale.git
|
||||
git clone git@github.com:Comcast/petasos.git
|
||||
@@ -38,6 +38,10 @@ cd ..
|
||||
cd tr1d1um
|
||||
docker build -t tr1d1um:local .
|
||||
cd ..
|
||||
|
||||
cd xmidt/simulator
|
||||
docker build -t simulator:local .
|
||||
cd ../..
|
||||
```
|
||||
|
||||
_note_: for building goaws:local since master breaks docker networking
|
||||
@@ -57,6 +61,9 @@ cd ..
|
||||
export CADUCEUS_VERSION=local
|
||||
export PETASOS_VERSION=local
|
||||
|
||||
# This is the client code setup to run locally.
|
||||
export SIMULATOR_VERSION=local
|
||||
|
||||
# This is WebPA not XMiDT
|
||||
export TR1D1UM_VERSION=local
|
||||
```
|
||||
@@ -123,7 +130,7 @@ Content-Length: 57
|
||||
|
||||
Checkout that tr1d1um is able to talk with scytale & talaria:
|
||||
```
|
||||
curl localhost:6100/api/v2/device/mac:112233445566/config?names=Foo -i -H "Authorization: Basic dXNlcjpwYXNz"
|
||||
curl localhost:6100/api/v2/device/mac:112233445577/config?names=Foo -i -H "Authorization: Basic dXNlcjpwYXNz"
|
||||
```
|
||||
|
||||
Should give you:
|
||||
@@ -153,3 +160,70 @@ Content-Type: text/plain; charset=utf-8
|
||||
|
||||
{"code": 404, "message": "Could not process device request: The device does not exist"}
|
||||
```
|
||||
|
||||
Check out that your simulator is connected:
|
||||
|
||||
```
|
||||
curl -H "Authorization: Basic dXNlcjpwYXNz" localhost:6100/api/v2/device/mac:112233445566/stat -i
|
||||
```
|
||||
|
||||
Should give you something similar to:
|
||||
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
X-Scytale-Build: development
|
||||
X-Scytale-Flavor: development
|
||||
X-Scytale-Region: local
|
||||
X-Scytale-Server: localhost
|
||||
X-Scytale-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Talaria-Build: development
|
||||
X-Talaria-Flavor: development
|
||||
X-Talaria-Region: local
|
||||
X-Talaria-Server: localhost
|
||||
X-Talaria-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Tr1d1um-Build: development
|
||||
X-Tr1d1um-Flavor: development
|
||||
X-Tr1d1um-Region: local
|
||||
X-Tr1d1um-Server: localhost
|
||||
X-Tr1d1um-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Webpa-Transaction-Id: CIyqnI23RjWhyC_vNO7hbA
|
||||
X-Xmidt-Span: "http://petasos:6400/api/v2/device/mac:112233445566/stat","2019-06-10T06:38:13Z","2.947332ms"
|
||||
Date: Mon, 10 Jun 2019 06:38:13 GMT
|
||||
Content-Length: 231
|
||||
|
||||
{"id": "mac:112233445566", "pending": 0, "statistics": {"bytesSent": 0, "messagesSent": 0, "bytesReceived": 0, "messagesReceived": 0, "duplications": 0, "connectedAt": "2019-06-10T06:37:02.915435853Z", "upTime": "1m10.110197482s"}}
|
||||
```
|
||||
|
||||
Read a single parameter:
|
||||
|
||||
```
|
||||
curl -H "Authorization: Basic dXNlcjpwYXNz" localhost:6100/api/v2/device/mac:112233445566/config?names=Device.DeviceInfo.X_CISCO_COM_BootloaderVersion -i
|
||||
```
|
||||
|
||||
Results in:
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json; charset=utf-8
|
||||
X-Scytale-Build: development
|
||||
X-Scytale-Flavor: development
|
||||
X-Scytale-Region: local
|
||||
X-Scytale-Server: localhost
|
||||
X-Scytale-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Talaria-Build: development
|
||||
X-Talaria-Flavor: development
|
||||
X-Talaria-Region: local
|
||||
X-Talaria-Server: localhost
|
||||
X-Talaria-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Tr1d1um-Build: development
|
||||
X-Tr1d1um-Flavor: development
|
||||
X-Tr1d1um-Region: local
|
||||
X-Tr1d1um-Server: localhost
|
||||
X-Tr1d1um-Start-Time: 10 Jun 19 06:36 UTC
|
||||
X-Webpa-Transaction-Id: cDYIIKLgoDtrt3XrVfUKkg
|
||||
X-Xmidt-Span: "http://petasos:6400/api/v2/device/send","2019-06-10T06:45:04Z","15.869854ms"
|
||||
Date: Mon, 10 Jun 2019 06:45:04 GMT
|
||||
Content-Length: 163
|
||||
|
||||
{"parameters":[{"name":"Device.DeviceInfo.X_CISCO_COM_BootloaderVersion","value":"4.2.0.45","dataType":0,"parameterCount":1,"message":"Success"}],"statusCode":200}
|
||||
```
|
||||
|
||||
@@ -118,6 +118,17 @@ services:
|
||||
volumes:
|
||||
- ./docFiles/talaria-2.yaml:/etc/talaria/talaria.yaml
|
||||
|
||||
# Mark rdkb-simulator Services
|
||||
simulator: &simulator
|
||||
image: simulator:${SIMULATOR_VERSION}
|
||||
depends_on:
|
||||
- talaria-0
|
||||
- talaria-1
|
||||
- talaria-2
|
||||
- petasos
|
||||
networks:
|
||||
- xmidt
|
||||
|
||||
# Mark Consul Definitions
|
||||
consul0:
|
||||
image: consul:latest
|
||||
|
||||
58
simulator/Dockerfile
Normal file
58
simulator/Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
||||
# build stage
|
||||
FROM alpine:3.7 AS packager
|
||||
|
||||
RUN \
|
||||
apk add --no-cache cmake autoconf make musl-dev gcc g++ openssl openssl-dev git cunit cunit-dev automake libtool util-linux-dev && \
|
||||
mkdir -p /build
|
||||
|
||||
RUN cd /build && \
|
||||
git clone https://github.com/Comcast/parodus2mockTr181.git && \
|
||||
cd parodus2mockTr181 && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. && make && \
|
||||
cd /build && \
|
||||
git clone https://github.com/Comcast/parodus.git && \
|
||||
cd parodus && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. && make && \
|
||||
cd /build && \
|
||||
git clone https://github.com/Comcast/aker.git && \
|
||||
cd aker && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. && make
|
||||
|
||||
# build image
|
||||
FROM alpine:3.7
|
||||
|
||||
WORKDIR /
|
||||
COPY --from=packager /build/parodus2mockTr181/build/src/mock_tr181 /usr/bin/
|
||||
COPY --from=packager /build/aker/build/src/aker /usr/bin/
|
||||
COPY --from=packager /build/parodus2mockTr181/etc/mock_tr181.json /etc/mock_tr181.json
|
||||
COPY --from=packager /build/parodus2mockTr181/build/_install/lib/libwdmp-c.so /usr/lib/
|
||||
COPY --from=packager /build/parodus2mockTr181/build/_install/lib/liblibparodus.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/src/parodus /usr/bin/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libcimplog.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib64/libcjson.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libcjwt.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libmsgpackc.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libnopoll.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libtrower-base64.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib/libwrp-c.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib64/libnanomsg.so /usr/lib/
|
||||
COPY --from=packager /build/parodus/build/_install/lib64/libcurl.so /usr/lib/
|
||||
COPY ./simulate /usr/bin/simulate
|
||||
RUN chmod uga+x /usr/bin/simulate && \
|
||||
apk add --no-cache openssl libuuid && \
|
||||
ln -s /usr/lib/libcurl.so /usr/lib/libcurl.so.1 && \
|
||||
ln -s /usr/lib/libmsgpackc.so /usr/lib/libmsgpackc.so.2 && \
|
||||
ln -s /usr/lib/libtrower-base64.so /usr/lib/libtrower-base64.so.1.0.0 && \
|
||||
ln -s /usr/lib/libnopoll.so /usr/lib/libnopoll.so.0 && \
|
||||
ln -s /usr/lib/libcimplog.so /usr/lib/libcimplog.so.1.0.0 && \
|
||||
ln -s /usr/lib/libnanomsg.so /usr/lib/libnanomsg.so.5 && \
|
||||
ln -s /usr/lib/libnanomsg.so /usr/lib/libnanomsg.so.5.1.0 && \
|
||||
ln -s /usr/lib/libcjson.so /usr/lib/libcjson.so.1
|
||||
|
||||
ENTRYPOINT [ "/usr/bin/simulate" ]
|
||||
37
simulator/README.md
Normal file
37
simulator/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# rdkb-simulator
|
||||
A docker file and assorted support files for an rdkb-simulator (from the Xmidt perspective)
|
||||
|
||||
# To Build
|
||||
|
||||
1. Install *docker-ce* locally.
|
||||
```
|
||||
Instructions to install docker-ce on Ubuntu:
|
||||
|
||||
1) Remove any old installation and update:
|
||||
> sudo apt-get remove docker docker-engine docker.io
|
||||
> sudo apt-get update
|
||||
> sudo apt autoremove
|
||||
2) Install essential packages:
|
||||
> sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
|
||||
3) Add key and verify if key is added:
|
||||
> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
> sudo apt-key fingerprint 0EBFCD88
|
||||
> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
note: The command 'lsb_release -cs' should print the system codename e.g. xenial, otherwise replace with suitable command.
|
||||
|
||||
4) Install docker-ce:
|
||||
> sudo apt-get update
|
||||
> sudo apt-get install docker-ce
|
||||
|
||||
Test: verify if docker-ce installation is success by running hello-world:
|
||||
> sudo docker run hello-world
|
||||
|
||||
```
|
||||
|
||||
2. Run: ```sudo docker build -t rdkb-simulator .```
|
||||
|
||||
|
||||
# To Execute
|
||||
|
||||
Run:
|
||||
```sudo docker run -e CMAC=xxxx rdkb-simulator```
|
||||
57
simulator/simulate
Normal file
57
simulator/simulate
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
parodus_port=16014
|
||||
aker_port=16015
|
||||
mocktr181_port=16016
|
||||
|
||||
if [[ -z "${URL}" ]]; then
|
||||
URL="http://petasos:6400"
|
||||
fi
|
||||
|
||||
if [[ -z "${FIRMWARE}" ]]; then
|
||||
FIRMWARE="mock-rdkb-firmware"
|
||||
fi
|
||||
|
||||
if [[ -z "${BOOT_TIME}" ]]; then
|
||||
BOOT_TIME=`date +%s`
|
||||
fi
|
||||
|
||||
if [[ -z "${HW_MANUFACTURER}" ]]; then
|
||||
HW_MANUFACTURER="Example Inc."
|
||||
fi
|
||||
|
||||
if [[ -z "${REBOOT_REASON}" ]]; then
|
||||
REBOOT_REASON="unknown"
|
||||
fi
|
||||
|
||||
if [[ -z "${SERIAL_NUMBER}" ]]; then
|
||||
SERIAL_NUMBER="mock-rdkb-simulator"
|
||||
fi
|
||||
|
||||
if [[ -z "${CMAC}" ]]; then
|
||||
CMAC="112233445566"
|
||||
fi
|
||||
|
||||
parodus --hw-model=aker-testing \
|
||||
--hw-serial-number=$SERIAL_NUMBER \
|
||||
--hw-manufacturer=$HW_MANUFACTURER \
|
||||
--hw-mac=$CMAC \
|
||||
--hw-last-reboot-reason=$REBOOT_REASON \
|
||||
--fw-name=$FIRMWARE \
|
||||
--boot-time=$BOOT_TIME \
|
||||
--parodus-local-url=tcp://127.0.0.1:$parodus_port \
|
||||
--webpa-ping-timeout=60 \
|
||||
--webpa-backoff-max=2 \
|
||||
--webpa-interface-used=eth0 \
|
||||
--webpa-url=$URL \
|
||||
--force-ipv4 > /dev/null &
|
||||
|
||||
aker -p tcp://127.0.0.1:$parodus_port \
|
||||
-c tcp://127.0.0.1:$aker_port \
|
||||
-w echo \
|
||||
-d /tmp/aker-data.msgpack \
|
||||
-f /tmp/aker-data.msgpack.md5 \
|
||||
-m 128 > /dev/null &
|
||||
|
||||
mock_tr181 -p $parodus_port \
|
||||
-c $mocktr181_port \
|
||||
-d /etc/mock_tr181.json > /dev/null
|
||||
Reference in New Issue
Block a user