From 8a18c275c38ed866134d4922529024caf90d1dd1 Mon Sep 17 00:00:00 2001 From: Modulos Date: Sun, 14 May 2017 03:41:30 +0200 Subject: [PATCH] Display configuration in virtualmachine detail --- hosting/templates/hosting/virtual_machine_detail.html | 2 +- opennebula_api/serializers.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html index e2f38d60..0b17878d 100644 --- a/hosting/templates/hosting/virtual_machine_detail.html +++ b/hosting/templates/hosting/virtual_machine_detail.html @@ -87,7 +87,7 @@
- {% trans "Configuration"%}: {{virtual_machine.get_configuration_display}} + {% trans "Configuration"%}: {{virtual_machine.configuration}}
diff --git a/opennebula_api/serializers.py b/opennebula_api/serializers.py index 44b873a5..34e122d1 100644 --- a/opennebula_api/serializers.py +++ b/opennebula_api/serializers.py @@ -88,6 +88,7 @@ class VirtualMachineSerializer(serializers.Serializer): state = serializers.CharField(read_only=True, source='str_state') price = serializers.SerializerMethodField() ssh_key = serializers.CharField(write_only=True) + configuration = serializers.SerializerMethodField() template_id = serializers.ChoiceField( choices=[(key.id, key.name) for key in @@ -140,3 +141,7 @@ class VirtualMachineSerializer(serializers.Serializer): for disk in template.disks: price += int(disk.size)/1024 * 0.6 return price + def get_configuration(self, obj): + template_id = obj.template.template_id + template = OpenNebulaManager().get_template(template_id) + return template.name