| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,16 +93,6 @@ | |||
| 93 | 93 | public interface ManagementService { | |
| 94 | 94 | static final String Name = "management-server"; | |
| 95 | 95 | ||
| 96 | - /** | ||
| 97 | - * Retrieves the list of data centers with search criteria. Currently the only search criteria is "available" zones | ||
| 98 | - * for the | ||
| 99 | - * account that invokes the API. By specifying available=true all zones which the account can access. By specifying | ||
| 100 | - * available=false the zones where the account has virtual machine instances will be returned. | ||
| 101 | - * | ||
| 102 | - * @return a list of DataCenters | ||
| 103 | - */ | ||
| 104 | - List<? extends DataCenter> listDataCenters(ListZonesByCmd cmd); | ||
| 105 | - | ||
| 106 | 96 | /** | |
| 107 | 97 | * returns the a map of the names/values in the configuraton table | |
| 108 | 98 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ | |||
| 27 | 27 | import org.apache.cloudstack.api.BaseListCmd; | |
| 28 | 28 | import org.apache.cloudstack.api.Parameter; | |
| 29 | 29 | import org.apache.cloudstack.api.response.ListResponse; | |
| 30 | + import org.apache.cloudstack.api.response.ServiceOfferingResponse; | ||
| 30 | 31 | import org.apache.cloudstack.api.response.ZoneResponse; | |
| 31 | 32 | import com.cloud.dc.DataCenter; | |
| 32 | 33 | ||
@@ -86,16 +87,8 @@ public String getCommandName() { | |||
| 86 | 87 | ||
| 87 | 88 | @Override | |
| 88 | 89 | public void execute(){ | |
| 89 | - List<? extends DataCenter> dataCenters = _mgr.listDataCenters(this); | ||
| 90 | - ListResponse<ZoneResponse> response = new ListResponse<ZoneResponse>(); | ||
| 91 | - List<ZoneResponse> zoneResponses = new ArrayList<ZoneResponse>(); | ||
| 92 | - for (DataCenter dataCenter : dataCenters) { | ||
| 93 | - ZoneResponse zoneResponse = _responseGenerator.createZoneResponse(dataCenter, showCapacities); | ||
| 94 | - zoneResponse.setObjectName("zone"); | ||
| 95 | - zoneResponses.add(zoneResponse); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - response.setResponses(zoneResponses); | ||
| 90 | + | ||
| 91 | + ListResponse<ZoneResponse> response = _queryService.listDataCenters(this); | ||
| 99 | 92 | response.setResponseName(getCommandName()); | |
| 100 | 93 | this.setResponseObject(response); | |
| 101 | 94 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,8 +65,8 @@ public class ZoneResponse extends BaseResponse { | |||
| 65 | 65 | @SerializedName(ApiConstants.DOMAIN) @Param(description="Network domain name for the networks in the zone") | |
| 66 | 66 | private String domain; | |
| 67 | 67 | ||
| 68 | - @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the containing domain, null for public zones") | ||
| 69 | - private Long domainId; | ||
| 68 | + @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the UUID of the containing domain, null for public zones") | ||
| 69 | + private String domainId; | ||
| 70 | 70 | ||
| 71 | 71 | @SerializedName("domainname") @Param(description="the name of the containing domain, null for public zones") | |
| 72 | 72 | private String domainName; | |
@@ -140,7 +140,7 @@ public void setDomain(String domain) { | |||
| 140 | 140 | this.domain = domain; | |
| 141 | 141 | } | |
| 142 | 142 | ||
| 143 | - public void setDomainId(Long domainId) { | ||
| 143 | + public void setDomainId(String domainId) { | ||
| 144 | 144 | this.domainId = domainId; | |
| 145 | 145 | } | |
| 146 | 146 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ | |||
| 35 | 35 | import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; | |
| 36 | 36 | import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd; | |
| 37 | 37 | import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; | |
| 38 | + import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; | ||
| 38 | 39 | import org.apache.cloudstack.api.response.AccountResponse; | |
| 39 | 40 | import org.apache.cloudstack.api.response.AsyncJobResponse; | |
| 40 | 41 | import org.apache.cloudstack.api.response.DiskOfferingResponse; | |
@@ -53,6 +54,7 @@ | |||
| 53 | 54 | import org.apache.cloudstack.api.response.UserResponse; | |
| 54 | 55 | import org.apache.cloudstack.api.response.UserVmResponse; | |
| 55 | 56 | import org.apache.cloudstack.api.response.VolumeResponse; | |
| 57 | + import org.apache.cloudstack.api.response.ZoneResponse; | ||
| 56 | 58 | ||
| 57 | 59 | ||
| 58 | 60 | ||
@@ -100,4 +102,6 @@ public interface QueryService { | |||
| 100 | 102 | public ListResponse<DiskOfferingResponse> searchForDiskOfferings(ListDiskOfferingsCmd cmd); | |
| 101 | 103 | ||
| 102 | 104 | public ListResponse<ServiceOfferingResponse> searchForServiceOfferings(ListServiceOfferingsCmd cmd); | |
| 105 | + | ||
| 106 | + public ListResponse<ZoneResponse> listDataCenters(ListZonesByCmd cmd); | ||
| 103 | 107 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,9 +41,11 @@ | |||
| 41 | 41 | import org.apache.cloudstack.api.response.UserResponse; | |
| 42 | 42 | import org.apache.cloudstack.api.response.UserVmResponse; | |
| 43 | 43 | import org.apache.cloudstack.api.response.VolumeResponse; | |
| 44 | + import org.apache.cloudstack.api.response.ZoneResponse; | ||
| 44 | 45 | ||
| 45 | 46 | import com.cloud.api.query.dao.AccountJoinDao; | |
| 46 | 47 | import com.cloud.api.query.dao.AsyncJobJoinDao; | |
| 48 | + import com.cloud.api.query.dao.DataCenterJoinDao; | ||
| 47 | 49 | import com.cloud.api.query.dao.DiskOfferingJoinDao; | |
| 48 | 50 | import com.cloud.api.query.dao.DomainRouterJoinDao; | |
| 49 | 51 | import com.cloud.api.query.dao.HostJoinDao; | |
@@ -60,6 +62,7 @@ | |||
| 60 | 62 | import com.cloud.api.query.dao.VolumeJoinDao; | |
| 61 | 63 | import com.cloud.api.query.vo.AccountJoinVO; | |
| 62 | 64 | import com.cloud.api.query.vo.AsyncJobJoinVO; | |
| 65 | + import com.cloud.api.query.vo.DataCenterJoinVO; | ||
| 63 | 66 | import com.cloud.api.query.vo.DiskOfferingJoinVO; | |
| 64 | 67 | import com.cloud.api.query.vo.DomainRouterJoinVO; | |
| 65 | 68 | import com.cloud.api.query.vo.EventJoinVO; | |
@@ -88,6 +91,7 @@ | |||
| 88 | 91 | import com.cloud.configuration.dao.ConfigurationDao; | |
| 89 | 92 | import com.cloud.dc.AccountVlanMapVO; | |
| 90 | 93 | import com.cloud.dc.ClusterVO; | |
| 94 | + import com.cloud.dc.DataCenter; | ||
| 91 | 95 | import com.cloud.dc.DataCenterVO; | |
| 92 | 96 | import com.cloud.dc.HostPodVO; | |
| 93 | 97 | import com.cloud.dc.Vlan; | |
@@ -342,6 +346,7 @@ public class ApiDBUtils { | |||
| 342 | 346 | private static AsyncJobJoinDao _jobJoinDao; | |
| 343 | 347 | private static DiskOfferingJoinDao _diskOfferingJoinDao; | |
| 344 | 348 | private static ServiceOfferingJoinDao _srvOfferingJoinDao; | |
| 349 | + private static DataCenterJoinDao _dcJoinDao; | ||
| 345 | 350 | ||
| 346 | 351 | private static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao; | |
| 347 | 352 | private static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao; | |
@@ -448,6 +453,7 @@ public class ApiDBUtils { | |||
| 448 | 453 | _asyncJobDao = locator.getDao(AsyncJobDao.class); | |
| 449 | 454 | _diskOfferingJoinDao = locator.getDao(DiskOfferingJoinDao.class); | |
| 450 | 455 | _srvOfferingJoinDao = locator.getDao(ServiceOfferingJoinDao.class); | |
| 456 | + _dcJoinDao = locator.getDao(DataCenterJoinDao.class); | ||
| 451 | 457 | ||
| 452 | 458 | // Note: stats collector should already have been initialized by this time, otherwise a null instance is returned | |
| 453 | 459 | _statsCollector = StatsCollector.getInstance(); | |
@@ -1426,4 +1432,12 @@ public static ServiceOfferingResponse newServiceOfferingResponse(ServiceOffering | |||
| 1426 | 1432 | public static ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering){ | |
| 1427 | 1433 | return _srvOfferingJoinDao.newServiceOfferingView(offering); | |
| 1428 | 1434 | } | |
| 1435 | + | ||
| 1436 | + public static ZoneResponse newDataCenterResponse(DataCenterJoinVO dc, Boolean showCapacities) { | ||
| 1437 | + return _dcJoinDao.newDataCenterResponse(dc, showCapacities); | ||
| 1438 | + } | ||
| 1439 | + | ||
| 1440 | + public static DataCenterJoinVO newDataCenterView(DataCenter dc){ | ||
| 1441 | + return _dcJoinDao.newDataCenterView(dc); | ||
| 1442 | + } | ||
| 1429 | 1443 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ | |||
| 44 | 44 | import com.cloud.api.query.vo.AccountJoinVO; | |
| 45 | 45 | import com.cloud.api.query.vo.AsyncJobJoinVO; | |
| 46 | 46 | import com.cloud.api.query.vo.ControlledViewEntity; | |
| 47 | + import com.cloud.api.query.vo.DataCenterJoinVO; | ||
| 47 | 48 | import com.cloud.api.query.vo.DiskOfferingJoinVO; | |
| 48 | 49 | import com.cloud.api.query.vo.DomainRouterJoinVO; | |
| 49 | 50 | import com.cloud.api.query.vo.EventJoinVO; | |
@@ -717,77 +718,42 @@ public PodResponse createPodResponse(Pod pod, Boolean showCapacities) { | |||
| 717 | 718 | ||
| 718 | 719 | @Override | |
| 719 | 720 | public ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities) { | |
| 720 | - Account account = UserContext.current().getCaller(); | ||
| 721 | - ZoneResponse zoneResponse = new ZoneResponse(); | ||
| 722 | - zoneResponse.setId(dataCenter.getUuid()); | ||
| 723 | - zoneResponse.setName(dataCenter.getName()); | ||
| 724 | - zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId())); | ||
| 725 | - zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled()); | ||
| 726 | - | ||
| 727 | - if ((dataCenter.getDescription() != null) && !dataCenter.getDescription().equalsIgnoreCase("null")) { | ||
| 728 | - zoneResponse.setDescription(dataCenter.getDescription()); | ||
| 729 | - } | ||
| 730 | - | ||
| 731 | - if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) { | ||
| 732 | - zoneResponse.setDns1(dataCenter.getDns1()); | ||
| 733 | - zoneResponse.setDns2(dataCenter.getDns2()); | ||
| 734 | - zoneResponse.setInternalDns1(dataCenter.getInternalDns1()); | ||
| 735 | - zoneResponse.setInternalDns2(dataCenter.getInternalDns2()); | ||
| 736 | - // FIXME zoneResponse.setVlan(dataCenter.get.getVnet()); | ||
| 737 | - zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr()); | ||
| 738 | - } | ||
| 721 | + DataCenterJoinVO vOffering = ApiDBUtils.newDataCenterView(dataCenter); | ||
| 722 | + return ApiDBUtils.newDataCenterResponse(vOffering, showCapacities); | ||
| 723 | + } | ||
| 739 | 724 | ||
| 740 | - if (showCapacities != null && showCapacities) { | ||
| 741 | - List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(dataCenter.getId(), null, null); | ||
| 742 | - Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>(); | ||
| 743 | - float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor(); | ||
| 725 | + public static List<CapacityResponse> getDataCenterCapacityResponse(Long zoneId){ | ||
| 726 | + List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(zoneId, null, null); | ||
| 727 | + Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>(); | ||
| 728 | + float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor(); | ||
| 744 | 729 | ||
| 745 | - for (SummedCapacity capacity : capacities) { | ||
| 746 | - CapacityResponse capacityResponse = new CapacityResponse(); | ||
| 747 | - capacityResponse.setCapacityType(capacity.getCapacityType()); | ||
| 748 | - capacityResponse.setCapacityUsed(capacity.getUsedCapacity()); | ||
| 749 | - if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) { | ||
| 750 | - capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor))); | ||
| 751 | - } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) { | ||
| 752 | - List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(dataCenter.getId(), null, null); | ||
| 753 | - capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity()); | ||
| 754 | - capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity()); | ||
| 755 | - } else { | ||
| 756 | - capacityResponse.setCapacityTotal(capacity.getTotalCapacity()); | ||
| 757 | - } | ||
| 758 | - if (capacityResponse.getCapacityTotal() != 0) { | ||
| 759 | - capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f)); | ||
| 760 | - } else { | ||
| 761 | - capacityResponse.setPercentUsed(s_percentFormat.format(0L)); | ||
| 762 | - } | ||
| 763 | - capacityResponses.add(capacityResponse); | ||
| 730 | + for (SummedCapacity capacity : capacities) { | ||
| 731 | + CapacityResponse capacityResponse = new CapacityResponse(); | ||
| 732 | + capacityResponse.setCapacityType(capacity.getCapacityType()); | ||
| 733 | + capacityResponse.setCapacityUsed(capacity.getUsedCapacity()); | ||
| 734 | + if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) { | ||
| 735 | + capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor))); | ||
| 736 | + } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) { | ||
| 737 | + List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(zoneId, null, null); | ||
| 738 | + capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity()); | ||
| 739 | + capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity()); | ||
| 740 | + } else { | ||
| 741 | + capacityResponse.setCapacityTotal(capacity.getTotalCapacity()); | ||
| 764 | 742 | } | |
| 765 | - // Do it for stats as well. | ||
| 766 | - capacityResponses.addAll(getStatsCapacityresponse(null, null, null, dataCenter.getId())); | ||
| 767 | - | ||
| 768 | - zoneResponse.setCapacitites(new ArrayList<CapacityResponse>(capacityResponses)); | ||
| 769 | - } | ||
| 770 | - | ||
| 771 | - // set network domain info | ||
| 772 | - zoneResponse.setDomain(dataCenter.getDomain()); | ||
| 773 | - | ||
| 774 | - // set domain info | ||
| 775 | - Long domainId = dataCenter.getDomainId(); | ||
| 776 | - if (domainId != null) { | ||
| 777 | - Domain domain = ApiDBUtils.findDomainById(domainId); | ||
| 778 | - zoneResponse.setDomainId(domain.getId()); | ||
| 779 | - zoneResponse.setDomainName(domain.getName()); | ||
| 743 | + if (capacityResponse.getCapacityTotal() != 0) { | ||
| 744 | + capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f)); | ||
| 745 | + } else { | ||
| 746 | + capacityResponse.setPercentUsed(s_percentFormat.format(0L)); | ||
| 747 | + } | ||
| 748 | + capacityResponses.add(capacityResponse); | ||
| 780 | 749 | } | |
| 750 | + // Do it for stats as well. | ||
| 751 | + capacityResponses.addAll(getStatsCapacityresponse(null, null, null, zoneId)); | ||
| 781 | 752 | ||
| 782 | - zoneResponse.setType(dataCenter.getNetworkType().toString()); | ||
| 783 | - zoneResponse.setAllocationState(dataCenter.getAllocationState().toString()); | ||
| 784 | - zoneResponse.setZoneToken(dataCenter.getZoneToken()); | ||
| 785 | - zoneResponse.setDhcpProvider(dataCenter.getDhcpProvider()); | ||
| 786 | - zoneResponse.setObjectName("zone"); | ||
| 787 | - return zoneResponse; | ||
| 753 | + return new ArrayList<CapacityResponse>(capacityResponses); | ||
| 788 | 754 | } | |
| 789 | 755 | ||
| 790 | - private List<CapacityResponse> getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId) { | ||
| 756 | + private static List<CapacityResponse> getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId) { | ||
| 791 | 757 | List<CapacityVO> capacities = new ArrayList<CapacityVO>(); | |
| 792 | 758 | capacities.add(ApiDBUtils.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId)); | |
| 793 | 759 | if (clusterId == null && podId == null) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,7 @@ | |||
| 61 | 61 | import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; | |
| 62 | 62 | import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd; | |
| 63 | 63 | import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; | |
| 64 | + import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; | ||
| 64 | 65 | import org.apache.commons.codec.binary.Base64; | |
| 65 | 66 | import org.apache.http.client.utils.URLEncodedUtils; | |
| 66 | 67 | import org.apache.http.ConnectionClosedException; | |
@@ -518,6 +519,7 @@ private String queueCommand(BaseCmd cmdObj, Map<String, String> params) throws E | |||
| 518 | 519 | && !(cmdObj instanceof ListStoragePoolsCmd) | |
| 519 | 520 | && !(cmdObj instanceof ListDiskOfferingsCmd) | |
| 520 | 521 | && !(cmdObj instanceof ListServiceOfferingsCmd) | |
| 522 | + && !(cmdObj instanceof ListZonesByCmd) | ||
| 521 | 523 | ) { | |
| 522 | 524 | buildAsyncListResponse((BaseListCmd) cmdObj, caller); | |
| 523 | 525 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments