aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/incubator
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-12-06 07:15:03 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-12-08 10:55:21 -0800
commit76dc892491948adae5e5e62cf94448967e8d865b (patch)
tree7a33ef05cc583946db21edad627060f280a53549 /framework/src/onos/incubator
parentd333c63fdec8b064184b0a26f8d777f267577fde (diff)
Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2
Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450 Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/incubator')
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java20
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/Alarm.java211
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java75
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEvent.java65
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java84
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java25
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java37
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistry.java25
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderService.java37
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmService.java121
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java309
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/package-info.java20
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java39
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java6
-rw-r--r--framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityIdTest.java74
-rw-r--r--framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmIdTest.java98
-rw-r--r--framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarmTest.java47
-rw-r--r--framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java85
-rw-r--r--framework/src/onos/incubator/rpc-grpc/pom.xml15
19 files changed, 1352 insertions, 41 deletions
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
index 9f2d4105..5246f313 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
@@ -28,6 +28,7 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.config.Config;
import org.onosproject.net.host.InterfaceIpAddress;
+import java.util.Iterator;
import java.util.Set;
/**
@@ -35,6 +36,7 @@ import java.util.Set;
*/
@Beta
public class InterfaceConfig extends Config<ConnectPoint> {
+ public static final String NAME = "name";
public static final String IPS = "ips";
public static final String MAC = "mac";
public static final String VLAN = "vlan";
@@ -52,6 +54,8 @@ public class InterfaceConfig extends Config<ConnectPoint> {
try {
for (JsonNode intfNode : array) {
+ String name = intfNode.path(NAME).asText(null);
+
Set<InterfaceIpAddress> ips = getIps(intfNode);
String mac = intfNode.path(MAC).asText();
@@ -59,7 +63,7 @@ public class InterfaceConfig extends Config<ConnectPoint> {
VlanId vlan = getVlan(intfNode);
- interfaces.add(new Interface(subject, ips, macAddr, vlan));
+ interfaces.add(new Interface(name, subject, ips, macAddr, vlan));
}
} catch (IllegalArgumentException e) {
throw new ConfigException(CONFIG_VALUE_ERROR, e);
@@ -76,6 +80,8 @@ public class InterfaceConfig extends Config<ConnectPoint> {
public void addInterface(Interface intf) {
ObjectNode intfNode = array.addObject();
+ intfNode.put(NAME, intf.name());
+
if (intf.mac() != null) {
intfNode.put(MAC, intf.mac().toString());
}
@@ -92,12 +98,14 @@ public class InterfaceConfig extends Config<ConnectPoint> {
/**
* Removes an interface from the config.
*
- * @param intf interface to remove
+ * @param name name of the interface to remove
*/
- public void removeInterface(Interface intf) {
- for (int i = 0; i < array.size(); i++) {
- if (intf.vlan().equals(getVlan(node))) {
- array.remove(i);
+ public void removeInterface(String name) {
+ Iterator<JsonNode> it = array.iterator();
+ while (it.hasNext()) {
+ JsonNode node = it.next();
+ if (node.path(NAME).asText().equals(name)) {
+ it.remove();
break;
}
}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/Alarm.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/Alarm.java
new file mode 100644
index 00000000..765fbfef
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/Alarm.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.net.DeviceId;
+
+/**
+ * Representation of an Alarm. At a given instant there can be only one alarm
+ * with the same deviceId + description + source combination.
+ */
+public interface Alarm {
+
+ /**
+ * Returns the unique alarm id within this ONOS instance.
+ *
+ * @return alarm identifier
+ */
+ AlarmId id();
+
+ /**
+ * The device to which this alarm is related.
+ *
+ * @return a device id
+ */
+ DeviceId deviceId();
+
+ /**
+ * Returns a description of alarm.
+ * <p>
+ * It may encapsulate Event Type as described by ITU Recommendation X.736
+ * ITU, Quoting https://tools.ietf.org/html/rfc3877 these include: other,
+ * communicationsAlarm, qualityOfServiceAlarm, processingErrorAlarm,
+ * equipmentAlarm, environmentalAlarm, integrityViolation,
+ * operationalViolation, physicalViolation,
+ * securityServiceOrMechanismViolation, timeDomainViolation
+ * <p>
+ * It may encapsulate Probable Cause as described by ITU Recommendation
+ * X.736 ITU, Quoting
+ * https://www.iana.org/assignments/ianaitualarmtc-mib/ianaitualarmtc-mib
+ * these include : aIS, callSetUpFailure, degradedSignal,
+ * farEndReceiverFailure, framingError, and hundreds more constants.
+ * <p>
+ * It may encapsulate a vendor-specific description of the underlying fault.
+ *
+ * @return description of alarm
+ */
+ String description();
+
+ /**
+ * Returns an entity within the context of this alarm's device. It may be
+ * null if deviceId sufficiently identifies the location. As an example, the
+ * source may indicate a port number
+ *
+ * @return source of alarm within the alarm's referenced Device.
+ */
+ AlarmEntityId source();
+
+ /**
+ * Returns the time when raised.
+ *
+ * @return time when raised, in milliseconds since start of epoch
+ */
+ long timeRaised();
+
+ /**
+ * Returns time at which the alarm was updated most recently, due to some
+ * change in the device, or ONOS. If the alarm has been cleared, this is the
+ * time at which the alarm was cleared.
+ *
+ * @return time when last updated, in milliseconds since start of epoch
+ */
+ long timeUpdated();
+
+ /**
+ * Returns the time when cleared. Null indicated no clear time, i.e. the
+ * alarm is still active.
+ *
+ * @return time when cleared, in milliseconds since start of epoch or null
+ * if uncleared.
+ */
+ Long timeCleared();
+
+ /**
+ * Returns the severity. Note, that cleared alarms may have EITHER
+ * SeverityLevel = CLEARED, or may be not present; both scenarios should be
+ * handled.
+ *
+ * @return severity of the alarm
+ */
+ SeverityLevel severity();
+
+ /**
+ * Returns true if alarm is service affecting Note: Whilst X.733 combines
+ * service-affecting state with severity (where severities of critical and
+ * major are deemed service-affecting) ONOS keeps these attributes separate.
+ *
+ * @return whether service affecting (true indicates it is)
+ */
+ boolean serviceAffecting();
+
+ /**
+ * Returns a flag to indicate if this alarm has been acknowledged. All
+ * alarms are unacknowledged until and unless an ONOS user takes action to
+ * indicate so.
+ *
+ * @return whether alarm is currently acknowledged (true indicates it is)
+ */
+ boolean acknowledged();
+
+ /**
+ * Returns a flag to indicate if this alarm is manually-cleared by a user action within ONOS. Some stateless events
+ * e.g. backup-failure or upgrade-failure, may be mapped by ONOS to alarms, and these may be deemed manually-
+ * clearable. The more typical case is that an alarm represents a persistent fault on or related to a device and
+ * such alarms are never manually clearable, i.e. a configuration or operational state must occur for the alarm to
+ * clear.
+ *
+ * @return whether it may be cleared by a user action (true indicates it is)
+ */
+ boolean manuallyClearable();
+
+ /**
+ * Returns the user to whom this alarm is assigned; this is for future use
+ * and always returns null in this release. It is anticipated that in future ONOS
+ * releases, the existing JAAS user/key/role configuration will be extended
+ * to include a mechanism whereby some groups of users may allocate alarms
+ * to other users for bookkeeping and administrative purposes, and that ONOS
+ * will additionally provide a REST based mechanism, to retrieve from JAAS,
+ * the set of users to whom alarm assignment is possible for the current
+ * user.
+ *
+ * @return the assigned user; always null in this release.
+ */
+ String assignedUser();
+
+ /**
+ * Represents the severity level on an alarm, as per ITU-T X.733
+ * specifications.
+ * <p>
+ * The precedence is as follows for : Critical &gt; Major &gt; Minor &gt; Warning.
+ */
+ enum SeverityLevel {
+
+ /**
+ * From X.733: This indicates the clearing of one or more previously
+ * reported alarms. This alarm clears all alarms for this managed object
+ * that have the same Alarm type, Probable cause and Specific problems
+ * (if given). Multiple associated notifications may be cleared by using
+ * the Correlated notifications parameter (defined below). This
+ * Recommendation | International Standard does not require that the
+ * clearing of previously reported alarms be reported. Therefore, a
+ * managing system cannot assume that the absence of an alarm with the
+ * Cleared severity level means that the condition that caused the
+ * generation of previous alarms is still present. Managed object
+ * definers shall state if, and under which conditions, the Cleared
+ * severity level is used.
+ */
+ CLEARED,
+ /**
+ * From X.733: This indicates that the severity level cannot be
+ * determined.
+ */
+ INDETERMINATE,
+ /**
+ * From X.733: This indicates that a service affecting condition has
+ * occurred and an immediate corrective action is required. Such a
+ * severity can be reported, for example, when a managed object becomes
+ * totally out of service and its capability must be restored.
+ */
+ CRITICAL,
+ /**
+ * X.733 definition: This indicates that a service affecting condition
+ * has developed and an urgent corrective action is required. Such a
+ * severity can be reported, for example, when there is a severe
+ * degradation in the capability of the managed object and its full
+ * capability must be restored.
+ */
+ MAJOR,
+ /**
+ * From X.733: This indicates the existence of a non-service affecting
+ * fault condition and that corrective action should be taken in order
+ * to prevent a more serious (for example, service affecting) fault.
+ * Such a severity can be reported, for example, when the detected alarm
+ * condition is not currently degrading the capacity of the managed
+ * object.
+ */
+ MINOR,
+ /**
+ * From X.733: This indicates the detection of a potential or impending
+ * service affecting fault, before any significant effects have been
+ * felt. Action should be taken to further diagnose (if necessary) and
+ * correct the problem in order to prevent it from becoming a more
+ * serious service affecting fault.
+ */
+ WARNING;
+
+ }
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java
new file mode 100644
index 00000000..5bf86749
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
+import java.net.URI;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * Immutable representation of a alarm source. It is meaningful within the
+ * context of a device.
+ */
+public final class AlarmEntityId {
+
+ public static final AlarmEntityId NONE = new AlarmEntityId(URI.create("none:none"));
+ public static final Set<String> SCHEMES = ImmutableSet.of("none", "port", "och", "other");
+
+ private final URI uri;
+
+ private AlarmEntityId(final URI uri) {
+ this.uri = uri;
+ }
+
+ protected AlarmEntityId() {
+ uri = NONE.uri;
+ }
+
+ public static AlarmEntityId alarmEntityId(final String string) {
+ return alarmEntityId(URI.create(string));
+ }
+
+ public static AlarmEntityId alarmEntityId(final URI uri) {
+ checkArgument(SCHEMES.contains(uri.getScheme()), "Unexpected scheme");
+ return new AlarmEntityId(uri);
+ }
+
+ @Override
+ public String toString() {
+ return uri.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(uri);
+
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AlarmEntityId) {
+ final AlarmEntityId other = (AlarmEntityId) obj;
+ return Objects.equals(this.uri, other.uri);
+ }
+ return false;
+ }
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEvent.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEvent.java
new file mode 100644
index 00000000..bbbd993e
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEvent.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Entity that represents Alarm events.
+ */
+public class AlarmEvent extends AbstractEvent<AlarmEvent.Type, Alarm> {
+
+
+ /**
+ * Creates an event of a given type and for the specified alarm and the
+ * current time.
+ *
+ * @param type topology event type
+ * @param alarm the alarm
+ */
+ public AlarmEvent(Type type, Alarm alarm) {
+ super(type, alarm);
+ }
+
+ /**
+ * Creates an event of a given type and for the specified alarm and time.
+ *
+ * @param type link event type
+ * @param alarm the alarm
+ * @param time occurrence time
+ */
+ public AlarmEvent(Type type, Alarm alarm,
+ long time) {
+ super(type, alarm, time);
+ }
+
+ /**
+ * Type of alarm events.
+ */
+ public enum Type {
+ /**
+ * A Raised Alarm.
+ */
+ RAISE,
+
+ /**
+ * A Cleared Alarm.
+ */
+ CLEAR
+ }
+
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
new file mode 100644
index 00000000..e0107f87
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import com.google.common.annotations.Beta;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Alarm identifier suitable as an external key.
+ * <p>
+ * This class is immutable.</p>
+ */
+@Beta
+public final class AlarmId {
+
+ private final long id;
+
+ /**
+ * Instantiates a new Alarm id.
+ *
+ * @param id the id
+ */
+ public AlarmId(final long id) {
+ this.id = id;
+ }
+
+ /**
+ * Creates an alarm identifier from the specified long representation.
+ *
+ * @param value long value
+ * @return intent identifier
+ */
+ public static AlarmId valueOf(final long value) {
+ return new AlarmId(value);
+ }
+
+ /**
+ * Returns the backing integer index.
+ *
+ * @return backing integer index
+ */
+ public long fingerprint() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AlarmId) {
+ final AlarmId other = (AlarmId) obj;
+ return Objects.equals(this.id, other.id);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).toString();
+ }
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java
new file mode 100644
index 00000000..c5e82ba5
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.event.EventListener;
+
+
+/**
+ * Entity capable of receiving Alarm related events.
+ */
+public interface AlarmListener extends EventListener<AlarmEvent> {
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java
new file mode 100644
index 00000000..82bcda2a
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.Provider;
+
+/**
+ * Abstraction of a Alarm provider.
+ */
+public interface AlarmProvider extends Provider {
+
+ /**
+ * Triggers an asynchronous discovery of the alarms on the specified device,
+ * intended to refresh internal alarm model for the device. An indirect
+ * result of this should be invocation of
+ * {@link org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService#updateAlarmList} )}
+ * at some later point in time.
+ *
+ * @param deviceId ID of device to be probed
+ */
+ void triggerProbe(DeviceId deviceId);
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistry.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistry.java
new file mode 100644
index 00000000..618298c0
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistry.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+
+import org.onosproject.net.provider.ProviderRegistry;
+
+/**
+ * Abstraction of a alarm provider registry.
+ */
+public interface AlarmProviderRegistry extends ProviderRegistry<AlarmProvider, AlarmProviderService> {
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderService.java
new file mode 100644
index 00000000..727aa281
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderService.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.ProviderService;
+
+import java.util.Collection;
+
+/**
+ * The interface Alarm provider service.
+ */
+public interface AlarmProviderService extends ProviderService<AlarmProvider> {
+
+ /**
+ * Sends active alarm list for a device.
+ *
+ * @param deviceId identity of the device
+ * @param alarms list of device alarms
+ */
+ void updateAlarmList(DeviceId deviceId, Collection<Alarm> alarms);
+
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmService.java
new file mode 100644
index 00000000..03c0c7b1
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmService.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import com.google.common.annotations.Beta;
+//import org.onosproject.event.ListenerService;
+
+import java.util.Set;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Service for interacting with the alarm handling of devices. Unless stated
+ * otherwise method return active AND recently-cleared alarms.
+ */
+@Beta
+public interface AlarmService {
+// extends ListenerService<AlarmEvent, AlarmListener> {
+
+ /**
+ * Alarm should be updated in ONOS's internal representation; only
+ * administration/book-keeping fields may be updated. Attempting to update
+ * fields which are mapped directly from device is prohibited.
+ *
+ * @param replacement alarm with updated book-keeping fields
+ * @return updated alarm (including any recent device derived changes)
+
+ * @throws java.lang.IllegalStateException if attempt to update not allowed
+ * fields.
+ */
+ Alarm update(Alarm replacement);
+
+ /**
+ * Returns the number of ACTIVE alarms on a device.
+ *
+ * @param deviceId the device
+ * @return number of alarms
+ */
+ int getActiveAlarmCount(DeviceId deviceId);
+
+ /**
+ * Returns the alarm with the specified identifier.
+ *
+ * @param alarmId alarm identifier
+ * @return alarm or null if one with the given identifier is not known
+ */
+ Alarm getAlarm(AlarmId alarmId);
+
+ /**
+ * Returns all of the alarms.
+ *
+ * @return the alarms
+ */
+ Set<Alarm> getAlarms();
+
+ /**
+ * Returns all of the ACTIVE alarms. Recently cleared alarms excluded.
+ *
+ * @return the alarms
+ */
+ Set<Alarm> getActiveAlarms();
+
+ /**
+ * Returns the alarms with the specified severity.
+ *
+ * @param severity the alarm severity
+ * @return the active alarms with a particular severity
+ */
+ Set<Alarm> getAlarms(Alarm.SeverityLevel severity);
+
+ /**
+ * Returns the alarm for a given device, regardless of source within that
+ * device.
+ *
+ * @param deviceId the device
+ * @return the alarms
+ */
+ Set<Alarm> getAlarms(DeviceId deviceId);
+
+ /**
+ * Returns the alarm for a given device and source.
+ *
+ * @param deviceId the device
+ * @param source the source within the device
+ * @return the alarms
+ */
+ Set<Alarm> getAlarms(DeviceId deviceId, AlarmEntityId source);
+
+ /**
+ * Returns the alarm affecting a given link.
+ *
+ * @param src one end of the link
+ * @param dst one end of the link
+ * @return the alarms
+ */
+ Set<Alarm> getAlarmsForLink(ConnectPoint src, ConnectPoint dst);
+
+ /**
+ * Returns the alarm affecting a given flow.
+ *
+ * @param deviceId the device
+ * @param flowId the flow
+ * @return the alarms
+ */
+ Set<Alarm> getAlarmsForFlow(DeviceId deviceId, long flowId);
+
+// Support retrieving alarms affecting other ONOS entity types may be added in future release
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java
new file mode 100644
index 00000000..afa366ad
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.net.DeviceId;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Default implementation of an alarm.
+ */
+public final class DefaultAlarm implements Alarm {
+
+ private final AlarmId id;
+
+ private final DeviceId deviceId;
+ private final String description;
+ private final AlarmEntityId source;
+ private final long timeRaised;
+ private final long timeUpdated;
+ private final Long timeCleared;
+ private final SeverityLevel severity;
+ private final boolean isServiceAffecting;
+ private final boolean isAcknowledged;
+ private final boolean isManuallyClearable;
+ private final String assignedUser;
+
+ /**
+ * Instantiates a new Default alarm.
+ *
+ * @param id the id
+ * @param deviceId the device id
+ * @param description the description
+ * @param source the source, null indicates none.
+ * @param timeRaised the time raised.
+ * @param timeUpdated the time last updated.
+ * @param timeCleared the time cleared, null indicates uncleared.
+ * @param severity the severity
+ * @param isServiceAffecting the service affecting
+ * @param isAcknowledged the acknowledged
+ * @param isManuallyClearable the manually clearable
+ * @param assignedUser the assigned user, `null` indicates none.
+ */
+ private DefaultAlarm(final AlarmId id,
+ final DeviceId deviceId,
+ final String description,
+ final AlarmEntityId source,
+ final long timeRaised,
+ final long timeUpdated,
+ final Long timeCleared,
+ final SeverityLevel severity,
+ final boolean isServiceAffecting,
+ final boolean isAcknowledged,
+ final boolean isManuallyClearable,
+ final String assignedUser) {
+ this.id = id;
+ this.deviceId = deviceId;
+ this.description = description;
+ this.source = source;
+ this.timeRaised = timeRaised;
+ this.timeUpdated = timeUpdated;
+ this.timeCleared = timeCleared;
+ this.severity = severity;
+ this.isServiceAffecting = isServiceAffecting;
+ this.isAcknowledged = isAcknowledged;
+ this.isManuallyClearable = isManuallyClearable;
+ this.assignedUser = assignedUser;
+ }
+
+ @Override
+ public AlarmId id() {
+ return id;
+ }
+
+ @Override
+ public DeviceId deviceId() {
+ return deviceId;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public AlarmEntityId source() {
+ return source;
+ }
+
+ @Override
+ public long timeRaised() {
+ return timeRaised;
+ }
+
+ @Override
+ public long timeUpdated() {
+ return timeUpdated;
+ }
+
+ @Override
+ public Long timeCleared() {
+ return timeCleared;
+ }
+
+ @Override
+ public SeverityLevel severity() {
+ return severity;
+ }
+
+ @Override
+ public boolean serviceAffecting() {
+ return isServiceAffecting;
+ }
+
+ @Override
+ public boolean acknowledged() {
+ return isAcknowledged;
+ }
+
+ @Override
+ public boolean manuallyClearable() {
+ return isManuallyClearable;
+ }
+
+ @Override
+ public String assignedUser() {
+ return assignedUser;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, deviceId, description,
+ source, timeRaised, timeUpdated, timeCleared, severity,
+ isServiceAffecting, isAcknowledged,
+ isManuallyClearable, assignedUser);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final DefaultAlarm other = (DefaultAlarm) obj;
+ if (!Objects.equals(this.id, other.id)) {
+ return false;
+ }
+ if (!Objects.equals(this.deviceId, other.deviceId)) {
+ return false;
+ }
+ if (!Objects.equals(this.description, other.description)) {
+ return false;
+ }
+ if (!Objects.equals(this.source, other.source)) {
+ return false;
+ }
+ if (this.timeRaised != other.timeRaised) {
+ return false;
+ }
+ if (this.timeUpdated != other.timeUpdated) {
+ return false;
+ }
+ if (!Objects.equals(this.timeCleared, other.timeCleared)) {
+ return false;
+ }
+ if (this.severity != other.severity) {
+ return false;
+ }
+ if (this.isServiceAffecting != other.isServiceAffecting) {
+ return false;
+ }
+ if (this.isAcknowledged != other.isAcknowledged) {
+ return false;
+ }
+ if (this.isManuallyClearable != other.isManuallyClearable) {
+ return false;
+ }
+ if (!Objects.equals(this.assignedUser, other.assignedUser)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", id)
+ .add("deviceId", deviceId)
+ .add("description", description)
+ .add("source", source)
+ .add("timeRaised", timeRaised)
+ .add("timeUpdated", timeUpdated)
+ .add("timeCleared", timeCleared)
+ .add("severity", severity)
+ .add("serviceAffecting", isServiceAffecting)
+ .add("acknowledged", isAcknowledged)
+ .add("manuallyClearable", isManuallyClearable)
+ .add("assignedUser", assignedUser)
+ .toString();
+ }
+
+ public static class Builder {
+
+ // Manadatory fields ..
+ private final AlarmId id;
+ private final DeviceId deviceId;
+ private final String description;
+ private final SeverityLevel severity;
+ private final long timeRaised;
+
+ // Optional fields ..
+ private AlarmEntityId source = AlarmEntityId.NONE;
+ private long timeUpdated;
+ private Long timeCleared = null;
+ private boolean isServiceAffecting = false;
+ private boolean isAcknowledged = false;
+ private boolean isManuallyClearable = false;
+ private String assignedUser = null;
+
+ public Builder(final Alarm alarm) {
+ this(alarm.id(), alarm.deviceId(), alarm.description(), alarm.severity(), alarm.timeRaised());
+ this.source = AlarmEntityId.NONE;
+ this.timeUpdated = alarm.timeUpdated();
+ this.timeCleared = alarm.timeCleared();
+ this.isServiceAffecting = alarm.serviceAffecting();
+ this.isAcknowledged = alarm.acknowledged();
+ this.isManuallyClearable = alarm.manuallyClearable();
+ this.assignedUser = alarm.assignedUser();
+
+ }
+
+ public Builder(final AlarmId id, final DeviceId deviceId,
+ final String description, final SeverityLevel severity, final long timeRaised) {
+ super();
+ this.id = id;
+ this.deviceId = deviceId;
+ this.description = description;
+ this.severity = severity;
+ this.timeRaised = timeRaised;
+ // Unless specified time-updated is same as raised.
+ this.timeUpdated = timeRaised;
+ }
+
+ public Builder forSource(final AlarmEntityId source) {
+ this.source = source;
+ return this;
+ }
+
+ public Builder withTimeUpdated(final long timeUpdated) {
+ this.timeUpdated = timeUpdated;
+ return this;
+ }
+
+ public Builder withTimeCleared(final Long timeCleared) {
+ this.timeCleared = timeCleared;
+ return this;
+ }
+
+ public Builder withServiceAffecting(final boolean isServiceAffecting) {
+ this.isServiceAffecting = isServiceAffecting;
+ return this;
+ }
+
+ public Builder withAcknowledged(final boolean isAcknowledged) {
+ this.isAcknowledged = isAcknowledged;
+ return this;
+ }
+
+ public Builder withManuallyClearable(final boolean isManuallyClearable) {
+ this.isManuallyClearable = isManuallyClearable;
+ return this;
+ }
+
+ public Builder withAssignedUser(final String assignedUser) {
+ this.assignedUser = assignedUser;
+ return this;
+ }
+
+ public DefaultAlarm build() {
+ checkNotNull(id, "Must specify an alarm id");
+ checkNotNull(deviceId, "Must specify a device");
+ checkNotNull(description, "Must specify a description");
+ checkNotNull(timeRaised, "Must specify a time raised");
+ checkNotNull(timeUpdated, "Must specify a time updated");
+ checkNotNull(severity, "Must specify a severity");
+
+ return new DefaultAlarm(id, deviceId, description, source, timeRaised, timeUpdated, timeCleared,
+ severity, isServiceAffecting, isAcknowledged, isManuallyClearable, assignedUser);
+ }
+ }
+}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/package-info.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/package-info.java
new file mode 100644
index 00000000..b2b8ec9f
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Abstractions for interacting with alarms. An alarm is a persistent indication
+ * of a fault that clears only when the triggering condition has been resolved.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
index b9d3eadf..e2109689 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
@@ -30,11 +30,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* An Interface maps network configuration information (such as addresses and
- * vlans) to a port in the network. This is considered a L2/L3 network
- * interface.
+ * vlans) to a port in the network.
*/
@Beta
public class Interface {
+ public static final String NO_INTERFACE_NAME = "";
+
+ private final String name;
private final ConnectPoint connectPoint;
private final Set<InterfaceIpAddress> ipAddresses;
private final MacAddress macAddress;
@@ -43,14 +45,16 @@ public class Interface {
/**
* Creates new Interface with the provided configuration.
*
+ * @param name name of the interface
* @param connectPoint the connect point this interface maps to
* @param ipAddresses Set of IP addresses
* @param macAddress MAC address
* @param vlan VLAN ID
*/
- public Interface(ConnectPoint connectPoint,
+ public Interface(String name, ConnectPoint connectPoint,
Set<InterfaceIpAddress> ipAddresses,
MacAddress macAddress, VlanId vlan) {
+ this.name = name == null ? NO_INTERFACE_NAME : name;
this.connectPoint = checkNotNull(connectPoint);
this.ipAddresses = ipAddresses == null ? Sets.newHashSet() : ipAddresses;
this.macAddress = macAddress == null ? MacAddress.NONE : macAddress;
@@ -58,6 +62,29 @@ public class Interface {
}
/**
+ * Creates new Interface with the provided configuration.
+ *
+ * @param connectPoint the connect point this interface maps to
+ * @param ipAddresses Set of IP addresses
+ * @param macAddress MAC address
+ * @param vlan VLAN ID
+ */
+ public Interface(ConnectPoint connectPoint,
+ Set<InterfaceIpAddress> ipAddresses,
+ MacAddress macAddress, VlanId vlan) {
+ this(NO_INTERFACE_NAME, connectPoint, ipAddresses, macAddress, vlan);
+ }
+
+ /**
+ * Retrieves the name of the interface.
+ *
+ * @return name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
* Retrieves the connection point that this interface maps to.
*
* @return the connection point
@@ -101,7 +128,8 @@ public class Interface {
Interface otherInterface = (Interface) other;
- return Objects.equals(connectPoint, otherInterface.connectPoint) &&
+ return Objects.equals(name, otherInterface.name) &&
+ Objects.equals(connectPoint, otherInterface.connectPoint) &&
Objects.equals(ipAddresses, otherInterface.ipAddresses) &&
Objects.equals(macAddress, otherInterface.macAddress) &&
Objects.equals(vlan, otherInterface.vlan);
@@ -109,12 +137,13 @@ public class Interface {
@Override
public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
+ return Objects.hash(connectPoint, name, ipAddresses, macAddress, vlan);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
+ .add("name", name)
.add("connectPoint", connectPoint)
.add("ipAddresses", ipAddresses)
.add("macAddress", macAddress)
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
index 56d5aecc..32d480d6 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
@@ -16,13 +16,13 @@
package org.onosproject.incubator.net.intf;
-import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
/**
* Provides a means to modify the interfaces configuration.
*/
public interface InterfaceAdminService {
+
/**
* Adds a new interface configuration to the system.
*
@@ -34,7 +34,7 @@ public interface InterfaceAdminService {
* Removes an interface configuration from the system.
*
* @param connectPoint connect point of the interface
- * @param vlanId vlan id
+ * @param name name of the interface
*/
- void remove(ConnectPoint connectPoint, VlanId vlanId);
+ boolean remove(ConnectPoint connectPoint, String name);
}
diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityIdTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityIdTest.java
new file mode 100644
index 00000000..55f052ac
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityIdTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import com.google.common.testing.EqualsTester;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId.alarmEntityId;
+
+/**
+ * Test of the alarm source identifier.
+ *
+ */
+public class AlarmEntityIdTest {
+
+ /**
+ * Checks that the class is immutable.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(AlarmEntityId.class);
+ }
+
+ @Test
+ public void string() {
+ assertEquals("och:foo",
+ alarmEntityId("och:foo").toString());
+ }
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(
+ alarmEntityId("och:foo"),
+ alarmEntityId("och:foo"))
+ .addEqualityGroup(alarmEntityId("och:bar"))
+ .testEquals();
+
+ }
+
+ @Test
+ public void validSchemaPermitted() {
+ alarmEntityId("none:foo");
+ alarmEntityId("port:foo");
+ alarmEntityId("och:foo");
+ alarmEntityId("other:foo");
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void verifyUnexpectedSchemaRejected() {
+ alarmEntityId("junk:foo");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void verifyCorruptSchemaRejected() {
+ alarmEntityId("other:");
+ }
+
+}
diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmIdTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmIdTest.java
new file mode 100644
index 00000000..74453a42
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmIdTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * This class tests the immutability, equality, and non-equality of
+ * {@link AlarmId}.
+ */
+public class AlarmIdTest {
+ private static final long ID_A = 1L;
+ private static final long ID_B = 2L;
+ private static final long ID_Z = 987654321L;
+
+ /**
+ * Tests the immutability of {@link AlarmId}.
+ */
+ @Test
+ public void intentIdFollowsGuidelineForImmutableObject() {
+ assertThatClassIsImmutable(AlarmId.class);
+ }
+
+ /**
+ * Tests equality of {@link AlarmId}.
+ */
+ @Test
+ public void testEquality() {
+ final AlarmId id1 = new AlarmId(ID_A);
+ final AlarmId id2 = new AlarmId(ID_A);
+
+ assertThat(id1, is(id2));
+ }
+
+
+ /**
+ * Tests non-equality of {@link AlarmId}.
+ */
+ @Test
+ public void testNonEquality() {
+ final AlarmId id1 = new AlarmId(ID_A);
+ final AlarmId id2 = new AlarmId(ID_B);
+
+ assertThat(id1, is(not(id2)));
+ }
+
+ @Test
+ public void valueOf() {
+ final AlarmId id = new AlarmId(0xdeadbeefL);
+ assertEquals("incorrect valueOf", id, AlarmId.valueOf(0xdeadbeefL));
+ }
+
+ /**
+ * Tests the equals(), hashCode() and toString() methods.
+ */
+ @Test
+ public void testEquals() {
+ final AlarmId id1 = new AlarmId(11111L);
+ final AlarmId sameAsId1 = new AlarmId(11111L);
+ final AlarmId id2 = new AlarmId(22222L);
+
+ new EqualsTester()
+ .addEqualityGroup(id1, sameAsId1)
+ .addEqualityGroup(id2)
+ .testEquals();
+ }
+
+ /**
+ * Tests construction of an AlarmId object.
+ */
+ @Test
+ public void testConstruction() {
+ final AlarmId id1 = new AlarmId(ID_Z);
+ assertEquals(id1.fingerprint(), ID_Z);
+
+ // No default constructor so no need to test it !
+ }
+}
diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarmTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarmTest.java
new file mode 100644
index 00000000..199ed0d9
--- /dev/null
+++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarmTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.faultmanagement.alarm;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import org.onosproject.net.DeviceId;
+
+public class DefaultAlarmTest {
+
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultAlarm.class);
+ }
+
+ /**
+ * Checks the construction of a DefaultAlarm object.
+ */
+ @Test
+ public void testConstruction() {
+ final String nameValue = "name3";
+ final DefaultAlarm a = new DefaultAlarm.Builder(AlarmId.valueOf(4),
+ DeviceId.NONE, nameValue, Alarm.SeverityLevel.CLEARED, 3).build();
+
+ assertThat(a, is(notNullValue()));
+ final DefaultAlarm b = new DefaultAlarm.Builder(a).build();
+
+ assertEquals(a, b);
+ }
+}
diff --git a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java
index 0439d038..bbd96de0 100644
--- a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java
+++ b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java
@@ -18,6 +18,7 @@ package org.onosproject.incubator.net.intf.impl;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -39,9 +40,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
+import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toSet;
@@ -145,7 +148,7 @@ public class InterfaceManager implements InterfaceService,
private void updateInterfaces(InterfaceConfig intfConfig) {
try {
- interfaces.put(intfConfig.subject(), intfConfig.getInterfaces());
+ interfaces.put(intfConfig.subject(), Sets.newHashSet(intfConfig.getInterfaces()));
} catch (ConfigException e) {
log.error("Error in interface config", e);
}
@@ -157,18 +160,7 @@ public class InterfaceManager implements InterfaceService,
@Override
public void add(Interface intf) {
- if (interfaces.containsKey(intf.connectPoint())) {
- boolean conflict = interfaces.get(intf.connectPoint()).stream()
- .filter(i -> i.connectPoint().equals(intf.connectPoint()))
- .filter(i -> i.mac().equals(intf.mac()))
- .filter(i -> i.vlan().equals(intf.vlan()))
- .findAny().isPresent();
-
- if (conflict) {
- log.error("Can't add interface because it conflicts with existing config");
- return;
- }
- }
+ addInternal(intf);
InterfaceConfig config =
configService.addConfig(intf.connectPoint(), CONFIG_CLASS);
@@ -178,29 +170,72 @@ public class InterfaceManager implements InterfaceService,
configService.applyConfig(intf.connectPoint(), CONFIG_CLASS, config.node());
}
+ private void addInternal(Interface intf) {
+ interfaces.compute(intf.connectPoint(), (cp, current) -> {
+ if (current == null) {
+ return Sets.newHashSet(intf);
+ }
+
+ Iterator<Interface> it = current.iterator();
+ while (it.hasNext()) {
+ Interface i = it.next();
+ if (i.name().equals(intf.name())) {
+ it.remove();
+ break;
+ }
+ }
+
+ current.add(intf);
+ return current;
+ });
+ }
+
@Override
- public void remove(ConnectPoint connectPoint, VlanId vlanId) {
- Optional<Interface> intf = interfaces.get(connectPoint).stream()
- .filter(i -> i.vlan().equals(vlanId))
- .findAny();
-
- if (!intf.isPresent()) {
- log.error("Can't find interface {}/{} to remove", connectPoint, vlanId);
- return;
- }
+ public boolean remove(ConnectPoint connectPoint, String name) {
+ boolean success = removeInternal(name, connectPoint);
- InterfaceConfig config = configService.addConfig(intf.get().connectPoint(), CONFIG_CLASS);
- config.removeInterface(intf.get());
+ InterfaceConfig config = configService.addConfig(connectPoint, CONFIG_CLASS);
+ config.removeInterface(name);
try {
if (config.getInterfaces().isEmpty()) {
configService.removeConfig(connectPoint, CONFIG_CLASS);
} else {
- configService.applyConfig(intf.get().connectPoint(), CONFIG_CLASS, config.node());
+ configService.applyConfig(connectPoint, CONFIG_CLASS, config.node());
}
} catch (ConfigException e) {
log.error("Error reading interfaces JSON", e);
}
+
+ return success;
+ }
+
+ public boolean removeInternal(String name, ConnectPoint connectPoint) {
+ AtomicBoolean removed = new AtomicBoolean(false);
+
+ interfaces.compute(connectPoint, (cp, current) -> {
+ if (current == null) {
+ return null;
+ }
+
+ Iterator<Interface> it = current.iterator();
+ while (it.hasNext()) {
+ Interface i = it.next();
+ if (i.name().equals(name)) {
+ it.remove();
+ removed.set(true);
+ break;
+ }
+ }
+
+ if (current.isEmpty()) {
+ return null;
+ } else {
+ return current;
+ }
+ });
+
+ return removed.get();
}
/**
diff --git a/framework/src/onos/incubator/rpc-grpc/pom.xml b/framework/src/onos/incubator/rpc-grpc/pom.xml
index f528ca53..367b50a2 100644
--- a/framework/src/onos/incubator/rpc-grpc/pom.xml
+++ b/framework/src/onos/incubator/rpc-grpc/pom.xml
@@ -122,6 +122,18 @@
</extensions>
<plugins>
+ <!-- TODO This is included to suppress the generation of javadocs for
+ this package. There is a problem when we try to package the
+ auto-generated code's javadoc into a jar. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <sourcepath>${basedir}/src/main/java/</sourcepath>
+ <excludePackageNames>org.onosproject.incubator.rpc.grpc</excludePackageNames>
+ </configuration>
+ </plugin>
+
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -224,8 +236,7 @@
</configuration>
</execution>
</executions>
- </plugin>
-
+ </plugin>
</plugins>
</build>