39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
|
class ServiceBase :
|
||
|
config = {}
|
||
|
namespace = {}
|
||
|
data = {}
|
||
|
_status = "Ready"
|
||
|
_subjects = []
|
||
|
def __init__(self,config,namespace,subjects,dossiercopy):
|
||
|
if not config or config == {} :
|
||
|
self.results.update({"No configuration found":"Nothing to do"})
|
||
|
self._status = "Error"
|
||
|
else :
|
||
|
self.config = config
|
||
|
self.data = dossiercopy
|
||
|
self.namespace = namespace
|
||
|
self._subjects = subjects
|
||
|
pass
|
||
|
|
||
|
def _lookup_subjects(self) :
|
||
|
finaldictionary = {}
|
||
|
for item in self._subjects :
|
||
|
finaldictionary.update({item:self.perform_lookup(item)})
|
||
|
return finaldictionary
|
||
|
|
||
|
def get_arguments() :
|
||
|
"""Returns an array of information used to construct an argumentparser argument."""
|
||
|
# [ <short flag>,<unix flag>,<arg type>,<description> ]
|
||
|
# Example return: [ '-n', '--net', 'store_true', "Output network information about the subject" ]
|
||
|
return None
|
||
|
|
||
|
def perform_lookup(self,host_tuple) :
|
||
|
"""Returns a JSON string with lookup information about the given IP or Hostname."""
|
||
|
# Host tuple is a socket triple (hostname, aliaslist, ipaddrlist) where hostname is
|
||
|
# the primary host name responding to the given ip_address, aliaslist is a (possibly
|
||
|
# empty) tuple of alternative host names for the same address, and ipaddrlist is a tuple
|
||
|
# of IPv4/v6 addresses for the same interface on the same host (most likely containing
|
||
|
# only a single address).
|
||
|
return None
|
||
|
|