cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [01/54] [abbrv] Merge branch 'master' into rbac.
Date Fri, 14 Mar 2014 10:37:14 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/distributedrouter a8d43ba4b -> 42b553e30 (forced update)


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index c8cc5b3,208b4a4..e07e502
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@@ -447,9 -454,9 +456,10 @@@ public class AutoScaleManagerImpl<Type
          String otherDeployParams = cmd.getOtherDeployParams();
          Long serviceOffId = cmd.getServiceOfferingId();
          Long zoneId = cmd.getZoneId();
+         Boolean display = cmd.getDisplay();
  
 -        SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId());
 +        SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId(),
 +                "listAutoScaleVmProfiles");
          SearchBuilder<AutoScaleVmProfileVO> sb = searchWrapper.getSearchBuilder();
  
          sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
@@@ -859,9 -870,9 +879,10 @@@
          Long loadBalancerId = cmd.getLoadBalancerId();
          Long profileId = cmd.getProfileId();
          Long zoneId = cmd.getZoneId();
+         Boolean forDisplay = cmd.getDisplay();
  
 -        SearchWrapper<AutoScaleVmGroupVO> searchWrapper = new SearchWrapper<AutoScaleVmGroupVO>(_autoScaleVmGroupDao, AutoScaleVmGroupVO.class, cmd, cmd.getId());
 +        SearchWrapper<AutoScaleVmGroupVO> searchWrapper = new SearchWrapper<AutoScaleVmGroupVO>(_autoScaleVmGroupDao, AutoScaleVmGroupVO.class, cmd, cmd.getId(),
 +                "listAutoScaleVmGroups");
          SearchBuilder<AutoScaleVmGroupVO> sb = searchWrapper.getSearchBuilder();
  
          sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index b5374e7d,ca474d6..c312d3d
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@@ -232,19 -233,22 +233,22 @@@ public class FirewallManagerImpl extend
                  FirewallRuleVO newRule =
                      new FirewallRuleVO(xId, ipAddrId, portStart, portEnd, protocol.toLowerCase(), networkId, accountIdFinal, domainIdFinal, Purpose.Firewall,
                          sourceCidrList, icmpCode, icmpType, relatedRuleId, trafficType);
 -                newRule.setType(type);
 +        newRule.setType(type);
+                 if (forDisplay != null) {
+                     newRule.setDisplay(forDisplay);
+                 }
 -                newRule = _firewallDao.persist(newRule);
 +        newRule = _firewallDao.persist(newRule);
  
 -                if (type == FirewallRuleType.User)
 -                    detectRulesConflict(newRule);
 +        if (type == FirewallRuleType.User)
 +            detectRulesConflict(newRule);
  
 -                if (!_firewallDao.setStateToAdd(newRule)) {
 -                    throw new CloudRuntimeException("Unable to update the state to add for " + newRule);
 -                }
 -                CallContext.current().setEventDetails("Rule Id: " + newRule.getId());
 +        if (!_firewallDao.setStateToAdd(newRule)) {
 +            throw new CloudRuntimeException("Unable to update the state to add for " + newRule);
 +        }
 +        CallContext.current().setEventDetails("Rule Id: " + newRule.getId());
  
 -                return newRule;
 -            }
 +        return newRule;
 +    }
          });
      }
  
@@@ -255,11 -259,10 +259,12 @@@
          Long networkId = cmd.getNetworkId();
          Map<String, String> tags = cmd.getTags();
          FirewallRule.TrafficType trafficType = cmd.getTrafficType();
