Skip to content

Commit

Permalink
Merge pull request #5 from alsigna:dev-http
Browse files Browse the repository at this point in the history
dev-http
  • Loading branch information
alsigna authored Apr 17, 2021
2 parents 83b58a9 + c793984 commit 3d61bdb
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 505 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,19 @@ docker build -t netbox-plugin .
>Why FTP? Originally scp was used to transfer files, but based on experience, FTP is much faster.
>HTTP was added in 0.0.3, But FTP_USERNAME in configuration still required as it used as folder name for IOS upload
```shell
cd ftp
docker build -t ftp_for_netbox .
cd ../../
```
or
```shell
cd http
docker build -t http_for_netbox .
cd ../../
```
## 3. Change docker-compose.yml

```dockerfile
Expand Down Expand Up @@ -175,6 +183,16 @@ cd ../../
- USERS=software-images|ftp_password
# Your external (host) IP address, not contaner's IP
- ADDRESS=192.168.0.1

# simple http server
http:
image: http_for_netbox
ports:
- "80:80"
volumes:
# Mount folder with IOS images. FTP has RO only.
- ./netbox-software-manager/software-images:/usr/share/nginx/html:z,ro

```

## 4. Change NetBox configuration.py
Expand All @@ -193,7 +211,11 @@ PLUGINS_CONFIG = {
'FTP_USERNAME': 'software-images',
'FTP_PASSWORD': 'ftp_password',
'FTP_SERVER': '192.168.0.1',

# HTTP server name with patch to images
"HTTP_SERVER": "http://192.168.0./",
# Default transport method, can be also changed while scheduling task, [tfp|http]
"DEFAULT_TRANSFER_METHOD": "ftp",

# Log file
'UPGRADE_LOG_FILE': '/var/log/upgrade.log',
# Queue name. Check step 1. Should be the same
Expand Down
9 changes: 9 additions & 0 deletions http/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
autoindex on;
}
}
5 changes: 5 additions & 0 deletions http/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx

ADD default.conf /etc/nginx/conf.d/

# VOLUME ["/usr/share/nginx/html"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="netbox-plugin-software-manager",
version="0.0.2",
version="0.0.3",
description="Software Manager for Cisco IOS/IOS-XE devices",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion software_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SoftwareManager(PluginConfig):
name = "software_manager"
verbose_name = "Software Manager"
description = "Software Manager for Cisco IOS/IOS-XE devices"
version = "0.0.2"
version = "0.0.3"
author = "Alexander Ignatov"
author_email = "[email protected]"
required_settings = []
Expand Down
78 changes: 44 additions & 34 deletions software_manager/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,62 @@


class TaskTypeChoices(ChoiceSet):
TYPE_UPLOAD = 'upload'
TYPE_UPGRADE = 'upgrade'
TYPE_UPLOAD = "upload"
TYPE_UPGRADE = "upgrade"

CHOICES = (
(TYPE_UPLOAD, 'upload'),
(TYPE_UPGRADE, 'upgrade'),
(TYPE_UPLOAD, "upload"),
(TYPE_UPGRADE, "upgrade"),
)


class TaskTransferMethod(ChoiceSet):
METHOD_FTP = "ftp"
METHOD_HTTP = "http"

CHOICES = (
(METHOD_FTP, "ftp"),
(METHOD_HTTP, "http"),
)


class TaskStatusChoices(ChoiceSet):
STATUS_UNKNOWN = 'unknown'
STATUS_SCHEDULED = 'scheduled'
STATUS_FAILED = 'failed'
STATUS_RUNNING = 'running'
STATUS_SUCCEEDED = 'succeeded'
STATUS_SKIPPED = 'skipped'
STATUS_UNKNOWN = "unknown"
STATUS_SCHEDULED = "scheduled"
STATUS_FAILED = "failed"
STATUS_RUNNING = "running"
STATUS_SUCCEEDED = "succeeded"
STATUS_SKIPPED = "skipped"

CHOICES = (
(STATUS_UNKNOWN, 'unknown'),
(STATUS_SCHEDULED, 'scheduled'),
(STATUS_FAILED, 'failed'),
(STATUS_RUNNING, 'running'),
(STATUS_SUCCEEDED, 'succeeded'),
(STATUS_SKIPPED, 'skipped'),
(STATUS_UNKNOWN, "unknown"),
(STATUS_SCHEDULED, "scheduled"),
(STATUS_FAILED, "failed"),
(STATUS_RUNNING, "running"),
(STATUS_SUCCEEDED, "succeeded"),
(STATUS_SKIPPED, "skipped"),
)


class TaskFailReasonChoices(ChoiceSet):
FAIL_UNKNOWN = 'fail-unknown'
FAIL_CHECK = 'fail-check'
FAIL_LOGIN = 'fail-login'
FAIL_CONFIG = 'fail-config'
FAIL_CONNECT = 'fail-connect'
FAIL_GENERAL = 'fail-general'
FAIL_ADD = 'fail-add'
FAIL_UPGRADE = 'fail-upgrade'
FAIL_UPLOAD = 'fail-upload'
FAIL_UNKNOWN = "fail-unknown"
FAIL_CHECK = "fail-check"
FAIL_LOGIN = "fail-login"
FAIL_CONFIG = "fail-config"
FAIL_CONNECT = "fail-connect"
FAIL_GENERAL = "fail-general"
FAIL_ADD = "fail-add"
FAIL_UPGRADE = "fail-upgrade"
FAIL_UPLOAD = "fail-upload"

CHOICES = (
(FAIL_UNKNOWN, 'fail-unknown'),
(FAIL_CHECK, 'fail-check'),
(FAIL_LOGIN, 'fail-login'),
(FAIL_CONFIG, 'fail-config'),
(FAIL_CONNECT, 'fail-connect'),
(FAIL_GENERAL, 'fail-general'),
(FAIL_ADD, 'fail-add'),
(FAIL_UPGRADE, 'fail-upgrade'),
(FAIL_UPLOAD, 'fail-upload'),
(FAIL_UNKNOWN, "fail-unknown"),
(FAIL_CHECK, "fail-check"),
(FAIL_LOGIN, "fail-login"),
(FAIL_CONFIG, "fail-config"),
(FAIL_CONNECT, "fail-connect"),
(FAIL_GENERAL, "fail-general"),
(FAIL_ADD, "fail-add"),
(FAIL_UPGRADE, "fail-upgrade"),
(FAIL_UPLOAD, "fail-upload"),
)
Loading

0 comments on commit 3d61bdb

Please sign in to comment.