Skip to content

Commit

Permalink
Changed tasks naming
Browse files Browse the repository at this point in the history
  • Loading branch information
erjac77 committed Feb 9, 2021
1 parent 79b3140 commit 48ee1cf
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 93 deletions.
18 changes: 9 additions & 9 deletions .nornir.meta
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ intro_file: README.md
connection_plugins:
- nornir_f5.plugins.connections.F5RestClient
task_plugins:
- nornir_f5.plugins.tasks.f5_atc
- nornir_f5.plugins.tasks.f5_bigip_cm_failover_status
- nornir_f5.plugins.tasks.f5_bigip_cm_sync_config
- nornir_f5.plugins.tasks.f5_bigip_cm_sync_status
- nornir_f5.plugins.tasks.f5_bigip_shared_file_transfer_uploads
- nornir_f5.plugins.tasks.f5_bigip_shared_iapp_lx_package
- nornir_f5.plugins.tasks.f5_bigip_sys_version
- nornir_f5.plugins.tasks.f5_bigip_util_unix_ls
- nornir_f5.plugins.tasks.f5_bigip_util_unix_rm
- nornir_f5.plugins.tasks.atc
- nornir_f5.plugins.tasks.bigip_cm_failover_status
- nornir_f5.plugins.tasks.bigip_cm_sync_config
- nornir_f5.plugins.tasks.bigip_cm_sync_status
- nornir_f5.plugins.tasks.bigip_shared_file_transfer_uploads
- nornir_f5.plugins.tasks.bigip_shared_iapp_lx_package
- nornir_f5.plugins.tasks.bigip_sys_version
- nornir_f5.plugins.tasks.bigip_util_unix_ls
- nornir_f5.plugins.tasks.bigip_util_unix_rm
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ from nornir.core.task import Result, Task
from nornir_utils.plugins.functions import print_result

from nornir_f5.plugins.tasks import (
f5_atc,
f5_bigip_cm_config_sync,
f5_bigip_cm_failover_status,
atc,
bigip_cm_config_sync,
bigip_cm_failover_status,
)

def as3_post(task: Task, as3_tenant: str) -> Result:
# Get the failover status of the device.
failover_status = task.run(
name="Get failover status", task=f5_bigip_cm_failover_status
name="Get failover status", task=bigip_cm_failover_status
).result

