Display configuration in virtualmachine detail

This commit is contained in:
Modulos 2017-05-14 03:41:30 +02:00
parent 921fa209ce
commit 8a18c275c3
2 changed files with 6 additions and 1 deletions

View file

@ -87,7 +87,7 @@
</div><!--/row-->
<div class="row">
<div class="col-md-12">
{% trans "Configuration"%}: {{virtual_machine.get_configuration_display}}
{% trans "Configuration"%}: {{virtual_machine.configuration}}
</div>
</div>

View file

@ -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