+         Boolean display = cmd.getDisplay();
  
          Account caller = CallContext.current().getCallingAccount();
 +        List<Long> permittedDomains = new ArrayList<Long>();
          List<Long> permittedAccounts = new ArrayList<Long>();
 +        List<Long> permittedResources = new ArrayList<Long>();
  
          if (ipId != null) {
              IPAddressVO ipAddressVO = _ipAddressDao.findById(ipId);
@@@ -280,9 -285,10 +285,10 @@@
  
          sb.and("id", sb.entity().getId(), Op.EQ);
          sb.and("trafficType", sb.entity().getTrafficType(), Op.EQ);
 -        sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
 +            sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
          sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
          sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
+         sb.and("display", sb.entity().isDisplay(), Op.EQ);
  
          if (tags != null && !tags.isEmpty()) {
              SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index e08b76c,6f0c1e9..9f280ef
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@@ -1498,8 -1497,9 +1497,9 @@@ public class LoadBalancingRulesManagerI
      @DB
      @Override
      public LoadBalancer createPublicLoadBalancer(final String xId, final String name, final String description, final int srcPort, final int destPort,
-         final long sourceIpId, final String protocol, final String algorithm, final boolean openFirewall, final CallContext caller, final String lbProtocol)
+  final long sourceIpId,
+             final String protocol, final String algorithm, final boolean openFirewall, final CallContext caller, final String lbProtocol, final Boolean forDisplay)
 -        throws NetworkRuleConflictException {
 +            throws NetworkRuleConflictException {
  
          if (!NetUtils.isValidPort(destPort)) {
              throw new InvalidParameterValueException("privatePort is an invalid value: " + destPort);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/rules/RulesManagerImpl.java
index 4a75d40,ad977a2..9a76219
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@@ -201,8 -201,8 +201,8 @@@ public class RulesManagerImpl extends M
      @Override
      @DB
      @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_ADD, eventDescription = "creating forwarding rule", create = true)
-     public PortForwardingRule createPortForwardingRule(final PortForwardingRule rule, final Long vmId, Ip vmIp, final boolean openFirewall)
+     public PortForwardingRule createPortForwardingRule(final PortForwardingRule rule, final Long vmId, Ip vmIp, final boolean openFirewall, final Boolean forDisplay)
 -        throws NetworkRuleConflictException {
 +            throws NetworkRuleConflictException {
          CallContext ctx = CallContext.current();
          final Account caller = ctx.getCallingAccount();
  
@@@ -775,11 -779,10 +779,12 @@@
          Long id = cmd.getId();
          Map<String, String> tags = cmd.getTags();
          Long networkId = cmd.getNetworkId();
+         Boolean display = cmd.getDisplay();
  
          Account caller = CallContext.current().getCallingAccount();
 +        List<Long> permittedDomains = new ArrayList<Long>();
          List<Long> permittedAccounts = new ArrayList<Long>();
 +        List<Long> permittedResources = new ArrayList<Long>();
  
          if (ipId != null) {
              IPAddressVO ipAddressVO = _ipAddressDao.findById(ipId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 39fb19e,403b95e..08381e2
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@@ -658,13 -658,16 +658,16 @@@ public class VpcManagerImpl extends Man
              @Override
              public VpcVO doInTransaction(TransactionStatus status) {
                  VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr, networkDomain);
+                 if (displayVpc != null) {
+                     vpc.setDisplay(displayVpc);
+                 }
 -                vpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(zoneId, vpcOffId));
 -                _resourceLimitMgr.incrementResourceCount(vpcOwner.getId(), ResourceType.vpc);
 +        vpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(zoneId, vpcOffId));
 +        _resourceLimitMgr.incrementResourceCount(vpcOwner.getId(), ResourceType.vpc);
  
 -                s_logger.debug("Created VPC " + vpc);
 +        s_logger.debug("Created VPC " + vpc);
  
 -                return vpc;
 -            }
 +        return vpc;
 +    }
          });
      }
  
@@@ -806,16 -813,14 +813,16 @@@
      @Override
      public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
          String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
-         Map<String, String> tags, Long projectId) {
+         Map<String, String> tags, Long projectId, Boolean display) {
          Account caller = CallContext.current().getCallingAccount();
 +        List<Long> permittedDomains = new ArrayList<Long>();
          List<Long> permittedAccounts = new ArrayList<Long>();
 +        List<Long> permittedResources = new ArrayList<Long>();
  
 -        Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
 -            new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
 -        _accountMgr.buildACLSearchParameters(caller, id, accountName, projectId, permittedAccounts, domainIdRecursiveListProject, listAll, false);
 -        domainId = domainIdRecursiveListProject.first();
 +        Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
 +                ListProjectResourcesCriteria>(domainId, isRecursive, null);
 +        _accountMgr.buildACLSearchParameters(caller, id, accountName, projectId, permittedDomains, permittedAccounts, permittedResources, domainIdRecursiveListProject, listAll,
 +                false, "listVPCs");
          isRecursive = domainIdRecursiveListProject.second();
          ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
          Filter searchFilter = new Filter(VpcVO.class, "created", false, startIndex, pageSizeVal);
@@@ -871,8 -877,12 +879,12 @@@
                  sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key));
                  count++;
              }
 -        }
 +       }
  
