本文整理汇总了Java中org.onosproject.vtnrsc.FixedIp.fixedIp方法的典型用法代码示例。如果您正苦于以下问题:Java FixedIp.fixedIp方法的具体用法?Java FixedIp.fixedIp怎么用?Java FixedIp.fixedIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.vtnrsc.FixedIp
的用法示例。
在下文中一共展示了FixedIp.fixedIp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGwIpAndMac
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的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;
}
示例2: execute
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的package包/类
@Override
protected void execute() {
VirtualPortService service = get(VirtualPortService.class);
SubnetService subnetService = get(SubnetService.class);
TenantNetworkService tenantNetworkService = get(TenantNetworkService.class);
Iterable<TenantNetwork> networks = tenantNetworkService.getNetworks();
if (networks != null) {
for (TenantNetwork network : networks) {
if (network.routerExternal()) {
Iterable<Subnet> subnets = subnetService.getSubnets();
if (subnets != null) {
for (Subnet subnet : subnets) {
if (network.id().networkId().equals(subnet.networkId().networkId())) {
IpAddress exgwip = subnet.gatewayIp();
FixedIp fixedGwIp = FixedIp.fixedIp(subnet.id(), exgwip);
VirtualPort exgwPort = service.getPort(fixedGwIp);
if (exgwPort == null) {
createExGwPort(network, subnet, fixedGwIp);
} else {
updateExGwPort(exgwPort);
}
}
}
}
}
}
}
}
示例3: jsonNodeToFixedIp
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的package包/类
/**
* Changes JsonNode fixedIp to a collection of the fixedIp.
*
* @param fixedIp the allocationPools JsonNode
* @return a collection of fixedIp
*/
private Iterable<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) {
checkNotNull(fixedIp, JSON_NOT_NULL);
ConcurrentMap<Integer, FixedIp> fixedIpMaps = Maps.newConcurrentMap();
Integer i = 0;
for (JsonNode node : fixedIp) {
if (!node.hasNonNull("subnet_id")) {
throw new IllegalArgumentException("subnet_id should not be null");
} else if (node.get("subnet_id").asText().isEmpty()) {
throw new IllegalArgumentException("subnet_id should not be empty");
}
SubnetId subnetId = SubnetId
.subnetId(node.get("subnet_id").asText());
if (!node.hasNonNull("ip_address")) {
throw new IllegalArgumentException("ip_address should not be null");
} else if (node.get("ip_address").asText().isEmpty()) {
throw new IllegalArgumentException("ip_address should not be empty");
}
IpAddress ipAddress = IpAddress
.valueOf(node.get("ip_address").asText());
FixedIp fixedIpObj = FixedIp.fixedIp(subnetId, ipAddress);
fixedIpMaps.putIfAbsent(i, fixedIpObj);
i++;
}
return Collections.unmodifiableCollection(fixedIpMaps.values());
}
示例4: jsonNodeToFixedIps
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的package包/类
/**
* Returns a collection of fixedIps.
*
* @param fixedIpNode the fixedIp jsonnode
* @return a collection of SecurityGroup
*/
public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
.asText());
IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
.asText());
FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
return fixedIps;
}
示例5: createVirtualPort
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的package包/类
private VirtualPort createVirtualPort(VirtualPortId id) {
Set<FixedIp> fixedIps;
Map<String, String> propertyMap;
Set<AllowedAddressPair> allowedAddressPairs;
Set<SecurityGroup> securityGroups = Sets.newHashSet();
String macAddressStr = "fa:12:3e:56:ee:a2";
String ipAddress = "10.1.1.1";
String subnet = "1212";
String hostIdStr = "fa:e2:3e:56:ee:a2";
String deviceOwner = "james";
propertyMap = Maps.newHashMap();
propertyMap.putIfAbsent("deviceOwner", deviceOwner);
TenantNetworkId networkId = TenantNetworkId.networkId(networkIdStr);
MacAddress macAddress = MacAddress.valueOf(macAddressStr);
BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr);
FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet),
IpAddress.valueOf(ipAddress));
fixedIps = Sets.newHashSet();
fixedIps.add(fixedIp);
allowedAddressPairs = Sets.newHashSet();
AllowedAddressPair allowedAddressPair = AllowedAddressPair
.allowedAddressPair(IpAddress.valueOf(ipAddress),
MacAddress.valueOf(macAddressStr));
allowedAddressPairs.add(allowedAddressPair);
VirtualPort d1 = new DefaultVirtualPort(id, networkId, true,
propertyMap,
VirtualPort.State.ACTIVE,
macAddress, tenantId, deviceId,
fixedIps, bindingHostId,
allowedAddressPairs,
securityGroups);
return d1;
}
示例6: changeJsonToSub
import org.onosproject.vtnrsc.FixedIp; //导入方法依赖的package包/类
/**
* Returns a collection of vpnPort from subnetNodes.
*
* @param vpnPortNodes the vpnPort json node
* @return list of vpnports
*/
private Collection<VpnPort> changeJsonToSub(JsonNode vpnPortNodes) {
checkNotNull(vpnPortNodes, JSON_NOT_NULL);
Map<VpnPortId, VpnPort> vpnPortMap = new HashMap<>();
String interfaceId = vpnPortNodes.get(INTERFACE_ID).asText();
VpnPortId vpnPortId = VpnPortId.vpnPortId(interfaceId);
VpnInstanceId vpnInstanceId = VpnInstanceId
.vpnInstanceId(vpnPortNodes.get(VPN_INSTANCE).asText());
VpnPort vpnPort = new DefaultVpnPort(vpnPortId, vpnInstanceId);
vpnPortMap.put(vpnPortId, vpnPort);
// update ip address and tenant network information in vtn
TenantNetworkId tenantNetworkId = null;
Map<VirtualPortId, VirtualPort> vPortMap = new HashMap<>();
BasePortId basePortId = BasePortId.portId(interfaceId);
VirtualPortId virtualPortId = VirtualPortId.portId(interfaceId);
BasePort bPort = basePortService.getPort(basePortId);
if (bPort != null) {
FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(basePortId.toString()),
IpAddress.valueOf(vpnPortNodes
.get("ipaddress").asText()));
Set<FixedIp> fixedIps = new HashSet<>();
fixedIps.add(fixedIp);
Map<String, String> strMap = new HashMap<>();
boolean adminStateUp = bPort.adminStateUp();
strMap.put("name", bPort.name());
strMap.put("deviceOwner", bPort.deviceOwner());
strMap.put("bindingVnicType", bPort.bindingVnicType());
strMap.put("bindingVifType", bPort.bindingVifType());
strMap.put("bindingVifDetails", bPort.bindingVifDetails());
String state = bPort.state();
MacAddress macAddress = bPort.macAddress();
TenantId tenantId = bPort.tenantId();
DeviceId deviceId = bPort.deviceId();
BindingHostId bindingHostId = bPort.bindingHostId();
// Creates Dummy Gluon Network and Subnet
createDummyGluonNetwork(adminStateUp, state, tenantId);
createDummySubnet(tenantId);
Iterable<TenantNetwork> networks
= tenantNetworkService.getNetworks();
for (TenantNetwork tenantNetwork : networks) {
if (tenantNetwork.name().equals("GluonNetwork")) {
tenantNetworkId = tenantNetwork.id();
break;
}
}
if (tenantNetworkId != null) {
DefaultVirtualPort vPort = new DefaultVirtualPort(virtualPortId,
tenantNetworkId,
adminStateUp,
strMap, isState(state),
macAddress, tenantId,
deviceId, fixedIps,
bindingHostId,
null,
null);
vPortMap.put(virtualPortId, vPort);
Collection<VirtualPort> virtualPorts
= Collections.unmodifiableCollection(vPortMap.values());
virtualPortService.createPorts(virtualPorts);
}
}
return Collections.unmodifiableCollection(vpnPortMap.values());
}