Let's work on some plugins\!

This commit is contained in:
Daniel Dayley 2019-12-04 12:00:50 -07:00
parent 472d87c0ce
commit 4f86b7621e
11 changed files with 28 additions and 14 deletions

32
ifxtool
View File

@ -25,6 +25,8 @@ class IFXTool():
servicedelegates = []
totalconfig = {}
_internal_messages = {}
_subjecttuples = []
_dnsmaps = {}
def __init__(self,delegates,arglist) :
self.servicedelegates = delegates
self.namespace = arglist
@ -56,7 +58,6 @@ class IFXTool():
def dispatch(self) :
# Resolve subject names
subjecttuples = []
for item in self.namespace.subjects :
try:
quicklookup = socket.gethostbyname(item)
@ -70,7 +71,8 @@ class IFXTool():
subjecttuple = tuple(['',[],[item]])
# Convert mutable types to immutable (to be used as dictionary keys)
immutablesubjecttuple = tuple([subjecttuple[0],tuple(subjecttuple[1]),tuple(subjecttuple[2])])
subjecttuples.append(immutablesubjecttuple)
self._dnsmaps.update({immutablesubjecttuple:item})
self._subjecttuples.append(immutablesubjecttuple)
# Stop on initialization error
if self.stopinfo != '' :
@ -86,9 +88,11 @@ class IFXTool():
delegateconfig = self.totalconfig[delegatename]
else :
delegateconfig = {}
delegateinstance = delegate(delegateconfig,self.namespace,subjecttuples,delegatereports)
print(delegatename + ": " + delegateinstance._status)
delegatereports.update({delegatename:delegateinstance._lookup_subjects()})
delegateinstance = delegate(delegateconfig,self.namespace,self._subjecttuples,delegatereports)
#print(delegatename + ": " + delegateinstance._status)
delegateresponse = delegateinstance._lookup_subjects()
if delegateresponse:
delegatereports.update({delegatename:delegateresponse})
# Format and display results
delegatereports.update(self._internal_messages)
@ -108,11 +112,21 @@ class IFXTool():
pass
def print_results(self,dataset) :
"""Prints the submitted dataset to the console"""
"""Returns the submitted dataset"""
finalresult = {}
for subject in self._subjecttuples :
subjectname = self._dnsmaps[subject]
subjectdataset = {}
for plugin in dataset:
subjectdataset.update({plugin:dataset[plugin][subject]})
finalresult.update({subjectname:subjectdataset})
if self.namespace.json :
print(json.dumps(dataset))
print(json.dumps(finalresult))
else :
yaml.dump(dataset,sys.stdout)
yaml.dump(finalresult,sys.stdout)
if __name__ == "__main__":
@ -130,7 +144,7 @@ if __name__ == "__main__":
parser.add_argument('-l', '--link', action='store_true', help="Return physical link information about the subject")
parser.add_argument('-c', '--config', action='store', help="Specify a config file (~/.config/ifxtool.yml by default)")
for delegate in delegates :
arguments = delegate.get_arguments()
arguments = delegate.get_arguments(delegate)
if arguments and len(arguments) == 4 :
parser.add_argument(arguments[0],arguments[1],action=arguments[2],help=arguments[3])
parser.add_argument('-a', '--all', action='store_true', help="Return all searchable information about the subject")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@ from servicebase import ServiceBase
class ServiceDelegate(ServiceBase) :
def get_arguments() :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
# [ <short flag>,<unix flag>,<arg type>,<description> ]
# Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]

View File

@ -2,7 +2,7 @@ from servicebase import ServiceBase
class ServiceDelegate(ServiceBase) :
def get_arguments() :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
# [ <short flag>,<unix flag>,<arg type>,<description> ]
# Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]

View File

@ -1,7 +1,7 @@
from servicebase import ServiceBase
class ServiceDelegate(ServiceBase) :
def get_arguments() :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
# [ <short flag>,<unix flag>,<arg type>,<description> ]
# Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]

View File

@ -1,7 +1,7 @@
from servicebase import ServiceBase
class ServiceDelegate(ServiceBase) :
def get_arguments() :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
# [ <short flag>,<unix flag>,<arg type>,<description> ]
# Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]

View File

@ -1,7 +1,7 @@
from servicebase import ServiceBase
class ServiceDelegate(ServiceBase) :
def get_arguments() :
def get_arguments(cls) :
"""Returns an array of information used to construct an argumentparser argument."""
# [ <short flag>,<unix flag>,<arg type>,<description> ]
# Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]