+         if (display != null) {
+             sc.setParameters("display", display);
+         }
+ 
          if (id != null) {
              sc.addAnd("id", SearchCriteria.Op.EQ, id);
          }
@@@ -1401,37 -1411,38 +1413,38 @@@
                          s_logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri);
                          DataCenterVO dc = _dcDao.lockRow(physNetFinal.getDataCenterId(), true);
  
 -                        //add entry to private_ip_address table
 -                        PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNtwk.getId(), ipAddress);
 -                        if (privateIp != null) {
 +            //add entry to private_ip_address table
 +            PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNtwk.getId(), ipAddress);
 +            if (privateIp != null) {
                              throw new InvalidParameterValueException("Private ip address " + ipAddress + " already used for private gateway" + " in zone " +
                                  _entityMgr.findById(DataCenter.class, dcId).getName());
 -                        }
 +            }
  
 -                        Long mac = dc.getMacAddress();
 -                        Long nextMac = mac + 1;
 -                        dc.setMacAddress(nextMac);
 +            Long mac = dc.getMacAddress();
 +            Long nextMac = mac + 1;
 +            dc.setMacAddress(nextMac);
  
-             privateIp = new PrivateIpVO(ipAddress, privateNtwk.getId(), nextMac, vpcId, true);
+                         s_logger.info("creating private ip adress for vpc (" + ipAddress + ", " + privateNtwk.getId() + ", " + nextMac + ", " + vpcId + ", " + isSourceNat + ")");
+                         privateIp = new PrivateIpVO(ipAddress, privateNtwk.getId(), nextMac, vpcId, isSourceNat);
 -                        _privateIpDao.persist(privateIp);
 +            _privateIpDao.persist(privateIp);
  
 -                        _dcDao.update(dc.getId(), dc);
 -                    }
 +            _dcDao.update(dc.getId(), dc);
 +        }
  
 -                    long networkAclId = NetworkACL.DEFAULT_DENY;
 -                    if (aclId != null) {
 -                        NetworkACLVO aclVO = _networkAclDao.findById(aclId);
 +        long networkAclId = NetworkACL.DEFAULT_DENY;
 +        if (aclId != null) {
 +            NetworkACLVO aclVO = _networkAclDao.findById(aclId);
                          if (aclVO == null) {
 -                            throw new InvalidParameterValueException("Invalid network acl id passed ");
 -                        }
 -                        if ((aclVO.getVpcId() != vpcId) && !(aclId == NetworkACL.DEFAULT_DENY || aclId == NetworkACL.DEFAULT_ALLOW)) {
 -                            throw new InvalidParameterValueException("Private gateway and network acl are not in the same vpc");
 -                        }
 +                throw new InvalidParameterValueException("Invalid network acl id passed ");
 +            }
 +            if ((aclVO.getVpcId() != vpcId) && !(aclId == NetworkACL.DEFAULT_DENY || aclId == NetworkACL.DEFAULT_ALLOW)) {
 +                throw new InvalidParameterValueException("Private gateway and network acl are not in the same vpc");
 +            }
  
 -                        networkAclId = aclId;
 -                    }
 +            networkAclId = aclId;
 +        }
  
 -                    //2) create gateway entry
 +        //2) create gateway entry
                      VpcGatewayVO gatewayVO =
                          new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(), privateNtwk.getId(), broadcastUri, gateway, netmask,
                              vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId);
@@@ -2022,14 -2028,15 +2035,15 @@@
          Transaction.execute(new TransactionCallbackNoReturn() {
              @Override
              public void doInTransactionWithoutResult(TransactionStatus status) {
 -                IPAddressVO ip = _ipAddressDao.findById(ipId);
 -                //update ip address with networkId
 -                ip.setVpcId(vpcId);
 +        IPAddressVO ip = _ipAddressDao.findById(ipId);
 +        //update ip address with networkId
 +        ip.setVpcId(vpcId);
                  ip.setSourceNat(isSourceNatFinal);
+ 
 -                _ipAddressDao.update(ipId, ip);
 +        _ipAddressDao.update(ipId, ip);
  
 -                //mark ip as allocated
 -                _ipAddrMgr.markPublicIpAsAllocated(ip);
 +        //mark ip as allocated
 +        _ipAddrMgr.markPublicIpAsAllocated(ip);
              }
          });
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index a8505a7,0306fad..531adad
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@@ -650,9 -649,10 +654,10 @@@ public class RemoteAccessVpnManagerImp
          sb.and("id", sb.entity().getId(), Op.EQ);
          sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
          sb.and("state", sb.entity().getState(), Op.EQ);
