當前位置: 首頁>>代碼示例>>Java>>正文


Java Pod.getDescription方法代碼示例

本文整理匯總了Java中com.cloud.dc.Pod.getDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java Pod.getDescription方法的具體用法?Java Pod.getDescription怎麽用?Java Pod.getDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cloud.dc.Pod的用法示例。


在下文中一共展示了Pod.getDescription方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createPodResponse

import com.cloud.dc.Pod; //導入方法依賴的package包/類
@Override
public PodResponse createPodResponse(final Pod pod, final Boolean showCapacities) {
    String[] ipRange = new String[2];
    if (pod.getDescription() != null && pod.getDescription().length() > 0) {
        ipRange = pod.getDescription().split("-");
    } else {
        ipRange[0] = pod.getDescription();
    }

    final PodResponse podResponse = new PodResponse();
    podResponse.setId(pod.getUuid());
    podResponse.setName(pod.getName());
    final DataCenter zone = ApiDBUtils.findZoneById(pod.getDataCenterId());
    if (zone != null) {
        podResponse.setZoneId(zone.getUuid());
        podResponse.setZoneName(zone.getName());
    }
    podResponse.setNetmask(NetUtils.getCidrNetmask(pod.getCidrSize()));
    podResponse.setStartIp(ipRange[0]);
    podResponse.setEndIp(ipRange.length > 1 && ipRange[1] != null ? ipRange[1] : "");
    podResponse.setGateway(pod.getGateway());
    podResponse.setAllocationState(pod.getAllocationState().toString());
    if (showCapacities != null && showCapacities) {
        final List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, pod.getId(), null);
        final Set<CapacityResponse> capacityResponses = new HashSet<>();
        for (final SummedCapacity capacity : capacities) {
            final CapacityResponse capacityResponse = new CapacityResponse();
            capacityResponse.setCapacityType(capacity.getCapacityType());
            capacityResponse.setCapacityUsed(capacity.getUsedCapacity() + capacity.getReservedCapacity());
            if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
                final List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
                capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
                capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
            } else {
                capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
            }
            if (capacityResponse.getCapacityTotal() != 0) {
                capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
            } else {
                capacityResponse.setPercentUsed(s_percentFormat.format(0L));
            }
            capacityResponses.add(capacityResponse);
        }
        // Do it for stats as well.
        capacityResponses.addAll(getStatsCapacityresponse(null, null, pod.getId(), pod.getDataCenterId()));
        podResponse.setCapacitites(new ArrayList<>(capacityResponses));
    }
    podResponse.setObjectName("pod");
    return podResponse;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:51,代碼來源:ApiResponseHelper.java

示例2: createPodResponse

import com.cloud.dc.Pod; //導入方法依賴的package包/類
@Override
public PodResponse createPodResponse(Pod pod, Boolean showCapacities) {
    String[] ipRange = new String[2];
    List<String> startIp = new ArrayList<String>();
    List<String> endIp = new ArrayList<String>();
    List<String> forSystemVms = new ArrayList<String>();
    List<String> vlanIds = new ArrayList<String>();

    if (pod.getDescription() != null && pod.getDescription().length() > 0) {
        final String[] existingPodIpRanges = pod.getDescription().split(",");

        for(String podIpRange: existingPodIpRanges) {
            final String[] existingPodIpRange = podIpRange.split("-");

            startIp.add(((existingPodIpRange.length > 0) && (existingPodIpRange[0] != null)) ? existingPodIpRange[0] : "");
            endIp.add(((existingPodIpRange.length > 1) && (existingPodIpRange[1] != null)) ? existingPodIpRange[1] : "");
            forSystemVms.add((existingPodIpRange.length > 2) && (existingPodIpRange[2] != null) ? existingPodIpRange[2] : "0");
            vlanIds.add((existingPodIpRange.length > 3) &&
                    (existingPodIpRange[3] != null && !existingPodIpRange.equals("untagged")) ?
                    BroadcastDomainType.Vlan.toUri(existingPodIpRange[3]).toString() :
                    BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString());
        }
    }

    PodResponse podResponse = new PodResponse();
    podResponse.setId(pod.getUuid());
    podResponse.setName(pod.getName());
    DataCenter zone = ApiDBUtils.findZoneById(pod.getDataCenterId());
    if (zone != null) {
        podResponse.setZoneId(zone.getUuid());
        podResponse.setZoneName(zone.getName());
    }
    podResponse.setNetmask(NetUtils.getCidrNetmask(pod.getCidrSize()));
    podResponse.setStartIp(startIp);
    podResponse.setEndIp(endIp);
    podResponse.setForSystemVms(forSystemVms);
    podResponse.setVlanId(vlanIds);
    podResponse.setGateway(pod.getGateway());
    podResponse.setAllocationState(pod.getAllocationState().toString());
    if (showCapacities != null && showCapacities) {
        List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, pod.getId(), null);
        Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
        for (SummedCapacity capacity : capacities) {
            CapacityResponse capacityResponse = new CapacityResponse();
            capacityResponse.setCapacityType(capacity.getCapacityType());
            capacityResponse.setCapacityName(CapacityVO.getCapacityName(capacity.getCapacityType()));
            capacityResponse.setCapacityUsed(capacity.getUsedCapacity() + capacity.getReservedCapacity());
            if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
                List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
                capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
                capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
            } else {
                capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
            }
            if (capacityResponse.getCapacityTotal() != 0) {
                capacityResponse.setPercentUsed(s_percentFormat.format((float)capacityResponse.getCapacityUsed() / (float)capacityResponse.getCapacityTotal() * 100f));
            } else {
                capacityResponse.setPercentUsed(s_percentFormat.format(0L));
            }
            capacityResponses.add(capacityResponse);
        }
        // Do it for stats as well.
        capacityResponses.addAll(getStatsCapacityresponse(null, null, pod.getId(), pod.getDataCenterId()));
        podResponse.setCapacitites(new ArrayList<CapacityResponse>(capacityResponses));
    }
    podResponse.setObjectName("pod");
    return podResponse;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:69,代碼來源:ApiResponseHelper.java


注:本文中的com.cloud.dc.Pod.getDescription方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。