diff --git a/ifxtool b/ifxtool index d4210b3..2e3bf53 100755 --- a/ifxtool +++ b/ifxtool @@ -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") diff --git a/plugins/__pycache__/aruba.cpython-37.pyc b/plugins/__pycache__/aruba.cpython-37.pyc new file mode 100644 index 0000000..a4398df Binary files /dev/null and b/plugins/__pycache__/aruba.cpython-37.pyc differ diff --git a/plugins/__pycache__/bluecat.cpython-37.pyc b/plugins/__pycache__/bluecat.cpython-37.pyc new file mode 100644 index 0000000..edfe753 Binary files /dev/null and b/plugins/__pycache__/bluecat.cpython-37.pyc differ diff --git a/plugins/__pycache__/f5.cpython-37.pyc b/plugins/__pycache__/f5.cpython-37.pyc new file mode 100644 index 0000000..b9b2708 Binary files /dev/null and b/plugins/__pycache__/f5.cpython-37.pyc differ diff --git a/plugins/__pycache__/openvpn.cpython-37.pyc b/plugins/__pycache__/openvpn.cpython-37.pyc new file mode 100644 index 0000000..7ae35cd Binary files /dev/null and b/plugins/__pycache__/openvpn.cpython-37.pyc differ diff --git a/plugins/__pycache__/paloalto.cpython-37.pyc b/plugins/__pycache__/paloalto.cpython-37.pyc new file mode 100644 index 0000000..dad9ef8 Binary files /dev/null and b/plugins/__pycache__/paloalto.cpython-37.pyc differ diff --git a/plugins/aruba.py b/plugins/aruba.py index 90783d0..2511919 100644 --- a/plugins/aruba.py +++ b/plugins/aruba.py @@ -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.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ] diff --git a/plugins/bluecat.py b/plugins/bluecat.py index dcec3a8..5378c2b 100644 --- a/plugins/bluecat.py +++ b/plugins/bluecat.py @@ -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.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ] diff --git a/plugins/f5.py b/plugins/f5.py index ed799d9..e1ac20a 100644 --- a/plugins/f5.py +++ b/plugins/f5.py @@ -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.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ] diff --git a/plugins/openvpn.py b/plugins/openvpn.py index 2b006b9..30dd964 100644 --- a/plugins/openvpn.py +++ b/plugins/openvpn.py @@ -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.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ] diff --git a/plugins/paloalto.py b/plugins/paloalto.py index d36018e..a10d5ad 100644 --- a/plugins/paloalto.py +++ b/plugins/paloalto.py @@ -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.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Return network information about the subject" ]