+         sb.and("display", sb.entity().isDisplay(), Op.EQ);
  
          SearchCriteria<RemoteAccessVpnVO> sc = sb.create();
 -        _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
 +        _accountMgr.buildACLSearchCriteria(sc, isRecursive, permittedDomains, permittedAccounts, permittedResources, listProjectResourcesCriteria);
  
          sc.setParameters("state", RemoteAccessVpn.State.Running);
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index 03a13c3,66a2b58..fdb5bbf
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@@ -632,9 -636,10 +642,10 @@@ public class Site2SiteVpnManagerImpl ex
  
          sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
          sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
+         sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
  
          SearchCriteria<Site2SiteVpnGatewayVO> sc = sb.create();
 -        _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
 +        _accountMgr.buildACLSearchCriteria(sc, isRecursive, permittedDomains, permittedAccounts, permittedResources, listProjectResourcesCriteria);
  
          if (id != null) {
              sc.addAnd("id", SearchCriteria.Op.EQ, id);
@@@ -675,9 -682,10 +691,10 @@@
          Filter searchFilter = new Filter(Site2SiteVpnConnectionVO.class, "id", false, startIndex, pageSizeVal);
  
          SearchBuilder<Site2SiteVpnConnectionVO> sb = _vpnConnectionDao.createSearchBuilder();
 -        _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
 +        _accountMgr.buildACLSearchBuilder(sb, isRecursive, permittedDomains, permittedAccounts, permittedResources, listProjectResourcesCriteria);
  
          sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+         sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
  
          if (vpcId != null) {
              SearchBuilder<Site2SiteVpnGatewayVO> gwSearch = _vpnGatewayDao.createSearchBuilder();
@@@ -686,8 -694,11 +703,11 @@@
          }
  
          SearchCriteria<Site2SiteVpnConnectionVO> sc = sb.create();
 -        _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
 +        _accountMgr.buildACLSearchCriteria(sc, isRecursive, permittedDomains, permittedAccounts, permittedResources, listProjectResourcesCriteria);
  
+         if (display != null) {
+             sc.setParameters("display", display);
+         }
          if (id != null) {
              sc.addAnd("id", SearchCriteria.Op.EQ, id);
          }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/VolumeApiServiceImpl.java
index ad8a4ba,50aa87e..3ef8e13
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@@ -563,43 -564,43 +564,43 @@@ public class VolumeApiServiceImpl exten
          return Transaction.execute(new TransactionCallback<VolumeVO>() {
              @Override
              public VolumeVO doInTransaction(TransactionStatus status) {
 -                VolumeVO volume = new VolumeVO(userSpecifiedName, -1, -1, -1, -1, new Long(-1), null, null, 0, Volume.Type.DATADISK);
 -                volume.setPoolId(null);
 +        VolumeVO volume = new VolumeVO(userSpecifiedName, -1, -1, -1, -1, new Long(-1), null, null, 0, Volume.Type.DATADISK);
 +        volume.setPoolId(null);
                  volume.setUuid(uuid);
 -                volume.setDataCenterId(zoneId);
 -                volume.setPodId(null);
 -                volume.setAccountId(ownerId);
 -                volume.setDomainId(((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId()));
 -                volume.setDiskOfferingId(diskOfferingId);
 -                volume.setSize(size);
 -                volume.setMinIops(minIops);
 -                volume.setMaxIops(maxIops);
 -                volume.setInstanceId(null);
 -                volume.setUpdated(new Date());
 -                volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId());
 +        volume.setDataCenterId(zoneId);
 +        volume.setPodId(null);
 +        volume.setAccountId(ownerId);
 +        volume.setDomainId(((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId()));
 +        volume.setDiskOfferingId(diskOfferingId);
 +        volume.setSize(size);
 +        volume.setMinIops(minIops);
 +        volume.setMaxIops(maxIops);
 +        volume.setInstanceId(null);
 +        volume.setUpdated(new Date());
 +        volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId());
-         volume.setDisplayVolume(displayVolumeEnabled);
+                 volume.setDisplayVolume(displayVolume);
 -                if (parentVolume != null) {
 -                    volume.setTemplateId(parentVolume.getTemplateId());
 -                    volume.setFormat(parentVolume.getFormat());
 -                } else {
 -                    volume.setTemplateId(null);
 -                }
 +        if (parentVolume != null) {
 +            volume.setTemplateId(parentVolume.getTemplateId());
 +            volume.setFormat(parentVolume.getFormat());
 +        } else {
 +            volume.setTemplateId(null);
 +        }
  
 -                volume = _volsDao.persist(volume);
 -                if (cmd.getSnapshotId() == null) {
 -                    // for volume created from snapshot, create usage event after volume creation
 +        volume = _volsDao.persist(volume);
 +        if (cmd.getSnapshotId() == null) {
 +            // for volume created from snapshot, create usage event after volume creation
                      UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
                              diskOfferingId, null, size, Volume.class.getName(), volume.getUuid());
 -                }
 +        }
  
 -                CallContext.current().setEventDetails("Volume Id: " + volume.getId());
 +        CallContext.current().setEventDetails("Volume Id: " + volume.getId());
  
 -                // Increment resource count during allocation; if actual creation fails,
 -                // decrement it
 +        // Increment resource count during allocation; if actual creation fails,
 +        // decrement it
-                 _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume, displayVolumeEnabled);
-                 _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, displayVolumeEnabled, new Long(volume.getSize()));
+                 _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume, displayVolume);
+                 _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, displayVolume, new Long(volume.getSize()));
 -                return volume;
 -            }
 +        return volume;
 +    }
          });
      }
  
