Check template_id attr exists within template
This commit is contained in:
		
					parent
					
						
							
								85b251d2e6
							
						
					
				
			
			
				commit
				
					
						6a5a5ed160
					
				
			
		
					 1 changed files with 7 additions and 6 deletions
				
			
		|  | @ -138,12 +138,13 @@ class VirtualMachineSerializer(serializers.Serializer): | ||||||
| 
 | 
 | ||||||
|     def get_configuration(self, obj): |     def get_configuration(self, obj): | ||||||
|         if hasattr(obj, 'template'): |         if hasattr(obj, 'template'): | ||||||
|             template_id = obj.template.template_id |             if hasattr(obj, 'template.template_id'): | ||||||
|             template = OpenNebulaManager().get_template(template_id) |                 template_id = obj.template.template_id | ||||||
|             if template.name.startswith('public-'): |                 template = OpenNebulaManager().get_template(template_id) | ||||||
|                 return template.name.lstrip('public-') |                 if template.name.startswith('public-'): | ||||||
|             else: |                     return template.name.lstrip('public-') | ||||||
|                 return template.name |                 else: | ||||||
|  |                     return template.name | ||||||
|         else: |         else: | ||||||
|             return "" |             return "" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue