blob: 8d4fffda0c227d469e7b76eb022f72c81fb37707 [file] [log] [blame]
Rizwan Haider51fdb3f2016-11-09 18:29:32 -05001from xos.logger import Logger, logging
2from synchronizers.vnodlocal.pseudowireproviders.pseudowireprovider import PseudowireProvider
3from services.metronetwork.models import NetworkEdgeToEdgePointConnection, NetworkEdgePort
4
5logger = Logger(level=logging.INFO)
6
7class MetronetworkPseudowireProvider(PseudowireProvider):
8
9 def __init__(self, **args):
10 pass
11
12 # Methods to support creation
13 #
14 # Returns: handle
15 #
16 def create(self, port1, port2, vlanid, psuedowireservice):
17 # Create method - create eline with the ports
18 # Vlan is TBD
Michael Best162b08e2016-11-10 15:44:50 -050019 pseudowirename = ("Vlan: %s" % vlanid)
Rizwan Haider51fdb3f2016-11-09 18:29:32 -050020 logger.info("Metronetwork create called, name: %s" % pseudowirename )
21 # Edge to Edge Point Connectivity creation
22 edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection()
23 uni1port = NetworkEdgePort.objects.filter(pid__icontains=port1)
24 if uni1port:
25 uni1port = uni1port[0]
26 uni2port = NetworkEdgePort.objects.filter(pid__icontains=port2)
27 if uni2port:
28 uni2port = uni2port[0]
29 edgetoedgeconnectivity.uni1 = uni1port
30 edgetoedgeconnectivity.uni2 = uni2port
31 edgetoedgeconnectivity.vlanid = vlanid
32 edgetoedgeconnectivity.type = 'Point_To_Point'
33 edgetoedgeconnectivity.operstate = 'inactive'
34 edgetoedgeconnectivity.adminstate = 'disabled'
Michael Best162b08e2016-11-10 15:44:50 -050035 edgetoedgeconnectivity.name = pseudowirename
Rizwan Haider51fdb3f2016-11-09 18:29:32 -050036 edgetoedgeconnectivity.save()
37 return pseudowirename
38
39 # Method to support connect
40 #
41 def connect(self, handle):
42 # Connect method - simply transition the state of the underlying object - the Metronet sync will do the rest
43 logger.info("Metronetwork Pseudowire connect called, handle = %s" % handle)
Michael Best162b08e2016-11-10 15:44:50 -050044 edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection.objects.get(name=handle)
Rizwan Haider51fdb3f2016-11-09 18:29:32 -050045 edgetoedgeconnectivity.adminstate = 'activationrequested'
46 edgetoedgeconnectivity.save()
47
48 # Method to support disconnect connect
49 #
50 def disconnect(self, handle):
51 # Connect method - simply transition the state of the underlying object - the Metronet sync will do the rest
52 logger.info("Metronetwork Pseudowire disconnect called, handle = %s" % handle)
Michael Best162b08e2016-11-10 15:44:50 -050053 edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection.objects.get(name=handle)
Rizwan Haider51fdb3f2016-11-09 18:29:32 -050054 edgetoedgeconnectivity.adminstate = 'deactivationrequested'
55 edgetoedgeconnectivity.save()
56
57 # Method to support deletion
58 #
59 def delete(self, handle):
60 # Delete method - simply set the state to deleted and the Metronet sync will do the rest
61 logger.info("Metronetwork Pseudowire delete called, handle = %s" % handle)
Michael Best162b08e2016-11-10 15:44:50 -050062 edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection.objects.get(name=handle)
Rizwan Haider51fdb3f2016-11-09 18:29:32 -050063 edgetoedgeconnectivity.deleted = True
64 edgetoedgeconnectivity.save()
65