Remove vms field from vmhost

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-03-05 14:58:45 +01:00
parent 2a73f0e767
commit 139aca6a61
3 changed files with 23 additions and 5 deletions

View file

@ -0,0 +1,17 @@
# Generated by Django 3.0.3 on 2020-03-05 13:58
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('uncloud_vm', '0002_auto_20200305_1321'),
]
operations = [
migrations.RemoveField(
model_name='vmhost',
name='vms',
),
]

View file

@ -41,11 +41,9 @@ class VMHost(models.Model):
max_length=32, choices=STATUS_CHOICES, default=STATUS_DEFAULT
)
# List of VMs running on this host
vms = models.TextField(default='')
def get_vms(self):
return self.vms.split(',')
@property
def vms(self):
return VMProduct.objects.filter(vmhost=self)
class VMProduct(Product):

View file

@ -13,9 +13,12 @@ GB_HDD_PER_DAY=0.0006
class VMHostSerializer(serializers.ModelSerializer):
vms = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
class Meta:
model = VMHost
fields = '__all__'
read_only_fields = [ 'vms' ]
class VMDiskProductSerializer(serializers.ModelSerializer):