blob: 873804157720e41ba9b9931e926fd8b97ec97af4 [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
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 */
16package org.onosproject.incubator.net.l2monitoring.soam.impl;
17
Sean Condon0e89bda2017-03-21 14:23:19 +000018import org.onosproject.core.ApplicationId;
19import org.onosproject.core.CoreService;
20import org.onosproject.incubator.net.l2monitoring.cfm.MepEntry;
21import org.onosproject.incubator.net.l2monitoring.cfm.MepTsCreate;
22import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
23import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
24import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
25import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
26import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService;
27import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
28import org.onosproject.incubator.net.l2monitoring.soam.SoamDmProgrammable;
29import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
30import org.onosproject.incubator.net.l2monitoring.soam.SoamService;
31import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate;
32import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry;
33import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatCurrent;
34import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory;
35import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate;
36import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry;
37import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent;
38import org.onosproject.net.DeviceId;
39import org.onosproject.net.device.DeviceService;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070040import org.osgi.service.component.annotations.Activate;
41import org.osgi.service.component.annotations.Component;
42import org.osgi.service.component.annotations.Deactivate;
43import org.osgi.service.component.annotations.Reference;
44import org.osgi.service.component.annotations.ReferenceCardinality;
Sean Condon0e89bda2017-03-21 14:23:19 +000045import org.slf4j.Logger;
46import org.slf4j.LoggerFactory;
47
Ray Milkeyd84f89b2018-08-17 14:54:17 -070048import java.util.Collection;
49import java.util.Optional;
50
Sean Condon0e89bda2017-03-21 14:23:19 +000051/**
52 * ONOS application component.
53 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070054@Component(immediate = true, service = SoamService.class)
Sean Condon0e89bda2017-03-21 14:23:19 +000055public class SoamManager implements SoamService {
56
57 private final Logger log = LoggerFactory.getLogger(getClass());
58 private static final String APP_ID = "org.onosproject.app.soam";
59
60 private ApplicationId appId;
61
Ray Milkeyd84f89b2018-08-17 14:54:17 -070062 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Sean Condon0e89bda2017-03-21 14:23:19 +000063 protected DeviceService deviceService;
64
Ray Milkeyd84f89b2018-08-17 14:54:17 -070065 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Sean Condon0e89bda2017-03-21 14:23:19 +000066 protected CoreService coreService;
67
Ray Milkeyd84f89b2018-08-17 14:54:17 -070068 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Sean Condon0e89bda2017-03-21 14:23:19 +000069 protected CfmMepService cfmMepService;
70
71 @Activate
72 protected void activate() {
73 appId = coreService.registerApplication(APP_ID);
74
75 log.info("SOAM Service Started");
76 }
77
78 @Deactivate
79 protected void deactivate() {
80 log.info("SOAM Service Stopped");
81 }
82
83 @Override
84 public Collection<DelayMeasurementEntry> getAllDms(
85 MdId mdName, MaIdShort maName, MepId mepId)
86 throws CfmConfigException, SoamConfigException {
87 MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
Sean Condon085621b2017-10-29 23:27:32 +000088 if (mep == null || mep.deviceId() == null) {
89 throw new CfmConfigException("MEP :"
90 + mdName + "/" + maName + "/" + mepId + " does not exist");
91 } else if (deviceService.getDevice(mep.deviceId()) == null) {
92 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
93 + mdName + "/" + maName + "/" + mepId + " does not exist");
94 } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
95 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
96 + mdName + "/" + maName + "/" + mepId +
97 " does not implement SoamDmProgrammable");
98 }
Sean Condon0e89bda2017-03-21 14:23:19 +000099 log.debug("Retrieving DMs for MD {}, MA {}, MEP {} on Device {}",
100 mdName, maName, mepId, mep.deviceId());
Sean Condon085621b2017-10-29 23:27:32 +0000101
102 return deviceService.getDevice(mep.deviceId())
103 .as(SoamDmProgrammable.class).getAllDms(mdName, maName, mepId);
Sean Condon0e89bda2017-03-21 14:23:19 +0000104 };
105
106 @Override
107 public DelayMeasurementEntry getDm(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
108 throws CfmConfigException, SoamConfigException {
109 MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
110 if (mep == null || mep.deviceId() == null) {
111 throw new CfmConfigException("MEP :"
112 + mdName + "/" + maName + "/" + mepId + " does not exist");
113 } else if (deviceService.getDevice(mep.deviceId()) == null) {
114 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
115 + mdName + "/" + maName + "/" + mepId + " does not exist");
116 } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
117 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
118 + mdName + "/" + maName + "/" + mepId +
119 " does not implement SoamDmProgrammable");
120 }
121 log.debug("Retrieving DM for DM {} in MD {}, MA {}, MEP {} on Device {}",
122 dmId, mdName, maName, mepId, mep.deviceId());
123 return deviceService.getDevice(mep.deviceId())
124 .as(SoamDmProgrammable.class).getDm(mdName, maName, mepId, dmId);
125 }
126
127 @Override
128 public DelayMeasurementStatCurrent getDmCurrentStat(MdId mdName,
129 MaIdShort maName, MepId mepId, SoamId dmId)
130 throws CfmConfigException, SoamConfigException {
131 MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
132 if (mep == null || mep.deviceId() == null) {
133 throw new CfmConfigException("MEP :"
134 + mdName + "/" + maName + "/" + mepId + " does not exist");
135 } else if (deviceService.getDevice(mep.deviceId()) == null) {
136 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
137 + mdName + "/" + maName + "/" + mepId + " does not exist");
138 } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
139 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
140 + mdName + "/" + maName + "/" + mepId +
141 " does not implement SoamDmProgrammable");
142 }
143 log.debug("Retrieving Current Stats for DM {} in MD {}, MA {}, MEP {} "
144 + "on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
145 return deviceService.getDevice(mep.deviceId())
146 .as(SoamDmProgrammable.class).getDmCurrentStat(mdName, maName, mepId, dmId);
147 }
148
149 @Override
150 public Collection<DelayMeasurementStatHistory> getDmHistoricalStats(
151 MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
152 throws SoamConfigException, CfmConfigException {
153 MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
154 if (mep == null || mep.deviceId() == null) {
155 throw new CfmConfigException("MEP :"
156 + mdName + "/" + maName + "/" + mepId + " does not exist");
157 } else if (deviceService.getDevice(mep.deviceId()) == null) {
158 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
159 + mdName + "/" + maName + "/" + mepId + " does not exist");
160 } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
161 throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
162 + mdName + "/" + maName + "/" + mepId +
163 " does not implement SoamDmProgrammable");
164 }
165 log.debug("Retrieving History Stats for DM {} in MD {}, MA {}, MEP {} "
166 + "on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
167 return deviceService.getDevice(mep.deviceId())
168 .as(SoamDmProgrammable.class).getDmHistoricalStats(mdName, maName, mepId, dmId);
169 }
170
171 @Override
172 public Optional<SoamId> createDm(MdId mdName, MaIdShort maName, MepId mepId,
173 DelayMeasurementCreate dmNew)
174 throws CfmConfigException, SoamConfigException {
175 DeviceId mepDeviceId = cfmMepService.getMep(mdName, maName, mepId).deviceId();
176 if (mepDeviceId == null) {
177 throw new CfmConfigException("Unable to create DM. MEP :"
178 + mdName + "/" + maName + "/" + mepId + " does not exist");
179 } else if (deviceService.getDevice(mepDeviceId) == null) {
180 throw new CfmConfigException("Device " + mepDeviceId + " from MEP :"
181 + mdName + "/" + maName + "/" + mepId + " does not exist");
182 } else if (!deviceService.getDevice(mepDeviceId).is(SoamDmProgrammable.class)) {
183 throw new CfmConfigException("Device " + mepDeviceId + " from MEP :"
184 + mdName + "/" + maName + "/" + mepId +
185 " does not implement SoamDmProgrammable");
186 }
187 log.debug("Creating new DM in MD {}, MA {}, MEP {} on Device {}",
188 mdName, maName, mepId, mepDeviceId);
189 return deviceService.getDevice(mepDeviceId)
190 .as(SoamDmProgrammable.class).createDm(mdName, maName, mepId, dmNew);
191 }
192
193 @Override
194 public void abortDm(MdId mdName, MaIdShort maName, MepId mepId)
195 throws CfmConfigException {
196 throw new UnsupportedOperationException("Not yet implemented");
197 }
198
199 @Override
200 public void abortDm(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
201 throws CfmConfigException {
202 throw new UnsupportedOperationException("Not yet implemented");
203 }
204
205 @Override
206 public void clearDelayHistoryStats(MdId mdName, MaIdShort maName,
207 MepId mepId) throws CfmConfigException {
208 throw new UnsupportedOperationException("Not yet implemented");
209 }
210
211 @Override
212 public void clearDelayHistoryStats(MdId mdName, MaIdShort maName,
213 MepId mepId, SoamId dmId) throws CfmConfigException {
214 throw new UnsupportedOperationException("Not yet implemented");
215 }
216
217 @Override
218 public Collection<LossMeasurementEntry> getAllLms(MdId mdName,
219 MaIdShort maName, MepId mepId) throws CfmConfigException {
220 throw new UnsupportedOperationException("Not yet implemented");
221 }
222
223 @Override
224 public LossMeasurementEntry getLm(MdId mdName, MaIdShort maName,
225 MepId mepId, SoamId lmId) throws CfmConfigException {
226 throw new UnsupportedOperationException("Not yet implemented");
227 }
228
229 @Override
230 public LossMeasurementStatCurrent getLmCurrentStat(MdId mdName,
Sean Condon3a1efef2018-02-24 13:16:03 +0000231 MaIdShort maName, MepId mepId, SoamId lmId) {
Sean Condon0e89bda2017-03-21 14:23:19 +0000232 throw new UnsupportedOperationException("Not yet implemented");
233 }
234
235 @Override
236 public Collection<LossMeasurementStatCurrent> getLmHistoricalStats(
237 MdId mdName, MaIdShort maName, MepId mepId, SoamId lmId) {
238 throw new UnsupportedOperationException("Not yet implemented");
239 }
240
241 @Override
242 public Optional<SoamId> createLm(MdId mdName, MaIdShort maName, MepId mepId,
243 LossMeasurementCreate lm) throws CfmConfigException {
244 throw new UnsupportedOperationException("Not yet implemented");
245 }
246
247 @Override
248 public void abortLm(MdId mdName, MaIdShort maName, MepId mepId)
249 throws CfmConfigException {
250 throw new UnsupportedOperationException("Not yet implemented");
251 }
252
253 @Override
254 public void abortLm(MdId mdName, MaIdShort maName, MepId mepId, SoamId lmId)
255 throws CfmConfigException {
256 throw new UnsupportedOperationException("Not yet implemented");
257 }
258
259 @Override
260 public void clearLossHistoryStats(MdId mdName, MaIdShort maName,
261 MepId mepId) throws CfmConfigException {
262 throw new UnsupportedOperationException("Not yet implemented");
263 }
264
265 @Override
266 public void clearLossHistoryStats(MdId mdName, MaIdShort maName,
267 MepId mepId, SoamId lmId) throws CfmConfigException {
268 throw new UnsupportedOperationException("Not yet implemented");
269 }
270
271 @Override
272 public void createTestSignal(MdId mdName, MaIdShort maName, MepId mepId,
273 MepTsCreate tsCreate) throws CfmConfigException {
274 throw new UnsupportedOperationException("Not yet implemented");
275 }
276
277 @Override
278 public void abortTestSignal(MdId mdName, MaIdShort maName, MepId mepId)
279 throws CfmConfigException {
280 throw new UnsupportedOperationException("Not yet implemented");
281 }
282}