cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/5] git commit: updated refs/heads/master to 7cb4b57
Date Tue, 04 Feb 2014 23:52:45 GMT
Updated Branches:
  refs/heads/master 929099518 -> 7cb4b571c


External UUID control support for VPC and NetworkACLItemp


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

Branch: refs/heads/master
Commit: 8065ee445f3c5fd18cdfe1659eaad09f380d804d
Parents: 7cd0ad3
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Feb 4 14:43:50 2014 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Feb 4 15:47:12 2014 -0800

----------------------------------------------------------------------
 .../com/cloud/network/vpc/NetworkACLService.java    |  3 ++-
 api/src/com/cloud/network/vpc/VpcService.java       |  3 ++-
 .../user/network/UpdateNetworkACLItemCmd.java       | 16 +++++++++++-----
 .../api/command/user/vpc/UpdateVPCCmd.java          | 15 +++++++++++----
 .../com/cloud/network/vpc/NetworkACLManager.java    |  3 ++-
 .../src/com/cloud/network/vpc/NetworkACLItemVO.java |  4 ++++
 engine/schema/src/com/cloud/network/vpc/VpcVO.java  |  5 +++++
 .../cloud/network/vpc/NetworkACLManagerImpl.java    |  9 ++++++---
 .../cloud/network/vpc/NetworkACLServiceImpl.java    | 15 +++++++--------
 .../src/com/cloud/network/vpc/VpcManagerImpl.java   |  9 ++++++---
 .../test/com/cloud/vpc/NetworkACLManagerTest.java   |  9 ++++-----
 11 files changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/api/src/com/cloud/network/vpc/NetworkACLService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/NetworkACLService.java b/api/src/com/cloud/network/vpc/NetworkACLService.java
index 4d11880..dff718d 100644
--- a/api/src/com/cloud/network/vpc/NetworkACLService.java
+++ b/api/src/com/cloud/network/vpc/NetworkACLService.java
@@ -114,11 +114,12 @@ public interface NetworkACLService {
      * @param sourcePortEnd
      * @param icmpCode
      * @param icmpType
+     * @param newUUID TODO
      * @return
      * @throws ResourceUnavailableException
      */
     NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourceCidrList,
NetworkACLItem.TrafficType trafficType, String action, Integer number,
-        Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType)
throws ResourceUnavailableException;
+        Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType,
String newUUID) throws ResourceUnavailableException;
 
     /**
      * Associates ACL with specified Network

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index e28f351..218e675 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -66,9 +66,10 @@ public interface VpcService {
      * @param vpcId
      * @param vpcName
      * @param displayText
+     * @param customId TODO
      * @return
      */