@@@ -2124,30 -2138,34 +2138,34 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkAttachVolume.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkAttachVolume.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 +                // save work context info (there are some duplications)
-                 VmWorkAttachVolume workInfo = new VmWorkAttachVolume(callingUser.getId(), callingAccount.getId(), vm.getId(), VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId,
-                         deviceId);
+                     VmWorkAttachVolume workInfo = new VmWorkAttachVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
+                             VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, deviceId);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    AsyncJobVO jobVo = _jobMgr.getAsyncJob(workJob.getId());
 -                    s_logger.debug("New job " + workJob.getId() + ", result field: " + jobVo.getResult());
 +                AsyncJobVO jobVo = _jobMgr.getAsyncJob(workJob.getId());
 +                s_logger.debug("New job " + workJob.getId() + ", result field: " + jobVo.getResult());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -2171,26 -2189,31 +2189,31 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkDetachVolume.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkDetachVolume.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 +                // save work context info (there are some duplications)
-                 VmWorkDetachVolume workInfo = new VmWorkDetachVolume(callingUser.getId(), callingAccount.getId(), vm.getId(), VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId);
+                     VmWorkDetachVolume workInfo = new VmWorkDetachVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
+                             VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -2215,27 -2238,32 +2238,32 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+ 
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkResizeVolume.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkResizeVolume.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkResizeVolume workInfo = new VmWorkResizeVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, currentSize, newSize, newServiceOfferingId, shrinkOk);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkResizeVolume workInfo = new VmWorkResizeVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, currentSize, newSize, newServiceOfferingId, shrinkOk);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -2260,27 -2288,31 +2288,31 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkMigrateVolume.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkMigrateVolume.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, destPoolId, liveMigrate);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, destPoolId, liveMigrate);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -2305,28 -2337,32 +2337,32 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkTakeVolumeSnapshot.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkTakeVolumeSnapshot.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkTakeVolumeSnapshot workInfo = new VmWorkTakeVolumeSnapshot(
 -                            callingUser.getId(), accountId != null ? accountId : callingAccount.getId(), vm.getId(),
 -                            VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, policyId, snapshotId, quiesceVm);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkTakeVolumeSnapshot workInfo = new VmWorkTakeVolumeSnapshot(
 +                        callingUser.getId(), accountId != null ? accountId : callingAccount.getId(), vm.getId(),
 +                        VolumeApiServiceImpl.VM_WORK_JOB_HANDLER, volumeId, policyId, snapshotId, quiesceVm);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/template/TemplateManagerImpl.java
