本文整理汇总了Java中com.cloud.dc.HostPodVO.getCidrSize方法的典型用法代码示例。如果您正苦于以下问题:Java HostPodVO.getCidrSize方法的具体用法?Java HostPodVO.getCidrSize怎么用?Java HostPodVO.getCidrSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloud.dc.HostPodVO
的用法示例。
在下文中一共展示了HostPodVO.getCidrSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCIDR
import com.cloud.dc.HostPodVO; //导入方法依赖的package包/类
private boolean checkCIDR(final HostPodVO pod, final String serverPrivateIP, final String serverPrivateNetmask) {
if (serverPrivateIP == null) {
return true;
}
// Get the CIDR address and CIDR size
final String cidrAddress = pod.getCidrAddress();
final long cidrSize = pod.getCidrSize();
// If the server's private IP address is not in the same subnet as the
// pod's CIDR, return false
final String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSize);
final String serverSubnet = NetUtils.getSubNet(serverPrivateIP, serverPrivateNetmask);
if (!cidrSubnet.equals(serverSubnet)) {
return false;
}
// If the server's private netmask is less inclusive than the pod's CIDR
// netmask, return false
final String cidrNetmask = NetUtils.getCidrSubNet("255.255.255.255", cidrSize);
final long cidrNetmaskNumeric = NetUtils.ip2Long(cidrNetmask);
final long serverNetmaskNumeric = NetUtils.ip2Long(serverPrivateNetmask);
return serverNetmaskNumeric <= cidrNetmaskNumeric;
}
示例2: checkCIDR
import com.cloud.dc.HostPodVO; //导入方法依赖的package包/类
private boolean checkCIDR(final HostPodVO pod, final String serverPrivateIP, final String serverPrivateNetmask) {
if (serverPrivateIP == null) {
return true;
}
// Get the CIDR address and CIDR size
final String cidrAddress = pod.getCidrAddress();
final long cidrSize = pod.getCidrSize();
// If the server's private IP address is not in the same subnet as the
// pod's CIDR, return false
final String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSize);
final String serverSubnet = NetUtils.getSubNet(serverPrivateIP, serverPrivateNetmask);
if (!cidrSubnet.equals(serverSubnet)) {
return false;
}
// If the server's private netmask is less inclusive than the pod's CIDR
// netmask, return false
final String cidrNetmask = NetUtils.getCidrSubNet("255.255.255.255", cidrSize);
final long cidrNetmaskNumeric = NetUtils.ip2Long(cidrNetmask);
final long serverNetmaskNumeric = NetUtils.ip2Long(serverPrivateNetmask);
if (serverNetmaskNumeric > cidrNetmaskNumeric) {
return false;
}
return true;
}
示例3: checkCIDR
import com.cloud.dc.HostPodVO; //导入方法依赖的package包/类
private boolean checkCIDR(Host.Type type, HostPodVO pod, String serverPrivateIP, String serverPrivateNetmask) {
if (serverPrivateIP == null) {
return true;
}
// Get the CIDR address and CIDR size
String cidrAddress = pod.getCidrAddress();
long cidrSize = pod.getCidrSize();
// If the server's private IP address is not in the same subnet as the
// pod's CIDR, return false
String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSize);
String serverSubnet = NetUtils.getSubNet(serverPrivateIP, serverPrivateNetmask);
if (!cidrSubnet.equals(serverSubnet)) {
return false;
}
return true;
}
示例4: updatePodNetmaskIfNeeded
import com.cloud.dc.HostPodVO; //导入方法依赖的package包/类
private void updatePodNetmaskIfNeeded(HostPodVO pod, String agentNetmask) {
// If the server's private netmask is less inclusive than the pod's CIDR
// netmask, update cidrSize of the default POD
//(reason: we are maintaining pods only for internal accounting.)
long cidrSize = pod.getCidrSize();
String cidrNetmask = NetUtils.getCidrSubNet("255.255.255.255", cidrSize);
long cidrNetmaskNumeric = NetUtils.ip2Long(cidrNetmask);
long serverNetmaskNumeric = NetUtils.ip2Long(agentNetmask);//
if (serverNetmaskNumeric > cidrNetmaskNumeric) {
//update pod's cidrsize
int newCidrSize = new Long(NetUtils.getCidrSize(agentNetmask)).intValue();
pod.setCidrSize(newCidrSize);
_podDao.update(pod.getId(), pod);
}
}