-    public Vpc updateVpc(long vpcId, String vpcName, String displayText);
+    public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId);
 
     /**
      * Lists VPC(s) based on the parameters passed to the method call

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
index 1e559c2..accad84 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
@@ -18,16 +18,15 @@ package org.apache.cloudstack.api.command.user.network;
 
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 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.BaseAsyncCustomIdCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceUnavailableException;
@@ -35,7 +34,7 @@ import com.cloud.network.vpc.NetworkACLItem;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified
Id", responseObject = NetworkACLItemResponse.class)
-public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
+public class UpdateNetworkACLItemCmd extends BaseAsyncCustomIdCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLItemCmd.class.getName());
 
     private static final String s_name = "createnetworkaclresponse";
@@ -165,7 +164,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
         CallContext.current().setEventDetails("Rule Id: " + getId());
         NetworkACLItem aclItem =
             _networkACLService.updateNetworkACLItem(getId(), getProtocol(), getSourceCidrList(),
getTrafficType(), getAction(), getNumber(), getSourcePortStart(),
-                getSourcePortEnd(), getIcmpCode(), getIcmpType());
+                getSourcePortEnd(), getIcmpCode(), getIcmpType(), this.getCustomId());
         if (aclItem == null) {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network
ACL Item");
         }
@@ -174,4 +173,11 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
         aclResponse.setResponseName(getCommandName());
     }
 
+    @Override
+    public void checkUuid(String id, Class<?> cls) {
+        if (this.getCustomId() != null) {
+            _uuidMgr.checkUuid(this.getCustomId(), NetworkACLItem.class);
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java
index 5732c65..60dae31 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java
@@ -16,22 +16,22 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpc;
 
-import org.apache.log4j.Logger;
-
 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.BaseAsyncCustomIdCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateVPC", description = "Updates a VPC", responseObject = VpcResponse.class)
-public class UpdateVPCCmd extends BaseAsyncCmd {
+public class UpdateVPCCmd extends BaseAsyncCustomIdCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateVPCCmd.class.getName());
     private static final String Name = "updatevpcresponse";
 
@@ -84,7 +84,7 @@ public class UpdateVPCCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() {
-        Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText());
+        Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), this.getCustomId());
         if (result != null) {
             VpcResponse response = _responseGenerator.createVpcResponse(result);
             response.setResponseName(getCommandName());
@@ -113,4 +113,11 @@ public class UpdateVPCCmd extends BaseAsyncCmd {
     public Long getSyncObjId() {
         return getId();
     }
+
+    @Override
+    public void checkUuid(String id, Class<?> cls) {
+        if (this.getCustomId() != null) {
+            _uuidMgr.checkUuid(this.getCustomId(), Vpc.class);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java
index 06952fc..dee8c4a 100644
--- a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java
+++ b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java
@@ -130,11 +130,12 @@ public interface NetworkACLManager {
      * @param sourcePortEnd
      * @param icmpCode
      * @param icmpType
+     * @param customId TODO
      * @return
      * @throws ResourceUnavailableException
      */
     NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourceCidrList,
