From db2415441054c22f1188369ebffa26170ecb9921 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Thu, 16 Jan 2020 02:36:56 -0700 Subject: [PATCH] rename command to execution --- hyperglass/__init__.py | 2 +- hyperglass/{command => execution}/.gitignore | 0 hyperglass/{command => execution}/__init__.py | 6 +++--- hyperglass/{command => execution}/construct.py | 4 ++-- hyperglass/{command => execution}/encode.py | 0 hyperglass/{command => execution}/execute.py | 18 +++++++++--------- hyperglass/{command => execution}/validate.py | 10 +++++----- 7 files changed, 20 insertions(+), 20 deletions(-) rename hyperglass/{command => execution}/.gitignore (100%) rename hyperglass/{command => execution}/__init__.py (63%) rename hyperglass/{command => execution}/construct.py (98%) rename hyperglass/{command => execution}/encode.py (100%) rename hyperglass/{command => execution}/execute.py (96%) rename hyperglass/{command => execution}/validate.py (98%) diff --git a/hyperglass/__init__.py b/hyperglass/__init__.py index 9518138..01aade3 100644 --- a/hyperglass/__init__.py +++ b/hyperglass/__init__.py @@ -46,7 +46,7 @@ import uvloop # Project Imports # flake8: noqa: F401 -from hyperglass import command +from hyperglass import execution from hyperglass import configuration from hyperglass import constants from hyperglass import exceptions diff --git a/hyperglass/command/.gitignore b/hyperglass/execution/.gitignore similarity index 100% rename from hyperglass/command/.gitignore rename to hyperglass/execution/.gitignore diff --git a/hyperglass/command/__init__.py b/hyperglass/execution/__init__.py similarity index 63% rename from hyperglass/command/__init__.py rename to hyperglass/execution/__init__.py index 1b910f7..d200351 100644 --- a/hyperglass/command/__init__.py +++ b/hyperglass/execution/__init__.py @@ -6,6 +6,6 @@ input, executes the commands/calls, returns the output to front end. # Project Imports # flake8: noqa: F401 -from hyperglass.command import construct -from hyperglass.command import execute -from hyperglass.command import validate +from hyperglass.execution import construct +from hyperglass.execution import execute +from hyperglass.execution import validate diff --git a/hyperglass/command/construct.py b/hyperglass/execution/construct.py similarity index 98% rename from hyperglass/command/construct.py rename to hyperglass/execution/construct.py index 89bc47b..db93b21 100644 --- a/hyperglass/command/construct.py +++ b/hyperglass/execution/construct.py @@ -53,8 +53,8 @@ class Construct: self.device = device self.query_data = query_data self.transport = transport - self.query_target = self.query_data["query_target"] - self.query_vrf = self.query_data["query_vrf"] + self.query_target = self.query_data.query_target + self.query_vrf = self.query_data.query_vrf self.device_vrf = self.get_device_vrf() def format_target(self, target): diff --git a/hyperglass/command/encode.py b/hyperglass/execution/encode.py similarity index 100% rename from hyperglass/command/encode.py rename to hyperglass/execution/encode.py diff --git a/hyperglass/command/execute.py b/hyperglass/execution/execute.py similarity index 96% rename from hyperglass/command/execute.py rename to hyperglass/execution/execute.py index 3097ecb..987e997 100644 --- a/hyperglass/command/execute.py +++ b/hyperglass/execution/execute.py @@ -19,10 +19,10 @@ from netmiko import NetmikoTimeoutError from netmiko import NetMikoTimeoutException # Project Imports -from hyperglass.command.construct import Construct -from hyperglass.command.encode import jwt_decode -from hyperglass.command.encode import jwt_encode -from hyperglass.command.validate import Validate +from hyperglass.execution.construct import Construct +from hyperglass.execution.encode import jwt_decode +from hyperglass.execution.encode import jwt_encode +from hyperglass.execution.validate import Validate from hyperglass.configuration import devices from hyperglass.configuration import params from hyperglass.constants import Supported @@ -54,8 +54,8 @@ class Connect: """ self.device = device self.query_data = query_data - self.query_type = self.query_data["query_type"] - self.query_target = self.query_data["query_target"] + self.query_type = self.query_data.query_type + self.query_target = self.query_data.query_target self.transport = transport self.query = getattr( Construct( @@ -331,9 +331,9 @@ class Execute: lg_data {object} -- Validated query object """ self.query_data = lg_data - self.query_location = self.query_data["query_location"] - self.query_type = self.query_data["query_type"] - self.query_target = self.query_data["query_target"] + self.query_location = self.query_data.query_location + self.query_type = self.query_data.query_type + self.query_target = self.query_data.query_target async def response(self): """Initiate query validation and execution.""" diff --git a/hyperglass/command/validate.py b/hyperglass/execution/validate.py similarity index 98% rename from hyperglass/command/validate.py rename to hyperglass/execution/validate.py index 631427d..994f82b 100644 --- a/hyperglass/command/validate.py +++ b/hyperglass/execution/validate.py @@ -137,7 +137,7 @@ def ip_access_list(query_data, device): Returns: {str} -- Allowed target """ - log.debug(f'Checking Access List for: {query_data["query_target"]}') + log.debug(f"Checking Access List for: {query_data.query_target}") def _member_of(target, network): """Check if IP address belongs to network. @@ -160,17 +160,17 @@ def ip_access_list(query_data, device): membership = True return membership - target = ipaddress.ip_network(query_data["query_target"]) + target = ipaddress.ip_network(query_data.query_target) vrf_acl = None for vrf in device.vrfs: - if vrf.name == query_data["query_vrf"]: + if vrf.name == query_data.query_vrf: vrf_acl = vrf.access_list if not vrf_acl: raise HyperglassError( message="Unable to match query VRF to any configured VRFs", alert="danger", - keywords=[query_data["query_vrf"]], + keywords=[query_data.query_vrf], ) target_ver = target.version @@ -289,7 +289,7 @@ class Validate: """Initialize device parameters and error codes.""" self.device = device self.query_data = query_data - self.query_type = self.query_data["query_type"] + self.query_type = self.query_data.query_type self.target = target def validate_ip(self):