From 66e224e9262a458b3343f8b7ba2b0f00548732ae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Mar 2020 14:21:10 +0100 Subject: [PATCH] [storage] move choices to uncloud_storage --- uncloud/uncloud_storage/models.py | 6 +++++- uncloud/uncloud_vm/models.py | 17 +++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/uncloud/uncloud_storage/models.py b/uncloud/uncloud_storage/models.py index 71a8362..0dac5c2 100644 --- a/uncloud/uncloud_storage/models.py +++ b/uncloud/uncloud_storage/models.py @@ -1,3 +1,7 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ -# Create your models here. + +class StorageClass(models.TextChoices): + HDD = 'HDD', _('HDD') + SSD = 'SSD', _('SSD') diff --git a/uncloud/uncloud_vm/models.py b/uncloud/uncloud_vm/models.py index c0acee2..41a1e93 100644 --- a/uncloud/uncloud_vm/models.py +++ b/uncloud/uncloud_vm/models.py @@ -8,6 +8,7 @@ from django.contrib.auth import get_user_model from uncloud_pay.models import Product, RecurringPeriod import uncloud_pay.models as pay_models +import uncloud_storage.models STATUS_CHOICES = ( ('pending', 'Pending'), # Initial state @@ -52,9 +53,9 @@ class VMProduct(Product): VMHost, on_delete=models.CASCADE, editable=False, blank=True, null=True ) - # VM-specific. The name is only intended for customers: it's a pain te + # VM-specific. The name is only intended for customers: it's a pain to # remember IDs (speaking from experience as ungleich customer)! - name = models.CharField(max_length=32) + name = models.CharField(max_length=32, blank=True, null=True) cores = models.IntegerField() ram_in_gb = models.FloatField() vmid = models.IntegerField(null=True) @@ -106,14 +107,10 @@ class VMDiskImageProduct(models.Model): import_url = models.URLField(null=True, blank=True) image_source = models.CharField(max_length=128, null=True) image_source_type = models.CharField(max_length=128, null=True) - storage_class = models.CharField( - max_length=32, - choices=( - ('hdd', 'HDD'), - ('ssd', 'SSD'), - ), - default='ssd' - ) + + storage_class = models.CharField(max_length=32, + choices = uncloud_storage.models.StorageClass.choices, + default = uncloud_storage.models.StorageClass.SSD) status = models.CharField( max_length=32, choices=STATUS_CHOICES, default=STATUS_DEFAULT