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
|
||||
|
||||
def get_configuration(self, obj):
|
||||
template_id = obj.template.template_id
|
||||
template = OpenNebulaManager().get_template(template_id)
|
||||
if template.name.startswith('public-'):
|
||||
return template.name.lstrip('public-')
|
||||
if hasattr(obj, 'template'):
|
||||
template_id = obj.template.template_id
|
||||
template = OpenNebulaManager().get_template(template_id)
|
||||
if template.name.startswith('public-'):
|
||||
return template.name.lstrip('public-')
|
||||
else:
|
||||
return template.name
|
||||
else:
|
||||
return template.name
|
||||
return ""
|
||||
|
||||
def get_ipv4(self, obj):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue