Matteo Scandolo | fcf842e | 2017-08-08 13:05:25 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 17 | import json |
| 18 | from synchronizers.metronetwork.invokers.invoker import Invoker |
| 19 | from services.metronetwork.models import NetworkEdgePort |
| 20 | |
| 21 | |
| 22 | class NetworkEdgeToEdgePointInvoker(Invoker): |
| 23 | def __init__(self, **args): |
| 24 | pass |
| 25 | |
| 26 | # Method for handline pre 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 - None - this is a pure invoke() call, return type is None |
| 32 | # |
| 33 | def presave(self, obj): |
| 34 | # Now that the Ports are created - get a proper reference to them and update the |
| 35 | # src and dst fields |
Rizwan Haider | e6ffdc0 | 2016-11-08 13:43:48 -0500 | [diff] [blame] | 36 | if hasattr(obj, 'uni1_createbuffer'): |
| 37 | uni1port = NetworkEdgePort.objects.get(pid=obj.uni1_createbuffer) |
| 38 | uni2port = NetworkEdgePort.objects.get(pid=obj.uni2_createbuffer) |
| 39 | obj.uni1 = uni1port |
| 40 | obj.uni2 = uni2port |
Rizwan Haider | 65baf55 | 2016-09-28 16:47:28 -0400 | [diff] [blame] | 41 | |
| 42 | # Method for handline post save semantics |
| 43 | # content here would be model specific but could include handling Many-to-Many relationship |
| 44 | # creation - which must occur post save |
| 45 | # |
| 46 | # obj - Whatever obj was just saved |
| 47 | # returns - N/A - this is a pure invoke() call |
| 48 | # |
| 49 | def postsave(self, obj): |
| 50 | pass |