yjimmyy
Committed by Gerrit Code Review

Implement Oplink drivers for port adjacency

Change-Id: I3cdc402c4dac544a7cb48544352df758c416345d
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 +package org.onosproject.net.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +
20 +/**
21 + * Collection of keys for annotation for optical devices.
22 + */
23 +@Beta
24 +public final class OpticalAnnotations {
25 +
26 + private OpticalAnnotations() {}
27 +
28 + /**
29 + * Annotation key for optical port's target power.
30 + */
31 + public static final String TARGET_POWER = "targetPower";
32 +
33 + /**
34 + * Annotation key for optical port's current power.
35 + */
36 + public static final String CURRENT_POWER = "currentPower";
37 +
38 + /**
39 + * Annotation key for optical port's neighbor's DeviceId#toString().
40 + */
41 + public static final String NEIGHBOR_ID = "neighborDeviceId";
42 +
43 + /**
44 + * Annotation key for optical port's neighbor's PortNumber#toString().
45 + */
46 + public static final String NEIGHBOR_PORT = "neighborPort";
47 +}
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
15 */ 15 */
16 package org.onosproject.net; 16 package org.onosproject.net;
17 17
18 -import com.google.common.annotations.Beta;
19 -
20 /** 18 /**
21 * Collection of keys for annotation. 19 * Collection of keys for annotation.
22 * <p> 20 * <p>
...@@ -112,18 +110,6 @@ public final class AnnotationKeys { ...@@ -112,18 +110,6 @@ public final class AnnotationKeys {
112 public static final String STATIC_LAMBDA = "staticLambda"; 110 public static final String STATIC_LAMBDA = "staticLambda";
113 111
114 /** 112 /**
115 - * Annotation key for optical port's target power.
116 - */
117 - @Beta
118 - public static final String TARGET_POWER = "targetPower";
119 -
120 - /**
121 - * Annotation key for optical port's current power.
122 - */
123 - @Beta
124 - public static final String CURRENT_POWER = "currentPower";
125 -
126 - /**
127 * Annotation key for the static port. 113 * Annotation key for the static port.
128 */ 114 */
129 public static final String STATIC_PORT = "staticPort"; 115 public static final String STATIC_PORT = "staticPort";
......
...@@ -22,5 +22,6 @@ ...@@ -22,5 +22,6 @@
22 22
23 <bundle>mvn:org.onosproject/openflowj/0.9.5.onos</bundle> 23 <bundle>mvn:org.onosproject/openflowj/0.9.5.onos</bundle>
24 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle>
25 +
25 </feature> 26 </feature>
26 </features> 27 </features>
......
...@@ -18,13 +18,13 @@ package org.onosproject.driver.optical.power; ...@@ -18,13 +18,13 @@ package org.onosproject.driver.optical.power;
18 18
19 import java.util.Optional; 19 import java.util.Optional;
20 20
21 -import org.onosproject.net.AnnotationKeys;
22 import org.onosproject.net.driver.AbstractHandlerBehaviour; 21 import org.onosproject.net.driver.AbstractHandlerBehaviour;
23 import org.onosproject.net.Direction; 22 import org.onosproject.net.Direction;
24 import org.onosproject.net.Port; 23 import org.onosproject.net.Port;
25 import org.onosproject.net.PortNumber; 24 import org.onosproject.net.PortNumber;
26 import org.onosproject.net.behaviour.PowerConfig; 25 import org.onosproject.net.behaviour.PowerConfig;
27 import org.onosproject.net.device.DeviceService; 26 import org.onosproject.net.device.DeviceService;
27 +import org.onosproject.net.optical.OpticalAnnotations;
28 import org.onosproject.openflow.controller.Dpid; 28 import org.onosproject.openflow.controller.Dpid;
29 import org.onosproject.openflow.controller.OpenFlowController; 29 import org.onosproject.openflow.controller.OpenFlowController;
30 import org.onosproject.openflow.controller.OpenFlowSwitch; 30 import org.onosproject.openflow.controller.OpenFlowSwitch;
...@@ -69,7 +69,7 @@ public class OplinkRoadmPowerConfig extends AbstractHandlerBehaviour ...@@ -69,7 +69,7 @@ public class OplinkRoadmPowerConfig extends AbstractHandlerBehaviour
69 DeviceService deviceService = this.handler().get(DeviceService.class); 69 DeviceService deviceService = this.handler().get(DeviceService.class);
70 Port port = deviceService.getPort(this.data().deviceId(), portNum); 70 Port port = deviceService.getPort(this.data().deviceId(), portNum);
71 if (port != null) { 71 if (port != null) {
72 - String currentPower = port.annotations().value(AnnotationKeys.CURRENT_POWER); 72 + String currentPower = port.annotations().value(OpticalAnnotations.CURRENT_POWER);
73 if (currentPower != null) { 73 if (currentPower != null) {
74 returnVal = Long.valueOf(currentPower); 74 returnVal = Long.valueOf(currentPower);
75 } 75 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 +package org.onosproject.drivers.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +import org.apache.felix.scr.annotations.Activate;
20 +import org.apache.felix.scr.annotations.Component;
21 +import org.apache.felix.scr.annotations.Deactivate;
22 +import org.apache.felix.scr.annotations.Reference;
23 +import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.apache.felix.scr.annotations.Service;
25 +import org.onosproject.net.ConnectPoint;
26 +import org.onosproject.net.DeviceId;
27 +import org.onosproject.net.link.LinkDescription;
28 +import org.onosproject.net.link.LinkProvider;
29 +import org.onosproject.net.link.LinkProviderRegistry;
30 +import org.onosproject.net.link.LinkProviderService;
31 +import org.onosproject.net.provider.ProviderId;
32 +import org.slf4j.Logger;
33 +
34 +import static org.slf4j.LoggerFactory.getLogger;
35 +
36 +
37 +/**
38 + * Interface to allow for optical device drivers to add/remove links to
39 + * the store. Acts as a proxy to LinkProviderService.
40 + *
41 + * Registers a dummy LinkProvider to get an instance of LinkProviderService.
42 + */
43 +@Beta
44 +@Component(immediate = true)
45 +@Service
46 +public class OpticalAdjacencyLinkManager implements OpticalAdjacencyLinkService {
47 +
48 + private static final ProviderId PID =
49 + new ProviderId("of", "org.onosproject.drivers.optical");
50 +
51 + private final Logger log = getLogger(getClass());
52 +
53 + private LinkProvider linkProvider = new StubLinkProvider();
54 + private LinkProviderService linkProviderService;
55 +
56 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 + protected LinkProviderRegistry linkProviderRegistry;
58 +
59 + @Activate
60 + public void activate() {
61 + linkProviderService = linkProviderRegistry.register(linkProvider);
62 + log.info("Started");
63 + }
64 +
65 + @Deactivate
66 + public void deactivate() {
67 + linkProviderRegistry.unregister(linkProvider);
68 + log.info("Stopped");
69 + }
70 +
71 + /**
72 + * Signals that an infrastructure link has been detected.
73 + *
74 + * @param linkDescription link information
75 + */
76 + @Override
77 + public void linkDetected(LinkDescription linkDescription) {
78 + linkProviderService.linkDetected(linkDescription);
79 + }
80 +
81 + /**
82 + * Signals that an infrastructure link has disappeared.
83 + *
84 + * @param linkDescription link information
85 + */
86 + @Override
87 + public void linkVanished(LinkDescription linkDescription) {
88 + linkProviderService.linkVanished(linkDescription);
89 + }
90 +
91 + /**
92 + * Signals that infrastructure links associated with the specified
93 + * connect point have vanished.
94 + *
95 + * @param connectPoint connect point
96 + */
97 + @Override
98 + public void linksVanished(ConnectPoint connectPoint) {
99 + linkProviderService.linksVanished(connectPoint);
100 + }
101 +
102 + /**
103 + * Signals that infrastructure links associated with the specified
104 + * device have vanished.
105 + *
106 + * @param deviceId device identifier
107 + */
108 + @Override
109 + public void linksVanished(DeviceId deviceId) {
110 + linkProviderService.linksVanished(deviceId);
111 + }
112 +
113 + // Stub provider used to get LinkProviderService
114 + private static final class StubLinkProvider implements LinkProvider {
115 + @Override
116 + public ProviderId id() {
117 + return PID;
118 + }
119 + }
120 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 +package org.onosproject.drivers.optical;
17 +
18 +import com.google.common.annotations.Beta;
19 +import org.onosproject.net.ConnectPoint;
20 +import org.onosproject.net.DeviceId;
21 +import org.onosproject.net.link.LinkDescription;
22 +
23 +/**
24 + * Interface to allow for optical device drivers to add/remove links to
25 + * the store. Acts as a proxy to LinkProviderService.
26 + */
27 +@Beta
28 +public interface OpticalAdjacencyLinkService {
29 + /**
30 + * Signals that an infrastructure link has been detected.
31 + *
32 + * @param linkDescription link information
33 + */
34 + void linkDetected(LinkDescription linkDescription);
35 +
36 + /**
37 + * Signals that an infrastructure link has disappeared.
38 + *
39 + * @param linkDescription link information
40 + */
41 + void linkVanished(LinkDescription linkDescription);
42 +
43 + /**
44 + * Signals that infrastructure links associated with the specified
45 + * connect point have vanished.
46 + *
47 + * @param connectPoint connect point
48 + */
49 + void linksVanished(ConnectPoint connectPoint);
50 +
51 + /**
52 + * Signals that infrastructure links associated with the specified
53 + * device have vanished.
54 + *
55 + * @param deviceId device identifier
56 + */
57 + void linksVanished(DeviceId deviceId);
58 +}
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
51 manufacturer="Oplink a Molex company" hwVersion="ROADM" 51 manufacturer="Oplink a Molex company" hwVersion="ROADM"
52 swVersion="of-agent"> 52 swVersion="of-agent">
53 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" 53 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
54 - impl="org.onosproject.driver.optical.handshaker.OplinkRoadmHandshaker"/> 54 + impl="org.onosproject.driver.optical.handshaker.OplinkRoadm"/>
55 <behaviour api="org.onosproject.net.behaviour.LambdaQuery" 55 <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
56 impl="org.onosproject.driver.optical.query.OplinkRoadmLambdaQuery"/> 56 impl="org.onosproject.driver.optical.query.OplinkRoadmLambdaQuery"/>
57 <behaviour api="org.onosproject.net.optical.OpticalDevice" 57 <behaviour api="org.onosproject.net.optical.OpticalDevice"
......