From 5f136a9dfe5e615a9e04ef8df634a3272cfd27e7 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 20 Feb 2018 15:13:12 +0100 Subject: [PATCH] Remove BetaAccess related models --- datacenterlight/admin.py | 9 ------- datacenterlight/models.py | 50 --------------------------------------- 2 files changed, 59 deletions(-) delete mode 100644 datacenterlight/admin.py diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py deleted file mode 100644 index 7a846c71..00000000 --- a/datacenterlight/admin.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.contrib import admin - -from .models import BetaAccess, BetaAccessVMType, BetaAccessVM -# Register your models here. - - -admin.site.register(BetaAccess) -admin.site.register(BetaAccessVMType) -admin.site.register(BetaAccessVM) diff --git a/datacenterlight/models.py b/datacenterlight/models.py index e2de41e1..2fbed5c8 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -1,56 +1,6 @@ from django.db import models -class BetaAccessVMType(models.Model): - ssd = models.IntegerField() - ram = models.IntegerField() - cpu = models.IntegerField() - price = models.FloatField() - - def __str__(self): - return "ID: %s - SSD %s - RAM %s - CPU %s - Price %s " % \ - (self.id, str(self.ssd), self.ram, self.cpu, self.price) - - -class BetaAccess(models.Model): - email = models.CharField(max_length=250) - name = models.CharField(max_length=250) - - # vm = models.ForeignKey(BetaAccessVM) - - def __str__(self): - vms = self.betaaccessvm_set.all() - rep = "Email: %s " % self.email - for vm in vms: - rep += "(vm:%s - amount:%s) - " % (vm.type.id, vm.amount) - return rep - - -class BetaAccessVM(models.Model): - type = models.ForeignKey(BetaAccessVMType) - access = models.ForeignKey(BetaAccess) - amount = models.IntegerField() - - @classmethod - def create(cls, data): - VM_KEY_ID = 0 - VM_AMOUNT = 1 - ZERO = 0 - email = data.get('email') - beta_access = BetaAccess.objects.create(email=email) - vm_data = [(key, value) for key, value in data.items() if 'vm' in key] - created_vms = [] - for vm in vm_data: - if int(vm[VM_AMOUNT]) == ZERO: - continue - vm_id = vm[VM_KEY_ID].split('-').pop() - vm_type = BetaAccessVMType.objects.get(id=vm_id) - created_vms.append(cls.objects.create(access=beta_access, - amount=vm[VM_AMOUNT], type=vm_type)) - - return created_vms - - class VMTemplate(models.Model): name = models.CharField(max_length=50) opennebula_vm_template_id = models.IntegerField()