@ -49,7 +49,7 @@ class SoftLayerInventory(object):
' primaryBackendIpAddress ' ,
' primaryBackendIpAddress ' ,
' primaryIpAddress ' ,
' primaryIpAddress ' ,
' datacenter ' ,
' datacenter ' ,
' tagReferences .tag.name ' ,
' tagReferences ' ,
' userData.value ' ,
' userData.value ' ,
]
]
@ -82,7 +82,7 @@ class SoftLayerInventory(object):
self . get_all_servers ( )
self . get_all_servers ( )
print ( self . json_format_dict ( self . inventory , True ) )
print ( self . json_format_dict ( self . inventory , True ) )
elif self . args . host :
elif self . args . host :
self . get_ virtu al_servers( )
self . get_ al l_servers( )
print ( self . json_format_dict ( self . inventory [ " _meta " ] [ " hostvars " ] [ self . args . host ] , True ) )
print ( self . json_format_dict ( self . inventory [ " _meta " ] [ " hostvars " ] [ self . args . host ] , True ) )
def to_safe ( self , word ) :
def to_safe ( self , word ) :
@ -139,6 +139,12 @@ class SoftLayerInventory(object):
dest = instance [ ' primaryIpAddress ' ]
dest = instance [ ' primaryIpAddress ' ]
instance [ ' tags ' ] = list ( )
for tag in instance [ ' tagReferences ' ] :
instance [ ' tags ' ] . append ( tag [ ' tag ' ] [ ' name ' ] )
del instance [ ' tagReferences ' ]
self . inventory [ " _meta " ] [ " hostvars " ] [ dest ] = instance
self . inventory [ " _meta " ] [ " hostvars " ] [ dest ] = instance
# Inventory: group by memory
# Inventory: group by memory
@ -168,9 +174,8 @@ class SoftLayerInventory(object):
# Inventory: group by type (hardware/virtual)
# Inventory: group by type (hardware/virtual)
self . push ( self . inventory , instance_type , dest )
self . push ( self . inventory , instance_type , dest )
# Inventory: group by tag
for tag in instance [ ' tags ' ] :
for tag in instance [ ' tagReferences ' ] :
self . push ( self . inventory , tag , dest )
self . push ( self . inventory , tag [ ' tag ' ] [ ' name ' ] , dest )
def get_virtual_servers ( self ) :
def get_virtual_servers ( self ) :
''' Get all the CCI instances '''
''' Get all the CCI instances '''