NetworkACLItem.TrafficType trafficType, String action, Integer number,
-        Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType)
throws ResourceUnavailableException;
+        Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType,
String customId) throws ResourceUnavailableException;
 
     /**
      * Associates acl with a network and applies the ACLItems

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java
index f45b8c4..7cd0946 100644
--- a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java
@@ -241,4 +241,8 @@ public class NetworkACLItemVO implements NetworkACLItem {
     public void setAction(Action action) {
         this.action = action;
     }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/engine/schema/src/com/cloud/network/vpc/VpcVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
index 23bcf93..5f3528d 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
@@ -31,6 +31,7 @@ import com.cloud.utils.db.GenericDao;
 @Entity
 @Table(name = "vpc")
 public class VpcVO implements Vpc {
+
     @Id
     @Column(name = "id")
     long id;
@@ -177,4 +178,8 @@ public class VpcVO implements Vpc {
     public boolean isRestartRequired() {
         return restartRequired;
     }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index 979d407..82360f5 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -22,9 +22,8 @@ import java.util.List;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.event.ActionEvent;
@@ -399,7 +398,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
 
     @Override
     public NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String>
sourceCidrList, NetworkACLItem.TrafficType trafficType, String action,
-        Integer number, Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode,
Integer icmpType) throws ResourceUnavailableException {
+        Integer number, Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode,
Integer icmpType, String customId) throws ResourceUnavailableException {
         NetworkACLItemVO aclItem = _networkACLItemDao.findById(id);
         aclItem.setState(State.Add);
 
@@ -443,6 +442,10 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
             aclItem.setIcmpType(icmpType);
         }
 
+        if (customId != null) {
+            aclItem.setUuid(customId);
+        }
+
         if (_networkACLItemDao.update(id, aclItem)) {
             if (applyNetworkACL(aclItem.getAclId())) {
                 return aclItem;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
index e5a59ff..a9d2b1d 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
@@ -23,17 +23,15 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import com.cloud.network.vpc.dao.VpcDao;
-import org.apache.cloudstack.api.command.user.network.ListNetworkACLListsCmd;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
+import org.apache.cloudstack.api.command.user.network.ListNetworkACLListsCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
@@ -43,6 +41,7 @@ import com.cloud.network.Networks;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.vpc.dao.NetworkACLDao;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.network.vpc.dao.VpcGatewayDao;
 import com.cloud.projects.Project.ListProjectResourcesCriteria;
 import com.cloud.server.ResourceTag.ResourceObjectType;
@@ -606,7 +605,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
     @Override
     public NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String>
sourceCidrList, NetworkACLItem.TrafficType trafficType, String action,
-        Integer number, Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode,
Integer icmpType) throws ResourceUnavailableException {
+        Integer number, Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode,
Integer icmpType, String newUUID) throws ResourceUnavailableException {
         NetworkACLItemVO aclItem = _networkACLItemDao.findById(id);
         if (aclItem == null) {
             throw new InvalidParameterValueException("Unable to find ACL Item cannot be found");
@@ -635,7 +634,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
         validateNetworkACLItem((sourcePortStart == null) ? aclItem.getSourcePortStart() :
sourcePortStart, (sourcePortEnd == null) ? aclItem.getSourcePortEnd()
             : sourcePortEnd, sourceCidrList, protocol, icmpCode, (icmpType == null) ? aclItem.getIcmpType()
: icmpType, action, number);
 
-        return _networkAclMgr.updateNetworkACLItem(id, protocol, sourceCidrList, trafficType,
action, number, sourcePortStart, sourcePortEnd, icmpCode, icmpType);
+        return _networkAclMgr.updateNetworkACLItem(id, protocol, sourceCidrList, trafficType,
action, number, sourcePortStart, sourcePortEnd, icmpCode, icmpType, newUUID);
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 909e464..11d8c7a 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -32,8 +32,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
 import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
@@ -42,6 +40,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
@@ -770,7 +769,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc")
-    public Vpc updateVpc(long vpcId, String vpcName, String displayText) {
+    public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId)
{
         CallContext.current().setEventDetails(" Id: " + vpcId);
         Account caller = CallContext.current().getCallingAccount();
 
@@ -792,6 +791,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
             vpc.setDisplayText(displayText);
         }
 
+        if (customId != null) {
+            vpc.setUuid(customId);
+        }
+
         if (_vpcDao.update(vpcId, vpc)) {
             s_logger.debug("Updated VPC id=" + vpcId);
             return _vpcDao.findById(vpcId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8065ee44/server/test/com/cloud/vpc/NetworkACLManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/NetworkACLManagerTest.java b/server/test/com/cloud/vpc/NetworkACLManagerTest.java
index 629afa3..edf183e 100644
--- a/server/test/com/cloud/vpc/NetworkACLManagerTest.java
+++ b/server/test/com/cloud/vpc/NetworkACLManagerTest.java
@@ -24,6 +24,9 @@ import javax.inject.Inject;
 
 import junit.framework.TestCase;
 
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.test.utils.SpringUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,10 +44,6 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.support.AnnotationConfigContextLoader;
 
-import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
-import org.apache.cloudstack.test.utils.SpringUtils;
-
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.network.Network;
 import com.cloud.network.NetworkModel;
@@ -228,7 +227,7 @@ public class NetworkACLManagerTest extends TestCase {
     public void testUpdateACLItem() throws Exception {
         Mockito.when(_networkACLItemDao.findById(Matchers.anyLong())).thenReturn(aclItem);
         Mockito.when(_networkACLItemDao.update(Matchers.anyLong(), Matchers.any(NetworkACLItemVO.class))).thenReturn(true);
-        assertNotNull(_aclMgr.updateNetworkACLItem(1L, "UDP", null, NetworkACLItem.TrafficType.Ingress,
"Deny", 10, 22, 32, null, null));
+        assertNotNull(_aclMgr.updateNetworkACLItem(1L, "UDP", null, NetworkACLItem.TrafficType.Ingress,
"Deny", 10, 22, 32, null, null, null));
     }
 
     @Test(expected = CloudRuntimeException.class)


Mime
View raw message