diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/models.py | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/api/models.py b/src/api/models.py index 8de3ec7..9b9b778 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -384,7 +384,7 @@ class Job(models.Model): class TaskConfig(models.Model): - state = models.IntegerField(default=ConfigState.CLEAN) + state = models.IntegerField(default=ConfigState.NEW) keys = set() # TODO: This needs to be an instance variable, not a class variable delta_keys_list = models.CharField(max_length=200, default="[]") @@ -525,10 +525,7 @@ class OpnfvApiConfig(models.Model): self.delta = '{}' def get_delta(self): - if not self.delta: - self.delta = self.to_json() - self.save() - return json.loads(self.delta) + return json.loads(self.to_json()) class AccessConfig(TaskConfig): @@ -550,10 +547,7 @@ class AccessConfig(TaskConfig): return d def get_delta(self): - if not self.delta: - self.delta = self.to_json() - self.save() - d = json.loads(self.delta) + d = json.loads(self.to_json()) d["lab_token"] = self.accessrelation.lab_token return d @@ -649,10 +643,11 @@ class NetworkConfig(TaskConfig): d[hid] = {} for interface in self.interfaces.all(): d[hid][interface.mac_address] = [] - for vlan in interface.config.all(): - # TODO: should this come from the interface? - # e.g. will different interfaces for different resources need different configs? - d[hid][interface.mac_address].append({"vlan_id": vlan.vlan_id, "tagged": vlan.tagged}) + if self.state != ConfigState.CLEAN: + for vlan in interface.config.all(): + # TODO: should this come from the interface? + # e.g. will different interfaces for different resources need different configs? + d[hid][interface.mac_address].append({"vlan_id": vlan.vlan_id, "tagged": vlan.tagged}) return d @@ -660,10 +655,7 @@ class NetworkConfig(TaskConfig): return json.dumps(self.to_dict()) def get_delta(self): - if not self.delta: - self.delta = self.to_json() - self.save() - d = json.loads(self.delta) + d = json.loads(self.to_json()) d['lab_token'] = self.hostnetworkrelation.lab_token return d @@ -703,11 +695,7 @@ class SnapshotConfig(TaskConfig): return json.dumps(self.to_dict()) def get_delta(self): - if not self.delta: - self.delta = self.to_json() - self.save() - - d = json.loads(self.delta) + d = json.loads(self.to_json()) return d def clear_delta(self): |