aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2020-03-17 12:52:21 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-03-17 12:52:21 +0000
commit287a9e199abf29c4872390e4ff15db5f87382e20 (patch)
tree01948e75db2eb3c398de4ae9d266fc6c60da59e9 /src/api
parentc8998d426cbf12afb2d2e68059e0969388b50c95 (diff)
parente90f13e0413594d95e50256b1206ffd64217f2da (diff)
Merge "Quick Deploy Fixes." into resource
Diffstat (limited to 'src/api')
-rw-r--r--src/api/models.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/api/models.py b/src/api/models.py
index c61341e..df9bbf7 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)