from django.db import models


class Worker(models.Model):
    address = models.GenericIPAddressField(protocol='IPv4', unique=True)
    cpus = models.PositiveSmallIntegerField()
    cpus_reserved = models.PositiveSmallIntegerField(default=0)
    memory = models.PositiveSmallIntegerField()
    memory_reserved = models.PositiveSmallIntegerField(default=0)
    last_health_report_date = models.DateTimeField(null=True)

    @property
    def available_cpus(self):
        return self.cpus - self.cpus_reserved

    @property
    def available_memory(self):
        return self.memory - self.memory_reserved

09d243a80b0f638521d9a52e2530602668cc2848
<mask token>


class Worker(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @property
    def available_memory(self):
        return self.memory - self.memory_reserved

<mask token>


class Worker(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @property
    def available_cpus(self):
        return self.cpus - self.cpus_reserved

    @property
    def available_memory(self):
        return self.memory - self.memory_reserved

<mask token>


class Worker(models.Model):
    address = models.GenericIPAddressField(protocol='IPv4', unique=True)
    cpus = models.PositiveSmallIntegerField()
    cpus_reserved = models.PositiveSmallIntegerField(default=0)
    memory = models.PositiveSmallIntegerField()
    memory_reserved = models.PositiveSmallIntegerField(default=0)
    last_health_report_date = models.DateTimeField(null=True)

    @property
    def available_cpus(self):
        return self.cpus - self.cpus_reserved

    @property
    def available_memory(self):
        return self.memory - self.memory_reserved

from django.db import models


class Worker(models.Model):
    address = models.GenericIPAddressField(protocol='IPv4', unique=True)
    cpus = models.PositiveSmallIntegerField()
    cpus_reserved = models.PositiveSmallIntegerField(default=0)
    memory = models.PositiveSmallIntegerField()
    memory_reserved = models.PositiveSmallIntegerField(default=0)
    last_health_report_date = models.DateTimeField(null=True)

    @property
    def available_cpus(self):
        return self.cpus - self.cpus_reserved

    @property
    def available_memory(self):
        return self.memory - self.memory_reserved
