mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
rename command to execution
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
@@ -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):
|
@@ -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."""
|
@@ -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):
|
Reference in New Issue
Block a user