blob: 8470cf52f9bb5f32b5e01267dad8c7b23e501a8c [file] [log] [blame]
Rizwan Haidere6ffdc02016-11-08 13:43:48 -05001import json
2from synchronizers.metronetwork.invokers.invoker import Invoker
3from core.models import Site
4from services.metronetwork.models import RemotePort
5
6
7class ServiceSpokeInvoker(Invoker):
8 def __init__(self, **args):
9 pass
10
11 # Method for handline pre save semantics
12 # content here would be model specific but could include handling Many-to-Many relationship
13 # creation - which must occur post save
14 #
15 # obj - Whatever obj was just saved
16 # returns - None - this is a pure invoke() call, return type is None
17 #
18 def presave(self, obj):
19 # Now that the Ports are created - get a proper reference to them and update the
20 # src and dst fields
21 if hasattr(obj, 'sitename'):
22 site = Site.objects.get(login_base=obj.sitename)
23 obj.vnodlocalsite = site
24
25 if hasattr(obj, 'remoteportname'):
26 remoteport = RemotePort.objects.get(name=obj.remoteportname)
27 obj.vnodlocalport = remoteport
28
29 # Method for handline post save semantics
30 # content here would be model specific but could include handling Many-to-Many relationship
31 # creation - which must occur post save
32 #
33 # obj - Whatever obj was just saved
34 # returns - N/A - this is a pure invoke() call
35 #
36 def postsave(self, obj):
37 pass