Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Thomas Vachuska
2014-10-29 17:25:29 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d16ce18d0c38089c55e955db6f2bec578fddf96c
d16ce18d
1 parent
49e159ac
Added Port.Type and plumbed it throughout.
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
256 additions
and
68 deletions
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
core/api/src/main/java/org/onlab/onos/net/DefaultPort.java
core/api/src/main/java/org/onlab/onos/net/Port.java
core/api/src/main/java/org/onlab/onos/net/device/DefaultPortDescription.java
core/api/src/main/java/org/onlab/onos/net/device/PortDescription.java
core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
tools/build/onos-build
tools/dev/bash_profile
tools/test/topos/oe-linear-3.json
utils/misc/src/main/java/org/onlab/packet/IpAddress.java
web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
View file @
d16ce18
...
...
@@ -40,7 +40,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
description
=
"Lists all ports or all ports of a device"
)
public
class
DevicePortsListCommand
extends
DevicesListCommand
{
private
static
final
String
FMT
=
" port=%s, state=%s%s"
;
private
static
final
String
FMT
=
" port=%s, state=%s
, type=%s, speed=%s
%s"
;
@Option
(
name
=
"-e"
,
aliases
=
"--enabled"
,
description
=
"Show only enabled ports"
,
required
=
false
,
multiValued
=
false
)
...
...
@@ -110,10 +110,14 @@ public class DevicePortsListCommand extends DevicesListCommand {
ports
.
add
(
mapper
.
createObjectNode
()
.
put
(
"port"
,
port
.
number
().
toString
())
.
put
(
"isEnabled"
,
port
.
isEnabled
())
.
put
(
"type"
,
port
.
type
().
toString
().
toLowerCase
())
.
put
(
"portSpeed"
,
port
.
portSpeed
())
.
set
(
"annotations"
,
annotations
(
mapper
,
port
.
annotations
())));
}
}
return
result
.
put
(
"device"
,
device
.
id
().
toString
()).
set
(
"ports"
,
ports
);
result
.
set
(
"device"
,
json
(
service
,
mapper
,
device
));
result
.
set
(
"ports"
,
ports
);
return
result
;
}
// Determines if a port should be included in output.
...
...
@@ -130,6 +134,7 @@ public class DevicePortsListCommand extends DevicesListCommand {
for
(
Port
port
:
ports
)
{
if
(
isIncluded
(
port
))
{
print
(
FMT
,
port
.
number
(),
port
.
isEnabled
()
?
"enabled"
:
"disabled"
,
port
.
type
().
toString
().
toLowerCase
(),
port
.
portSpeed
(),
annotations
(
port
.
annotations
()));
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/DefaultPort.java
View file @
d16ce18
...
...
@@ -24,9 +24,27 @@ import static com.google.common.base.MoreObjects.toStringHelper;
*/
public
class
DefaultPort
extends
AbstractAnnotated
implements
Port
{
/** Default port speed in Mbps. */
public
static
final
long
DEFAULT_SPEED
=
1_000
;
private
final
Element
element
;
private
final
PortNumber
number
;
private
final
boolean
isEnabled
;
private
final
Type
type
;
private
final
long
portSpeed
;
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
* @param annotations optional key/value annotations
*/
public
DefaultPort
(
Element
element
,
PortNumber
number
,
boolean
isEnabled
,
Annotations
...
annotations
)
{
this
(
element
,
number
,
isEnabled
,
Type
.
COPPER
,
DEFAULT_SPEED
,
annotations
);
}
/**
* Creates a network element attributed to the specified provider.
...
...
@@ -34,19 +52,49 @@ public class DefaultPort extends AbstractAnnotated implements Port {
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
* @param type port type
* @param portSpeed port speed in Mbs
* @param annotations optional key/value annotations
*/
public
DefaultPort
(
Element
element
,
PortNumber
number
,
boolean
isEnabl
ed
,
Annotations
...
annotations
)
{
public
DefaultPort
(
Element
element
,
PortNumber
number
,
boolean
isEnabled
,
Type
type
,
long
portSpe
ed
,
Annotations
...
annotations
)
{
super
(
annotations
);
this
.
element
=
element
;
this
.
number
=
number
;
this
.
isEnabled
=
isEnabled
;
this
.
type
=
type
;
this
.
portSpeed
=
portSpeed
;
}
@Override
public
Element
element
()
{
return
element
;
}
@Override
public
PortNumber
number
()
{
return
number
;
}
@Override
public
boolean
isEnabled
()
{
return
isEnabled
;
}
@Override
public
Type
type
()
{
return
type
;
}
@Override
public
long
portSpeed
()
{
return
portSpeed
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
number
,
isEnabled
);
return
Objects
.
hash
(
number
,
isEnabled
,
type
,
portSpeed
);
}
@Override
...
...
@@ -58,7 +106,9 @@ public class DefaultPort extends AbstractAnnotated implements Port {
final
DefaultPort
other
=
(
DefaultPort
)
obj
;
return
Objects
.
equals
(
this
.
element
.
id
(),
other
.
element
.
id
())
&&
Objects
.
equals
(
this
.
number
,
other
.
number
)
&&
Objects
.
equals
(
this
.
isEnabled
,
other
.
isEnabled
);
Objects
.
equals
(
this
.
isEnabled
,
other
.
isEnabled
)
&&
Objects
.
equals
(
this
.
type
,
other
.
type
)
&&
Objects
.
equals
(
this
.
portSpeed
,
other
.
portSpeed
);
}
return
false
;
}
...
...
@@ -69,22 +119,9 @@ public class DefaultPort extends AbstractAnnotated implements Port {
.
add
(
"element"
,
element
.
id
())
.
add
(
"number"
,
number
)
.
add
(
"isEnabled"
,
isEnabled
)
.
add
(
"type"
,
type
)
.
add
(
"portSpeed"
,
portSpeed
)
.
toString
();
}
@Override
public
PortNumber
number
()
{
return
number
;
}
@Override
public
boolean
isEnabled
()
{
return
isEnabled
;
}
@Override
public
Element
element
()
{
return
element
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/Port.java
View file @
d16ce18
...
...
@@ -21,6 +21,26 @@ package org.onlab.onos.net;
*/
public
interface
Port
extends
Annotated
{
/** Represents coarse port type classification. */
public
enum
Type
{
/**
* Signifies copper-based connectivity.
*/
COPPER
,
/**
* Signifies optical fiber-based connectivity.
*/
FIBER
}
/**
* Returns the parent network element to which this port belongs.
*
* @return parent network element
*/
Element
element
();
/**
* Returns the port number.
*
...
...
@@ -36,12 +56,18 @@ public interface Port extends Annotated {
boolean
isEnabled
();
/**
* Returns the p
arent network element to which this port belongs
.
* Returns the p
ort type
.
*
* @return p
arent network element
* @return p
ort type
*/
Element
element
();
Type
type
();
// set of port attributes
/**
* Returns the current port speed in Mbps.
*
* @return current port speed
*/
long
portSpeed
();
// TODO: more attributes?
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/DefaultPortDescription.java
View file @
d16ce18
...
...
@@ -15,11 +15,12 @@
*/
package
org
.
onlab
.
onos
.
net
.
device
;
import
com.google.common.base.MoreObjects
;
import
org.onlab.onos.net.AbstractDescription
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.SparseAnnotations
;
import
com.google.common.base.MoreObjects
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
;
/**
* Default implementation of immutable port description.
...
...
@@ -27,8 +28,12 @@ import com.google.common.base.MoreObjects;
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.
...
...
@@ -39,9 +44,34 @@ public class DefaultPortDescription extends AbstractDescription
*/
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
;
}
/**
...
...
@@ -52,7 +82,8 @@ public class DefaultPortDescription extends AbstractDescription
*/
public
DefaultPortDescription
(
PortDescription
base
,
SparseAnnotations
annotations
)
{
this
(
base
.
portNumber
(),
base
.
isEnabled
(),
annotations
);
this
(
base
.
portNumber
(),
base
.
isEnabled
(),
base
.
type
(),
base
.
portSpeed
(),
annotations
);
}
@Override
...
...
@@ -66,17 +97,24 @@ public class DefaultPortDescription extends AbstractDescription
}
@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
();
}
// default constructor for serialization
private
DefaultPortDescription
()
{
this
.
number
=
null
;
this
.
isEnabled
=
false
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/PortDescription.java
View file @
d16ce18
...
...
@@ -18,13 +18,13 @@ package org.onlab.onos.net.device;
import
org.onlab.onos.net.Description
;
import
org.onlab.onos.net.PortNumber
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
;
/**
* Information about a port.
*/
public
interface
PortDescription
extends
Description
{
// TODO: possibly relocate this to a common ground so that this can also used by host tracking if required
/**
* Returns the port number.
*
...
...
@@ -39,4 +39,18 @@ public interface PortDescription extends Description {
*/
boolean
isEnabled
();
/**
* Returns the port type.
*
* @return port type
*/
Type
type
();
/**
* Returns the current port speed in Mbps.
*
* @return current port speed
*/
long
portSpeed
();
}
...
...
core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java
View file @
d16ce18
...
...
@@ -23,6 +23,8 @@ import org.onlab.packet.ChassisId;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
Device
.
Type
.
SWITCH
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
.
COPPER
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
.
FIBER
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
...
...
@@ -35,15 +37,16 @@ public class DefaultPortTest {
private
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
private
static
final
PortNumber
P1
=
portNumber
(
1
);
private
static
final
PortNumber
P2
=
portNumber
(
2
);
private
static
final
long
SP1
=
1_000_000
;
@Test
public
void
testEquality
()
{
Device
device
=
new
DefaultDevice
(
PID
,
DID1
,
SWITCH
,
"m"
,
"h"
,
"s"
,
"n"
,
new
ChassisId
());
Port
p1
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
);
Port
p2
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
);
Port
p3
=
new
DefaultPort
(
device
,
portNumber
(
2
),
true
);
Port
p4
=
new
DefaultPort
(
device
,
portNumber
(
2
),
true
);
Port
p1
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
,
COPPER
,
SP1
);
Port
p2
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
,
COPPER
,
SP1
);
Port
p3
=
new
DefaultPort
(
device
,
portNumber
(
2
),
true
,
FIBER
,
SP1
);
Port
p4
=
new
DefaultPort
(
device
,
portNumber
(
2
),
true
,
FIBER
,
SP1
);
Port
p5
=
new
DefaultPort
(
device
,
portNumber
(
1
),
false
);
new
EqualsTester
().
addEqualityGroup
(
p1
,
p2
)
...
...
@@ -56,10 +59,12 @@ public class DefaultPortTest {
public
void
basics
()
{
Device
device
=
new
DefaultDevice
(
PID
,
DID1
,
SWITCH
,
"m"
,
"h"
,
"s"
,
"n"
,
new
ChassisId
());
Port
port
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
);
Port
port
=
new
DefaultPort
(
device
,
portNumber
(
1
),
true
,
FIBER
,
SP1
);
assertEquals
(
"incorrect element"
,
device
,
port
.
element
());
assertEquals
(
"incorrect number"
,
portNumber
(
1
),
port
.
number
());
assertEquals
(
"incorrect state"
,
true
,
port
.
isEnabled
());
assertEquals
(
"incorrect speed"
,
SP1
,
port
.
portSpeed
());
assertEquals
(
"incorrect type"
,
FIBER
,
port
.
type
());
}
}
...
...
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
View file @
d16ce18
...
...
@@ -435,7 +435,8 @@ public class DeviceManager
return
;
}
//flag the device as online. Is there a better way to do this?
DeviceEvent
devEvent
=
store
.
createOrUpdateDevice
(
device
.
providerId
(),
did
,
DeviceEvent
devEvent
=
store
.
createOrUpdateDevice
(
device
.
providerId
(),
did
,
new
DefaultDeviceDescription
(
did
.
uri
(),
device
.
type
(),
device
.
manufacturer
(),
device
.
hwVersion
(),
device
.
swVersion
(),
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
d16ce18
...
...
@@ -543,8 +543,9 @@ public class GossipDeviceStore
Port
newPort
,
Map
<
PortNumber
,
Port
>
ports
)
{
if
(
oldPort
.
isEnabled
()
!=
newPort
.
isEnabled
()
||
oldPort
.
type
()
!=
newPort
.
type
()
||
oldPort
.
portSpeed
()
!=
newPort
.
portSpeed
()
||
!
AnnotationsUtil
.
isEqual
(
oldPort
.
annotations
(),
newPort
.
annotations
()))
{
ports
.
put
(
oldPort
.
number
(),
newPort
);
return
new
DeviceEvent
(
PORT_UPDATED
,
device
,
newPort
);
}
...
...
@@ -867,7 +868,10 @@ public class GossipDeviceStore
}
}
return
new
DefaultPort
(
device
,
number
,
isEnabled
,
annotations
);
return
portDesc
==
null
?
new
DefaultPort
(
device
,
number
,
false
,
annotations
)
:
new
DefaultPort
(
device
,
number
,
isEnabled
,
portDesc
.
value
().
type
(),
portDesc
.
value
().
portSpeed
(),
annotations
);
}
/**
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
View file @
d16ce18
...
...
@@ -115,6 +115,7 @@ public final class KryoNamespaces {
//
ControllerNode
.
State
.
class
,
Device
.
Type
.
class
,
Port
.
Type
.
class
,
ChassisId
.
class
,
DefaultAnnotations
.
class
,
DefaultControllerNode
.
class
,
...
...
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
View file @
d16ce18
...
...
@@ -15,13 +15,10 @@
*/
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
import
static
java
.
util
.
Arrays
.
asList
;
import
java.nio.ByteBuffer
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
...
...
@@ -50,10 +47,12 @@ import org.onlab.packet.IpPrefix;
import
org.onlab.packet.MacAddress
;
import
org.onlab.util.KryoNamespace
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.testing.EqualsTester
;
import
java.nio.ByteBuffer
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
public
class
KryoSerializerTest
{
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
View file @
d16ce18
...
...
@@ -291,8 +291,9 @@ public class SimpleDeviceStore
Port
newPort
,
Map
<
PortNumber
,
Port
>
ports
)
{
if
(
oldPort
.
isEnabled
()
!=
newPort
.
isEnabled
()
||
oldPort
.
type
()
!=
newPort
.
type
()
||
oldPort
.
portSpeed
()
!=
newPort
.
portSpeed
()
||
!
AnnotationsUtil
.
isEqual
(
oldPort
.
annotations
(),
newPort
.
annotations
()))
{
ports
.
put
(
oldPort
.
number
(),
newPort
);
return
new
DeviceEvent
(
PORT_UPDATED
,
device
,
newPort
);
}
...
...
@@ -510,7 +511,10 @@ public class SimpleDeviceStore
}
}
return
new
DefaultPort
(
device
,
number
,
isEnabled
,
annotations
);
return
portDesc
==
null
?
new
DefaultPort
(
device
,
number
,
false
,
annotations
)
:
new
DefaultPort
(
device
,
number
,
isEnabled
,
portDesc
.
type
(),
portDesc
.
portSpeed
(),
annotations
);
}
/**
...
...
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
d16ce18
...
...
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
...
...
@@ -43,14 +44,19 @@ import org.onlab.packet.ChassisId;
import
org.projectfloodlight.openflow.protocol.OFFactory
;
import
org.projectfloodlight.openflow.protocol.OFPortConfig
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
import
org.projectfloodlight.openflow.protocol.OFPortFeatures
;
import
org.projectfloodlight.openflow.protocol.OFPortState
;
import
org.projectfloodlight.openflow.protocol.OFPortStatus
;
import
org.projectfloodlight.openflow.protocol.OFVersion
;
import
org.projectfloodlight.openflow.types.PortSpeed
;
import
org.slf4j.Logger
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
.
COPPER
;
import
static
org
.
onlab
.
onos
.
net
.
Port
.
Type
.
FIBER
;
import
static
org
.
onlab
.
onos
.
openflow
.
controller
.
Dpid
.
dpid
;
import
static
org
.
onlab
.
onos
.
openflow
.
controller
.
Dpid
.
uri
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -63,6 +69,7 @@ import static org.slf4j.LoggerFactory.getLogger;
public
class
OpenFlowDeviceProvider
extends
AbstractProvider
implements
DeviceProvider
{
private
static
final
Logger
LOG
=
getLogger
(
OpenFlowDeviceProvider
.
class
);
private
static
final
long
MBPS
=
1_000
*
1_000
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
DeviceProviderRegistry
providerRegistry
;
...
...
@@ -244,8 +251,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
* @param ports the list of ports
* @return list of portdescriptions
*/
private
List
<
PortDescription
>
buildPortDescriptions
(
List
<
OFPortDesc
>
ports
)
{
private
List
<
PortDescription
>
buildPortDescriptions
(
List
<
OFPortDesc
>
ports
)
{
final
List
<
PortDescription
>
portDescs
=
new
ArrayList
<>(
ports
.
size
());
for
(
OFPortDesc
port
:
ports
)
{
portDescs
.
add
(
buildPortDescription
(
port
));
...
...
@@ -260,12 +266,25 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
* @return portDescription for the port.
*/
private
PortDescription
buildPortDescription
(
OFPortDesc
port
)
{
final
PortNumber
portNo
=
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
());
final
boolean
enabled
=
!
port
.
getState
().
contains
(
OFPortState
.
LINK_DOWN
)
&&
PortNumber
portNo
=
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
());
boolean
enabled
=
!
port
.
getState
().
contains
(
OFPortState
.
LINK_DOWN
)
&&
!
port
.
getConfig
().
contains
(
OFPortConfig
.
PORT_DOWN
);
return
new
DefaultPortDescription
(
portNo
,
enabled
);
Port
.
Type
type
=
port
.
getCurr
().
contains
(
OFPortFeatures
.
PF_FIBER
)
?
FIBER
:
COPPER
;
return
new
DefaultPortDescription
(
portNo
,
enabled
,
type
,
portSpeed
(
port
));
}
private
long
portSpeed
(
OFPortDesc
port
)
{
if
(
port
.
getVersion
()
==
OFVersion
.
OF_13
)
{
return
port
.
getCurrSpeed
()
/
MBPS
;
}
PortSpeed
portSpeed
=
PortSpeed
.
SPEED_NONE
;
for
(
OFPortFeatures
feat
:
port
.
getCurr
())
{
portSpeed
=
PortSpeed
.
max
(
portSpeed
,
feat
.
getPortSpeed
());
}
return
portSpeed
.
getSpeedBps
()
/
MBPS
;
}
}
}
...
...
tools/build/onos-build
View file @
d16ce18
...
...
@@ -6,4 +6,4 @@
[
! -d
"
$ONOS_ROOT
"
]
&&
echo
"ONOS_ROOT is not defined"
>&2
&&
exit
1
.
$ONOS_ROOT
/tools/build/envDefaults
cd
$ONOS_ROOT
&&
mvn clean install
&&
cd
docs
&&
mvn javadoc:aggregate
cd
$ONOS_ROOT
&&
mvn clean install
"
$@
"
&&
cd
docs
&&
mvn javadoc:aggregate
...
...
tools/dev/bash_profile
View file @
d16ce18
...
...
@@ -34,6 +34,7 @@ alias mci='mvn clean install'
# Short-hand for ONOS build, package and test.
alias
ob
=
'onos-build'
alias
obi
=
'onos-build -Dmaven.test.failure.ignore=true'
alias
obs
=
'onos-build-selective'
alias
op
=
'onos-package'
alias
ot
=
'onos-test'
...
...
tools/test/topos/oe-linear-3.json
View file @
d16ce18
...
...
@@ -3,28 +3,33 @@
{
"uri"
:
"of:0000ffffffffff01"
,
"mac"
:
"ffffffffffff01"
,
"type"
:
"ROADM"
,
"mfr"
:
"Linc"
,
"hw"
:
"OE"
,
"sw"
:
"?"
,
"serial"
:
"?"
,
"name"
:
"ROADM1"
,
"annotations"
:
{
"latitude"
:
37.6
,
"longitude"
:
122.3
,
"optical.regens"
:
0
}
"annotations"
:
{
"latitude"
:
37.6
,
"longitude"
:
122.3
,
"optical.regens"
:
0
},
"ports"
:
[
{
"port"
:
10
,
"speed"
:
100000
,
"type"
:
"FIBER"
},
{
"port"
:
20
,
"speed"
:
0
,
"type"
:
"FIBER"
}
]
},
{
"uri"
:
"of:0000ffffffffff02"
,
"mac"
:
"ffffffffffff02"
,
"type"
:
"ROADM"
,
"mfr"
:
"Linc"
,
"hw"
:
"OE"
,
"sw"
:
"?"
,
"serial"
:
"?"
,
"name"
:
"ROADM2"
,
"annotations"
:
{
"latitude"
:
37.3
,
"longitude"
:
121.9
,
"optical.regens"
:
0
}
"annotations"
:
{
"latitude"
:
37.3
,
"longitude"
:
121.9
,
"optical.regens"
:
0
},
"ports"
:
[
{
"port"
:
11
,
"speed"
:
100000
,
"type"
:
"FIBER"
},
{
"port"
:
21
,
"speed"
:
0
,
"type"
:
"FIBER"
}
]
},
{
"uri"
:
"of:0000ffffffffff03"
,
"mac"
:
"ffffffffffff03"
,
"type"
:
"ROADM"
,
"mfr"
:
"Linc"
,
"hw"
:
"OE"
,
"sw"
:
"?"
,
"serial"
:
"?"
,
"name"
:
"ROADM3"
,
"annotations"
:
{
"latitude"
:
33.9
,
"longitude"
:
118.4
,
"optical.regens"
:
2
}
"annotations"
:
{
"latitude"
:
33.9
,
"longitude"
:
118.4
,
"optical.regens"
:
2
},
"ports"
:
[
{
"port"
:
30
,
"speed"
:
0
,
"type"
:
"FIBER"
},
{
"port"
:
31
,
"speed"
:
0
,
"type"
:
"FIBER"
}
]
},
{
"uri"
:
"of:0000ffffffff0001"
,
"mac"
:
"ffffffffff0003"
,
"type"
:
"SWITCH"
,
"mfr"
:
"Linc"
,
"hw"
:
"PK"
,
"sw"
:
"?"
,
"serial"
:
"?"
,
"name"
:
"ROUTER1"
,
"annotations"
:
{
"latitude"
:
37.6
,
"longitude"
:
122.3
}
"annotations"
:
{
"latitude"
:
37.6
,
"longitude"
:
122.3
},
"ports"
:
[
{
"port"
:
1
,
"speed"
:
10000
,
"type"
:
"COPPER"
},
{
"port"
:
2
,
"speed"
:
100000
,
"type"
:
"FIBER"
}
]
},
{
"uri"
:
"of:0000ffffffff0002"
,
"mac"
:
"ffffffffff0002"
,
"type"
:
"SWITCH"
,
"mfr"
:
"Linc"
,
"hw"
:
"PK"
,
"sw"
:
"?"
,
"serial"
:
"?"
,
"name"
:
"ROUTER2"
,
"annotations"
:
{
"latitude"
:
37.3
,
"longitude"
:
121.9
}
"annotations"
:
{
"latitude"
:
37.3
,
"longitude"
:
121.9
},
"ports"
:
[
{
"port"
:
1
,
"speed"
:
10000
,
"type"
:
"COPPER"
},
{
"port"
:
2
,
"speed"
:
100000
,
"type"
:
"FIBER"
}
]
}
],
...
...
utils/misc/src/main/java/org/onlab/packet/IpAddress.java
View file @
d16ce18
...
...
@@ -202,7 +202,7 @@ public final class IpAddress implements Comparable<IpAddress> {
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
version
,
octets
);
return
Objects
.
hash
(
version
,
Arrays
.
hashCode
(
octets
)
);
}
@Override
...
...
web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
View file @
d16ce18
...
...
@@ -19,17 +19,21 @@ import com.fasterxml.jackson.databind.JsonNode;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultAnnotations
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.SparseAnnotations
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderRegistry
;
import
org.onlab.onos.net.device.DeviceProviderService
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.host.DefaultHostDescription
;
import
org.onlab.onos.net.host.HostProvider
;
import
org.onlab.onos.net.host.HostProviderRegistry
;
...
...
@@ -45,7 +49,9 @@ import org.onlab.packet.MacAddress;
import
org.onlab.packet.VlanId
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
...
...
@@ -120,7 +126,30 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
DeviceDescription
desc
=
new
DefaultDeviceDescription
(
uri
,
type
,
mfr
,
hw
,
sw
,
serial
,
cid
,
annotations
);
dps
.
deviceConnected
(
deviceId
(
uri
),
desc
);
DeviceId
deviceId
=
deviceId
(
uri
);
dps
.
deviceConnected
(
deviceId
,
desc
);
JsonNode
ports
=
node
.
get
(
"ports"
);
if
(
ports
!=
null
)
{
parsePorts
(
dps
,
deviceId
,
ports
);
}
}
// Parses the given node with list of device ports.
private
void
parsePorts
(
DeviceProviderService
dps
,
DeviceId
deviceId
,
JsonNode
nodes
)
{
List
<
PortDescription
>
ports
=
new
ArrayList
<>();
for
(
JsonNode
node
:
nodes
)
{
ports
.
add
(
parsePort
(
node
));
}
dps
.
updatePorts
(
deviceId
,
ports
);
}
// Parses the given node with port information.
private
PortDescription
parsePort
(
JsonNode
node
)
{
Port
.
Type
type
=
Port
.
Type
.
valueOf
(
node
.
path
(
"type"
).
asText
(
"COPPER"
));
return
new
DefaultPortDescription
(
portNumber
(
node
.
path
(
"port"
).
asLong
(
0
)),
node
.
path
(
"enabled"
).
asBoolean
(
true
),
type
,
node
.
path
(
"speed"
).
asLong
(
1_000
));
}
// Parses the given JSON and provides links as configured.
...
...
Please
register
or
login
to post a comment