From 29c4cc44547992ec5216bec4d80477027d5d846d Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Aug 2018 00:10:03 +0200 Subject: [PATCH] Correct IPv6 VM name in serializer --- opennebula_api/serializers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opennebula_api/serializers.py b/opennebula_api/serializers.py index f63f2eb0..c7418aa5 100644 --- a/opennebula_api/serializers.py +++ b/opennebula_api/serializers.py @@ -36,7 +36,10 @@ class VirtualMachineTemplateSerializer(serializers.Serializer): return int(obj.template.memory) / 1024 def get_name(self, obj): - return obj.name.lstrip('public-') + if obj.name.startswith('public-'): + return obj.name.lstrip('public-') + else: + return obj.name class VirtualMachineSerializer(serializers.Serializer): @@ -133,7 +136,10 @@ class VirtualMachineSerializer(serializers.Serializer): def get_configuration(self, obj): template_id = obj.template.template_id 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 def get_ipv4(self, obj): """