本文整理匯總了Java中org.onosproject.vtnrsc.VirtualPort類的典型用法代碼示例。如果您正苦於以下問題:Java VirtualPort類的具體用法?Java VirtualPort怎麽用?Java VirtualPort使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VirtualPort類屬於org.onosproject.vtnrsc包,在下文中一共展示了VirtualPort類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onOvsDetected
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的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.vtnrsc.VirtualPort; //導入依賴的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: onRouterInterfaceDetected
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
public void onRouterInterfaceDetected(VtnRscEventFeedback l3Feedback) {
Objective.Operation operation = Objective.Operation.ADD;
RouterInterface routerInf = l3Feedback.routerInterface();
VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
vPortStore.put(gwPort.portId(), gwPort);
Iterable<RouterInterface> interfaces = routerInterfaceService
.getRouterInterfaces();
Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces).stream()
.filter(r -> r.tenantId().equals(routerInf.tenantId()))
.filter(r -> r.routerId().equals(routerInf.routerId()))
.collect(Collectors.toSet());
TenantRouter tenantRouter = TenantRouter
.tenantRouter(routerInf.tenantId(), routerInf.routerId());
if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
programRouterInterface(routerInf, operation);
} else {
if (interfacesSet.size() >= SUBNET_NUM) {
programInterfacesSet(interfacesSet, operation);
}
}
// apply L3 arp flows
applyL3ArpFlows(null, gwPort, operation);
}
示例4: sendNorthSouthL3Flows
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
private void sendNorthSouthL3Flows(DeviceId deviceId, FloatingIp floatingIp,
IpAddress dstVmGwIp,
MacAddress dstVmGwMac,
SegmentationId l3vni,
TenantNetwork vmNetwork,
VirtualPort vmPort, Host host,
Objective.Operation operation) {
l3ForwardService
.programRouteRules(deviceId, l3vni, floatingIp.fixedIp(),
vmNetwork.segmentationId(), dstVmGwMac,
vmPort.macAddress(), operation);
classifierService.programL3InPortClassifierRules(deviceId,
host.location().port(),
host.mac(), dstVmGwMac,
l3vni, operation);
classifierService.programArpClassifierRules(deviceId, host.location()
.port(), dstVmGwIp, vmNetwork.segmentationId(), operation);
}
示例5: getGwIpAndMac
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的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;
}
示例6: getDeviceIdOfFloatingIP
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的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();
}
}
示例7: getPort
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
/**
* Get VirtualPort.
*
* @param vPortStore EventuallyConsistentMap of VirtualPort
* @param fixedIP FixedIp of the VirtualPort
* @return VirtualPort
*/
public static VirtualPort getPort(EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore,
FixedIp fixedIP) {
if (vPortStore != null) {
List<VirtualPort> vPorts = new ArrayList<>();
vPortStore.values().stream().forEach(p -> {
Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
while (fixedIps.hasNext()) {
if (fixedIps.next().equals(fixedIP)) {
vPorts.add(p);
break;
}
}
});
if (vPorts.size() == 0) {
return null;
}
return vPorts.get(0);
}
return null;
}
示例8: modifyHostDetails
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
pp.title(MY_HOST_TITLE);
pp.removeAllProps();
PortPairService portPairService = AbstractShellCommand.get(PortPairService.class);
VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class);
HostService hostService = AbstractShellCommand.get(HostService.class);
Iterable<PortPair> portPairs = portPairService.getPortPairs();
for (PortPair portPair : portPairs) {
VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
MacAddress dstMacAddress = vPort.macAddress();
Host host = hostService.getHost(HostId.hostId(dstMacAddress));
if (hostId.toString().equals(host.id().toString())) {
pp.addProp("SF Name", portPair.name());
pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip());
}
}
pp.addProp("SF host Address", hostId.toString());
}
示例9: getGatewayMac
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
public MacAddress getGatewayMac(HostId hostId) {
checkNotNull(hostId, "hostId cannot be null");
Host host = hostService.getHost(hostId);
String ifaceId = host.annotations().value(IFACEID);
VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
VirtualPort hPort = virtualPortService.getPort(hPortId);
SubnetId subnetId = hPort.fixedIps().iterator().next().subnetId();
Subnet subnet = subnetService.getSubnet(subnetId);
IpAddress gatewayIp = subnet.gatewayIp();
Iterable<VirtualPort> virtualPorts = virtualPortService.getPorts();
MacAddress macAddress = null;
for (VirtualPort port : virtualPorts) {
Set<FixedIp> fixedIpSet = port.fixedIps();
for (FixedIp fixedIp : fixedIpSet) {
if (fixedIp.ip().equals(gatewayIp)) {
macAddress = port.macAddress();
}
}
}
return macAddress;
}
示例10: getPort
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
public VirtualPort getPort(FixedIp fixedIP) {
checkNotNull(fixedIP, FIXEDIP_NOT_NULL);
List<VirtualPort> vPorts = new ArrayList<>();
vPortStore.values().stream().forEach(p -> {
Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
while (fixedIps.hasNext()) {
if (fixedIps.next().equals(fixedIP)) {
vPorts.add(p);
break;
}
}
});
if (vPorts.size() == 0) {
return null;
}
return vPorts.get(0);
}
示例11: updatePorts
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
public boolean updatePorts(Iterable<VirtualPort> vPorts) {
checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
for (VirtualPort vPort : vPorts) {
vPortStore.put(vPort.portId(), vPort);
if (!vPortStore.containsKey(vPort.portId())) {
log.debug("The virtualPort is not exist whose identifier is {}",
vPort.portId().toString());
return false;
}
vPortStore.put(vPort.portId(), vPort);
if (!vPort.equals(vPortStore.get(vPort.portId()))) {
log.debug("The virtualPort is updated failed whose identifier is {}",
vPort.portId().toString());
return false;
}
}
return true;
}
示例12: createExGwPort
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
private void createExGwPort(TenantNetwork network, Subnet subnet, FixedIp fixedGwIp) {
VirtualPortService service = get(VirtualPortService.class);
Map<String, String> strMap = Maps.newHashMap();
VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId("externalgateway-update-id"),
network.id(),
false, strMap,
VirtualPort.State.DOWN,
MacAddress.valueOf(macAddress),
subnet.tenantId(),
DeviceId.deviceId(""),
Sets.newHashSet(fixedGwIp),
BindingHostId.bindingHostId(""),
Sets.newHashSet(),
Sets.newHashSet());
Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
service.createPorts(virtualPorts);
}
示例13: updateExGwPort
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
private void updateExGwPort(VirtualPort exgwPort) {
VirtualPortService service = get(VirtualPortService.class);
Map<String, String> strMap = Maps.newHashMap();
strMap.putIfAbsent("name", exgwPort.name());
strMap.putIfAbsent("deviceOwner", exgwPort.deviceOwner());
strMap.putIfAbsent("bindingvnicType", exgwPort.bindingVnicType());
strMap.putIfAbsent("bindingvifType", exgwPort.bindingVifType());
strMap.putIfAbsent("bindingvnicDetails", exgwPort.bindingVifDetails());
VirtualPort virtualPort = new DefaultVirtualPort(exgwPort.portId(),
exgwPort.networkId(),
false, strMap,
VirtualPort.State.DOWN,
MacAddress.valueOf(macAddress),
exgwPort.tenantId(),
exgwPort.deviceId(),
exgwPort.fixedIps(),
exgwPort.bindingHostId(),
Sets.newHashSet(exgwPort
.allowedAddressPairs()),
Sets.newHashSet(exgwPort
.securityGroups()));
Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
service.updatePorts(virtualPorts);
}
示例14: execute
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
protected void execute() {
Map<String, String> strMap = Maps.newHashMap();
strMap.putIfAbsent("name", name);
strMap.putIfAbsent("deviceOwner", deviceOwner);
strMap.putIfAbsent("bindingvnicType", bindingvnicType);
strMap.putIfAbsent("bindingvifType", bindingvifType);
strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
VirtualPortService service = get(VirtualPortService.class);
VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
TenantNetworkId.networkId(networkId),
false, strMap, VirtualPort.State.ACTIVE,
MacAddress.valueOf(macAddress),
TenantId.tenantId(tenantId),
DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
BindingHostId.bindingHostId(bindingHostId),
allowedAddressPairs, securityGroups);
Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
service.createPorts(virtualPorts);
}
示例15: execute
import org.onosproject.vtnrsc.VirtualPort; //導入依賴的package包/類
@Override
protected void execute() {
VirtualPortService service = get(VirtualPortService.class);
Map<String, String> strMap = Maps.newHashMap();
strMap.putIfAbsent("name", name);
strMap.putIfAbsent("deviceOwner", deviceOwner);
strMap.putIfAbsent("bindingvnicType", bindingvnicType);
strMap.putIfAbsent("bindingvifType", bindingvifType);
strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
TenantNetworkId.networkId(networkId),
false, strMap, VirtualPort.State.ACTIVE,
MacAddress.valueOf(macAddress),
TenantId.tenantId(tenantId),
DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
BindingHostId.bindingHostId(bindingHostId),
allowedAddressPairs, securityGroups);
Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
service.updatePorts(virtualPorts);
}