Skip to content

Commit

Permalink
Merge pull request #10 from ayushishu/main
Browse files Browse the repository at this point in the history
Implement Composable Workflow Functionality in csit-1-node test and add  README.md for OpenDaylight dockerfile
  • Loading branch information
askb authored Nov 21, 2023
2 parents ffaa6cf + 26b6eb5 commit d77d2cb
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 26 deletions.
38 changes: 38 additions & 0 deletions .github/action/ssh-setup-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "ssh-setup"
inputs:
docker_repository:
description: "Docker repository name"
required: true
robot_image:
description: "Robot image name"
required: true

runs:
using: "composite"
steps:
- name: Setup SSH
run: |
# Set up SSH in the container
docker exec odl-container bash -c "mkdir -p /home/user/.ssh && touch /home/user/.ssh/authorized_keys"
shell: bash

- name: Start robot container
run: |
# Start the robot container
docker run -d --network container:odl-container --name robot ${{ inputs.docker_repository }}/${{ inputs.robot_image }} tail -f /dev/null
shell: bash

- name: Extract id_rsa.pub from the robot container
id: extract_pubkey
run: |
# Extract the id_rsa.pub from the robot container
docker exec robot cat /root/.ssh/id_rsa.pub > id_rsa.pub
continue-on-error: true
shell: bash

- name: Add public key to opendaylight container
run: |
# Add the public key to the OpenDaylight container
PUB_KEY=$(cat id_rsa.pub)
docker exec odl-container bash -c "mkdir -p /home/user/.ssh && echo \"$PUB_KEY\" >> /home/user/.ssh/authorized_keys"
shell: bash
33 changes: 9 additions & 24 deletions .github/workflows/csit-1-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
on:
push:
branches:
- main
- '*'

jobs:
csit:
Expand Down Expand Up @@ -39,29 +39,14 @@
'echo "org.jolokia.authMode=basic" >> /home/user/karaf-0.18.1/etc/org.jolokia.osgi.cfg && \
echo "org.jolokia.user=admin" >> /home/user/karaf-0.18.1/etc/org.jolokia.osgi.cfg && \
echo "org.jolokia.password=admin" >> /home/user/karaf-0.18.1/etc/org.jolokia.osgi.cfg'
- name: Setup SSH
run: |
# Set up SSH in the container
docker exec odl-container bash -c "mkdir -p /home/user/.ssh && touch /home/user/.ssh/authorized_keys"
- name: Start robot container
run: |
# Start the robot container
docker run -d --network container:odl-container --name robot ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_IMAGE }} tail -f /dev/null
- name: Extract id_rsa.pub from the robot container
id: extract_pubkey
run: |
# Extract the id_rsa.pub from the robot container
docker exec robot cat /root/.ssh/id_rsa.pub > id_rsa.pub
continue-on-error: true

- name: Add public key to opendaylight container
run: |
# Add the public key to the OpenDaylight container
PUB_KEY=$(cat id_rsa.pub)
docker exec odl-container bash -c "mkdir -p /home/user/.ssh && echo \"$PUB_KEY\" >> /home/user/.ssh/authorized_keys"
- name: Delay for 30 seconds
run: sleep 30
- name: Robot Setup
uses: ./.github/action/ssh-setup-action
with:
docker_repository: ${{ vars.DOCKER_REPOSITORY }}
robot_image: ${{ vars.ROBOT_IMAGE }}
- name: Delay for 10 seconds
run: sleep 10

- name: Run Test
run: |
Expand Down
37 changes: 37 additions & 0 deletions opendaylight-docker-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Opendaylight Docker Image

This Dockerfile creates an image that contains the Opendaylight Karaf distribution and an SSH server. The image can be used to run Opendaylight as a container and access it via SSH.

## Prerequisites

- Docker installed on your machine
- A base image of either Ubuntu or CentOS

## Build the Image

By default, the Dockerfile uses Ubuntu as the base image. To build the image with CentOS as the base OS and specify the Karaf version as build arguments, run the following command:

```bash
docker build --build-arg BASE_IMAGE=centos --build-arg KARAF_VERSION=0.18.1 -t opendaylight:0.18.1 .
```

This will create an image named opendaylight:0.18.1 with Centos as the base OS and Karaf 0.18.1 as the Opendaylight distribution.

## Run the container
To run the container, run the following command:
```bash
docker run -p 8181:8181 -p 8101:8101 -p 2222:22 opendaylight:0.18.1
```
### Environment Variables
You can customize the behavior of the OpenDaylight container using environment variables:

`FEATURES`: Specifies the Karaf features to be installed. For example, if you want to install additional features, set the FEATURES environment variable when running the container. For example:

```bash
docker run -d -p 8181:8181 -p 8101:8101 -p 2222:22 --name opendaylight --env FEATURES=odl-restconf,odl-netconf-topology opendaylight:0.18.1
```
### Access the container
To access the container ,
```bash
docker exec opendaylight -it bash
```
4 changes: 2 additions & 2 deletions robot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Begin by cloning this repository to your local machine:

```
git clone https://github.com/askb/releng-docker
cd robot-framework-docker
cd robot
```

Step 2: Build the Docker Image
Expand All @@ -43,7 +43,7 @@ You can now access the container using
Step 4: Run the OpenDaylight container on the same network.

```
docker run -d --name opendaylight --network=host opendaylight-image --env FEATURES=odl-restconf,odl-netconf-topology
docker run -d --name opendaylight --network=host --env FEATURES=odl-restconf,odl-netconf-topology opendaylight_image_name
```

Step 5: Clone the integration-test repository
Expand Down

0 comments on commit d77d2cb

Please sign in to comment.