Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projects and template summary #17

Merged
merged 2 commits into from
Aug 19, 2019
Merged
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
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- checkout
- restore_cache:
keys:
- deps-{{ checksum "poetry.lock" }}
# - deps-clear
# - deps-{{ checksum "poetry.lock" }}
- deps-clear
- run:
name: Install Dependencies
command: |
Expand All @@ -39,8 +39,8 @@ jobs:
command: |
poetry run tox
- save_cache:
key: deps-{{ checksum "poetry.lock" }}
# key: deps-clear
# key: deps-{{ checksum "poetry.lock" }}
key: deps-clear
paths:
- /home/circleci/.cache/pypoetry/virtualenvs
- /home/circleci/.cache/.tox
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,26 @@ For example:

```python
>>> import gns3fy
>>> from tabulate import tabulate

# Define the server object to establish the connection
>>> gns3_server = gns3fy.Gns3Connector("http://<server address>:3080")

# Show the available projects on the server
>>> print(
tabulate(
gns3_server.projects_summary(is_print=False),
headers=["Project Name", "Project ID", "Total Nodes", "Total Links", "Status"],
)
)
"""
Project Name Project ID Total Nodes Total Links Status
-------------- ------------------------------------ ------------- ------------- --------
test2 c9dc56bf-37b9-453b-8f95-2845ce8908e3 10 9 opened
API_TEST 4b21dfb3-675a-4efa-8613-2f7fb32e76fe 6 4 opened
mpls-bgpv2 f5de5917-0ac5-4850-82b1-1d7e3c777fa1 30 40 closed
"""

# Define the lab you want to load and assign the server connector
>>> lab = gns3fy.Project(name="API_TEST", connector=gns3_server)

Expand Down
3 changes: 2 additions & 1 deletion docs/content/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

**Added:**

- `tox` for pipeline testing
- `tox` for pipeline testing.
- `projects_summary` and `templates_summary` methods for `Gns3Connector`.

## 0.2.0

Expand Down
22 changes: 22 additions & 0 deletions docs/content/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def get_version(self)

Returns the version information of GNS3 server

### `Gns3Connector.projects_summary()`

```python
def projects_summary(self, is_print=True)
```

Returns a summary of the projects in the server. If `is_print` is `False`, it
will return a list of tuples like:

`[(name, project_id, total_nodes, total_links, status) ...]`

### `Gns3Connector.get_projects()`

```python
Expand All @@ -86,6 +97,17 @@ Retrieves a project from either a name or ID

- `name` or `project_id`

### `Gns3Connector.templates_summary()`

```python
def templates_summary(self, is_print=True)
```

Returns a summary of the templates in the server. If `is_print` is `False`, it
will return a list of tuples like:

`[(name, template_id, template_type, builtin, console_type, category) ...]`

### `Gns3Connector.get_templates()`

```python
Expand Down
Loading