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
Jonathan Hart
2015-11-10 16:09:22 -0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4832784ed4032361f4c776b79a1de9c013c41226
4832784e
1 parent
d9df7bd2
Add configuration for default vlan
Change-Id: I183def6d1de3d10b2f53895f7fb7723df315379f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
7 deletions
apps/olt/src/main/java/org/onosproject/olt/AccessDeviceConfig.java
apps/olt/src/main/java/org/onosproject/olt/AccessDeviceData.java
apps/olt/src/main/java/org/onosproject/olt/OLT.java
apps/olt/src/main/java/org/onosproject/olt/AccessDeviceConfig.java
View file @
4832784
...
...
@@ -16,11 +16,14 @@
package
org
.
onosproject
.
olt
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
org.onlab.packet.VlanId
;
import
org.onosproject.net.DeviceId
;
import
org.onosproject.net.PortNumber
;
import
org.onosproject.net.config.Config
;
import
java.util.Optional
;
/**
* Config object for access device data.
*/
...
...
@@ -28,6 +31,7 @@ public class AccessDeviceConfig extends Config<DeviceId> {
private
static
final
String
UPLINK
=
"uplink"
;
private
static
final
String
VLAN
=
"vlan"
;
private
static
final
String
DEFAULT_VLAN
=
"defaultVlan"
;
/**
* Gets the access device configuration for this device.
...
...
@@ -37,7 +41,15 @@ public class AccessDeviceConfig extends Config<DeviceId> {
public
AccessDeviceData
getOlt
()
{
PortNumber
uplink
=
PortNumber
.
portNumber
(
node
.
path
(
UPLINK
).
asText
());
VlanId
vlan
=
VlanId
.
vlanId
(
Short
.
parseShort
(
node
.
path
(
VLAN
).
asText
()));
JsonNode
defaultVlanNode
=
node
.
path
(
DEFAULT_VLAN
);
Optional
<
VlanId
>
defaultVlan
;
if
(
defaultVlanNode
.
isMissingNode
())
{
defaultVlan
=
Optional
.
empty
();
}
else
{
defaultVlan
=
Optional
.
of
(
VlanId
.
vlanId
(
Short
.
parseShort
(
defaultVlanNode
.
asText
())));
}
return
new
AccessDeviceData
(
subject
(),
uplink
,
vlan
);
return
new
AccessDeviceData
(
subject
(),
uplink
,
vlan
,
defaultVlan
);
}
}
...
...
apps/olt/src/main/java/org/onosproject/olt/AccessDeviceData.java
View file @
4832784
...
...
@@ -20,6 +20,8 @@ import org.onlab.packet.VlanId;
import
org.onosproject.net.DeviceId
;
import
org.onosproject.net.PortNumber
;
import
java.util.Optional
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
/**
...
...
@@ -33,6 +35,7 @@ public class AccessDeviceData {
private
final
DeviceId
deviceId
;
private
final
PortNumber
uplink
;
private
final
VlanId
vlan
;
private
final
Optional
<
VlanId
>
defaultVlan
;
/**
* Class constructor.
...
...
@@ -41,10 +44,12 @@ public class AccessDeviceData {
* @param uplink uplink port number
* @param vlan device VLAN ID
*/
public
AccessDeviceData
(
DeviceId
deviceId
,
PortNumber
uplink
,
VlanId
vlan
)
{
public
AccessDeviceData
(
DeviceId
deviceId
,
PortNumber
uplink
,
VlanId
vlan
,
Optional
<
VlanId
>
defaultVlan
)
{
this
.
deviceId
=
checkNotNull
(
deviceId
,
DEVICE_ID_MISSING
);
this
.
uplink
=
checkNotNull
(
uplink
,
UPLINK_MISSING
);
this
.
vlan
=
checkNotNull
(
vlan
,
VLAN_MISSING
);
this
.
defaultVlan
=
checkNotNull
(
defaultVlan
);
}
/**
...
...
@@ -68,9 +73,18 @@ public class AccessDeviceData {
/**
* Retrieves the VLAN ID assigned to the device.
*
* @return
vlan
ID
* @return
VLAN
ID
*/
public
VlanId
vlan
()
{
return
vlan
;
}
/**
* Retrieves the default VLAN ID that will be used for this device.
*
* @return default VLAN ID
*/
public
Optional
<
VlanId
>
defaultVlan
()
{
return
defaultVlan
;
}
}
...
...
apps/olt/src/main/java/org/onosproject/olt/OLT.java
View file @
4832784
...
...
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
import
java.util.Dictionary
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.ConcurrentHashMap
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -247,15 +248,17 @@ public class OLT implements AccessDeviceService {
return
;
}
provisionVlans
(
olt
.
deviceId
(),
olt
.
uplink
(),
port
.
port
(),
vlan
,
olt
.
vlan
());
provisionVlans
(
olt
.
deviceId
(),
olt
.
uplink
(),
port
.
port
(),
vlan
,
olt
.
vlan
(),
olt
.
defaultVlan
());
}
private
void
provisionVlans
(
DeviceId
deviceId
,
PortNumber
uplinkPort
,
PortNumber
subscriberPort
,
VlanId
subscriberVlan
,
VlanId
deviceVlan
)
{
VlanId
subscriberVlan
,
VlanId
deviceVlan
,
Optional
<
VlanId
>
defaultVlan
)
{
TrafficSelector
upstream
=
DefaultTrafficSelector
.
builder
()
.
matchVlanId
(
DEFAULT_VLAN
)
.
matchVlanId
(
(
defaultVlan
.
isPresent
())
?
defaultVlan
.
get
()
:
DEFAULT_VLAN
)
.
matchInPort
(
subscriberPort
)
.
build
();
...
...
@@ -273,7 +276,7 @@ public class OLT implements AccessDeviceService {
TrafficTreatment
downstreamTreatment
=
DefaultTrafficTreatment
.
builder
()
.
popVlan
()
.
setVlanId
(
DEFAULT_VLAN
)
.
setVlanId
(
(
defaultVlan
.
isPresent
())
?
defaultVlan
.
get
()
:
DEFAULT_VLAN
)
.
setOutput
(
subscriberPort
)
.
build
();
...
...
Please
register
or
login
to post a comment