本文整理汇总了Java中org.onosproject.vtn.util.VtnData类的典型用法代码示例。如果您正苦于以下问题:Java VtnData类的具体用法?Java VtnData怎么用?Java VtnData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VtnData类属于org.onosproject.vtn.util包,在下文中一共展示了VtnData类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOvsDetected
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
@Override
public void onOvsDetected(Device device) {
if (device == null) {
log.error("The device is null");
return;
}
if (!mastershipService.isLocalMaster(device.id())) {
return;
}
// Create tunnel out flow rules
applyTunnelOut(device, Objective.Operation.ADD);
// apply L3 arp flows
Iterable<RouterInterface> interfaces = routerInterfaceService
.getRouterInterfaces();
interfaces.forEach(routerInf -> {
VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, routerInf.portId());
}
applyL3ArpFlows(device.id(), gwPort, Objective.Operation.ADD);
});
}
示例2: onOvsVanished
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
@Override
public void onOvsVanished(Device device) {
if (device == null) {
log.error("The device is null");
return;
}
if (!mastershipService.isLocalMaster(device.id())) {
return;
}
// Remove Tunnel out flow rules
applyTunnelOut(device, Objective.Operation.REMOVE);
// apply L3 arp flows
Iterable<RouterInterface> interfaces = routerInterfaceService
.getRouterInterfaces();
interfaces.forEach(routerInf -> {
VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, routerInf.portId());
}
applyL3ArpFlows(device.id(), gwPort, Objective.Operation.REMOVE);
});
}
示例3: getGwIpAndMac
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private List getGwIpAndMac(VirtualPort port) {
List list = new ArrayList();
MacAddress gwMac = null;
SubnetId subnetId = null;
IpAddress gwIp = null;
Iterator<FixedIp> fixips = port.fixedIps().iterator();
if (fixips.hasNext()) {
FixedIp fixip = fixips.next();
subnetId = fixip.subnetId();
gwIp = subnetService.getSubnet(subnetId).gatewayIp();
FixedIp fixedGwIp = FixedIp.fixedIp(fixip.subnetId(), gwIp);
VirtualPort gwPort = virtualPortService.getPort(fixedGwIp);
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, fixedGwIp);
}
gwMac = gwPort.macAddress();
}
list.add(gwIp);
list.add(gwMac);
return list;
}
示例4: getDeviceIdOfFloatingIP
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private DeviceId getDeviceIdOfFloatingIP(FloatingIp floatingIp) {
VirtualPortId vmPortId = floatingIp.portId();
VirtualPort vmPort = virtualPortService.getPort(vmPortId);
if (vmPort == null) {
vmPort = VtnData.getPort(vPortStore, vmPortId);
}
Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
Host host = null;
for (Host h : hostSet) {
String ifaceid = h.annotations().value(IFACEID);
if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
host = h;
break;
}
}
if (host == null) {
return null;
} else {
return host.location().deviceId();
}
}
示例5: programSffAndClassifierHost
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private void programSffAndClassifierHost(Host host, Objective.Operation type) {
DeviceId deviceId = host.location().deviceId();
String ifaceId = host.annotations().value(IFACEID);
VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
VirtualPort virtualPort = virtualPortService.getPort(virtualPortId);
if (virtualPort == null) {
virtualPort = VtnData.getPort(vPortStore, virtualPortId);
}
TenantId tenantId = virtualPort.tenantId();
if (Objective.Operation.ADD == type) {
vtnRscService.addDeviceIdOfOvsMap(virtualPortId, tenantId, deviceId);
} else if (Objective.Operation.REMOVE == type) {
vtnRscService.removeDeviceIdOfOvsMap(host, tenantId, deviceId);
}
}
示例6: onRouterInterfaceVanished
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
@Override
public void onRouterInterfaceVanished(VtnRscEventFeedback l3Feedback) {
Objective.Operation operation = Objective.Operation.REMOVE;
RouterInterface routerInf = l3Feedback.routerInterface();
Iterable<RouterInterface> interfaces = routerInterfaceService
.getRouterInterfaces();
Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces)
.stream().filter(r -> r.tenantId().equals(routerInf.tenantId()))
.collect(Collectors.toSet());
TenantRouter tenantRouter = TenantRouter
.tenantRouter(routerInf.tenantId(), routerInf.routerId());
if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
programRouterInterface(routerInf, operation);
if (interfacesSet.size() == 1) {
routerInfFlagOfTenantRouter.remove(tenantRouter);
interfacesSet.stream().forEach(r -> {
programRouterInterface(r, operation);
});
}
}
VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, routerInf.portId());
}
vPortStore.remove(gwPort.portId());
// apply L3 arp flows
applyL3ArpFlows(null, gwPort, operation);
}
示例7: onRouterInterfaceVanished
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
@Override
public void onRouterInterfaceVanished(VtnRscEventFeedback l3Feedback) {
Objective.Operation operation = Objective.Operation.REMOVE;
RouterInterface routerInf = l3Feedback.routerInterface();
Iterable<RouterInterface> interfaces = routerInterfaceService
.getRouterInterfaces();
Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces)
.stream().filter(r -> r.tenantId().equals(routerInf.tenantId()))
.collect(Collectors.toSet());
TenantRouter tenantRouter = TenantRouter
.tenantRouter(routerInf.tenantId(), routerInf.routerId());
if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
programRouterInterface(routerInf, operation);
if (interfacesSet.size() == 1) {
routerInfFlagOfTenantRouter.remove(tenantRouter);
interfacesSet.forEach(r -> {
programRouterInterface(r, operation);
});
}
}
VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, routerInf.portId());
}
vPortStore.remove(gwPort.portId());
// apply L3 arp flows
applyL3ArpFlows(null, gwPort, operation);
}
示例8: applyTunnelOut
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private void applyTunnelOut(Device device, Objective.Operation type) {
String controllerIp = VtnData.getControllerIpOfSwitch(device);
if (controllerIp == null) {
log.error("Can't find controller of device: {}",
device.id().toString());
return;
}
IpAddress ipAddress = IpAddress.valueOf(controllerIp);
if (!switchesOfController.containsKey(ipAddress)) {
log.error("Can't find controller of device: {}",
device.id().toString());
return;
}
if (type == Objective.Operation.ADD) {
// Save external port
Port export = getExPort(device.id());
if (export != null) {
classifierService.programExportPortArpClassifierRules(export,
device.id(),
type);
exPortOfDevice.put(device.id(), export);
}
switchOfLocalHostPorts.put(device.id(), new NetworkOfLocalHostPorts());
} else if (type == Objective.Operation.REMOVE) {
exPortOfDevice.remove(device.id());
switchOfLocalHostPorts.remove(device.id());
}
Iterable<Device> devices = deviceService.getAvailableDevices();
DeviceId localControllerId = VtnData.getControllerId(device, devices);
DriverHandler handler = driverService.createHandler(localControllerId);
Set<PortNumber> ports = VtnConfig.getPortNumbers(handler);
Iterable<Host> allHosts = hostService.getHosts();
String tunnelName = "vxlan-" + DEFAULT_IP;
if (allHosts != null) {
Sets.newHashSet(allHosts).stream().forEach(host -> {
MacAddress hostMac = host.mac();
String ifaceId = host.annotations().value(IFACEID);
if (ifaceId == null) {
log.error("The ifaceId of Host is null");
return;
}
VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
VirtualPort virtualPort = virtualPortService
.getPort(virtualPortId);
TenantNetwork network = tenantNetworkService
.getNetwork(virtualPort.networkId());
SegmentationId segmentationId = network.segmentationId();
DeviceId remoteDeviceId = host.location().deviceId();
Device remoteDevice = deviceService.getDevice(remoteDeviceId);
String remoteControllerIp = VtnData
.getControllerIpOfSwitch(remoteDevice);
if (remoteControllerIp == null) {
log.error("Can't find remote controller of device: {}",
remoteDeviceId.toString());
return;
}
IpAddress remoteIpAddress = IpAddress
.valueOf(remoteControllerIp);
ports.stream()
.filter(p -> p.name().equalsIgnoreCase(tunnelName))
.forEach(p -> {
l2ForwardService
.programTunnelOut(device.id(), segmentationId, p,
hostMac, type, remoteIpAddress);
});
});
}
}
示例9: programFloatingIpEvent
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private void programFloatingIpEvent(VtnRscEventFeedback l3Feedback,
VtnRscEvent.Type type) {
FloatingIp floaingIp = l3Feedback.floatingIp();
if (floaingIp != null) {
VirtualPortId vmPortId = floaingIp.portId();
VirtualPort vmPort = virtualPortService.getPort(vmPortId);
VirtualPort fipPort = virtualPortService
.getPort(floaingIp.networkId(), floaingIp.floatingIp());
if (vmPort == null) {
vmPort = VtnData.getPort(vPortStore, vmPortId);
}
if (fipPort == null) {
fipPort = VtnData.getPort(vPortStore, floaingIp.networkId(),
floaingIp.floatingIp());
}
Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
Host host = null;
for (Host h : hostSet) {
String ifaceid = h.annotations().value(IFACEID);
if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
host = h;
break;
}
}
if (host != null && vmPort != null && fipPort != null) {
DeviceId deviceId = host.location().deviceId();
Port exPort = exPortOfDevice.get(deviceId);
TenantRouter tenantRouter = TenantRouter
.tenantRouter(floaingIp.tenantId(), floaingIp.routerId());
SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
// Floating ip BIND
if (type == VtnRscEvent.Type.FLOATINGIP_BIND) {
vPortStore.put(fipPort.portId(), fipPort);
applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
vmPort, fipPort, floaingIp, l3vni,
exPort, Objective.Operation.ADD);
} else if (type == VtnRscEvent.Type.FLOATINGIP_UNBIND) {
// Floating ip UNBIND
applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
vmPort, fipPort, floaingIp, l3vni,
exPort,
Objective.Operation.REMOVE);
vPortStore.remove(fipPort.portId());
}
}
}
}
示例10: downloadSnatRules
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private boolean downloadSnatRules(DeviceId deviceId, MacAddress srcMac,
IpAddress srcIp, MacAddress dstMac,
IpAddress dstIp, FloatingIp floatingIp) {
TenantNetwork exNetwork = tenantNetworkService
.getNetwork(floatingIp.networkId());
IpAddress fixedIp = floatingIp.fixedIp();
VirtualPortId vmPortId = floatingIp.portId();
VirtualPort vmPort = virtualPortService.getPort(vmPortId);
if (vmPort == null) {
vmPort = VtnData.getPort(vPortStore, vmPortId);
}
Subnet subnet = getSubnetOfFloatingIP(floatingIp);
IpPrefix ipPrefix = subnet.cidr();
IpAddress gwIp = subnet.gatewayIp();
if (ipPrefix == null) {
return false;
}
int mask = ipPrefix.prefixLength();
if (mask <= 0) {
return false;
}
TenantRouter tenantRouter = TenantRouter
.tenantRouter(floatingIp.tenantId(), floatingIp.routerId());
SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
// if the same ip segment
if (IpUtil.checkSameSegment(srcIp, dstIp, mask)) {
snatService.programSnatSameSegmentRules(deviceId, l3vni, fixedIp,
dstIp, dstMac, srcMac,
srcIp,
exNetwork.segmentationId(),
Objective.Operation.ADD);
if (dstIp.equals(gwIp)) {
snatService
.programSnatDiffSegmentRules(deviceId, l3vni, fixedIp,
dstMac, srcMac, srcIp,
exNetwork.segmentationId(),
Objective.Operation.ADD);
}
}
return true;
}
示例11: applyTunnelOut
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private void applyTunnelOut(Device device, Objective.Operation type) {
String controllerIp = VtnData.getControllerIpOfSwitch(device);
if (controllerIp == null) {
log.error("Can't find controller of device: {}",
device.id().toString());
return;
}
IpAddress ipAddress = IpAddress.valueOf(controllerIp);
if (!switchesOfController.containsKey(ipAddress)) {
log.error("Can't find controller of device: {}",
device.id().toString());
return;
}
if (type == Objective.Operation.ADD) {
// Save external port
Port export = getExPort(device.id());
if (export != null) {
classifierService.programExportPortArpClassifierRules(export,
device.id(),
type);
exPortOfDevice.put(device.id(), export);
}
switchOfLocalHostPorts.put(device.id(), new NetworkOfLocalHostPorts());
} else if (type == Objective.Operation.REMOVE) {
exPortOfDevice.remove(device.id());
switchOfLocalHostPorts.remove(device.id());
}
Iterable<Device> devices = deviceService.getAvailableDevices();
DeviceId localControllerId = VtnData.getControllerId(device, devices);
DriverHandler handler = driverService.createHandler(localControllerId);
Set<PortNumber> ports = VtnConfig.getPortNumbers(handler);
Iterable<Host> allHosts = hostService.getHosts();
String tunnelName = "vxlan-" + DEFAULT_IP;
if (allHosts != null) {
Sets.newHashSet(allHosts).forEach(host -> {
MacAddress hostMac = host.mac();
String ifaceId = host.annotations().value(IFACEID);
if (ifaceId == null) {
log.error("The ifaceId of Host is null");
return;
}
VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
VirtualPort virtualPort = virtualPortService
.getPort(virtualPortId);
TenantNetwork network = tenantNetworkService
.getNetwork(virtualPort.networkId());
SegmentationId segmentationId = network.segmentationId();
DeviceId remoteDeviceId = host.location().deviceId();
Device remoteDevice = deviceService.getDevice(remoteDeviceId);
String remoteControllerIp = VtnData
.getControllerIpOfSwitch(remoteDevice);
if (remoteControllerIp == null) {
log.error("Can't find remote controller of device: {}",
remoteDeviceId.toString());
return;
}
IpAddress remoteIpAddress = IpAddress
.valueOf(remoteControllerIp);
ports.stream()
.filter(p -> p.name().equalsIgnoreCase(tunnelName))
.forEach(p -> {
l2ForwardService
.programTunnelOut(device.id(), segmentationId, p,
hostMac, type, remoteIpAddress);
});
});
}
}
示例12: programFloatingIpEvent
import org.onosproject.vtn.util.VtnData; //导入依赖的package包/类
private void programFloatingIpEvent(VtnRscEventFeedback l3Feedback,
VtnRscEvent.Type type) {
FloatingIp floaingIp = l3Feedback.floatingIp();
if (floaingIp != null) {
VirtualPortId vmPortId = floaingIp.portId();
VirtualPort vmPort = virtualPortService.getPort(vmPortId);
VirtualPort fipPort = virtualPortService
.getPort(floaingIp.networkId(), floaingIp.floatingIp());
if (vmPort == null) {
vmPort = VtnData.getPort(vPortStore, vmPortId);
}
if (fipPort == null) {
fipPort = VtnData.getPort(vPortStore, floaingIp.networkId(),
floaingIp.floatingIp());
}
Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
Host host = null;
for (Host h : hostSet) {
String ifaceid = h.annotations().value(IFACEID);
if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
host = h;
break;
}
}
if (host != null && fipPort != null) {
DeviceId deviceId = host.location().deviceId();
Port exPort = exPortOfDevice.get(deviceId);
TenantRouter tenantRouter = TenantRouter
.tenantRouter(floaingIp.tenantId(), floaingIp.routerId());
SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
// Floating ip BIND
if (type == VtnRscEvent.Type.FLOATINGIP_BIND) {
vPortStore.put(fipPort.portId(), fipPort);
applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
vmPort, fipPort, floaingIp, l3vni,
exPort, Objective.Operation.ADD);
} else if (type == VtnRscEvent.Type.FLOATINGIP_UNBIND) {
// Floating ip UNBIND
applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
vmPort, fipPort, floaingIp, l3vni,
exPort,
Objective.Operation.REMOVE);
vPortStore.remove(fipPort.portId());
}
}
}
}