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-09 16:43:00 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a89cc58da1632d73c5e369c5152c7223da30775b
a89cc58d
1 parent
505bc6ba
cleaning Device Provider
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
a89cc58
...
...
@@ -43,7 +43,7 @@ import org.slf4j.Logger;
@Component
(
immediate
=
true
)
public
class
OpenFlowDeviceProvider
extends
AbstractProvider
implements
DeviceProvider
{
private
final
Logger
log
=
getLogger
(
getClass
()
);
private
static
final
Logger
LOG
=
getLogger
(
OpenFlowDeviceProvider
.
class
);
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
DeviceProviderRegistry
providerRegistry
;
...
...
@@ -66,7 +66,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
public
void
activate
()
{
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addListener
(
listener
);
log
.
info
(
"Started"
);
LOG
.
info
(
"Started"
);
}
@Deactivate
...
...
@@ -74,33 +74,34 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
providerRegistry
.
unregister
(
this
);
controller
.
removeListener
(
listener
);
providerService
=
null
;
log
.
info
(
"Stopped"
);
LOG
.
info
(
"Stopped"
);
}
@Override
public
void
triggerProbe
(
Device
device
)
{
log
.
info
(
"Triggering probe on device {}"
,
device
.
id
());
LOG
.
info
(
"Triggering probe on device {}"
,
device
.
id
());
}
@Override
public
void
roleChanged
(
Device
device
,
MastershipRole
newRole
)
{
switch
(
newRole
)
{
case
MASTER:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
MASTER
);
break
;
case
STANDBY:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
EQUAL
);
case
NONE:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
SLAVE
);
break
;
default
:
log
.
error
(
"Unknown Mastership state : {}"
,
newRole
);
case
MASTER:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
MASTER
);
break
;
case
STANDBY:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
EQUAL
);
break
;
case
NONE:
controller
.
setRole
(
new
Dpid
(
device
.
id
().
uri
().
getSchemeSpecificPart
()),
RoleState
.
SLAVE
);
break
;
default
:
LOG
.
error
(
"Unknown Mastership state : {}"
,
newRole
);
}
log
.
info
(
"Accepting mastership role change for device {}"
,
device
.
id
());
LOG
.
info
(
"Accepting mastership role change for device {}"
,
device
.
id
());
}
private
class
InternalDeviceProvider
implements
OpenFlowSwitchListener
{
...
...
@@ -114,10 +115,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
DeviceDescription
description
=
new
DefaultDeviceDescription
(
buildURI
(
dpid
),
Device
.
Type
.
SWITCH
,
sw
.
manfacturerDescription
(),
sw
.
hardwareDescription
(),
sw
.
softwareDescription
(),
sw
.
serialNumber
());
sw
.
manfacturerDescription
(),
sw
.
hardwareDescription
(),
sw
.
softwareDescription
(),
sw
.
serialNumber
());
providerService
.
deviceConnected
(
deviceId
(
uri
),
description
);
providerService
.
updatePorts
(
deviceId
(
uri
),
buildPortDescriptions
(
sw
.
getPorts
()));
}
...
...
@@ -149,7 +150,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
try
{
uri
=
new
URI
(
"of"
,
Long
.
toHexString
(
dpid
.
value
()),
null
);
}
catch
(
URISyntaxException
e
)
{
log
.
warn
(
"URI construction for device {} failed."
,
dpid
);
LOG
.
warn
(
"URI construction for device {} failed."
,
dpid
);
}
return
uri
;
}
...
...
Please
register
or
login
to post a comment