@@ -99,7 +99,6 @@ def reference_lookup(self, resource_table_id, tag_type):
9999 service = self .type_to_service (tag_type )
100100 if service is None :
101101 raise SoftLayerAPIError (404 , "Unable to lookup {} types" .format (tag_type ))
102- # return {}
103102 return self .client .call (service , 'getObject' , id = resource_table_id )
104103
105104 def delete_tag (self , name ):
@@ -182,6 +181,26 @@ def type_to_service(tag_type):
182181 service = re .sub (r'(^[a-z]|\_[a-z])' , lambda x : x .group ().upper (), tag_type )
183182 return service
184183
184+ @staticmethod
185+ def get_resource_name (resource , tag_type ):
186+ """Returns a string that names a resource
187+
188+ :param dict resource: A SoftLayer datatype for the given tag_type
189+ :param string tag_type: Key name for the tag_type
190+ """
191+ if tag_type == 'NETWORK_VLAN_FIREWALL' :
192+ return resource .get ('primaryIpAddress' )
193+ elif tag_type == 'NETWORK_VLAN' :
194+ return "{} ({})" .format (resource .get ('vlanNumber' ), resource .get ('name' ))
195+ elif tag_type == 'IMAGE_TEMPLATE' or tag_type == 'APPLICATION_DELIVERY_CONTROLLER' :
196+ return resource .get ('name' )
197+ elif tag_type == 'TICKET' :
198+ return resource .get ('subjet' )
199+ elif tag_type == 'NETWORK_SUBNET' :
200+ return resource .get ('networkIdentifier' )
201+ else :
202+ return resource .get ('fullyQualifiedDomainName' )
203+
185204 # @staticmethod
186205 # def type_to_datatype(tag_type):
187206 # """Returns the SoftLayer datatye for the given tag_type"""
0 commit comments