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
alshabib
2014-09-16 15:58:06 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
beb7316a4209787557c83a1469a243a4bd56fe69
beb7316a
2 parents
57044ba8
61359e9c
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
596 additions
and
155 deletions
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
core/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
core/api/src/main/java/org/onlab/onos/net/HostId.java
core/api/src/main/java/org/onlab/onos/net/path/PathService.java
core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java
core/api/src/test/java/org/onlab/onos/net/topology/TopologyServiceAdapter.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/path/SimplePathManager.java
of/api/src/test/java/org/onlab/onos/of/controller/OpenflowControllerAdapter.java
pom.xml
providers/of/host/src/main/test/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java → providers/of/host/src/test/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java
providers/of/pom.xml
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
View file @
beb7316
...
...
@@ -11,6 +11,7 @@ import org.onlab.onos.net.Path;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.link.LinkService
;
import
org.onlab.onos.net.path.PathService
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyGraph
;
import
org.onlab.onos.net.topology.TopologyService
;
...
...
@@ -28,6 +29,7 @@ import java.util.Map;
import
java.util.Set
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
HostId
.
hostId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
...
...
@@ -99,12 +101,11 @@ public class TopologyResource extends BaseResource {
@Produces
(
"application/json"
)
public
Response
paths
(
@PathParam
(
"src"
)
String
src
,
@PathParam
(
"dst"
)
String
dst
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
TopologyService
topologyService
=
get
(
TopologyService
.
class
);
Topology
topology
=
topologyService
.
currentTopology
();
PathService
pathService
=
get
(
PathService
.
class
);
Set
<
Path
>
paths
=
pathService
.
getPaths
(
elementId
(
src
),
elementId
(
dst
));
ArrayNode
pathsNode
=
mapper
.
createArrayNode
();
for
(
Path
path
:
topologyService
.
getPaths
(
topology
,
deviceId
(
src
),
deviceId
(
dst
))
)
{
for
(
Path
path
:
paths
)
{
pathsNode
.
add
(
json
(
mapper
,
path
));
}
...
...
@@ -114,6 +115,11 @@ public class TopologyResource extends BaseResource {
return
Response
.
ok
(
rootNode
.
toString
()).
build
();
}
// Creates either device ID or host ID as appropriate.
private
ElementId
elementId
(
String
id
)
{
return
id
.
startsWith
(
"nic:"
)
?
hostId
(
id
)
:
deviceId
(
id
);
}
// Scan all links and counts number of them between the same devices
// using a normalized link key.
private
Map
<
String
,
AggLink
>
aggregateLinks
()
{
...
...
core/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
View file @
beb7316
...
...
@@ -23,8 +23,8 @@ public class DefaultEdgeLink extends DefaultLink implements EdgeLink {
*/
public
DefaultEdgeLink
(
ProviderId
providerId
,
ConnectPoint
hostPoint
,
HostLocation
hostLocation
,
boolean
isIngress
)
{
super
(
providerId
,
isIngress
?
host
Location
:
hostPoint
,
isIngress
?
host
Point
:
hostLocation
,
Type
.
EDGE
);
super
(
providerId
,
isIngress
?
host
Point
:
hostLocation
,
isIngress
?
host
Location
:
hostPoint
,
Type
.
EDGE
);
checkArgument
(
hostPoint
.
elementId
()
instanceof
HostId
,
"Host point does not refer to a host ID"
);
this
.
hostId
=
(
HostId
)
hostPoint
.
elementId
();
...
...
core/api/src/main/java/org/onlab/onos/net/HostId.java
View file @
beb7316
...
...
@@ -44,7 +44,7 @@ public final class HostId extends ElementId {
*/
public
static
HostId
hostId
(
MACAddress
mac
,
VLANID
vlanId
)
{
// FIXME: use more efficient means of encoding
return
hostId
(
"nic"
+
":"
+
mac
+
"
/
"
+
vlanId
);
return
hostId
(
"nic"
+
":"
+
mac
+
"
-
"
+
vlanId
);
}
/**
...
...
core/api/src/main/java/org/onlab/onos/net/path/PathService.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
path
;
import
org.onlab.onos.net.ElementId
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
java.util.Set
;
/**
* Service for obtaining pre-computed paths or for requesting computation of
* paths using the current topology snapshot.
*/
public
interface
PathService
{
/**
* Returns the set of all shortest paths, precomputed in terms of hop-count,
* between the specified source and destination elements.
*
* @param src source element
* @param dst destination element
* @return set of all shortest paths between the two elements
*/
Set
<
Path
>
getPaths
(
ElementId
src
,
ElementId
dst
);
/**
* Returns the set of all shortest paths, computed using the supplied
* edge-weight entity, between the specified source and destination
* network elements.
*
* @param src source element
* @param dst destination element
* @return set of all shortest paths between the two element
*/
Set
<
Path
>
getPaths
(
ElementId
src
,
ElementId
dst
,
LinkWeight
weight
);
}
core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
View file @
beb7316
...
...
@@ -47,8 +47,8 @@ public class DefaultEdgeLinkTest {
public
void
basics
()
{
HostLocation
hostLocation
=
new
HostLocation
(
DID1
,
P1
,
123L
);
EdgeLink
link
=
new
DefaultEdgeLink
(
PID
,
cp
(
HID1
,
P0
),
hostLocation
,
false
);
assertEquals
(
"incorrect src"
,
cp
(
HID1
,
P0
),
link
.
src
());
assertEquals
(
"incorrect dst"
,
hostLocation
,
link
.
dst
());
assertEquals
(
"incorrect src"
,
cp
(
HID1
,
P0
),
link
.
dst
());
assertEquals
(
"incorrect dst"
,
hostLocation
,
link
.
src
());
assertEquals
(
"incorrect type"
,
Link
.
Type
.
EDGE
,
link
.
type
());
assertEquals
(
"incorrect hostId"
,
HID1
,
link
.
hostId
());
assertEquals
(
"incorrect connect point"
,
hostLocation
,
link
.
hostLocation
());
...
...
core/api/src/test/java/org/onlab/onos/net/HostIdTest.java
View file @
beb7316
...
...
@@ -22,7 +22,7 @@ public class HostIdTest extends ElementIdTest {
@Test
public
void
basics
()
{
new
EqualsTester
()
.
addEqualityGroup
(
hostId
(
"nic:00:11:00:00:00:01
/
11"
),
.
addEqualityGroup
(
hostId
(
"nic:00:11:00:00:00:01
-
11"
),
hostId
(
MAC1
,
VLAN1
))
.
addEqualityGroup
(
hostId
(
MAC2
,
VLAN2
))
.
testEquals
();
...
...
core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
device
;
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
java.util.List
;
/**
* Test adapter for device service.
*/
public
class
DeviceServiceAdapter
implements
DeviceService
{
@Override
public
int
getDeviceCount
()
{
return
0
;
}
@Override
public
Iterable
<
Device
>
getDevices
()
{
return
null
;
}
@Override
public
Device
getDevice
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
MastershipRole
getRole
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
List
<
Port
>
getPorts
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
Port
getPort
(
DeviceId
deviceId
,
PortNumber
portNumber
)
{
return
null
;
}
@Override
public
boolean
isAvailable
(
DeviceId
deviceId
)
{
return
false
;
}
@Override
public
void
addListener
(
DeviceListener
listener
)
{
}
@Override
public
void
removeListener
(
DeviceListener
listener
)
{
}
}
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IPAddress
;
import
org.onlab.packet.MACAddress
;
import
org.onlab.packet.VLANID
;
import
java.util.Set
;
/**
* Test adapter for host service.
*/
public
class
HostServiceAdapter
implements
HostService
{
@Override
public
int
getHostCount
()
{
return
0
;
}
@Override
public
Iterable
<
Host
>
getHosts
()
{
return
null
;
}
@Override
public
Host
getHost
(
HostId
hostId
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getHostsByVlan
(
VLANID
vlanId
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getHostsByMac
(
MACAddress
mac
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getHostsByIp
(
IPAddress
ip
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getConnectedHosts
(
ConnectPoint
connectPoint
)
{
return
null
;
}
@Override
public
Set
<
Host
>
getConnectedHosts
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
void
addListener
(
HostListener
listener
)
{
}
@Override
public
void
removeListener
(
HostListener
listener
)
{
}
}
core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
java.util.Set
;
/**
* Test adapter for link service.
*/
public
class
LinkServiceAdapter
implements
LinkService
{
@Override
public
int
getLinkCount
()
{
return
0
;
}
@Override
public
Iterable
<
Link
>
getLinks
()
{
return
null
;
}
@Override
public
Set
<
Link
>
getDeviceLinks
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getDeviceEgressLinks
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getDeviceIngressLinks
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getLinks
(
ConnectPoint
connectPoint
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getEgressLinks
(
ConnectPoint
connectPoint
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getIngressLinks
(
ConnectPoint
connectPoint
)
{
return
null
;
}
@Override
public
Link
getLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
return
null
;
}
@Override
public
void
addListener
(
LinkListener
listener
)
{
}
@Override
public
void
removeListener
(
LinkListener
listener
)
{
}
}
core/api/src/test/java/org/onlab/onos/net/topology/TopologyServiceAdapter.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
topology
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.Path
;
import
java.util.Set
;
/**
* Test adapter for topology service.
*/
public
class
TopologyServiceAdapter
implements
TopologyService
{
@Override
public
Topology
currentTopology
()
{
return
null
;
}
@Override
public
boolean
isLatest
(
Topology
topology
)
{
return
false
;
}
@Override
public
TopologyGraph
getGraph
(
Topology
topology
)
{
return
null
;
}
@Override
public
Set
<
TopologyCluster
>
getClusters
(
Topology
topology
)
{
return
null
;
}
@Override
public
TopologyCluster
getCluster
(
Topology
topology
,
ClusterId
clusterId
)
{
return
null
;
}
@Override
public
Set
<
DeviceId
>
getClusterDevices
(
Topology
topology
,
TopologyCluster
cluster
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getClusterLinks
(
Topology
topology
,
TopologyCluster
cluster
)
{
return
null
;
}
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
)
{
return
null
;
}
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
,
LinkWeight
weight
)
{
return
null
;
}
@Override
public
boolean
isInfrastructure
(
Topology
topology
,
ConnectPoint
connectPoint
)
{
return
false
;
}
@Override
public
boolean
isBroadcastPoint
(
Topology
topology
,
ConnectPoint
connectPoint
)
{
return
false
;
}
@Override
public
void
addListener
(
TopologyListener
listener
)
{
}
@Override
public
void
removeListener
(
TopologyListener
listener
)
{
}
}
core/trivial/src/main/java/org/onlab/onos/net/trivial/path/SimplePathManager.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
net
.
trivial
.
path
;
import
com.google.common.collect.Lists
;
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
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultEdgeLink
;
import
org.onlab.onos.net.DefaultPath
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.EdgeLink
;
import
org.onlab.onos.net.ElementId
;
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.Path
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.path.PathService
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.slf4j.Logger
;
import
java.util.List
;
import
java.util.Set
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* Provides implementation of a path selection service atop the current
* topology and host services.
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimplePathManager
implements
PathService
{
private
static
final
String
ELEMENT_ID_NULL
=
"Element ID cannot be null"
;
private
static
final
ProviderId
PID
=
new
ProviderId
(
"org.onlab.onos.core"
);
private
static
final
PortNumber
P0
=
PortNumber
.
portNumber
(
0
);
private
static
final
EdgeLink
NOT_HOST
=
new
NotHost
();
private
final
Logger
log
=
getLogger
(
getClass
());
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
TopologyService
topologyService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
HostService
hostService
;
@Activate
public
void
setUp
()
{
log
.
info
(
"Started"
);
}
@Deactivate
public
void
tearDown
()
{
log
.
info
(
"Stopped"
);
}
@Override
public
Set
<
Path
>
getPaths
(
ElementId
src
,
ElementId
dst
)
{
return
getPaths
(
src
,
dst
,
null
);
}
@Override
public
Set
<
Path
>
getPaths
(
ElementId
src
,
ElementId
dst
,
LinkWeight
weight
)
{
checkNotNull
(
src
,
ELEMENT_ID_NULL
);
checkNotNull
(
dst
,
ELEMENT_ID_NULL
);
// Get the source and destination edge locations
EdgeLink
srcEdge
=
getEdgeLink
(
src
,
true
);
EdgeLink
dstEdge
=
getEdgeLink
(
dst
,
false
);
DeviceId
srcDevice
=
srcEdge
!=
NOT_HOST
?
srcEdge
.
dst
().
deviceId
()
:
(
DeviceId
)
src
;
DeviceId
dstDevice
=
dstEdge
!=
NOT_HOST
?
dstEdge
.
src
().
deviceId
()
:
(
DeviceId
)
dst
;
// If the source and destination are on the same edge device, there
// is just one path, so build it and return it.
if
(
srcDevice
.
equals
(
dstDevice
))
{
return
edgeToEdgePaths
(
srcEdge
,
dstEdge
);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology
topology
=
topologyService
.
currentTopology
();
Set
<
Path
>
paths
=
weight
==
null
?
topologyService
.
getPaths
(
topology
,
srcDevice
,
dstDevice
)
:
topologyService
.
getPaths
(
topology
,
srcDevice
,
dstDevice
,
weight
);
return
edgeToEdgePaths
(
srcEdge
,
dstEdge
,
paths
);
}
// Finds the host edge link if the element ID is a host id of an existing
// host. Otherwise, if the host does not exist, it returns null and if
// the element ID is not a host ID, returns NOT_HOST edge link.
private
EdgeLink
getEdgeLink
(
ElementId
elementId
,
boolean
isIngress
)
{
if
(
elementId
instanceof
HostId
)
{
// Resolve the host, return null.
Host
host
=
hostService
.
getHost
((
HostId
)
elementId
);
if
(
host
==
null
)
{
return
null
;
}
return
new
DefaultEdgeLink
(
PID
,
new
ConnectPoint
(
elementId
,
P0
),
host
.
location
(),
isIngress
);
}
return
NOT_HOST
;
}
// Produces a set of direct edge-to-edge paths.
private
Set
<
Path
>
edgeToEdgePaths
(
EdgeLink
srcLink
,
EdgeLink
dstLink
)
{
Set
<
Path
>
endToEndPaths
=
Sets
.
newHashSetWithExpectedSize
(
1
);
if
(
srcLink
!=
NOT_HOST
||
dstLink
!=
NOT_HOST
)
{
endToEndPaths
.
add
(
edgeToEdgePath
(
srcLink
,
dstLink
));
}
return
endToEndPaths
;
}
// Produces a direct edge-to-edge path.
private
Path
edgeToEdgePath
(
EdgeLink
srcLink
,
EdgeLink
dstLink
)
{
List
<
Link
>
links
=
Lists
.
newArrayListWithCapacity
(
2
);
// Add source and destination edge links only if they are real.
if
(
srcLink
!=
NOT_HOST
)
{
links
.
add
(
srcLink
);
}
if
(
dstLink
!=
NOT_HOST
)
{
links
.
add
(
dstLink
);
}
return
new
DefaultPath
(
PID
,
links
,
2
);
}
// Produces a set of edge-to-edge paths using the set of infrastructure
// paths and the given edge links.
private
Set
<
Path
>
edgeToEdgePaths
(
EdgeLink
srcLink
,
EdgeLink
dstLink
,
Set
<
Path
>
paths
)
{
Set
<
Path
>
endToEndPaths
=
Sets
.
newHashSetWithExpectedSize
(
paths
.
size
());
for
(
Path
path
:
paths
)
{
endToEndPaths
.
add
(
edgeToEdgePath
(
srcLink
,
dstLink
,
path
));
}
return
endToEndPaths
;
}
// Produces an edge-to-edge path using the specified infrastructure path
// and edge links.
private
Path
edgeToEdgePath
(
EdgeLink
srcLink
,
EdgeLink
dstLink
,
Path
path
)
{
List
<
Link
>
links
=
Lists
.
newArrayListWithCapacity
(
path
.
links
().
size
()
+
2
);
links
.
add
(
srcLink
);
links
.
addAll
(
path
.
links
());
links
.
add
(
dstLink
);
return
new
DefaultPath
(
path
.
providerId
(),
links
,
path
.
cost
()
+
2
);
}
// Special value for edge link to represent that this is really not an
// edge link since the src or dst are really an infrastructure device.
private
static
class
NotHost
extends
DefaultEdgeLink
implements
EdgeLink
{
NotHost
()
{
super
(
PID
,
new
ConnectPoint
(
HostId
.
hostId
(
"nic:none"
),
P0
),
new
HostLocation
(
deviceId
(
"none:none"
),
P0
,
0L
),
false
);
}
}
}
of/api/src/test/java/org/onlab/onos/of/controller/OpenflowControllerAdapter.java
0 → 100644
View file @
beb7316
package
org
.
onlab
.
onos
.
of
.
controller
;
import
org.projectfloodlight.openflow.protocol.OFMessage
;
/**
* Test adapter for the OpenFlow controller interface.
*/
public
class
OpenflowControllerAdapter
implements
OpenFlowController
{
@Override
public
Iterable
<
OpenFlowSwitch
>
getSwitches
()
{
return
null
;
}
@Override
public
Iterable
<
OpenFlowSwitch
>
getMasterSwitches
()
{
return
null
;
}
@Override
public
Iterable
<
OpenFlowSwitch
>
getEqualSwitches
()
{
return
null
;
}
@Override
public
OpenFlowSwitch
getSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
OpenFlowSwitch
getMasterSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
OpenFlowSwitch
getEqualSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
void
addListener
(
OpenFlowSwitchListener
listener
)
{
}
@Override
public
void
removeListener
(
OpenFlowSwitchListener
listener
)
{
}
@Override
public
void
addPacketListener
(
int
priority
,
PacketListener
listener
)
{
}
@Override
public
void
removePacketListener
(
PacketListener
listener
)
{
}
@Override
public
void
write
(
Dpid
dpid
,
OFMessage
msg
)
{
}
@Override
public
void
processPacket
(
Dpid
dpid
,
OFMessage
msg
)
{
}
@Override
public
void
setRole
(
Dpid
dpid
,
RoleState
role
)
{
}
}
pom.xml
View file @
beb7316
...
...
@@ -144,10 +144,24 @@
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-
of-
api
</artifactId>
<artifactId>
onos-api
</artifactId>
<version>
${project.version}
</version>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-of-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-of-api
</artifactId>
<version>
${project.version}
</version>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
...
providers/of/host/src/
main/test
/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java
→
providers/of/host/src/
test/java
/org/onlab/onos/provider/of/host/impl/OpenFlowHostProviderTest.java
View file @
beb7316
package
org
.
onlab
.
onos
.
provider
.
of
.
host
.
impl
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
java.util.Set
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.host.HostDescription
;
import
org.onlab.onos.net.host.HostProvider
;
import
org.onlab.onos.net.host.HostProviderRegistry
;
import
org.onlab.onos.net.host.HostProviderService
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.net.topology.ClusterId
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyCluster
;
import
org.onlab.onos.net.topology.TopologyGraph
;
import
org.onlab.onos.net.topology.TopologyListener
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.onos.net.topology.TopologyServiceAdapter
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.OpenFlowController
;
import
org.onlab.onos.of.controller.OpenFlowPacketContext
;
import
org.onlab.onos.of.controller.OpenFlowSwitch
;
import
org.onlab.onos.of.controller.OpenFlowSwitchListener
;
import
org.onlab.onos.of.controller.OpenflowControllerAdapter
;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.onlab.onos.of.controller.RoleState
;
import
org.onlab.packet.ARP
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.MACAddress
;
...
...
@@ -41,6 +24,10 @@ import org.onlab.packet.VLANID;
import
org.projectfloodlight.openflow.protocol.OFMessage
;
import
org.projectfloodlight.openflow.types.OFPort
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.*;
public
class
OpenFlowHostProviderTest
{
private
static
final
Integer
INPORT
=
10
;
...
...
@@ -51,7 +38,7 @@ public class OpenFlowHostProviderTest {
private
static
final
VLANID
VLAN
=
VLANID
.
vlanId
();
private
static
final
MACAddress
MAC
=
MACAddress
.
valueOf
(
"00:00:11:00:00:01"
);
private
static
final
MACAddress
BCMAC
=
MACAddress
.
valueOf
(
"ff:ff:ff:ff:ff:ff"
);
private
static
byte
[]
IP
=
new
byte
[]
{
10
,
0
,
0
,
1
};
private
static
final
byte
[]
IP
=
new
byte
[]{
10
,
0
,
0
,
1
};
private
OpenFlowHostProvider
provider
=
new
OpenFlowHostProvider
();
private
TestHostRegistry
hostService
=
new
TestHostRegistry
();
...
...
@@ -145,148 +132,31 @@ public class OpenFlowHostProviderTest {
}
private
class
TestController
implements
OpenFlowController
{
private
class
TestController
extends
OpenflowControllerAdapter
{
PacketListener
pktListener
;
@Override
public
Iterable
<
OpenFlowSwitch
>
getSwitches
()
{
return
null
;
}
@Override
public
Iterable
<
OpenFlowSwitch
>
getMasterSwitches
()
{
return
null
;
}
@Override
public
Iterable
<
OpenFlowSwitch
>
getEqualSwitches
()
{
return
null
;
}
@Override
public
OpenFlowSwitch
getSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
OpenFlowSwitch
getMasterSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
OpenFlowSwitch
getEqualSwitch
(
Dpid
dpid
)
{
return
null
;
}
@Override
public
void
addListener
(
OpenFlowSwitchListener
listener
)
{
}
@Override
public
void
removeListener
(
OpenFlowSwitchListener
listener
)
{
}
@Override
public
void
addPacketListener
(
int
priority
,
PacketListener
listener
)
{
pktListener
=
listener
;
}
@Override
public
void
removePacketListener
(
PacketListener
listener
)
{
}
@Override
public
void
write
(
Dpid
dpid
,
OFMessage
msg
)
{
}
@Override
public
void
processPacket
(
Dpid
dpid
,
OFMessage
msg
)
{
OpenFlowPacketContext
ctx
=
new
TestPacketContext
(
dpid
);
OpenFlowPacketContext
ctx
=
new
TestPacketContext
(
dpid
);
pktListener
.
handlePacket
(
ctx
);
}
@Override
public
void
setRole
(
Dpid
dpid
,
RoleState
role
)
{
}
}
private
class
TestTopologyService
implements
TopologyService
{
@Override
public
Topology
currentTopology
()
{
return
null
;
}
@Override
public
boolean
isLatest
(
Topology
topology
)
{
return
false
;
}
@Override
public
TopologyGraph
getGraph
(
Topology
topology
)
{
return
null
;
}
@Override
public
Set
<
TopologyCluster
>
getClusters
(
Topology
topology
)
{
return
null
;
}
@Override
public
TopologyCluster
getCluster
(
Topology
topology
,
ClusterId
clusterId
)
{
return
null
;
}
@Override
public
Set
<
DeviceId
>
getClusterDevices
(
Topology
topology
,
TopologyCluster
cluster
)
{
return
null
;
}
@Override
public
Set
<
Link
>
getClusterLinks
(
Topology
topology
,
TopologyCluster
cluster
)
{
return
null
;
}
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
)
{
return
null
;
}
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
,
LinkWeight
weight
)
{
return
null
;
}
private
class
TestTopologyService
extends
TopologyServiceAdapter
{
@Override
public
boolean
isInfrastructure
(
Topology
topology
,
ConnectPoint
connectPoint
)
{
ConnectPoint
connectPoint
)
{
//simulate DPID3 as an infrastructure switch
if
(
Dpid
.
dpid
(
connectPoint
.
deviceId
().
uri
()).
equals
(
DPID3
))
{
return
true
;
}
return
false
;
}
@Override
public
boolean
isBroadcastPoint
(
Topology
topology
,
ConnectPoint
connectPoint
)
{
return
false
;
}
@Override
public
void
addListener
(
TopologyListener
listener
)
{
}
@Override
public
void
removeListener
(
TopologyListener
listener
)
{
}
}
private
class
TestPacketContext
implements
OpenFlowPacketContext
{
...
...
@@ -319,9 +189,9 @@ public class OpenFlowHostProviderTest {
// just things we (and serializers) need
ARP
arp
=
new
ARP
();
arp
.
setSenderProtocolAddress
(
IP
)
.
setSenderHardwareAddress
(
MAC
.
toBytes
())
.
setTargetHardwareAddress
(
BCMAC
.
toBytes
())
.
setTargetProtocolAddress
(
IP
);
.
setSenderHardwareAddress
(
MAC
.
toBytes
())
.
setTargetHardwareAddress
(
BCMAC
.
toBytes
())
.
setTargetProtocolAddress
(
IP
);
Ethernet
eth
=
new
Ethernet
();
eth
.
setEtherType
(
Ethernet
.
TYPE_ARP
)
...
...
providers/of/pom.xml
View file @
beb7316
...
...
@@ -29,6 +29,19 @@
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-of-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-of-api
</artifactId>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-api
</artifactId>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
...
...
Please
register
or
login
to post a comment