blob: 1061dc44564b0380ffeff1caddfc2f13a0d6f80f [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 NetworkEdgePort
5
6class RemotePortInvoker(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 Site and EdgePorts are created set the foreign keys
19 if hasattr(obj, 'sitename'):
20 site = Site.objects.get(login_base=obj.sitename)
21 obj.remoteportsite = site
22
23 if hasattr(obj, 'edgeportname'):
24 edgeport = NetworkEdgePort.objects.get(pid=obj.edgeportname)
25 obj.edgeport = edgeport
26
27 # Method for handline post 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 - N/A - this is a pure invoke() call
33 #
34 def postsave(self, obj):
35 pass