@ -120,6 +120,9 @@ class CobblerInventory(object):
def _connect ( self ) :
if not self . conn :
self . conn = xmlrpclib . Server ( self . cobbler_host , allow_none = True )
self . token = None
if self . cobbler_username is not None :
self . token = self . conn . login ( self . cobbler_username , self . cobbler_password )
def is_cache_valid ( self ) :
""" Determines if the cache files have expired, or if it is still valid """
@ -140,6 +143,12 @@ class CobblerInventory(object):
config . read ( os . path . dirname ( os . path . realpath ( __file__ ) ) + ' /cobbler.ini ' )
self . cobbler_host = config . get ( ' cobbler ' , ' host ' )
self . cobbler_username = None
self . cobbler_password = None
if config . has_option ( ' cobbler ' , ' username ' ) :
self . cobbler_username = config . get ( ' cobbler ' , ' username ' )
if config . has_option ( ' cobbler ' , ' password ' ) :
self . cobbler_password = config . get ( ' cobbler ' , ' password ' )
# Cache related
cache_path = config . get ( ' cobbler ' , ' cache_path ' )
@ -163,8 +172,10 @@ class CobblerInventory(object):
self . _connect ( )
self . groups = dict ( )
self . hosts = dict ( )
data = self . conn . get_systems ( )
if self . token is not None :
data = self . conn . get_systems ( self . token )
else :
data = self . conn . get_systems ( )
for host in data :
# Get the FQDN for the host and add it to the right groups