cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [3/4] git commit: updated refs/heads/master-6-17-stable to ff33a35
Date Wed, 26 Jun 2013 22:34:51 GMT
CLOUDSTACK-3169: ipAssoc - set account id of the ip to the project account. Used to be set
to the network owner which is System in Shared network case, and the further verification
used to fail because of that


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/728145f3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/728145f3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/728145f3

Branch: refs/heads/master-6-17-stable
Commit: 728145f3b142b85bfe464d2069237cae99e0b25b
Parents: 44e6595
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Jun 24 15:25:05 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Wed Jun 26 15:27:51 2013 -0700

----------------------------------------------------------------------
 .../user/address/AssociateIPAddrCmd.java        | 47 +++++++++++++++++---
 1 file changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/728145f3/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
index b99ca63..c97a5e4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
@@ -16,21 +16,42 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.address;
 
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.IPAddressResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.RegionResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
 import com.cloud.async.AsyncJob;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.event.EventTypes;
-import com.cloud.exception.*;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.vpc.Vpc;
+import com.cloud.projects.Project;
 import com.cloud.user.Account;
 import com.cloud.user.UserContext;
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.*;
-import org.apache.log4j.Logger;
-
-import java.util.List;
 
 @APICommand(name = "associateIpAddress", description="Acquires and associates a public IP
to an account.", responseObject=IPAddressResponse.class)
 public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@@ -175,7 +196,19 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
         if (accountName != null && domainId != null) {
             Account account = _accountService.finalizeOwner(caller, accountName, domainId,
projectId);
             return account.getId();
-        } else if (networkId != null){
+        } else if (projectId != null) {
+            Project project = _projectService.getProject(projectId);
+            if (project != null) {
+                if (project.getState() == Project.State.Active) {
+                    return project.getProjectAccountId();
+                } else {
+                    throw new PermissionDeniedException("Can't add resources to the project
with specified projectId in state="
+                           + project.getState() + " as it's no longer active");
+                }
+            } else {
+                throw new InvalidParameterValueException("Unable to find project by id");
+            }
+       } else if (networkId != null){
             Network network = _networkService.getNetwork(networkId);
             return network.getAccountId();
         } else if (vpcId != null) {


Mime
View raw message