Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM avdteam/base
LABEL maintainer="TiTom73<tom@inetsix.net>"

# Default ARG values

# Set term option
ARG TERM=xterm

# Install necessary packages
# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y update; yum -y install \
findutils \
make \
which \
python3 \
python3-pip \
rpm-build \
wget \
xorg-x11-server-Xvfb \
xorg-x11-fonts-Type1 \
xorg-x11-fonts-75dpi \
&& yum clean all

RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-rc/wkhtmltox-0.12.6-0.20200605.30.rc.faa06fa.centos8.x86_64.rpm && \
yum localinstall -y *.rpm

# Create the /project directory and add it as a mountpoint
WORKDIR /projects
VOLUME ["/projects"]

COPY . /projects/

# Install python modules required by the repo
RUN pip3 install -r requirements.txt

# Use Airsta_Chack as entrypoint
CMD ["python3", "run.py"]
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DOCKER_NAME ?= arista_check
DOCKER_TAG ?= latest
PORT ?= 8181
CONTAINER_NAME ?= arista_check
DATA ?= visuapp/static/data
HOME_DIR = $(shell pwd)

.PHONY: help
help: ## Display help message
@grep -E '^[0-9a-zA-Z_-]+\.*[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: build
build: ## Build docker image
docker build -t$(DOCKER_NAME):$(DOCKER_TAG) .

.PHONY: run
run: ## run docker image in foreground
docker run --rm -p $(PORT):80/tcp $(DOCKER_NAME):$(DOCKER_TAG)

.PHONY: daemon
daemon: ## run docker image in background
docker run -d --rm -p $(PORT):80/tcp -v $(HOME_DIR)/$(DATA):/projects/visuapp/static/data --name $(CONTAINER_NAME) $(DOCKER_NAME):$(DOCKER_TAG)

.PHONY: stop
stop: ## stop docker image
docker stop $(CONTAINER_NAME)

.PHONY: connect
connect: ## connect to docker image for debug purpose
docker exec -it $(CONTAINER_NAME) bash
142 changes: 103 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
![Arista Check](https://img.shields.io/badge/Arista-EOS%20Automation-blue)

# arista_Check

Software to check EOS topology and validate physical deployment in large environment.

- [arista_Check](#arista_check)
- [Supported features](#supported-features)
- [Requirements](#requirements)
- [Docker (Recommended)](#docker-recommended)
- [Build local docker image](#build-local-docker-image)
- [Makefile options](#makefile-options)
- [Server Configuration](#server-configuration)
- [Generate topology file](#generate-topology-file)
- [Configure Username and password](#configure-username-and-password)
- [Change DC hostname (optional)](#change-dc-hostname-optional)
- [Installation](#installation)
- [Step 1 : Install Python requirements](#step-1--install-python-requirements)
- [Step2 : Install wkhtmltopdf to generate PDF files](#step2--install-wkhtmltopdf-to-generate-pdf-files)
- [Run service](#run-service)
- [License](#license)

![overview](./medias/arista-check-overview.png)

## Supported features
Expand All @@ -16,62 +34,52 @@ Software to check EOS topology and validate physical deployment in large environ
## Requirements

- Python 3
- Flask
- wkhtmltopdf
- [`Flask`](https://flask.palletsprojects.com/en/1.1.x/)
- [`wkhtmltopdf`](https://wkhtmltopdf.org/)
- DNS resolution for EOS devices.
- eAPI running on port `80`

## Installation

### Step 1 : Install Python requirements
## Docker (Recommended)

```shell
$ pip install -r requirements.txt
```
This section explains how to build your own docker image and run __arista_check__ on any docker host.

### Step2 : Install wkhtmltopdf to generate PDF files
### Build local docker image

On Macos, use brew:
To make it easy to use, a docker image is available in the repository to build your own system.

```shell
$ brew install Caskroom/cask/wkhtmltopdf
```
# Build image
$ make build

On headless centos, use following setup:
# Docker command
$ docker build -t arista_check .
````

```shell
# Install base tool
$ yum install -y wkhtmltopdf
> Ensure to update your configuration first as described below.

# Required for headless use
$ yum install xorg-x11-server-Xvfb
$ yum install xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
### Run container

# Create Service file
$ vim xvfb.service
[Unit]
Description=Virtual Frame Buffer X Server
After=network.target
Run your image in the forground

[Service]
ExecStart=/usr/bin/Xvfb :42 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
```shell
# Run container
$ make run

[Install]
WantedBy=multi-user.target
# Docker command
$ docker run --rm -p 8181:80/tcp arista_check
```

# Deploy service
$ cp xvfb.service /etc/systemd/system/xvfb.service
$ sudo systemctl enable xvfb.service && sudo systemctl start xvfb.service && sudo systemctl status xvfb.service
$ sudo systemctl daemon-reload
System will be available on port `8181` of your host

# Create binary
$ printf '#!/bin/bash\nxvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $*' > /usr/bin/wkhtmltopdf.sh
$ chmod a+x /usr/bin/wkhtmltopdf.sh
$ ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
### Makefile options

# Run a test
$ wkhtmltopdf http://www.google.com output.pdf
```
These options can be applied to either build or run targets.

- `DATA`: relative path to folder where __referenceCablingMaps.json__ is saved (default is `visuapp/static/data`)
- `PORT`: Port to expose your arista_check server. (default is `8181`)
- `DOCKER_NAME`: Image name to use for build and run (default is `arista_check`)
- `DOCKER_TAG`: Docker tag (default is `latest`)
- `CONTAINER_NAME`: Name of your running container. (default is `arista_check`)

## Server Configuration

Expand Down Expand Up @@ -144,6 +152,62 @@ AUTHOR = "EOS User"
SITE = "DC1 Fabric"
```

## Installation

This section explains how to install __arista_check__ on a system.

### Step 1 : Install Python requirements

```shell
$ pip install -r requirements.txt
...
```

### Step2 : Install wkhtmltopdf to generate PDF files

On Macos, use brew:

```shell
$ brew install Caskroom/cask/wkhtmltopdf
...
```

On headless centos, use following setup:

```shell
# Install base tool
$ yum install -y wkhtmltopdf

# Required for headless use
$ yum install xorg-x11-server-Xvfb
$ yum install xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi

# Create Service file
$ vim xvfb.service
[Unit]
Description=Virtual Frame Buffer X Server
After=network.target

[Service]
ExecStart=/usr/bin/Xvfb :42 -screen 0 1024x768x24 -ac +extension GLX +render -noreset

[Install]
WantedBy=multi-user.target

# Deploy service
$ cp xvfb.service /etc/systemd/system/xvfb.service
$ sudo systemctl enable xvfb.service && sudo systemctl start xvfb.service && sudo systemctl status xvfb.service
$ sudo systemctl daemon-reload

# Create binary
$ printf '#!/bin/bash\nxvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $*' > /usr/bin/wkhtmltopdf.sh
$ chmod a+x /usr/bin/wkhtmltopdf.sh
$ ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf

# Run a test
$ wkhtmltopdf http://www.google.com output.pdf
```

### Run service

when executed, server is configured to listen on all interfaces on port 80. It means, you need to get root permission to open socket on that particular port
Expand Down