diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
commit | 13d05bc8458758ee39cb829098241e89616717ee (patch) | |
tree | 22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/core/api/src/main/java/org/onosproject/net/device | |
parent | 6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff) |
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/device')
20 files changed, 1894 insertions, 0 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java new file mode 100644 index 00000000..3a8c8c1f --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceDescription.java @@ -0,0 +1,145 @@ +/* + * 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.net.device; + +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.SparseAnnotations; +import org.onlab.packet.ChassisId; + +import java.net.URI; + +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.onosproject.net.Device.Type; + +/** + * Default implementation of immutable device description entity. + */ +public class DefaultDeviceDescription extends AbstractDescription + implements DeviceDescription { + private final URI uri; + private final Type type; + private final String manufacturer; + private final String hwVersion; + private final String swVersion; + private final String serialNumber; + private final ChassisId chassisId; + + /** + * Creates a device description using the supplied information. + * + * @param uri device URI + * @param type device type + * @param manufacturer device manufacturer + * @param hwVersion device HW version + * @param swVersion device SW version + * @param serialNumber device serial number + * @param chassis chassis id + * @param annotations optional key/value annotations map + */ + public DefaultDeviceDescription(URI uri, Type type, String manufacturer, + String hwVersion, String swVersion, + String serialNumber, ChassisId chassis, + SparseAnnotations... annotations) { + super(annotations); + this.uri = checkNotNull(uri, "Device URI cannot be null"); + this.type = checkNotNull(type, "Device type cannot be null"); + this.manufacturer = manufacturer; + this.hwVersion = hwVersion; + this.swVersion = swVersion; + this.serialNumber = serialNumber; + this.chassisId = chassis; + } + + /** + * Creates a device description using the supplied information. + * @param base DeviceDescription to basic information + * @param annotations Annotations to use. + */ + public DefaultDeviceDescription(DeviceDescription base, + SparseAnnotations... annotations) { + this(base.deviceURI(), base.type(), base.manufacturer(), + base.hwVersion(), base.swVersion(), base.serialNumber(), + base.chassisId(), annotations); + } + + /** + * Creates a device description using the supplied information. + * @param base DeviceDescription to basic information (except for type) + * @param type device type + * @param annotations Annotations to use. + */ + public DefaultDeviceDescription(DeviceDescription base, Type type, SparseAnnotations... annotations) { + this(base.deviceURI(), type, base.manufacturer(), + base.hwVersion(), base.swVersion(), base.serialNumber(), + base.chassisId(), annotations); + } + + @Override + public URI deviceURI() { + return uri; + } + + @Override + public Type type() { + return type; + } + + @Override + public String manufacturer() { + return manufacturer; + } + + @Override + public String hwVersion() { + return hwVersion; + } + + @Override + public String swVersion() { + return swVersion; + } + + @Override + public String serialNumber() { + return serialNumber; + } + + @Override + public ChassisId chassisId() { + return chassisId; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("uri", uri).add("type", type).add("mfr", manufacturer) + .add("hw", hwVersion).add("sw", swVersion) + .add("serial", serialNumber) + .toString(); + } + + // default constructor for serialization + private DefaultDeviceDescription() { + this.uri = null; + this.type = null; + this.manufacturer = null; + this.hwVersion = null; + this.swVersion = null; + this.serialNumber = null; + this.chassisId = null; + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java new file mode 100644 index 00000000..572d201c --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java @@ -0,0 +1,120 @@ +/* + * 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.net.device; + +import com.google.common.base.MoreObjects; +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.PortNumber; +import org.onosproject.net.SparseAnnotations; + +import static org.onosproject.net.Port.Type; + +/** + * Default implementation of immutable port description. + */ +public class DefaultPortDescription extends AbstractDescription + implements PortDescription { + + private static final long DEFAULT_SPEED = 1_000; + + private final PortNumber number; + private final boolean isEnabled; + private final Type type; + private final long portSpeed; + + /** + * Creates a port description using the supplied information. + * + * @param number port number + * @param isEnabled port enabled state + * @param annotations optional key/value annotations map + */ + public DefaultPortDescription(PortNumber number, boolean isEnabled, + SparseAnnotations... annotations) { + this(number, isEnabled, Type.COPPER, DEFAULT_SPEED, annotations); + } + + /** + * Creates a port description using the supplied information. + * + * @param number port number + * @param isEnabled port enabled state + * @param type port type + * @param portSpeed port speed in Mbps + * @param annotations optional key/value annotations map + */ + public DefaultPortDescription(PortNumber number, boolean isEnabled, + Type type, long portSpeed, + SparseAnnotations...annotations) { + super(annotations); + this.number = number; + this.isEnabled = isEnabled; + this.type = type; + this.portSpeed = portSpeed; + } + + // Default constructor for serialization + private DefaultPortDescription() { + this.number = null; + this.isEnabled = false; + this.portSpeed = DEFAULT_SPEED; + this.type = Type.COPPER; + } + + /** + * Creates a port description using the supplied information. + * + * @param base PortDescription to get basic information from + * @param annotations optional key/value annotations map + */ + public DefaultPortDescription(PortDescription base, + SparseAnnotations annotations) { + this(base.portNumber(), base.isEnabled(), base.type(), base.portSpeed(), + annotations); + } + + @Override + public PortNumber portNumber() { + return number; + } + + @Override + public boolean isEnabled() { + return isEnabled; + } + + @Override + public Type type() { + return type; + } + + @Override + public long portSpeed() { + return portSpeed; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("number", number) + .add("isEnabled", isEnabled) + .add("type", type) + .add("portSpeed", portSpeed) + .add("annotations", annotations()) + .toString(); + } + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortStatistics.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortStatistics.java new file mode 100644 index 00000000..540a945f --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DefaultPortStatistics.java @@ -0,0 +1,346 @@ +/* + * 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. + */ +package org.onosproject.net.device; + +import org.onosproject.net.DeviceId; + +/** + * Default implementation of immutable port statistics. + */ +public final class DefaultPortStatistics implements PortStatistics { + + private final DeviceId deviceId; + private final int port; + private final long packetsReceived; + private final long packetsSent; + private final long bytesReceived; + private final long bytesSent; + private final long packetsRxDropped; + private final long packetsTxDropped; + private final long packetsRxErrors; + private final long packetsTxErrors; + private final long durationSec; + private final long durationNano; + + private DefaultPortStatistics(DeviceId deviceId, + int port, + long packetsReceived, + long packetsSent, + long bytesReceived, + long bytesSent, + long packetsRxDropped, + long packetsTxDropped, + long packetsRxErrors, + long packetsTxErrors, + long durationSec, + long durationNano) { + this.deviceId = deviceId; + this.port = port; + this.packetsReceived = packetsReceived; + this.packetsSent = packetsSent; + this.bytesReceived = bytesReceived; + this.bytesSent = bytesSent; + this.packetsRxDropped = packetsRxDropped; + this.packetsTxDropped = packetsTxDropped; + this.packetsRxErrors = packetsRxErrors; + this.packetsTxErrors = packetsTxErrors; + this.durationSec = durationSec; + this.durationNano = durationNano; + } + + // Constructor for serializer + private DefaultPortStatistics() { + this.deviceId = null; + this.port = 0; + this.packetsReceived = 0; + this.packetsSent = 0; + this.bytesReceived = 0; + this.bytesSent = 0; + this.packetsRxDropped = 0; + this.packetsTxDropped = 0; + this.packetsRxErrors = 0; + this.packetsTxErrors = 0; + this.durationSec = 0; + this.durationNano = 0; + } + + /** + * Creates a builder for DefaultPortStatistics object. + * + * @return builder object for DefaultPortStatistics object + */ + public static DefaultPortStatistics.Builder builder() { + return new Builder(); + } + + @Override + public int port() { + return this.port; + } + + @Override + public long packetsReceived() { + return this.packetsReceived; + } + + @Override + public long packetsSent() { + return this.packetsSent; + } + + @Override + public long bytesReceived() { + return this.bytesReceived; + } + + @Override + public long bytesSent() { + return this.bytesSent; + } + + @Override + public long packetsRxDropped() { + return this.packetsRxDropped; + } + + @Override + public long packetsTxDropped() { + return this.packetsTxDropped; + } + + @Override + public long packetsRxErrors() { + return this.packetsRxErrors; + } + + @Override + public long packetsTxErrors() { + return this.packetsTxErrors; + } + + @Override + public long durationSec() { + return this.durationSec; + } + + @Override + public long durationNano() { + return this.durationNano; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("device: " + deviceId + ", "); + + sb.append("port: " + this.port + ", "); + sb.append("pktRx: " + this.packetsReceived + ", "); + sb.append("pktTx: " + this.packetsSent + ", "); + sb.append("byteRx: " + this.bytesReceived + ", "); + sb.append("byteTx: " + this.bytesSent + ", "); + sb.append("pktRxErr: " + this.packetsRxErrors + ", "); + sb.append("pktTxErr: " + this.packetsTxErrors + ", "); + sb.append("pktRxDrp: " + this.packetsRxDropped + ", "); + sb.append("pktTxDrp: " + this.packetsTxDropped); + + return sb.toString(); + } + + public static final class Builder { + + DeviceId deviceId; + int port; + long packetsReceived; + long packetsSent; + long bytesReceived; + long bytesSent; + long packetsRxDropped; + long packetsTxDropped; + long packetsRxErrors; + long packetsTxErrors; + long durationSec; + long durationNano; + + private Builder() { + + } + + /** + * Sets port number. + * + * @param port port number + * @return builder object + */ + public Builder setPort(int port) { + this.port = port; + + return this; + } + + /** + * Sets the device identifier. + * + * @param deviceId device identifier + * @return builder object + */ + public Builder setDeviceId(DeviceId deviceId) { + this.deviceId = deviceId; + + return this; + } + + /** + * Sets the number of packet received. + * + * @param packets number of packets received + * @return builder object + */ + public Builder setPacketsReceived(long packets) { + packetsReceived = packets; + + return this; + } + + /** + * Sets the number of packets sent. + * + * @param packets number of packets sent + * @return builder object + */ + public Builder setPacketsSent(long packets) { + packetsSent = packets; + + return this; + } + + /** + * Sets the number of received bytes. + * + * @param bytes number of received bytes. + * @return builder object + */ + public Builder setBytesReceived(long bytes) { + bytesReceived = bytes; + + return this; + } + + /** + * Sets the number of sent bytes. + * + * @param bytes number of sent bytes + * @return builder object + */ + public Builder setBytesSent(long bytes) { + bytesSent = bytes; + + return this; + } + + /** + * Sets the number of packets dropped by RX. + * + * @param packets number of packets dropped by RX + * @return builder object + */ + public Builder setPacketsRxDropped(long packets) { + packetsRxDropped = packets; + + return this; + } + + /** + * Sets the number of packets dropped by TX. + * + * @param packets number of packets + * @return builder object + */ + public Builder setPacketsTxDropped(long packets) { + packetsTxDropped = packets; + + return this; + } + + /** + * Sets the number of receive errors. + * + * @param packets number of receive errors + * @return builder object + */ + public Builder setPacketsRxErrors(long packets) { + packetsRxErrors = packets; + + return this; + } + + /** + * Sets the number of transmit errors. + * + * @param packets number of transmit errors + * @return builder object + */ + public Builder setPacketsTxErrors(long packets) { + packetsTxErrors = packets; + + return this; + } + + /** + * Sets the time port has been alive in seconds. + * + * @param sec time port has been alive in seconds + * @return builder object + */ + public Builder setDurationSec(long sec) { + durationSec = sec; + + return this; + } + + /** + * Sets the time port has been alive in nano seconds. + * + * @param nano time port has been alive in nano seconds + * @return builder object + */ + public Builder setDurationNano(long nano) { + durationNano = nano; + + return this; + } + + /** + * Creates a PortStatistics object. + * + * @return DefaultPortStatistics object + */ + public DefaultPortStatistics build() { + return new DefaultPortStatistics( + deviceId, + port, + packetsReceived, + packetsSent, + bytesReceived, + bytesSent, + packetsRxDropped, + packetsTxDropped, + packetsRxErrors, + packetsTxErrors, + durationSec, + durationNano); + } + + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceAdminService.java new file mode 100644 index 00000000..500b6359 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceAdminService.java @@ -0,0 +1,34 @@ +/* + * 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.net.device; + +import org.onosproject.net.DeviceId; + +/** + * Service for administering the inventory of infrastructure devices. + */ +public interface DeviceAdminService extends DeviceService { + + /** + * Removes the device with the specified identifier. + * + * @param deviceId device identifier + */ + void removeDevice(DeviceId deviceId); + + // TODO: add ability to administratively suspend/resume device + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceClockService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceClockService.java new file mode 100644 index 00000000..5391999a --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceClockService.java @@ -0,0 +1,41 @@ +/* + * 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.net.device; + +import org.onosproject.net.DeviceId; +import org.onosproject.store.Timestamp; + +/** + * Interface for a logical clock service that vends per device timestamps. + */ +public interface DeviceClockService { + + /** + * Checks if this service can issue Timestamp for specified device. + * + * @param deviceId device identifier. + * @return true if timestamp can be issued for specified device + */ + boolean isTimestampAvailable(DeviceId deviceId); + + /** + * Returns a new timestamp for the specified deviceId. + * + * @param deviceId device identifier. + * @return timestamp. + */ + Timestamp getTimestamp(DeviceId deviceId); +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java new file mode 100644 index 00000000..64b84b5a --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceDescription.java @@ -0,0 +1,80 @@ +/* + * 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.net.device; + +import org.onosproject.net.Description; +import org.onosproject.net.Device; +import org.onlab.packet.ChassisId; + +import java.net.URI; + +/** + * Carrier of immutable information about a device. + */ +public interface DeviceDescription extends Description { + + /** + * Protocol/provider specific URI that can be used to encode the identity + * information required to communicate with the device externally, e.g. + * datapath ID. + * + * @return provider specific URI for the device + */ + URI deviceURI(); + + /** + * Returns the type of the infrastructure device. + * + * @return type of the device + */ + Device.Type type(); + + /** + * Returns the device manufacturer name. + * + * @return manufacturer name + */ + String manufacturer(); + + /** + * Returns the device hardware version. + * + * @return hardware version + */ + String hwVersion(); + + /** + * Returns the device software version. + * + * @return software version + */ + String swVersion(); + + /** + * Returns the device serial number. + * + * @return serial number + */ + String serialNumber(); + + /** + * Returns a device chassis id. + * + * @return chassis id + */ + ChassisId chassisId(); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java new file mode 100644 index 00000000..18ab046f --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java @@ -0,0 +1,141 @@ +/* + * 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.net.device; + +import org.joda.time.LocalDateTime; +import org.onosproject.event.AbstractEvent; +import org.onosproject.net.Device; +import org.onosproject.net.Port; + +import static com.google.common.base.MoreObjects.toStringHelper; + +/** + * Describes infrastructure device event. + */ +public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { + + private final Port port; + + /** + * Type of device events. + */ + public enum Type { + /** + * Signifies that a new device has been detected. + */ + DEVICE_ADDED, + + /** + * Signifies that some device attributes have changed; excludes + * availability changes. + */ + DEVICE_UPDATED, + + /** + * Signifies that a device has been removed. + */ + DEVICE_REMOVED, + + /** + * Signifies that a device has been administratively suspended. + */ + DEVICE_SUSPENDED, + + /** + * Signifies that a device has come online or has gone offline. + */ + DEVICE_AVAILABILITY_CHANGED, + + /** + * Signifies that a port has been added. + */ + PORT_ADDED, + + /** + * Signifies that a port has been updated. + */ + PORT_UPDATED, + + /** + * Signifies that a port has been removed. + */ + PORT_REMOVED, + + /** + * Signifies that port statistics has been updated. + */ + PORT_STATS_UPDATED + } + + /** + * Creates an event of a given type and for the specified device and the + * current time. + * + * @param type device event type + * @param device event device subject + */ + public DeviceEvent(Type type, Device device) { + this(type, device, null); + } + + /** + * Creates an event of a given type and for the specified device, port + * and the current time. + * + * @param type device event type + * @param device event device subject + * @param port optional port subject + */ + public DeviceEvent(Type type, Device device, Port port) { + super(type, device); + this.port = port; + } + + /** + * Creates an event of a given type and for the specified device and time. + * + * @param type device event type + * @param device event device subject + * @param port optional port subject + * @param time occurrence time + */ + public DeviceEvent(Type type, Device device, Port port, long time) { + super(type, device, time); + this.port = port; + } + + /** + * Returns the port subject. + * + * @return port subject or null if the event is not port specific. + */ + public Port port() { + return port; + } + + @Override + public String toString() { + if (port == null) { + return super.toString(); + } + return toStringHelper(this) + .add("time", new LocalDateTime(time())) + .add("type", type()) + .add("subject", subject()) + .add("port", port) + .toString(); + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceListener.java new file mode 100644 index 00000000..c9809b81 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceListener.java @@ -0,0 +1,24 @@ +/* + * 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.net.device; + +import org.onosproject.event.EventListener; + +/** + * Entity capable of receiving infrastructure device related events. + */ +public interface DeviceListener extends EventListener<DeviceEvent> { +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProvider.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProvider.java new file mode 100644 index 00000000..d8adbb0e --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProvider.java @@ -0,0 +1,57 @@ +/* + * 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.net.device; + +import org.onosproject.net.DeviceId; +import org.onosproject.net.MastershipRole; +import org.onosproject.net.provider.Provider; + +/** + * Abstraction of a device information provider. + */ +public interface DeviceProvider extends Provider { + + // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it + + /** + * Triggers an asynchronous probe of the specified device, intended to + * determine whether the device is present or not. An indirect result of this + * should be invocation of + * {@link org.onosproject.net.device.DeviceProviderService#deviceConnected} )} or + * {@link org.onosproject.net.device.DeviceProviderService#deviceDisconnected} + * at some later point in time. + * + * @param deviceId ID of device to be probed + */ + void triggerProbe(DeviceId deviceId); + + /** + * Notifies the provider of a mastership role change for the specified + * device as decided by the core. + * + * @param deviceId device identifier + * @param newRole newly determined mastership role + */ + void roleChanged(DeviceId deviceId, MastershipRole newRole); + + /** + * Checks the reachability (connectivity) of a device from this provider. + * + * @param deviceId device identifier + * @return true if reachable, false otherwise + */ + boolean isReachable(DeviceId deviceId); +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderRegistry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderRegistry.java new file mode 100644 index 00000000..a7ab7e36 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderRegistry.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.net.device; + +import org.onosproject.net.provider.ProviderRegistry; + +/** + * Abstraction of a device provider registry. + */ +public interface DeviceProviderRegistry + extends ProviderRegistry<DeviceProvider, DeviceProviderService> { +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderService.java new file mode 100644 index 00000000..e266df09 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceProviderService.java @@ -0,0 +1,82 @@ +/* + * 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.net.device; + +import org.onosproject.net.DeviceId; +import org.onosproject.net.MastershipRole; +import org.onosproject.net.provider.ProviderService; + +import java.util.Collection; +import java.util.List; + +/** + * Service through which device providers can inject device information into + * the core. + */ +public interface DeviceProviderService extends ProviderService<DeviceProvider> { + + // TODO: define suspend and remove actions on the mezzanine administrative API + + /** + * Signals the core that a device has connected or has been detected somehow. + * + * @param deviceId device identifier + * @param deviceDescription information about network device + */ + void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription); + + /** + * Signals the core that a device has disconnected or is no longer reachable. + * + * @param deviceId identity of the device to be removed + */ + void deviceDisconnected(DeviceId deviceId); + + /** + * Sends information about all ports of a device. It is up to the core to + * determine what has changed. + * + * @param deviceId identity of the device + * @param portDescriptions list of device ports + */ + void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions); + + /** + * Used to notify the core about port status change of a single port. + * + * @param deviceId identity of the device + * @param portDescription description of the port that changed + */ + void portStatusChanged(DeviceId deviceId, PortDescription portDescription); + + /** + * Notifies the core about the result of a RoleRequest sent to a device. + * + * @param deviceId identity of the device + * @param requested mastership role that was requested by the node + * @param response mastership role the switch accepted + */ + void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response); + + /** + * Sends statistics about all ports of a device. + * + * @param deviceId identity of the device + * @param portStatistics list of device port statistics + */ + void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceService.java new file mode 100644 index 00000000..f4671fb4 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceService.java @@ -0,0 +1,132 @@ +/* + * 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.net.device; + +import org.onosproject.event.ListenerService; +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; +import org.onosproject.net.MastershipRole; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; + +import java.util.List; + +/** + * Service for interacting with the inventory of infrastructure devices. + */ +public interface DeviceService + extends ListenerService<DeviceEvent, DeviceListener> { + + /** + * Returns the number of infrastructure devices known to the system. + * + * @return number of infrastructure devices + */ + int getDeviceCount(); + + /** + * Returns a collection of the currently known infrastructure + * devices. + * + * @return collection of devices + */ + Iterable<Device> getDevices(); + + /** + * Returns a collection of the currently known infrastructure + * devices by device type. + * + * @param type device type + * @return collection of devices + */ + Iterable<Device> getDevices(Device.Type type); + + /** + * Returns an iterable collection of all devices + * currently available to the system. + * + * @return device collection + */ + Iterable<Device> getAvailableDevices(); + + /** + * Returns an iterable collection of all devices currently available to the system by device type. + * + * @param type device type + * @return device collection + */ + Iterable<Device> getAvailableDevices(Device.Type type); + + /** + * Returns the device with the specified identifier. + * + * @param deviceId device identifier + * @return device or null if one with the given identifier is not known + */ + Device getDevice(DeviceId deviceId); + + /** + * Returns the current mastership role for the specified device. + * + * @param deviceId device identifier + * @return designated mastership role + */ + //XXX do we want this method here when MastershipService already does? + MastershipRole getRole(DeviceId deviceId); + + + /** + * Returns the list of ports associated with the device. + * + * @param deviceId device identifier + * @return list of ports + */ + List<Port> getPorts(DeviceId deviceId); + + /** + * Returns the list of port statistics associated with the device. + * + * @param deviceId device identifier + * @return list of port statistics + */ + List<PortStatistics> getPortStatistics(DeviceId deviceId); + + /** + * Returns the list of port delta statistics associated with the device. + * + * @param deviceId device identifier + * @return list of port statistics + */ + List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); + + /** + * Returns the port with the specified number and hosted by the given device. + * + * @param deviceId device identifier + * @param portNumber port number + * @return device port + */ + Port getPort(DeviceId deviceId, PortNumber portNumber); + + /** + * Indicates whether or not the device is presently online and available. + * + * @param deviceId device identifier + * @return true if the device is available + */ + boolean isAvailable(DeviceId deviceId); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStore.java new file mode 100644 index 00000000..851b9709 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStore.java @@ -0,0 +1,170 @@ +/* + * 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.net.device; + +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; +import org.onosproject.net.provider.ProviderId; +import org.onosproject.store.Store; + +import java.util.Collection; +import java.util.List; + +/** + * Manages inventory of infrastructure devices; not intended for direct use. + */ +public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { + + /** + * Returns the number of devices known to the system. + * + * @return number of devices + */ + int getDeviceCount(); + + /** + * Returns an iterable collection of all devices known to the system. + * + * @return device collection + */ + Iterable<Device> getDevices(); + + /** + * Returns an iterable collection of all devices currently available to the system. + * + * @return device collection + */ + Iterable<Device> getAvailableDevices(); + + + + /** + * Returns the device with the specified identifier. + * + * @param deviceId device identifier + * @return device + */ + Device getDevice(DeviceId deviceId); + + /** + * Creates a new infrastructure device, or updates an existing one using + * the supplied device description. + * + * @param providerId provider identifier + * @param deviceId device identifier + * @param deviceDescription device description + * @return ready to send event describing what occurred; null if no change + */ + DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, + DeviceDescription deviceDescription); + + // TODO: We may need to enforce that ancillary cannot interfere this state + /** + * Removes the specified infrastructure device. + * + * @param deviceId device identifier + * @return ready to send event describing what occurred; null if no change + */ + DeviceEvent markOffline(DeviceId deviceId); + + /** + * Updates the ports of the specified infrastructure device using the given + * list of port descriptions. The list is assumed to be comprehensive. + * + * @param providerId provider identifier + * @param deviceId device identifier + * @param portDescriptions list of port descriptions + * @return ready to send events describing what occurred; empty list if no change + */ + List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, + List<PortDescription> portDescriptions); + + /** + * Updates the port status of the specified infrastructure device using the + * given port description. + * + * @param providerId provider identifier + * @param deviceId device identifier + * @param portDescription port description + * @return ready to send event describing what occurred; null if no change + */ + DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, + PortDescription portDescription); + + /** + * Returns the list of ports that belong to the specified device. + * + * @param deviceId device identifier + * @return list of device ports + */ + List<Port> getPorts(DeviceId deviceId); + + /** + * Updates the port statistics of the specified device using the give port + * statistics. + * + * @param providerId provider identifier + * @param deviceId device identifier + * @param portStats list of port statistics + * @return ready to send event describing what occurred; + */ + DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId, + Collection<PortStatistics> portStats); + + /** + * Returns the list of port statistics of the specified device. + * + * @param deviceId device identifier + * @return list of port statistics of all ports of the device + */ + List<PortStatistics> getPortStatistics(DeviceId deviceId); + + /** + * Returns the list of delta port statistics of the specified device. + * + * @param deviceId device identifier + * @return list of delta port statistics of all ports of the device + */ + List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); + + /** + * Returns the specified device port. + * + * @param deviceId device identifier + * @param portNumber port number + * @return device port + */ + Port getPort(DeviceId deviceId, PortNumber portNumber); + + /** + * Indicates whether the specified device is available/online. + * + * @param deviceId device identifier + * @return true if device is available + */ + boolean isAvailable(DeviceId deviceId); + + /** + * Administratively removes the specified device from the store. + * + * @param deviceId device to be removed + * @return null if no such device, or was forwarded to remove master + */ + DeviceEvent removeDevice(DeviceId deviceId); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStoreDelegate.java new file mode 100644 index 00000000..1a4fc67d --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/DeviceStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * 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.net.device; + +import org.onosproject.store.StoreDelegate; + +/** + * Infrastructure device store delegate abstraction. + */ +public interface DeviceStoreDelegate extends StoreDelegate<DeviceEvent> { +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java new file mode 100644 index 00000000..c3a7f415 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java @@ -0,0 +1,111 @@ +/* + * 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. + */ +package org.onosproject.net.device; + +import com.google.common.base.MoreObjects; +import org.onosproject.net.OchSignal; +import org.onosproject.net.OduSignalType; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; +import org.onosproject.net.SparseAnnotations; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Default implementation of immutable OCh port description. + */ +public class OchPortDescription extends DefaultPortDescription { + + private final OduSignalType signalType; + private final boolean isTunable; + private final OchSignal lambda; + + /** + * Creates OCH port description based on the supplied information. + * + * @param number port number + * @param isEnabled port enabled state + * @param signalType ODU signal type + * @param isTunable tunable wavelength capability + * @param lambda OCh signal + * @param annotations optional key/value annotations map + */ + public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, + boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) { + super(number, isEnabled, Port.Type.OCH, 0, annotations); + this.signalType = signalType; + this.isTunable = isTunable; + this.lambda = checkNotNull(lambda); + } + + /** + * Creates OCH port description based on the supplied information. + * + * @param base PortDescription to get basic information from + * @param signalType ODU signal type + * @param isTunable tunable wavelength capability + * @param lambda OCh signal + * @param annotations optional key/value annotations map + */ + public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, + OchSignal lambda, SparseAnnotations annotations) { + super(base, annotations); + this.signalType = signalType; + this.isTunable = isTunable; + this.lambda = checkNotNull(lambda); + } + + /** + * Returns ODU signal type. + * + * @return ODU signal type + */ + public OduSignalType signalType() { + return signalType; + } + + /** + * Returns true if port is wavelength tunable. + * + * @return tunable wavelength capability + */ + public boolean isTunable() { + return isTunable; + } + + /** + * Returns OCh signal. + * + * @return OCh signal + */ + public OchSignal lambda() { + return lambda; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("number", portNumber()) + .add("isEnabled", isEnabled()) + .add("type", type()) + .add("signalType", signalType) + .add("isTunable", isTunable) + .add("lambda", lambda) + .add("annotations", annotations()) + .toString(); + } + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java new file mode 100644 index 00000000..eee7de2d --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java @@ -0,0 +1,77 @@ +/* + * 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. + */ +package org.onosproject.net.device; + +import com.google.common.base.MoreObjects; +import org.onosproject.net.OduCltPort; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; +import org.onosproject.net.SparseAnnotations; + +/** + * Default implementation of immutable ODU client port description. + */ +public class OduCltPortDescription extends DefaultPortDescription { + + private final OduCltPort.SignalType signalType; + + /** + * Creates ODU client port description based on the supplied information. + * + * @param number port number + * @param isEnabled port enabled state + * @param signalType ODU client signal type + * @param annotations optional key/value annotations map + */ + public OduCltPortDescription(PortNumber number, boolean isEnabled, OduCltPort.SignalType signalType, + SparseAnnotations... annotations) { + super(number, isEnabled, Port.Type.ODUCLT, 0, annotations); + this.signalType = signalType; + } + + /** + * Creates ODU client port description based on the supplied information. + * + * @param base PortDescription to get basic information from + * @param signalType ODU client signal type + * @param annotations optional key/value annotations map + */ + public OduCltPortDescription(PortDescription base, OduCltPort.SignalType signalType, + SparseAnnotations annotations) { + super(base, annotations); + this.signalType = signalType; + } + + /** + * Returns ODU client signal type. + * + * @return ODU client signal type + */ + public OduCltPort.SignalType signalType() { + return signalType; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("number", portNumber()) + .add("isEnabled", isEnabled()) + .add("type", type()) + .add("signalType", signalType) + .toString(); + } + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java new file mode 100644 index 00000000..131314a3 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java @@ -0,0 +1,109 @@ +/* + * 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. + */ +package org.onosproject.net.device; + +import com.google.common.base.MoreObjects; +import org.onlab.util.Frequency; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; +import org.onosproject.net.SparseAnnotations; + +/** + * Default implementation of immutable OMS port description. + */ +public class OmsPortDescription extends DefaultPortDescription { + + private final Frequency minFrequency; + private final Frequency maxFrequency; + private final Frequency grid; + + /** + * Creates OMS port description based on the supplied information. + * + * @param number port number + * @param isEnabled port enabled state + * @param minFrequency minimum frequency + * @param maxFrequency maximum frequency + * @param grid grid spacing frequency + * @param annotations optional key/value annotations map + */ + public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency, + Frequency grid, SparseAnnotations... annotations) { + super(number, isEnabled, Port.Type.OMS, 0, annotations); + this.minFrequency = minFrequency; + this.maxFrequency = maxFrequency; + this.grid = grid; + } + + /** + * Creates OMS port description based on the supplied information. + * + * @param base PortDescription to get basic information from + * @param minFrequency minimum frequency + * @param maxFrequency maximum frequency + * @param grid grid spacing frequency + * @param annotations optional key/value annotations map + */ + public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency, + Frequency grid, SparseAnnotations annotations) { + super(base, annotations); + this.minFrequency = minFrequency; + this.maxFrequency = maxFrequency; + this.grid = grid; + } + + /** + * Returns minimum frequency. + * + * @return minimum frequency + */ + public Frequency minFrequency() { + return minFrequency; + } + + /** + * Returns maximum frequency. + * + * @return maximum frequency + */ + public Frequency maxFrequency() { + return maxFrequency; + } + + /** + * Returns grid spacing frequency. + * + * @return grid spacing frequency + */ + public Frequency grid() { + return grid; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("number", portNumber()) + .add("isEnabled", isEnabled()) + .add("type", type()) + .add("minFrequency", minFrequency) + .add("maxFrequency", maxFrequency) + .add("grid", grid) + .add("annotations", annotations()) + .toString(); + } + +} + diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortDescription.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortDescription.java new file mode 100644 index 00000000..3ed3efce --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortDescription.java @@ -0,0 +1,56 @@ +/* + * 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.net.device; + +import org.onosproject.net.Description; +import org.onosproject.net.PortNumber; + +import static org.onosproject.net.Port.Type; + +/** + * Information about a port. + */ +public interface PortDescription extends Description { + + /** + * Returns the port number. + * + * @return port number + */ + PortNumber portNumber(); + + /** + * Indicates whether or not the port is up and active. + * + * @return true if the port is active and has carrier signal + */ + boolean isEnabled(); + + /** + * Returns the port type. + * + * @return port type + */ + Type type(); + + /** + * Returns the current port speed in Mbps. + * + * @return current port speed + */ + long portSpeed(); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortStatistics.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortStatistics.java new file mode 100644 index 00000000..201bd7b6 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/PortStatistics.java @@ -0,0 +1,100 @@ +/* + * 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. + */ +package org.onosproject.net.device; + +/** + * Statistics of a port. + */ +public interface PortStatistics { + + /** + * Returns the port number. + * + * @return port number + */ + int port(); + + /** + * Returns the number of packets received. + * + * @return the number of packets received + */ + long packetsReceived(); + + /** + * Returns the number of packets sent. + * + * @return the number of packets sent + */ + long packetsSent(); + + /** + * Returns the bytes received. + * + * @return the bytes received + */ + long bytesReceived(); + + /** + * Returns the bytes sent. + * + * @return the bytes sent + */ + long bytesSent(); + + /** + * Returns the number of packets dropped by RX. + * + * @return the number of packets dropped by RX + */ + long packetsRxDropped(); + + /** + * Returns the number of packets dropped by TX. + * + * @return the number of packets dropped by TX + */ + long packetsTxDropped(); + + /** + * Returns the number of transmit errors. + * + * @return the number of transmit errors + */ + long packetsRxErrors(); + + /** + * Returns the number of receive errors. + * + * @return the number of receive error + */ + long packetsTxErrors(); + + /** + * Returns the time port has been alive in seconds. + * + * @return the time port has been alive in seconds + */ + long durationSec(); + + /** + * Returns the time port has been alive in nano seconds. + * + * @return the time port has been alive in nano seconds + */ + long durationNano(); + +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/package-info.java new file mode 100644 index 00000000..4ee64dcf --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/device/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Infrastructure device model & related services API definitions. + */ +package org.onosproject.net.device; |