# If it's the ACTIVE device, send the declaration and perform a sync.
if failover_status == "ACTIVE":
task.run(
name="AS3 POST",
task=f5_atc,
task=atc,
atc_method="POST",
atc_service="AS3",
as3_tenant=as3_tenant,
Expand All @@ -57,7 +57,7 @@ def as3_post(task: Task, as3_tenant: str) -> Result:

task.run(
name="Synchronize the devices",
task=f5_bigip_cm_config_sync,
task=bigip_cm_config_sync,
device_group=task.host["device_group"],
)

Expand Down Expand Up @@ -85,24 +85,24 @@ print_result(result)

### Connections

* __f5__: Connect to F5 BIG-IP systems using REST APIs.
* __f5__: Connects to an F5 REST server.

### Tasks

* __f5_atc__: Deploy an F5 Automation Toolchain (ATC) declaration (AS3, DO and TS*) on a BIG-IP system.
* __f5_bigip_cm_config_sync__: Synchronize the configuration between BIG-IP systems.
* __f5_bigip_cm_failover_status__: Get the failover status of the BIG-IP system.
* __f5_bigip_cm_sync_status__: Get the configuration synchronization status of the BIG-IP system.
* __f5_bigip_shared_file_transfer_uploads__: Upload a file to a BIG-IP system.
* __f5_bigip_shared_iapp_lx_package__: Manage Javascript LX packages on a BIG-IP system.
* __f5_bigip_sys_version__: Get software version information for the BIG-IP system.
* __f5_bigip_util_unix_ls__: List information about the FILEs or directory content on a BIG-IP system.
* __f5_bigip_util_unix_rm__: Delete a file on a BIG-IP system.
* __atc__: Sends F5 Automation Toolchain (ATC) declaratives (like AS3, DO and TS) on a BIG-IP/BIG-IQ system.
* __bigip_cm_config_sync__: Synchronizes the configuration between BIG-IP systems.
* __bigip_cm_failover_status__: Gets the failover status of the BIG-IP system.
* __bigip_cm_sync_status__: Gets the configuration synchronization status of the BIG-IP system.
* __bigip_shared_file_transfer_uploads__: Uploads a file to a BIG-IP system.
* __bigip_shared_iapp_lx_package__: Manages Javascript LX packages on a BIG-IP system.
* __bigip_sys_version__: Gets software version information for the BIG-IP system.
* __bigip_util_unix_ls__: Lists information about the FILEs or directory content on a BIG-IP system.
* __bigip_util_unix_rm__: Deletes a file on a BIG-IP system.

## Roadmap

* ATC:
* *Support Telemetry (TS)
* Support Telemetry (TS)
* Support BIG-IQ
* Support dry-run mode

Expand Down
36 changes: 18 additions & 18 deletions nornir_f5/plugins/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
"""Nornir F5 tasks."""

from nornir_f5.plugins.tasks.atc import f5_atc
from nornir_f5.plugins.tasks.bigip.cm.config_sync import f5_bigip_cm_config_sync
from nornir_f5.plugins.tasks.bigip.cm.failover_status import f5_bigip_cm_failover_status
from nornir_f5.plugins.tasks.bigip.cm.sync_status import f5_bigip_cm_sync_status
from nornir_f5.plugins.tasks.atc import atc
from nornir_f5.plugins.tasks.bigip.cm.config_sync import bigip_cm_config_sync
from nornir_f5.plugins.tasks.bigip.cm.failover_status import bigip_cm_failover_status
from nornir_f5.plugins.tasks.bigip.cm.sync_status import bigip_cm_sync_status
from nornir_f5.plugins.tasks.bigip.shared.file_transfer.uploads import (
f5_bigip_shared_file_transfer_uploads,
bigip_shared_file_transfer_uploads,
)
from nornir_f5.plugins.tasks.bigip.shared.iapp.package_management_tasks import (
f5_bigip_shared_iapp_lx_package,
bigip_shared_iapp_lx_package,
)
from nornir_f5.plugins.tasks.bigip.sys.version import f5_bigip_sys_version
from nornir_f5.plugins.tasks.bigip.util.unix_ls import f5_bigip_util_unix_ls
from nornir_f5.plugins.tasks.bigip.util.unix_rm import f5_bigip_util_unix_rm
from nornir_f5.plugins.tasks.bigip.sys.version import bigip_sys_version
from nornir_f5.plugins.tasks.bigip.util.unix_ls import bigip_util_unix_ls
from nornir_f5.plugins.tasks.bigip.util.unix_rm import bigip_util_unix_rm

__all__ = (
"f5_atc",
"f5_bigip_cm_config_sync",
"f5_bigip_cm_failover_status",
"f5_bigip_cm_sync_status",
"f5_bigip_shared_file_transfer_uploads",
"f5_bigip_shared_iapp_lx_package",
"f5_bigip_sys_version",
"f5_bigip_util_unix_ls",
"f5_bigip_util_unix_rm",
"atc",
"bigip_cm_config_sync",
"bigip_cm_failover_status",
"bigip_cm_sync_status",
"bigip_shared_file_transfer_uploads",
"bigip_shared_iapp_lx_package",
"bigip_sys_version",
"bigip_util_unix_ls",
"bigip_util_unix_rm",
)
4 changes: 2 additions & 2 deletions nornir_f5/plugins/tasks/atc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def _build_as3_endpoint(
atc_config_endpoint: str,
atc_method: str,
as3_version: str,
as3_tenant: str = "",
as3_show: str = "",
as3_show_hash: bool = False,
as3_tenant: str = "",
) -> str:
# Setup AS3 endpoint with specified tenant when tenant specified
if as3_tenant and (
Expand Down Expand Up @@ -167,7 +167,7 @@ def _wait_task(
raise Exception("The task has reached maximum retries.")


def f5_atc(
def atc(
task: Task,
as3_show: str = "base",
as3_show_hash: bool = False,
Expand Down
8 changes: 4 additions & 4 deletions nornir_f5/plugins/tasks/bigip/cm/config_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from nornir.core.task import Result, Task

from nornir_f5.plugins.connections import f5_rest_client
from nornir_f5.plugins.tasks.bigip.cm.sync_status import f5_bigip_cm_sync_status
from nornir_f5.plugins.tasks.bigip.cm.sync_status import bigip_cm_sync_status

SYNC_DIRECTION_OPTIONS = ["to-group", "from-group"]


def f5_bigip_cm_config_sync(
def bigip_cm_config_sync(
task: Task,
device_group: str,
delay: int = 6,
Expand Down Expand Up @@ -46,7 +46,7 @@ def f5_bigip_cm_config_sync(
"""
sync_status = task.run(
name="Get the sync status",
task=f5_bigip_cm_sync_status,
task=bigip_cm_sync_status,
severity_level=logging.DEBUG,
).result

Expand All @@ -66,7 +66,7 @@ def f5_bigip_cm_config_sync(
time.sleep(delay)
sync_status = task.run(
name=f"Get the sync status (attempt {retry}/{retries})",
task=f5_bigip_cm_sync_status,
task=bigip_cm_sync_status,
severity_level=logging.DEBUG,
).result

Expand Down
2 changes: 1 addition & 1 deletion nornir_f5/plugins/tasks/bigip/cm/failover_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nornir_f5.plugins.connections import f5_rest_client


def f5_bigip_cm_failover_status(task: Task) -> Result:
def bigip_cm_failover_status(task: Task) -> Result:
"""Task to get the failover status of the device.
Args:
Expand Down
2 changes: 1 addition & 1 deletion nornir_f5/plugins/tasks/bigip/cm/sync_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nornir_f5.plugins.connections import f5_rest_client


def f5_bigip_cm_sync_status(task: Task) -> Result:
def bigip_cm_sync_status(task: Task) -> Result:
"""Task to get the synchronization status of the device.
Args:
Expand Down
4 changes: 2 additions & 2 deletions nornir_f5/plugins/tasks/bigip/shared/file_transfer/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _upload_file(
return Result(host=task.host, result="The file was uploaded successfully.")


def f5_bigip_shared_file_transfer_uploads(
def bigip_shared_file_transfer_uploads(
task: Task, local_file_path: str, destination_file_name: str = None
) -> Result:
"""Upload a file to a BIG-IP system using the iControl REST API.
Expand All @@ -63,7 +63,7 @@ def f5_bigip_shared_file_transfer_uploads(
on the remote device.
Returns:
Result: True if the upload was succesful.
Result: The result of the task.
"""
host = f"{task.host.hostname}:{task.host.port}"
uri = f"{FILE_TRANSFER_OPTIONS['file']['endpoints']['uploads']['uri']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from nornir_f5.plugins.connections import f5_rest_client
from nornir_f5.plugins.tasks.bigip.shared.file_transfer.uploads import (
FILE_TRANSFER_OPTIONS,
f5_bigip_shared_file_transfer_uploads,
bigip_shared_file_transfer_uploads,
)
from nornir_f5.plugins.tasks.bigip.sys.version import f5_bigip_sys_version
from nornir_f5.plugins.tasks.bigip.util.unix_ls import f5_bigip_util_unix_ls
from nornir_f5.plugins.tasks.bigip.util.unix_rm import f5_bigip_util_unix_rm
from nornir_f5.plugins.tasks.bigip.sys.version import bigip_sys_version
from nornir_f5.plugins.tasks.bigip.util.unix_ls import bigip_util_unix_ls
from nornir_f5.plugins.tasks.bigip.util.unix_rm import bigip_util_unix_rm


def _wait_task(
Expand Down Expand Up @@ -43,7 +43,7 @@ def _wait_task(
raise Exception("The task has reached maximum retries.")


def f5_bigip_shared_iapp_lx_package(
def bigip_shared_iapp_lx_package(
task: Task,
package: str,
delay: int = 3,
Expand Down Expand Up @@ -73,7 +73,7 @@ def f5_bigip_shared_iapp_lx_package(
client = f5_rest_client(task)

# Check if LX is supported on the BIG-IP
version = task.run(name="Get system version", task=f5_bigip_sys_version).result
version = task.run(name="Get system version", task=bigip_sys_version).result
if Version(version) < Version("12.0.0"):
raise Exception(f"BIG-IP version '{version}' is not supported.")

Expand All @@ -84,14 +84,14 @@ def f5_bigip_shared_iapp_lx_package(
# Check if the file exists on the device
content = task.run(
name="List content",
task=f5_bigip_util_unix_ls,
task=bigip_util_unix_ls,
file_path=remote_package_path,
).result
if "No such file or directory" in content:
# Upload the RPM on the BIG-IP
task.run(
name="Upload the RPM on the BIG-IP",
task=f5_bigip_shared_file_transfer_uploads,
task=bigip_shared_file_transfer_uploads,
local_file_path=package,
)

Expand Down Expand Up @@ -133,7 +133,7 @@ def f5_bigip_shared_iapp_lx_package(
if not retain_package_file:
task.run(
name="Remove LX package",
task=f5_bigip_util_unix_rm,
task=bigip_util_unix_rm,
file_path=remote_package_path,
)
return Result(
Expand Down
2 changes: 1 addition & 1 deletion nornir_f5/plugins/tasks/bigip/sys/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nornir_f5.plugins.connections import f5_rest_client


def f5_bigip_sys_version(task: Task) -> Result:
def bigip_sys_version(task: Task) -> Result:
"""Gets the system version of the BIG-IP.
Args:
Expand Down
2 changes: 1 addition & 1 deletion nornir_f5/plugins/tasks/bigip/util/unix_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nornir_f5.plugins.connections import f5_rest_client


def f5_bigip_util_unix_ls(task: Task, file_path: str) -> Result:
def bigip_util_unix_ls(task: Task, file_path: str) -> Result:
"""Task to list information about the FILEs.
Args:
Expand Down
2 changes: 1 addition & 1 deletion nornir_f5/plugins/tasks/bigip/util/unix_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nornir_f5.plugins.connections import f5_rest_client


def f5_bigip_util_unix_rm(task: Task, file_path: str) -> Result:
def bigip_util_unix_rm(task: Task, file_path: str) -> Result:
"""Task to delete a file from a BIG-IP system.
Args:
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/test_atc_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

import responses
from nornir_f5.plugins.tasks import f5_atc
from nornir_f5.plugins.tasks import atc

from .conftest import assert_result, base_decl_dir, base_resp_dir, load_json

Expand Down Expand Up @@ -245,7 +245,7 @@ def get_task_callback(request):
nornir = nornir.filter(name="bigip1.localhost")
result = nornir.run(
name="Deploy AS3 Declaration",
task=f5_atc,
task=atc,
atc_delay=0,
atc_retries=3,
**kwargs,
Expand Down Expand Up @@ -335,7 +335,7 @@ def get_task_callback(request):
nornir = nornir.filter(name="bigip1.localhost")
result = nornir.run(
name="Deploy DO Declaration",
task=f5_atc,
task=atc,
atc_delay=0,
atc_retries=3,
**kwargs,
Expand Down
Loading

0 comments on commit 48ee1cf

Please sign in to comment.