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