index f27fb74,7466670..34123cd
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@@ -1744,17 -1753,12 +1778,12 @@@ public class TemplateManagerImpl extend
              throw ex;
          }
  
-         // Don't allow to modify system template
-         if (id == Long.valueOf(1)) {
-             InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
-             ex.addProxyObject(String.valueOf(id), "templateId");
-             throw ex;
-         }
+         verifyTemplateId(id);
  
          // do a permission check
 -        _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
 +        _accountMgr.checkAccess(account, AccessType.OperateEntry, true, template);
          if (cmd.isRoutingType() != null) {
 -            if (!_accountService.isRootAdmin(account.getType())) {
 +            if (!_accountService.isRootAdmin(account.getId())) {
                  throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
              }
          }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/vm/UserVmManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/vm/UserVmManagerImpl.java
index 2957bac,9874dc3..ca734c2
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@@ -34,6 -35,6 +35,9 @@@ import javax.ejb.Local
  import javax.inject.Inject;
  import javax.naming.ConfigurationException;
  
++import org.apache.commons.codec.binary.Base64;
++import org.apache.log4j.Logger;
++
  import org.apache.cloudstack.acl.ControlledEntity.ACLType;
  import org.apache.cloudstack.acl.SecurityChecker.AccessType;
  import org.apache.cloudstack.affinity.AffinityGroupService;
@@@ -79,9 -79,8 +82,6 @@@ import org.apache.cloudstack.framework.
  import org.apache.cloudstack.managed.context.ManagedContextRunnable;
  import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
  import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
- import org.apache.cloudstack.storage.to.TemplateObjectTO;
--import org.apache.commons.codec.binary.Base64;
--import org.apache.log4j.Logger;
  
  import com.cloud.agent.AgentManager;
  import com.cloud.agent.api.Answer;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index e9d10b8,9d7a952..37cdf86
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@@ -865,27 -863,31 +865,31 @@@ public class VMSnapshotManagerImpl exte
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkCreateVMSnapshot.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkCreateVMSnapshot.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkCreateVMSnapshot workInfo = new VmWorkCreateVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId, quiesceVm);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkCreateVMSnapshot workInfo = new VmWorkCreateVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId, quiesceVm);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -909,27 -911,31 +913,31 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkDeleteVMSnapshot.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkDeleteVMSnapshot.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkDeleteVMSnapshot workInfo = new VmWorkDeleteVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkDeleteVMSnapshot workInfo = new VmWorkDeleteVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -953,27 -959,31 +961,31 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkRevertToVMSnapshot.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkRevertToVMSnapshot.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkRevertToVMSnapshot workInfo = new VmWorkRevertToVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkRevertToVMSnapshot workInfo = new VmWorkRevertToVMSnapshot(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, vmSnapshotId);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  
@@@ -997,27 -1007,31 +1009,31 @@@
              public Object[] doInTransaction(TransactionStatus status) {
                  VmWorkJobVO workJob = null;
  
-                 _vmInstanceDao.lockRow(vm.getId(), true);
+                 _vmInstanceDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE);
+                 try {
 -                    workJob = new VmWorkJobVO(context.getContextId());
 +                workJob = new VmWorkJobVO(context.getContextId());
  
 -                    workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 -                    workJob.setCmd(VmWorkDeleteAllVMSnapshots.class.getName());
 +                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
 +                workJob.setCmd(VmWorkDeleteAllVMSnapshots.class.getName());
  
 -                    workJob.setAccountId(callingAccount.getId());
 -                    workJob.setUserId(callingUser.getId());
 -                    workJob.setStep(VmWorkJobVO.Step.Starting);
 -                    workJob.setVmType(VirtualMachine.Type.Instance);
 -                    workJob.setVmInstanceId(vm.getId());
 +                workJob.setAccountId(callingAccount.getId());
 +                workJob.setUserId(callingUser.getId());
 +                workJob.setStep(VmWorkJobVO.Step.Starting);
 +                workJob.setVmType(VirtualMachine.Type.Instance);
 +                workJob.setVmInstanceId(vm.getId());
-                 workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                     workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
  
 -                    // save work context info (there are some duplications)
 -                    VmWorkDeleteAllVMSnapshots workInfo = new VmWorkDeleteAllVMSnapshots(callingUser.getId(), callingAccount.getId(), vm.getId(),
 -                            VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, type);
 -                    workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 +                // save work context info (there are some duplications)
 +                VmWorkDeleteAllVMSnapshots workInfo = new VmWorkDeleteAllVMSnapshots(callingUser.getId(), callingAccount.getId(), vm.getId(),
 +                        VMSnapshotManagerImpl.VM_WORK_JOB_HANDLER, type);
 +                workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
  
 -                    _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 +                _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
  
 -                    return new Object[] {workJob, new Long(workJob.getId())};
 +                return new Object[] {workJob, new Long(workJob.getId())};
+                 } finally {
+                     _vmInstanceDao.unlockFromLockTable(String.valueOf(vm.getId()));
+                 }
              }
          });
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/services/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --cc setup/db/db/schema-430to440.sql
index 917a954,f755a08..52f6c67
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@@ -122,9 -122,10 +122,10 @@@ CREATE VIEW `cloud`.`volume_view` A
          volumes.attached,
          volumes.removed,
          volumes.pod_id,
 -        volumes.display_volume,
 +    volumes.display_volume,
          volumes.format,
 -        volumes.path,
 +    volumes.path,
