diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/models.py | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/api/models.py b/src/api/models.py index ce62ea5..89ee6c6 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -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): |