diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2020-03-16 10:10:30 -0400 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2020-03-17 08:48:26 -0400 |
commit | e90f13e0413594d95e50256b1206ffd64217f2da (patch) | |
tree | 40895a885bb18fd44aeb342041f4be0a068fe69a /src/api/models.py | |
parent | b360e0e417f787e0266268596d630b87e88283d1 (diff) |
Quick Deploy Fixes.
Change-Id: I46d410af62e4962d235346ba56472aaacb9d3ff2
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/api/models.py')
-rw-r--r-- | src/api/models.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/api/models.py b/src/api/models.py index de73a7a..d8e023b 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -331,7 +331,7 @@ class Job(models.Model): return {"id": self.id, "payload": d} def get_tasklist(self, status="all"): - if status == "all": + if status != "all": return JobTaskQuery.filter(job=self, status=status) return JobTaskQuery.filter(job=self) @@ -408,7 +408,7 @@ class BridgeConfig(models.Model): def to_dict(self): d = {} - hid = self.interfaces.first().host.labid + hid = ResourceQuery.get(interface__pk=self.interfaces.first().pk).labid d[hid] = {} for interface in self.interfaces.all(): d[hid][interface.mac_address] = [] @@ -611,7 +611,7 @@ class HardwareConfig(TaskConfig): def get_delta(self): return self.format_delta( - self.hosthardwarerelation.host.get_configuration(self.state), + self.hosthardwarerelation.get_resource().get_configuration(self.state), self.hosthardwarerelation.lab_token) @@ -623,7 +623,7 @@ class NetworkConfig(TaskConfig): def to_dict(self): d = {} - hid = self.hostnetworkrelation.host.labid + hid = self.hostnetworkrelation.resource_id d[hid] = {} for interface in self.interfaces.all(): d[hid][interface.mac_address] = [] @@ -652,7 +652,7 @@ class NetworkConfig(TaskConfig): def add_interface(self, interface): self.interfaces.add(interface) d = json.loads(self.delta) - hid = self.hostnetworkrelation.host.labid + hid = self.hostnetworkrelation.resource_id if hid not in d: d[hid] = {} d[hid][interface.mac_address] = [] @@ -809,6 +809,9 @@ class HostHardwareRelation(TaskRelation): raise ValidationError("resource_id " + str(self.resource_id) + " does not refer to a single resource") super().save(*args, **kwargs) + def get_resource(self): + return ResourceQuery.get(labid=self.resource_id) + class HostNetworkRelation(TaskRelation): resource_id = models.CharField(max_length=200, default="default_id") @@ -827,6 +830,9 @@ class HostNetworkRelation(TaskRelation): raise ValidationError("resource_id " + str(self.resource_id) + " does not refer to a single resource") super().save(*args, **kwargs) + def get_resource(self): + return ResourceQuery.get(labid=self.resource_id) + class SnapshotRelation(TaskRelation): snapshot = models.ForeignKey(Image, on_delete=models.CASCADE) @@ -1011,7 +1017,7 @@ class JobFactory(object): @classmethod def make_bridge_config(cls, booking): - if booking.resource.hosts.count() < 2: + if len(booking.resource.get_resources()) < 2: return None try: jumphost_config = ResourceOPNFVConfig.objects.filter( @@ -1049,7 +1055,7 @@ class JobFactory(object): opnfv_api_config.set_xdf(booking, False) opnfv_api_config.save() - for host in booking.resource.hosts.all(): + for host in booking.resource.get_resources(): opnfv_api_config.roles.add(host) software_config = SoftwareConfig.objects.create(opnfv=opnfv_api_config) software_relation = SoftwareRelation.objects.create(job=job, config=software_config) |