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
Sho SHIMIZU
2015-08-26 14:36:21 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3be9fbe6d19a380c3222ea6abb7acd5b819b5f80
3be9fbe6
1 parent
a6b14811
Apply more functional style
Change-Id: Ib2194054dcddbc975f426c5a17a89031e3b1166d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
48 deletions
drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbBridgeConfig.java
drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbTunnelConfig.java
drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbBridgeConfig.java
View file @
3be9fbe
...
...
@@ -16,8 +16,8 @@
package
org
.
onosproject
.
driver
.
ovsdb
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.onlab.packet.IpAddress
;
import
org.onosproject.net.DeviceId
;
...
...
@@ -36,8 +36,6 @@ import org.onosproject.ovsdb.controller.OvsdbController;
import
org.onosproject.ovsdb.controller.OvsdbNodeId
;
import
org.onosproject.ovsdb.controller.OvsdbPort
;
import
com.google.common.collect.Sets
;
/**
* The implementation of BridageConfig.
*/
...
...
@@ -63,18 +61,16 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
DriverHandler
handler
=
handler
();
DeviceId
deviceId
=
handler
.
data
().
deviceId
();
OvsdbClientService
clientService
=
getOvsdbClientService
(
handler
);
Set
<
OvsdbBridge
>
ovsdbSet
=
clientService
.
getBridges
();
Collection
<
BridgeDescription
>
bridges
=
Sets
.
newHashSet
();
ovsdbSet
.
forEach
(
o
->
{
BridgeName
bridgeName
=
BridgeName
.
bridgeName
(
o
.
bridgeName
().
value
());
DeviceId
ownDeviceId
=
DeviceId
.
deviceId
(
"of:"
+
o
.
datapathId
().
value
());
BridgeDescription
description
=
new
DefaultBridgeDescription
(
bridgeName
,
deviceId
,
ownDeviceId
);
bridges
.
add
(
description
);
});
return
bridges
;
Set
<
OvsdbBridge
>
bridges
=
clientService
.
getBridges
();
return
bridges
.
stream
()
.
map
(
x
->
new
DefaultBridgeDescription
(
BridgeName
.
bridgeName
(
x
.
bridgeName
().
value
()),
deviceId
,
DeviceId
.
deviceId
(
"of:"
+
x
.
datapathId
().
value
())
)
)
.
collect
(
Collectors
.
toSet
());
}
@Override
...
...
@@ -105,14 +101,15 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
public
Collection
<
PortDescription
>
getPorts
()
{
DriverHandler
handler
=
handler
();
OvsdbClientService
clientService
=
getOvsdbClientService
(
handler
);
Set
<
OvsdbPort
>
ovsdbSet
=
clientService
.
getPorts
();
Collection
<
PortDescription
>
ports
=
Sets
.
newHashSet
();
ovsdbSet
.
forEach
(
o
->
{
PortNumber
port
=
PortNumber
.
portNumber
(
o
.
portNumber
().
value
());
PortDescription
description
=
new
DefaultPortDescription
(
port
,
true
);
ports
.
add
(
description
);
});
return
ports
;
Set
<
OvsdbPort
>
ports
=
clientService
.
getPorts
();
return
ports
.
stream
()
.
map
(
x
->
new
DefaultPortDescription
(
PortNumber
.
portNumber
(
x
.
portNumber
().
value
()),
true
)
)
.
collect
(
Collectors
.
toSet
());
}
// OvsdbNodeId(IP:port) is used in the adaptor while DeviceId(ovsdb:IP:port)
...
...
@@ -137,15 +134,16 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
@Override
public
Set
<
PortNumber
>
getPortNumbers
()
{
Set
<
PortNumber
>
ports
=
new
HashSet
<>();
DriverHandler
handler
=
handler
();
OvsdbClientService
clientService
=
getOvsdbClientService
(
handler
);
Set
<
OvsdbPort
>
ovsdbSet
=
clientService
.
getPorts
();
ovsdbSet
.
forEach
(
o
->
{
PortNumber
port
=
PortNumber
.
portNumber
(
o
.
portNumber
().
value
(),
o
.
portName
().
value
());
ports
.
add
(
port
);
});
return
ports
;
Set
<
OvsdbPort
>
ports
=
clientService
.
getPorts
();
return
ports
.
stream
()
.
map
(
x
->
PortNumber
.
portNumber
(
x
.
portNumber
().
value
(),
x
.
portName
().
value
()
)
)
.
collect
(
Collectors
.
toSet
());
}
}
...
...
drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbTunnelConfig.java
View file @
3be9fbe
...
...
@@ -18,6 +18,7 @@ package org.onosproject.driver.ovsdb;
import
java.util.Collection
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.onlab.packet.IpAddress
;
import
org.onosproject.net.DeviceId
;
...
...
@@ -25,7 +26,6 @@ import org.onosproject.net.behaviour.DefaultTunnelDescription;
import
org.onosproject.net.behaviour.IpTunnelEndPoint
;
import
org.onosproject.net.behaviour.TunnelConfig
;
import
org.onosproject.net.behaviour.TunnelDescription
;
import
org.onosproject.net.behaviour.TunnelEndPoint
;
import
org.onosproject.net.behaviour.TunnelName
;
import
org.onosproject.net.driver.AbstractHandlerBehaviour
;
import
org.onosproject.net.driver.DriverHandler
;
...
...
@@ -34,8 +34,6 @@ import org.onosproject.ovsdb.controller.OvsdbController;
import
org.onosproject.ovsdb.controller.OvsdbNodeId
;
import
org.onosproject.ovsdb.controller.OvsdbTunnel
;
import
com.google.common.collect.Sets
;
/**
* OVSDB-based implementation of tunnel config behaviour.
*/
...
...
@@ -90,20 +88,18 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour
public
Collection
<
TunnelDescription
>
getTunnels
()
{
DriverHandler
handler
=
handler
();
OvsdbClientService
ovsdbNode
=
getOvsdbNode
(
handler
);
Set
<
OvsdbTunnel
>
ovsdbSet
=
ovsdbNode
.
getTunnels
();
Collection
<
TunnelDescription
>
tunnels
=
Sets
.
newHashSet
();
ovsdbSet
.
forEach
(
o
->
{
TunnelEndPoint
ipSrc
=
IpTunnelEndPoint
.
ipTunnelPoint
(
o
.
localIp
());
TunnelEndPoint
ipDst
=
IpTunnelEndPoint
.
ipTunnelPoint
(
o
.
remoteIp
());
TunnelName
name
=
TunnelName
.
tunnelName
(
o
.
tunnelName
().
toString
());
TunnelDescription
des
=
new
DefaultTunnelDescription
(
ipSrc
,
ipDst
,
TunnelDescription
.
Type
.
VXLAN
,
name
);
tunnels
.
add
(
des
);
});
return
tunnels
;
Set
<
OvsdbTunnel
>
tunnels
=
ovsdbNode
.
getTunnels
();
return
tunnels
.
stream
()
.
map
(
x
->
new
DefaultTunnelDescription
(
IpTunnelEndPoint
.
ipTunnelPoint
(
x
.
localIp
()),
IpTunnelEndPoint
.
ipTunnelPoint
(
x
.
remoteIp
()),
TunnelDescription
.
Type
.
VXLAN
,
TunnelName
.
tunnelName
(
x
.
tunnelName
().
toString
())
)
)
.
collect
(
Collectors
.
toSet
());
}
// OvsdbNodeId(IP:port) is used in the adaptor while DeviceId(ovsdb:IP:port)
...
...
Please
register
or
login
to post a comment