blob: bc84add3c0ec103d7f28950cbb48867d90c39027 [file] [log] [blame]
Matteo Scandolofcf842e2017-08-08 13:05:25 -07001
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 Haidere6ffdc02016-11-08 13:43:48 -050017import json
18from synchronizers.metronetwork.invokers.invoker import Invoker
19from core.models import Site
20from services.metronetwork.models import NetworkEdgePort
21
22class RemotePortInvoker(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 Site and EdgePorts are created set the foreign keys
35 if hasattr(obj, 'sitename'):
36 site = Site.objects.get(login_base=obj.sitename)
37 obj.remoteportsite = site
38
39 if hasattr(obj, 'edgeportname'):
40 edgeport = NetworkEdgePort.objects.get(pid=obj.edgeportname)
41 obj.edgeport = edgeport
42
43 # Method for handline post save semantics
44 # content here would be model specific but could include handling Many-to-Many relationship
45 # creation - which must occur post save
46 #
47 # obj - Whatever obj was just saved
48 # returns - N/A - this is a pure invoke() call
49 #
50 def postsave(self, obj):
51 pass