Skip to content

Commit

Permalink
Adding 0.7.0 changes (#73)
Browse files Browse the repository at this point in the history
* Adding extra tag

* Updating pydantic and fixing changelog.md

* Refactoring verify_connector_and_id

* Fixing formatting

* Upload image (#63)

* minimal GNS3 version

* Added compute image upload method.

Co-authored-by: louis-oui <[email protected]>

* Upgrading to poetry v1.0 (#67)

* Enhancement py38 support (#68)

* Updating and fixing envlist in tox

* Adding tox-conda requirements and changing image on circleci

* Fixing step to install poetry

* Adding python 3.8 in classifiers

* Enhancement docker dev environment (#69)

* Adding devcontainer for vscode standardized testing

* Fixing the project close method update and wrap docstring

* fixing tests and adding some docs (#72)

Co-authored-by: Scott Keiffer <[email protected]>
Co-authored-by: louis-oui <[email protected]>
  • Loading branch information
3 people authored May 8, 2020
1 parent d1f8e81 commit 9e0ba6d
Show file tree
Hide file tree
Showing 13 changed files with 1,319 additions and 301 deletions.
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ orbs:
jobs:
build:
docker:
- image: circleci/python:3.7
# - image: circleci/python:3.7
- image: continuumio/miniconda3
steps:
- checkout
- restore_cache:
keys:
# - deps-{{ checksum "poetry.lock" }}
- deps-clear
- run:
name: Install Poetry
command: |
pip install poetry
poetry config virtualenvs.create false
- run:
name: Install Dependencies
command: |
poetry install
poetry install --no-interaction
- run:
name: Run flake8
command: |
Expand All @@ -42,8 +48,8 @@ jobs:
# key: deps-{{ checksum "poetry.lock" }}
key: deps-clear
paths:
- /home/circleci/.cache/pypoetry/virtualenvs
- /home/circleci/.cache/.tox
- /root/.cache/pypoetry/virtualenvs
- /root/.cache/.tox
- run:
name: Running tests
command: |
Expand Down
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Inspired from:
# https://github.com/nornir-automation/nornir/blob/develop/Dockerfile
# https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda
FROM continuumio/miniconda3

WORKDIR /gns3fy
ENV PATH="/root/.poetry/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -yq curl git openssh-client less iproute2 procps iproute2 lsb-release make \
&& curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python \
&& poetry config virtualenvs.create false \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

COPY pyproject.toml .
COPY poetry.lock .

RUN poetry install --no-interaction
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "gns3fy - Miniconda",
"context": "..",
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/opt/conda/bin/python",
"python.linting.enabled": true,
"python.linting.pylintPath": "/opt/conda/bin/pylint",
"python.formatting.blackPath": "/opt/conda/bin/black",
"python.formatting.provider": "black",
"python.linting.pylintEnabled": false,
"python.linting.flake8Path": "/opt/conda/bin/flake8",
"python.linting.flake8Enabled": true,
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
]
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "make docker-settings",
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ build:

publish:
poetry publish

docker-settings:
cp .vscode/docker-settings.json .vscode/settings.json

local-settings:
cp .vscode/local-settings.json .vscode/settings.json
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# gns3fy

[![Circle CI](https://circleci.com/gh/davidban77/gns3fy/tree/develop.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/davidban77/gns3fy/tree/develop)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![codecov](https://codecov.io/gh/davidban77/gns3fy/branch/develop/graph/badge.svg)](https://codecov.io/gh/davidban77/gns3fy)
Expand All @@ -6,8 +8,6 @@
[![pypi](https://img.shields.io/pypi/v/gns3fy.svg)](https://pypi.python.org/pypi/gns3fy)
[![versions](https://img.shields.io/pypi/pyversions/gns3fy.svg)](https://github.com/davidban77/gns3fy)


# gns3fy
Python wrapper around [GNS3 Server API](http://api.gns3.net/en/2.2/index.html). Minimal GNS3 version is 2.2.

Its main objective is to interact with the GNS3 server in a programatic way, so it can be integrated with the likes of Ansible, docker and scripts. Ideal for network CI/CD pipeline tooling.
Expand All @@ -28,7 +28,7 @@ Here are some examples where gns3fy is used in a programmatic way:

## Install

```
```shell
pip install gns3fy
```

Expand Down
69 changes: 42 additions & 27 deletions docs/content/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,68 @@
# Upgrading
# Upgrading and releases history

```
```shell
pip install -U gns3fy
```

# Releases
## Releases

## 0.6.0
### 0.7.0

**Enhancement:**

- Ability to manipulate SVGs. Added new methods: `create_drawing`, `update_drawing`, `delete_drawing` and `get_drawing`. Ref #66
- Added a `drawing_utils.py` module that have some helper functions to generate SVGs in the Project: `generate_rectangle_svg`, `generate_line_svg` and `generate_ellipse_svg`. Also `parsed_x` and `parsed_y` that helps positions the Nodes and drawings in the canvas.
- Python 3.8 support. Ref #68
- Added `upload_compute_image` to the `Gns3Connector` object. Thanks @skeiffer for the contribution. Ref #62

**Fix:**

- Fixes issue closing Project. Ref #71
- Update poetry and fix CI. Ref #64

### 0.6.0

**Enhancement:**

- Added `drawings` attribute. Used to gather information from `Drawing` endpoint, and for that there is also the `get_drawings` method.
- Added `arrange_nodes_circular` method, which as the name indicates it will arrange the nodes configured on a project in a circular fashion.
- Added `arrange_nodes_circular` method, which as the name indicates it will arrange the nodes configured on a project in a circular fashion. Thanks @Krlosromero for the contribution.

## 0.5.2
### 0.5.2

**Enhancement:**

- Added `restore_snapshot` to the available snapshot methods of a project

## 0.5.1
### 0.5.1

**Fix:**

- Argument specification for project snapshot methods
- Cred argument for user-based authentication with a GNS3 server

## 0.5.0
### 0.5.0

**New features:**

- Extended templates functionality with `create_template`, `update_template` and `delete_template`. Which can be used for migrating templates between GNS3 servers

- Added compute endpoint get method from the REST API. [Compute endpoint](http://api.gns3.net/en/2.2/api/v2/controller/compute.html)
- `get_computes`: Retrieves attributes and characteristics of the GNS3 server compute that will run the emulations.
- `get_compute_images`: Lists images configured for a specific emulator on a compute.
- `get_compute_ports`: Lists configured and used console ports and UDP ports on a compute.
- `get_computes`: Retrieves attributes and characteristics of the GNS3 server compute that will run the emulations.
- `get_compute_images`: Lists images configured for a specific emulator on a compute.
- `get_compute_ports`: Lists configured and used console ports and UDP ports on a compute.

- Added projects snapshots attribute and methods. [Snapshots endpoint](http://api.gns3.net/en/2.2/api/v2/controller/snapshot.html)
- `snapshots`: Attribute that stores snapshots names, IDs and created times of a project. Updated by the `get_snapshots` method.
- `get_snapshot`: Retrieves an specific snapshot information.
- `create_snapshot` and `delete_snapshot`: Creates/Delete an specific snapshot
- `snapshots`: Attribute that stores snapshots names, IDs and created times of a project. Updated by the `get_snapshots` method.
- `get_snapshot`: Retrieves an specific snapshot information.
- `create_snapshot` and `delete_snapshot`: Creates/Delete an specific snapshot

## 0.4.1
### 0.4.1

**Fix:**

- Dependency of python to start at version 3.6

## 0.4.0
### 0.4.0

**New features:**

Expand All @@ -58,16 +72,16 @@ pip install -U gns3fy

- A "template not found" message, when creating a `Node` specifiying a missing/wrong template name.

## 0.3.0
### 0.3.0

**Enhancement:**

- `tox` for pipeline testing. https://github.com/davidban77/gns3fy/pull/15
- `projects_summary` and `templates_summary` methods for `Gns3Connector`. https://github.com/davidban77/gns3fy/pull/17
- Improved `nodes_inventory` method. https://github.com/davidban77/gns3fy/pull/23
- Refactor of `Node` creation, basically changed the API endpoint from Node to Template. https://github.com/davidban77/gns3fy/pull/27
- `tox` for pipeline testing. [PR-15](https://github.com/davidban77/gns3fy/pull/15)
- `projects_summary` and `templates_summary` methods for `Gns3Connector`. [PR-17](https://github.com/davidban77/gns3fy/pull/17)
- Improved `nodes_inventory` method. [PR-23](https://github.com/davidban77/gns3fy/pull/23)
- Refactor of `Node` creation, basically changed the API endpoint from Node to Template. [PR-27](https://github.com/davidban77/gns3fy/pull/27)

## 0.2.0
### 0.2.0

**New features:**

Expand All @@ -77,15 +91,16 @@ pip install -U gns3fy
- Created the `docs`
- Improved the tests and coverage
- Added CircleCI with the following checks:
- flake8
- black formatting
- pytest
- flake8
- black formatting
- pytest

## 0.1.1
### 0.1.1

**Enhancement:**

- Adding `Gns3Connector` method `get_version`

## 0.1.0
### 0.1.0

- Initial Push
61 changes: 61 additions & 0 deletions gns3fy/drawing_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Functions used as helpers for drawing objects in a GNS3 Project.
"""


def generate_rectangle_svg(
height: int = 100,
width: int = 200,
fill: str = "#ffffff",
fill_opacity: float = 1.0,
stroke: str = "#000000",
stroke_width: int = 2,
) -> str:
return (
f'<svg height="{height}" width="{width}"><rect fill="{fill}" fill-opacity="'
f'{fill_opacity}" height="{height}" stroke="{stroke}" stroke-width="'
f'{stroke_width}" width="{width}" /></svg>'
)


def generate_ellipse_svg(
height: float = 200.0,
width: float = 200.0,
cx: int = 100,
cy: int = 100,
fill: str = "#ffffff",
fill_opacity: float = 1.0,
rx: int = 100,
ry: int = 100,
stroke: str = "#000000",
stroke_width: int = 2,
) -> str:
return (
f'<svg height="{height}" width="{width}"><ellipse cx="{cx}" cy="{cy}" fill="'
f'{fill}" fill-opacity="{fill_opacity}" rx="{rx}" ry="{ry}" stroke="{stroke}" '
f'stroke-width="{stroke_width}" /></svg>'
)


def generate_line_svg(
height: int = 0,
width: int = 200,
x1: int = 0,
x2: int = 200,
y1: int = 0,
y2: int = 0,
stroke: str = "#000000",
stroke_width: int = 2,
) -> str:
return (
f'<svg height="{height}" width="{width}"><line stroke="{stroke}" stroke-width="'
f'{stroke_width}" x1="{x1}" x2="{x2}" y1="{y1}" y2="{y2}" /></svg>'
)


def parsed_x(x: int, obj_width: int = 100) -> int:
return x * obj_width


def parsed_y(y: int, obj_height: int = 100) -> int:
return (y * obj_height) * -1
Loading

0 comments on commit 9e0ba6d

Please sign in to comment.