Added VMTemplateSerializer
This commit is contained in:
parent
1a6e497e38
commit
fca291c6a5
2 changed files with 9 additions and 2 deletions
|
@ -21,7 +21,7 @@ from datetime import datetime
|
|||
from membership.models import CustomUser, StripeCustomer
|
||||
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer, VMTemplateSerializer
|
||||
|
||||
|
||||
class LandingProgramView(TemplateView):
|
||||
|
@ -212,7 +212,8 @@ class IndexView(CreateView):
|
|||
storage = request.POST.get('storage')
|
||||
price = request.POST.get('total')
|
||||
template_id = int(request.POST.get('config'))
|
||||
template_data = VMTemplate.objects.all()
|
||||
template = VMTemplate.objects.filter(opennebula_vm_template_id=template_id).first()
|
||||
template_data = VMTemplateSerializer(template).data
|
||||
|
||||
name = request.POST.get('name')
|
||||
email = request.POST.get('email')
|
||||
|
|
|
@ -129,6 +129,12 @@ class VirtualMachineSerializer(serializers.Serializer):
|
|||
return obj.name.strip('public-')
|
||||
|
||||
|
||||
class VMTemplateSerializer(serializers.Serializer):
|
||||
"""Serializer to map the VMTemplate instance into JSON format."""
|
||||
id = serializers.IntegerField(read_only=True, source='opennebula_vm_template_id')
|
||||
name = serializers.CharField(read_only=True)
|
||||
|
||||
|
||||
def hexstr2int(string):
|
||||
return int(string.replace(':', ''), 16)
|
||||
|
||||
|
|
Loading…
Reference in a new issue