本文整理汇总了Java中net.floodlightcontroller.devicemanager.IDevice.getAttachmentPoints方法的典型用法代码示例。如果您正苦于以下问题:Java IDevice.getAttachmentPoints方法的具体用法?Java IDevice.getAttachmentPoints怎么用?Java IDevice.getAttachmentPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.devicemanager.IDevice
的用法示例。
在下文中一共展示了IDevice.getAttachmentPoints方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deviceAdded
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
if (switchPort.length == 0) {
//Device manager does not yet know an attachment point for a device (Bug Fix)
return;
}
IPv4Address[] ips = device.getIPv4Addresses();
if (ips.length == 0) {
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
.getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例2: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
.getLong());
String ip = null;
// some device may first appear with no IP address(default set to
// 0.0.0.0), ignore it
for (IPv4Address i : ips) {
if (i.getInt() != 0) {
ip = IPv4.fromIPv4Address(i.getInt());
break;
}
}
logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例3: deviceAdded
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
/**
* listen for new device
*/
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
if(ips.length == 0){
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
AP ap = new AP(ip,dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例4: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
String ip = null;
// some device may first appear with no IP address(default set to 0.0.0.0), ignore it
for(IPv4Address i : ips){
if(i.getInt() != 0){
ip = IPv4.fromIPv4Address(i.getInt());
break;
}
}
logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例5: installTCPProcessingRules
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
private void installTCPProcessingRules(FloodlightContext cntx){
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
IPv4 ipv4 = (IPv4) eth.getPayload();
int dstIP = ipv4.getDestinationAddress().getInt();
IDevice dstDevice = getDeviceFromIP(dstIP);
if (dstDevice == null){
log.error("[FRESCO] cannot send out TCP packets due to failure to locate destination");
return;
}
if (dstDevice.getAttachmentPoints().length < 1){
log.error("[FRESCO] can not install TCP processing"
+ " flow rules due to missing host location info");
return;
}
SwitchPort dstLocation = getLocationFromDevice(dstDevice);
IOFSwitch sw = switchService.getSwitch(dstLocation.getSwitchDPID());
if (sw == null){
log.error("[FRESCO] can not install TCP processing"
+ " due to to destionation switch is offline");
}
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
// set actions
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(sw.getOFFactory().actions().buildOutput().
setPort(dstLocation.getPort()).setMaxLen(Integer.MAX_VALUE).build());
pob.setActions(actions);
byte[] packetData = eth.serialize();
pob.setData(packetData);
sw.write(pob.build());
}
示例6: testBDAttachmentPointLearning
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
@Test
public void testBDAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT / 2 + 1);
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// this timestamp is too soon; don't switch
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// it should switch when we learn with a timestamp after the
// timeout
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(2)) }, aps);
}
示例7: testLOCALAttachmentPointLearning
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
/**
* This test verifies that the learning behavior on OFPP_LOCAL ports.
* Once a host is learned on OFPP_LOCAL, it is allowed to move only from
* one OFPP_LOCAL to another OFPP_LOCAL port.
* @throws Exception
*/
@Test
public void testLOCALAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).
andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.LOCAL)).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL,
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.LOCAL, c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT + 1);
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// Ensure that the attachment point changes to OFPP_LOCAL
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
// Even though the new attachment point is consistent with old
// and the time has elapsed, OFPP_LOCAL attachment point should
// be maintained.
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
}
示例8: testBDAttachmentPointLearning
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
@Test
public void testBDAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getL2DomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.of(2), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT / 2 + 1);
Entity entity3 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// this timestamp is too soon; don't switch
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// it should switch when we learn with a timestamp after the
// timeout
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(2)) }, aps);
}
示例9: testLOCALAttachmentPointLearning
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
/**
* This test verifies that the learning behavior on OFPP_LOCAL ports.
* Once a host is learned on OFPP_LOCAL, it is allowed to move only from
* one OFPP_LOCAL to another OFPP_LOCAL port.
* @throws Exception
*/
@Test
public void testLOCALAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getL2DomainId(DatapathId.of(anyLong()))).
andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.LOCAL)).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL,
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.LOCAL, c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT + 1);
Entity entity3 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// Ensure that the attachment point changes to OFPP_LOCAL
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
// Even though the new attachment point is consistent with old
// and the time has elapsed, OFPP_LOCAL attachment point should
// be maintained.
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
}
示例10: getLocationFromDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入方法依赖的package包/类
private SwitchPort getLocationFromDevice(IDevice d){
if (d != null && d.getAttachmentPoints() != null && d.getAttachmentPoints().length > 0)
return d.getAttachmentPoints()[0];
return null;
}