From 65a083b1db2ef361f7bfc8ff5c99ed6079613d8e Mon Sep 17 00:00:00 2001 From: alena Date: Mon, 28 Mar 2011 16:47:27 -0700 Subject: [PATCH] bug 8831: no need for "isdedicatedtodomain" and "dedicateddomainid" parameters. If 1) network is private, return account/domainId 2)If network is shared for specific domain, return domainId only 3) If network is shared in zone, don't return account/domainId status 8831: resolved fixed --- .../cloud/api/response/NetworkResponse.java | 22 ------------------- .../src/com/cloud/api/ApiResponseHelper.java | 11 +++++----- .../com/cloud/network/NetworkManagerImpl.java | 5 +++++ 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/api/src/com/cloud/api/response/NetworkResponse.java b/api/src/com/cloud/api/response/NetworkResponse.java index a716ded1afb..a18fdabedd9 100644 --- a/api/src/com/cloud/api/response/NetworkResponse.java +++ b/api/src/com/cloud/api/response/NetworkResponse.java @@ -97,12 +97,6 @@ public class NetworkResponse extends BaseResponse{ @SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is enabled, false otherwise") private Boolean isSecurityGroupEnabled; - - @SerializedName("isdedicatedtodomain") @Param(description="true if network is dedicated to specific domain") - private Boolean isDedicatedToDomain; - - @SerializedName("dedicateddomainid") @Param(description="the id of domain network dedicated to") - private Long dedicatedDomainId; public Long getId() { return id; @@ -343,21 +337,5 @@ public class NetworkResponse extends BaseResponse{ public void setIsSecurityGroupEnabled(Boolean sgEnabled) { this.isSecurityGroupEnabled = sgEnabled; } - - public Boolean getIsDedicatedToDomain() { - return isDedicatedToDomain; - } - - public void setIsDedicatedToDomain(Boolean isDedicatedToDomain) { - this.isDedicatedToDomain = isDedicatedToDomain; - } - - public Long getDedicatedDomainId() { - return dedicatedDomainId; - } - - public void setDedicatedDomainId(Long dedicatedDomainId) { - this.dedicatedDomainId = dedicatedDomainId; - } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 9e88ecdc436..637e4096790 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2350,7 +2350,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setServices(serviceResponses); Account account = ApiDBUtils.findAccountById(network.getAccountId()); - if (account != null) { + if (account != null && !network.getIsShared()) { response.setAccountName(account.getAccountName()); Domain domain = ApiDBUtils.findDomainById(account.getDomainId()); response.setDomainId(domain.getId()); @@ -2359,11 +2359,10 @@ public class ApiResponseHelper implements ResponseGenerator { Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId()); if (dedicatedDomainId != null) { - response.setIsDedicatedToDomain(true); - response.setDedicatedDomainId(dedicatedDomainId); - } else { - response.setIsDedicatedToDomain(false); - } + Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId); + response.setDomainId(dedicatedDomainId); + response.setDomain(domain.getName()); + } response.setObjectName("network"); return response; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 8a86a2aa2b8..7ac676bc754 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1608,6 +1608,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } + //if network is shared, defult its owner to be system + if (isShared) { + owner = _accountMgr.getSystemAccount(); + } + // Don't allow to create network with vlan that already exists in the system if (vlanId != null) { String uri = "vlan://" + vlanId;