+         volumes.chain_info,
          account.id account_id,
          account.uuid account_uuid,
          account.account_name account_name,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48e08fe6/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --cc tools/marvin/marvin/integration/lib/base.py
index d281f7b,0a7ad94..4d968d1
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@@ -3623,131 -3630,32 +3630,160 @@@ class Resources
          cmd = updateResourceCount.updateResourceCountCmd()
          [setattr(cmd, k, v) for k, v in kwargs.items()]
          return(apiclient.updateResourceCount(cmd))
-     
 -
++   
+ class NIC:
+     """NIC related API"""
+     def __init__(self, items):
+         self.__dict__.update(items)
+ 
+     @classmethod
+     def addIp(cls, apiclient, id, ipaddress=None):
+         """Add Ip (secondary) to NIC"""
+         cmd = addIpToNic.addIpToNicCmd()
+         cmd.nicid = id
+         if ipaddress:
+             cmd.ipaddress = ipaddress
+         return(apiclient.addIpToNic(cmd))
+ 
+     @classmethod
+     def removeIp(cls,apiclient,ipaddressid):
+         """Remove secondary Ip from NIC"""
+         cmd = removeIpFromNic.removeIpFromNicCmd()
+         cmd.id = ipaddressid
+         return(apiclient.addIpToNic(cmd))
+ 
+     @classmethod
+     def list(cls, apiclient, **kwargs):
+         """List NICs belonging to a virtual machine"""
+ 
+         cmd = listNics.listNicsCmd()
+         [setattr(cmd, k, v) for k, v in kwargs.items()]
+         return(apiclient.listNics(cmd))
++        
 +class IAMGroup:
 +    def __init__(self, items):
 +        self.__dict__.update(items)
 +
 +    @classmethod
 +    def create(cls, apiclient, iam_grp, account=None, domainid=None):
 +        cmd = createIAMGroup.createIAMGroupCmd()
 +        cmd.name = iam_grp['name']
 +        cmd.description = iam_grp['description']
 +        if account:
 +            cmd.account = account
 +        if domainid:
 +            cmd.domainid = domainid
 +        return IAMGroup(apiclient.createIAMGroup(cmd).__dict__)
 +
 +    def update(self, apiclient):
 +        pass
 +
 +    def delete(self, apiclient):
 +        cmd = deleteIAMGroup.deleteIAMGroupCmd()
 +        cmd.id = self.id
 +        return apiclient.deleteIAMGroup(cmd)
 +
 +    @classmethod
 +    def list(cls, apiclient, **kwargs):
 +        cmd = listIAMGroups.listIAMGroupsCmd()
 +        [setattr(cmd, k, v) for k, v in kwargs.items()]
 +        return apiclient.listIAMGroupsCmd(cmd)  
 +    
 +    def addAccount(self, apiclient, accts):
 +        """Add accounts to iam group"""
 +        cmd = addAccountToIAMGroup.addAccountToIAMGroupCmd()
 +        cmd.id = self.id
 +        cmd.accounts = [str(acct.id) for acct in accts]
 +        apiclient.addAccountToIAMGroup(cmd)
 +        return  
 +
 +    def removeAccount(self, apiclient, accts):
 +        """ Remove accounts from iam group"""
 +        cmd = removeAccountFromIAMGroup.removeAccountFromIAMGroupCmd()
 +        cmd.id = self.id
 +        cmd.accounts = [str(acct.id) for acct in accts]
 +        apiclient.removeAccountFromIAMGroup(cmd)
 +        return  
 +    
 +    def attachPolicy(self, apiclient, policies):
 +        """Add policies to iam group"""
 +        cmd = attachIAMPolicyToIAMGroup.attachIAMPolicyToIAMGroupCmd()
 +        cmd.id = self.id
 +        cmd.policies = [str(policy.id) for policy in policies]
 +        apiclient.attachIAMPolicyToIAMGroup(cmd)
 +        return   
 +    
 +    def detachPolicy(self, apiclient, policies):
 +        """Remove policies from iam group"""
 +        cmd = removeIAMPolicyFromIAMGroup.removeIAMPolicyFromIAMGroupCmd()
 +        cmd.id = self.id
 +        cmd.policies = [str(policy.id) for policy in policies]
 +        apiclient.removeIAMPolicyFromIAMGroup(cmd)
 +        return         
 +    
 +class IAMPolicy:
 +    def __init__(self, items):
 +        self.__dict__.update(items)
 +
 +    @classmethod
 +    def create(cls, apiclient, iam_policy, account=None, domainid=None):
 +        cmd = createIAMPolicy.createIAMPolicyCmd()
 +        cmd.name = iam_policy['name']
 +        cmd.description = iam_policy['description']
 +        if account:
 +            cmd.account = account
 +        if domainid:
 +            cmd.domainid = domainid
 +        return IAMPolicy(apiclient.createIAMPolicy(cmd).__dict__)
 +
 +    def update(self, apiclient):
 +        pass
 +
 +    def delete(self, apiclient):
 +        cmd = deleteIAMPolicy.deleteIAMPolicyCmd()
 +        cmd.id = self.id
 +        return apiclient.deleteIAMPolicy(cmd)
 +
 +    @classmethod
 +    def list(cls, apiclient, **kwargs):
 +        cmd = listIAMPolicies.listIAMPoliciesCmd()
 +        [setattr(cmd, k, v) for k, v in kwargs.items()]
 +        return apiclient.listIAMPoliciesCmd(cmd)  
 +
 +    def addPermission(self, apiclient, permission):
 +        """Add permission to iam policy"""
 +        cmd = addIAMPermissionToIAMPolicy.addIAMPermissionToIAMPolicyCmd()
 +        cmd.id = self.id
 +        cmd.action = permission['action']
 +        cmd.entitytype = permission['entitytype']
 +        cmd.scope = permission['scope']
 +        cmd.scopeid = permission['scopeid']
 +        apiclient.addIAMPermissionToIAMPolicy(cmd)
 +        return       
 +
 +    def removePermission(self, apiclient, permission):
 +        """Remove permission from iam policy"""
 +        cmd = removeIAMPermissionFromIAMPolicy.removeIAMPermissionFromIAMPolicyCmd()
 +        cmd.id = self.id
 +        cmd.action = permission['action']
 +        cmd.entitytype = permission['entitytype']
 +        cmd.scope = permission['scope']
 +        cmd.scopeid = permission['scopeid']
 +        apiclient.removeIAMPermissionFromIAMPolicy(cmd)
 +        return  
 +    
 +    def attachAccount(self, apiclient, accts):
 +        """Attach iam policy to accounts"""
 +        cmd = attachIAMPolicyToAccount.attachIAMPolicyToAccountCmd()
 +        cmd.id = self.id
 +        cmd.accounts = [str(acct.id) for acct in accts]
 +        apiclient.attachIAMPolicyToAccount(cmd)
 +        return  
 +    
 +    def detachAccount(self, apiclient, accts):
 +        """Detach iam policy from accounts"""
 +        cmd = removeIAMPolicyFromAccount.removeIAMPolicyFromAccountCmd()
 +        cmd.id = self.id
 +        cmd.accounts = [str(acct.id) for acct in accts]
 +        apiclient.removeIAMPolicyFromAccount(cmd)
-         return           
++        return           


Mime
View raw message