Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 1 | import json |
| 2 | from synchronizers.metronetwork.invokers.invoker import Invoker |
| 3 | from services.metronetwork.models import NetworkEdgePort |
| 4 | |
| 5 | |
| 6 | class NetworkEdgeToEdgePointInvoker(Invoker): |
| 7 | def __init__(self, **args): |
| 8 | pass |
| 9 | |
| 10 | # Method for handline pre save semantics |
| 11 | # content here would be model specific but could include handling Many-to-Many relationship |
| 12 | # creation - which must occur post save |
| 13 | # |
| 14 | # obj - Whatever obj was just saved |
| 15 | # returns - None - this is a pure invoke() call, return type is None |
| 16 | # |
| 17 | def presave(self, obj): |
| 18 | # Now that the Ports are created - get a proper reference to them and update the |
| 19 | # src and dst fields |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 20 | if hasattr(obj, 'uni1_createbuffer'): |
| 21 | uni1port = NetworkEdgePort.objects.get(pid=obj.uni1_createbuffer) |
| 22 | uni2port = NetworkEdgePort.objects.get(pid=obj.uni2_createbuffer) |
| 23 | obj.uni1 = uni1port |
| 24 | obj.uni2 = uni2port |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 25 | |
| 26 | # Method for handline post save semantics |
| 27 | # content here would be model specific but could include handling Many-to-Many relationship |
| 28 | # creation - which must occur post save |
| 29 | # |
| 30 | # obj - Whatever obj was just saved |
| 31 | # returns - N/A - this is a pure invoke() call |
| 32 | # |
| 33 | def postsave(self, obj): |
| 34 | pass |