Check if the template VM serializer object has template attr
This commit is contained in:
		
					parent
					
						
							
								9f58fdd456
							
						
					
				
			
			
				commit
				
					
						85b251d2e6
					
				
			
		
					 1 changed files with 8 additions and 5 deletions
				
			
		|  | @ -137,12 +137,15 @@ class VirtualMachineSerializer(serializers.Serializer): | ||||||
|         return price |         return price | ||||||
| 
 | 
 | ||||||
|     def get_configuration(self, obj): |     def get_configuration(self, obj): | ||||||
|  |         if hasattr(obj, 'template'): | ||||||
|             template_id = obj.template.template_id |             template_id = obj.template.template_id | ||||||
|             template = OpenNebulaManager().get_template(template_id) |             template = OpenNebulaManager().get_template(template_id) | ||||||
|             if template.name.startswith('public-'): |             if template.name.startswith('public-'): | ||||||
|                 return template.name.lstrip('public-') |                 return template.name.lstrip('public-') | ||||||
|             else: |             else: | ||||||
|                 return template.name |                 return template.name | ||||||
|  |         else: | ||||||
|  |             return "" | ||||||
| 
 | 
 | ||||||
|     def get_ipv4(self, obj): |     def get_ipv4(self, obj): | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue