blob: 4fde8daac048f6bd60e625107c667726dccebb29 [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 RemotePort
21
22
23class ServiceSpokeInvoker(Invoker):
24 def __init__(self, **args):
25 pass
26
27 # Method for handline pre save semantics
28 # content here would be model specific but could include handling Many-to-Many relationship
29 # creation - which must occur post save
30 #
31 # obj - Whatever obj was just saved
32 # returns - None - this is a pure invoke() call, return type is None
33 #
34 def presave(self, obj):
35 # Now that the Ports are created - get a proper reference to them and update the
36 # src and dst fields
37 if hasattr(obj, 'sitename'):
38 site = Site.objects.get(login_base=obj.sitename)
39 obj.vnodlocalsite = site
40
41 if hasattr(obj, 'remoteportname'):
42 remoteport = RemotePort.objects.get(name=obj.remoteportname)
43 obj.vnodlocalport = remoteport
44
45 # Method for handline post save semantics
46 # content here would be model specific but could include handling Many-to-Many relationship
47 # creation - which must occur post save
48 #
49 # obj - Whatever obj was just saved
50 # returns - N/A - this is a pure invoke() call
51 #
52 def postsave(self, obj):
53 pass