Remove vms field from vmhost
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
2a73f0e767
commit
139aca6a61
3 changed files with 23 additions and 5 deletions
17
uncloud/uncloud_vm/migrations/0003_remove_vmhost_vms.py
Normal file
17
uncloud/uncloud_vm/migrations/0003_remove_vmhost_vms.py
Normal 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',
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue