cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [47/47] git commit: updated refs/heads/internallb to 3795048
Date Thu, 11 Apr 2013 21:23:10 GMT
Merge branch 'master' into internallb1

Conflicts:
	api/src/com/cloud/async/AsyncJob.java
	api/src/org/apache/cloudstack/api/ApiConstants.java
	api/src/org/apache/cloudstack/api/BaseCmd.java
	api/src/org/apache/cloudstack/api/ResponseGenerator.java
	client/tomcatconf/commands.properties.in
	server/src/com/cloud/api/ApiDBUtils.java
	server/src/com/cloud/api/ApiResponseHelper.java
	server/src/com/cloud/server/ManagementServerImpl.java
	setup/db/db/schema-410to420.sql


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

Branch: refs/heads/internallb
Commit: 3795048fcc68ef23c24d82c9064946dfc082b1b6
Parents: f4c2b53 5f8a278
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Apr 11 14:09:31 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Apr 11 14:16:33 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/async/AsyncJob.java              |    3 +-
 api/src/com/cloud/event/EventTypes.java            |    8 +-
 .../cloud/exception/AffinityConflictException.java |   34 ++
 api/src/com/cloud/server/ManagementService.java    |    4 +-
 api/src/com/cloud/vm/UserVmService.java            |  183 +++++----
 .../apache/cloudstack/affinity/AffinityGroup.java  |   31 ++
 .../affinity/AffinityGroupProcessor.java           |   49 ++
 .../cloudstack/affinity/AffinityGroupResponse.java |  155 +++++++
 .../cloudstack/affinity/AffinityGroupService.java  |   79 ++++
 .../affinity/AffinityGroupTypeResponse.java        |   48 ++
 .../cloudstack/affinity/AffinityProcessorBase.java |   44 ++
 .../org/apache/cloudstack/api/ApiConstants.java    |    5 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    8 +-
 .../apache/cloudstack/api/ResponseGenerator.java   |   49 ++-
 .../admin/config/ListDeploymentPlannersCmd.java    |   71 +++
 .../admin/offering/CreateServiceOfferingCmd.java   |    7 +
 .../user/affinitygroup/CreateAffinityGroupCmd.java |  167 +++++++
 .../user/affinitygroup/DeleteAffinityGroupCmd.java |  154 +++++++
 .../affinitygroup/ListAffinityGroupTypesCmd.java   |   67 +++
 .../user/affinitygroup/ListAffinityGroupsCmd.java  |   90 ++++
 .../affinitygroup/UpdateVMAffinityGroupCmd.java    |  164 +++++++
 .../api/command/user/vm/DeployVMCmd.java           |   41 ++-
 .../api/response/DeploymentPlannersResponse.java   |   37 ++
 .../cloudstack/api/response/UserVmResponse.java    |   14 +
 .../org/apache/cloudstack/query/QueryService.java  |    4 +
 client/pom.xml                                     |    7 +-
 client/tomcatconf/applicationContext.xml.in        |   10 +
 client/tomcatconf/commands.properties.in           |    6 +
 client/tomcatconf/componentContext.xml.in          |   11 +-
 client/tomcatconf/simulatorComponentContext.xml.in |   23 +-
 .../cloud/entity/api/VMEntityManagerImpl.java      |   82 ++--
 .../platform/orchestration/CloudOrchestrator.java  |   63 ++--
 .../host-anti-affinity/pom.xml                     |   33 ++
 .../affinity/HostAntiAffinityProcessor.java        |   91 ++++
 plugins/pom.xml                                    |    1 +
 server/src/com/cloud/api/ApiDBUtils.java           |   28 ++-
 server/src/com/cloud/api/ApiResponseHelper.java    |   42 ++-
 .../src/com/cloud/api/query/QueryManagerImpl.java  |  108 +++++
 .../com/cloud/api/query/ViewResponseHelper.java    |   20 +-
 .../cloud/api/query/dao/AffinityGroupJoinDao.java  |   37 ++
 .../api/query/dao/AffinityGroupJoinDaoImpl.java    |  142 ++++++
 .../com/cloud/api/query/dao/UserVmJoinDaoImpl.java |   27 ++
 .../cloud/api/query/vo/AffinityGroupJoinVO.java    |  248 +++++++++++
 .../src/com/cloud/api/query/vo/UserVmJoinVO.java   |   37 ++
 .../cloud/configuration/ConfigurationManager.java  |    3 +-
 .../configuration/ConfigurationManagerImpl.java    |    6 +-
 .../cloud/deploy/DeploymentPlanningManager.java    |   45 ++
 .../deploy/DeploymentPlanningManagerImpl.java      |   96 ++++
 server/src/com/cloud/deploy/FirstFitPlanner.java   |   56 ++-
 server/src/com/cloud/domain/dao/DomainDaoImpl.java |   11 +-
 .../com/cloud/server/ConfigurationServerImpl.java  |   22 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   41 ++
 .../src/com/cloud/service/ServiceOfferingVO.java   |   81 +++--
 server/src/com/cloud/user/AccountManagerImpl.java  |    9 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   69 +++-
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |  132 +++---
 .../affinity/AffinityGroupServiceImpl.java         |  346 +++++++++++++++
 .../cloudstack/affinity/AffinityGroupVMMapVO.java  |   66 +++
 .../cloudstack/affinity/AffinityGroupVO.java       |  114 +++++
 .../cloudstack/affinity/dao/AffinityGroupDao.java  |   30 ++
 .../affinity/dao/AffinityGroupDaoImpl.java         |  102 +++++
 .../affinity/dao/AffinityGroupVMMapDao.java        |   47 ++
 .../affinity/dao/AffinityGroupVMMapDaoImpl.java    |  167 +++++++
 .../test/com/cloud/vm/MockUserVmManagerImpl.java   |   16 +-
 .../cloud/vpc/MockConfigurationManagerImpl.java    |    2 +-
 .../affinity/AffinityApiTestConfiguration.java     |  332 ++++++++++++++
 .../cloudstack/affinity/AffinityApiUnitTest.java   |  174 ++++++++
 server/test/resources/affinityContext.xml          |   47 ++
 setup/db/db/schema-410to420.sql                    |  240 ++++++++++-
 test/integration/smoke/test_affinity_groups.py     |  194 ++++++++
 tools/apidoc/gen_toc.py                            |    3 +-
 tools/marvin/marvin/integration/lib/base.py        |   42 ++-
 ui/index.jsp                                       |    2 +-
 ui/scripts/cloudStack.js                           |    4 +-
 ui/scripts/network.js                              |    8 +-
 ui/scripts/regions.js                              |  145 ++++++-
 ui/scripts/ui-custom/regions.js                    |    2 +-
 ui/scripts/ui/widgets/listView.js                  |    6 +-
 utils/src/com/cloud/utils/SerialVersionUID.java    |    1 +
 79 files changed, 4807 insertions(+), 386 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/api/src/com/cloud/async/AsyncJob.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/async/AsyncJob.java
index 1528809,866429b..386d4ef
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@@ -50,7 -50,7 +50,8 @@@ public interface AsyncJob extends Ident
          AutoScaleVmProfile,
          AutoScaleVmGroup,
          GlobalLoadBalancerRule,
-         LoadBalancerRule
++        LoadBalancerRule,
+         AffinityGroup
      }
  
      long getUserId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/ApiConstants.java
index 13bce07,b08e992..906630a
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@@ -473,12 -473,9 +473,15 @@@ public class ApiConstants 
      public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold";
      public static final String HEALTHCHECK_UNHEALTHY_THRESHOLD = "unhealthythreshold";
      public static final String HEALTHCHECK_PINGPATH = "pingpath";
 +    public static final String SOURCE_PORT = "sourceport";
 +    public static final String INSTANCE_PORT = "instanceport";
 +    public static final String SOURCE_IP = "sourceipaddress";
 +    public static final String SOURCE_IP_NETWORK_ID = "sourceipaddressnetworkid";
 +    public static final String SCHEME = "scheme";
 +    public static final String PROVIDER_TYPE = "providertype";
+     public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
+     public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
+     public static final String DEPLOYMENT_PLANNER = "deploymentplanner";
  
      public enum HostDetails {
          all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/BaseCmd.java
index 41f085e,42c0680..9030d22
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@@ -27,7 -27,7 +27,8 @@@ import java.util.regex.Pattern
  
  import javax.inject.Inject;
  
+ import org.apache.cloudstack.affinity.AffinityGroupService;
 +import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
  import org.apache.cloudstack.query.QueryService;
  import org.apache.cloudstack.usage.UsageService;
  import org.apache.log4j.Logger;
@@@ -134,9 -133,7 +135,10 @@@ public abstract class BaseCmd 
      @Inject public VMSnapshotService _vmSnapshotService;
      @Inject public DataStoreProviderApiService dataStoreProviderApiService;
      @Inject public VpcProvisioningService _vpcProvSvc;
 +    @Inject public ApplicationLoadBalancerService _newLbSvc;
 +    @Inject public NetworkModel _ntwkModel;
 +    @Inject public ApplicationLoadBalancerService _appLbService;
+     @Inject public AffinityGroupService _affinityGroupService;
  
      public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/ResponseGenerator.java
index a17b079,c0dd57e..2fc14a4
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@@ -19,12 -19,13 +19,15 @@@ package org.apache.cloudstack.api
  import java.text.DecimalFormat;
  import java.util.EnumSet;
  import java.util.List;
 +import java.util.Map;
  
+ import org.apache.cloudstack.affinity.AffinityGroup;
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
  import org.apache.cloudstack.api.ApiConstants.HostDetails;
  import org.apache.cloudstack.api.ApiConstants.VMDetails;
  import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
  import org.apache.cloudstack.api.response.AccountResponse;
++import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
  import org.apache.cloudstack.api.response.AsyncJobResponse;
  import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
  import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
@@@ -42,6 -43,6 +45,7 @@@ import org.apache.cloudstack.api.respon
  import org.apache.cloudstack.api.response.ExtractResponse;
  import org.apache.cloudstack.api.response.FirewallResponse;
  import org.apache.cloudstack.api.response.FirewallRuleResponse;
++import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
  import org.apache.cloudstack.api.response.GuestOSResponse;
  import org.apache.cloudstack.api.response.HostResponse;
  import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
@@@ -118,9 -117,9 +121,23 @@@ import com.cloud.domain.Domain
  import com.cloud.event.Event;
  import com.cloud.host.Host;
  import com.cloud.hypervisor.HypervisorCapabilities;
--import com.cloud.network.*;
++import com.cloud.network.IpAddress;
++import com.cloud.network.Network;
  import com.cloud.network.Network.Service;
--import com.cloud.network.as.*;
++import com.cloud.network.PhysicalNetwork;
++import com.cloud.network.PhysicalNetworkServiceProvider;
++import com.cloud.network.PhysicalNetworkTrafficType;
++import com.cloud.network.RemoteAccessVpn;
++import com.cloud.network.Site2SiteCustomerGateway;
++import com.cloud.network.Site2SiteVpnConnection;
++import com.cloud.network.Site2SiteVpnGateway;
++import com.cloud.network.VirtualRouterProvider;
++import com.cloud.network.VpnUser;
++import com.cloud.network.as.AutoScalePolicy;
++import com.cloud.network.as.AutoScaleVmGroup;
++import com.cloud.network.as.AutoScaleVmProfile;
++import com.cloud.network.as.Condition;
++import com.cloud.network.as.Counter;
  import com.cloud.network.router.VirtualRouter;
  import com.cloud.network.rules.FirewallRule;
  import com.cloud.network.rules.HealthCheckPolicy;
@@@ -143,7 -142,7 +160,12 @@@ import com.cloud.projects.ProjectAccoun
  import com.cloud.projects.ProjectInvitation;
  import com.cloud.region.ha.GlobalLoadBalancerRule;
  import com.cloud.server.ResourceTag;
--import com.cloud.storage.*;
++import com.cloud.storage.GuestOS;
++import com.cloud.storage.S3;
++import com.cloud.storage.Snapshot;
++import com.cloud.storage.StoragePool;
++import com.cloud.storage.Swift;
++import com.cloud.storage.Volume;
  import com.cloud.storage.snapshot.SnapshotPolicy;
  import com.cloud.storage.snapshot.SnapshotSchedule;
  import com.cloud.template.VirtualMachineTemplate;
@@@ -151,21 -150,11 +173,11 @@@ import com.cloud.user.Account
  import com.cloud.user.User;
  import com.cloud.user.UserAccount;
  import com.cloud.uservm.UserVm;
 +import com.cloud.utils.net.Ip;
  import com.cloud.vm.InstanceGroup;
  import com.cloud.vm.Nic;
- import com.cloud.vm.NicSecondaryIp;
--import com.cloud.vm.snapshot.VMSnapshot;
  import com.cloud.vm.VirtualMachine;
- import org.apache.cloudstack.api.ApiConstants.HostDetails;
- import org.apache.cloudstack.api.ApiConstants.VMDetails;
- import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
--import org.apache.cloudstack.api.response.*;
- import org.apache.cloudstack.region.Region;
- 
- import java.text.DecimalFormat;
- import java.util.EnumSet;
- import java.util.List;
++import com.cloud.vm.snapshot.VMSnapshot;
  
  public interface ResponseGenerator {
      UserResponse createUserResponse(UserAccount user);
@@@ -397,5 -387,7 +410,9 @@@
              Long nicId, Long networkId);
      public NicResponse createNicResponse(Nic result);
  
 +    ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(ApplicationLoadBalancerRule lb, Map<Ip, UserVm> lbInstances);
++    
+     AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group);
+ 
+     Long getAffinityGroupId(String name, long entityOwnerId);
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/client/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/commands.properties.in
index 2145a52,4ce9fd3..35f7ed2
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@@ -569,14 -569,9 +569,20 @@@ revertToSnapshot=1
  #### Baremetal commands
  addBaremetalHost=1
  
 +#### New Load Balancer commands
 +createLoadBalancer=15
 +listLoadBalancers=15
 +deleteLoadBalancer=15
 +
 +#Internal Load Balancer Element commands
 +configureInternalLoadBalancerElement=1
 +createInternalLoadBalancerElement=1
 +listInternalLoadBalancerElements=1
 +
 +
+ #### Affinity group commands
+ createAffinityGroup=15
+ deleteAffinityGroup=15
+ listAffinityGroups=15
+ updateVMAffinityGroup=15
+ listAffinityGroupTypes=15

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/plugins/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDBUtils.java
index 464592a,303f328..e3330ec
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@@ -484,7 -490,9 +491,10 @@@ public class ApiDBUtils 
      @Inject private VMSnapshotDao vmSnapshotDao;
      @Inject private NicSecondaryIpDao nicSecondaryIpDao;
      @Inject private VpcProvisioningService vpcProvSvc;
 +    @Inject private ApplicationLoadBalancerRuleDao _appLbDao;
+     @Inject private AffinityGroupDao affinityGroupDao;
+     @Inject private AffinityGroupJoinDao affinityGroupJoinDao;
+ 
      @PostConstruct
      void init() {
          _ms = ms;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiResponseHelper.java
index 993e374,651a8be..476038d
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@@ -36,6 -36,6 +36,8 @@@ import javax.inject.Inject
  
  import org.apache.cloudstack.acl.ControlledEntity;
  import org.apache.cloudstack.acl.ControlledEntity.ACLType;
++import org.apache.cloudstack.affinity.AffinityGroup;
++import org.apache.cloudstack.affinity.AffinityGroupResponse;
  import org.apache.cloudstack.api.ApiConstants.HostDetails;
  import org.apache.cloudstack.api.ApiConstants.VMDetails;
  import org.apache.cloudstack.api.BaseCmd;
@@@ -3627,70 -3650,29 +3629,96 @@@ public class ApiResponseHelper implemen
          response.setIsDefault(result.isDefaultNic());
          return response;
      }
+ 
 +    
 +    @Override
 +    public ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(ApplicationLoadBalancerRule lb, Map<Ip, UserVm> lbInstances) {
 +
 +        ApplicationLoadBalancerResponse lbResponse = new ApplicationLoadBalancerResponse();
 +        lbResponse.setId(lb.getUuid());
 +        lbResponse.setName(lb.getName());
 +        lbResponse.setDescription(lb.getDescription());
 +        lbResponse.setAlgorithm(lb.getAlgorithm());
 +        Network nw = ApiDBUtils.findNetworkById(lb.getNetworkId());
 +        lbResponse.setNetworkId(nw.getUuid());
 +        populateOwner(lbResponse, lb);
 +        
 +        if (lb.getScheme() == Scheme.Internal) {
 +            lbResponse.setSourceIp(lb.getSourceIp().addr());
 +            //TODO - create the view for the load balancer rule to reflect the network uuid
 +            Network network = ApiDBUtils.findNetworkById(lb.getNetworkId());
 +            lbResponse.setSourceIpNetworkId(network.getUuid());
 +        } else {
 +            //for public, populate the ip information from the ip address
 +            IpAddress publicIp = ApiDBUtils.findIpAddressById(lb.getSourceIpAddressId());
 +            lbResponse.setSourceIp(publicIp.getAddress().addr());
 +            Network ntwk = ApiDBUtils.findNetworkById(publicIp.getNetworkId());
 +            lbResponse.setSourceIpNetworkId(ntwk.getUuid());
 +        }
 +        
 +        //set load balancer rules information (only one rule per load balancer in this release)
 +        List<ApplicationLoadBalancerRuleResponse> ruleResponses = new ArrayList<ApplicationLoadBalancerRuleResponse>();
 +        ApplicationLoadBalancerRuleResponse ruleResponse = new ApplicationLoadBalancerRuleResponse();
 +        ruleResponse.setInstancePort(lb.getDefaultPortStart());
 +        ruleResponse.setSourcePort(lb.getSourcePortStart());
 +        String stateToSet = lb.getState().toString();
 +        if (stateToSet.equals(FirewallRule.State.Revoke)) {
 +            stateToSet = "Deleting";
 +        }
 +        ruleResponse.setState(stateToSet);
 +        ruleResponse.setObjectName("loadbalancerrule");
 +        ruleResponses.add(ruleResponse);
 +        lbResponse.setLbRules(ruleResponses);
 +        
 +        //set Lb instances information
 +        List<ApplicationLoadBalancerInstanceResponse> instanceResponses = new ArrayList<ApplicationLoadBalancerInstanceResponse>();
 +        for (Ip ip : lbInstances.keySet()) {
 +            ApplicationLoadBalancerInstanceResponse instanceResponse = new ApplicationLoadBalancerInstanceResponse();
 +            instanceResponse.setIpAddress(ip.addr());
 +            UserVm vm = lbInstances.get(ip);
 +            instanceResponse.setId(vm.getUuid());
 +            instanceResponse.setName(vm.getInstanceName());
 +            instanceResponse.setObjectName("loadbalancerinstance");
 +            instanceResponses.add(instanceResponse);
 +        }
 +        
 +        lbResponse.setLbInstances(instanceResponses);
 +
 +        //set tag information
 +        List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.LoadBalancer, lb.getId());
 +        List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
 +        for (ResourceTag tag : tags) {
 +            ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
 +            tagResponses.add(tagResponse);
 +        }
 +        lbResponse.setTags(tagResponses);
 +
 +        lbResponse.setObjectName("loadbalancer");
 +        return lbResponse;
 +    }
++
+     @Override
+     public AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group) {
+ 
+         AffinityGroupResponse response = new AffinityGroupResponse();
+ 
+         Account account = ApiDBUtils.findAccountById(group.getAccountId());
+         response.setAccountName(account.getAccountName());
+         response.setName(group.getName());
+         response.setType(group.getType());
+         response.setDescription(group.getDescription());
+         // response.setDomainId(account.)
+ 
+         return response;
+     }
+ 
+     @Override
+     public Long getAffinityGroupId(String groupName, long accountId) {
+         AffinityGroup ag = ApiDBUtils.getAffinityGroup(groupName, accountId);
+         if (ag == null) {
+             return null;
+         } else {
+             return ag.getId();
+         }
+     }
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/server/ManagementServerImpl.java
index 9ffea9c,b869d1e..8dc27ae
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@@ -42,351 -42,50 +42,358 @@@ import javax.crypto.spec.SecretKeySpec
  import javax.inject.Inject;
  import javax.naming.ConfigurationException;
  
 -import com.cloud.storage.dao.*;
 +import org.apache.cloudstack.acl.ControlledEntity;
  import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 -import org.apache.cloudstack.api.ApiConstants;
 -
 -import com.cloud.event.ActionEventUtils;
 -import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 -import org.apache.cloudstack.api.command.admin.account.*;
 -import org.apache.cloudstack.api.command.admin.domain.*;
 -import org.apache.cloudstack.api.command.admin.host.*;
 -import org.apache.cloudstack.api.command.admin.network.*;
 -import org.apache.cloudstack.api.command.admin.offering.*;
 -import org.apache.cloudstack.api.command.admin.resource.*;
 -import org.apache.cloudstack.api.command.admin.router.*;
 -import org.apache.cloudstack.api.command.admin.storage.*;
 -import org.apache.cloudstack.api.command.admin.systemvm.*;
 -import org.apache.cloudstack.api.command.admin.usage.*;
 -import org.apache.cloudstack.api.command.admin.user.*;
 -import org.apache.cloudstack.api.command.admin.vpc.*;
 -import org.apache.cloudstack.api.command.user.autoscale.*;
 -import org.apache.cloudstack.api.command.user.firewall.*;
 -import org.apache.cloudstack.api.command.user.iso.*;
 -import org.apache.cloudstack.api.command.user.loadbalancer.*;
 -import org.apache.cloudstack.api.command.user.nat.*;
 -import org.apache.cloudstack.api.command.user.network.*;
 -import org.apache.cloudstack.api.command.user.project.*;
 -import org.apache.cloudstack.api.command.user.resource.*;
 -import org.apache.cloudstack.api.command.user.securitygroup.*;
 -import org.apache.cloudstack.api.command.user.snapshot.*;
 -import org.apache.cloudstack.api.command.user.template.*;
 -import org.apache.cloudstack.api.command.user.vm.*;
 -import org.apache.cloudstack.api.command.user.volume.*;
 -import org.apache.cloudstack.api.command.user.vpc.*;
 -import org.apache.cloudstack.api.command.user.vpn.*;
 -import org.apache.cloudstack.api.response.ExtractResponse;
 -import org.apache.commons.codec.binary.Base64;
 -import org.apache.log4j.Logger;
+ import org.apache.cloudstack.affinity.AffinityGroupProcessor;
+ import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 -
 +import org.apache.cloudstack.api.ApiConstants;
 +import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 +import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd;
 +import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd;
 +import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd;
 +import org.apache.cloudstack.api.command.admin.account.EnableAccountCmd;
 +import org.apache.cloudstack.api.command.admin.account.LockAccountCmd;
 +import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
 +import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
 +import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd;
 +import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 +import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
 +import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
 +import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd;
 +import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
 +import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd;
 +import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
 +import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
 +import org.apache.cloudstack.api.command.admin.domain.CreateDomainCmd;
 +import org.apache.cloudstack.api.command.admin.domain.DeleteDomainCmd;
 +import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd;
 +import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
 +import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
 +import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
 +import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
 +import org.apache.cloudstack.api.command.admin.host.CancelMaintenanceCmd;
 +import org.apache.cloudstack.api.command.admin.host.DeleteHostCmd;
 +import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 +import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
 +import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
 +import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
 +import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
 +import org.apache.cloudstack.api.command.admin.internallb.ConfigureInternalLoadBalancerElementCmd;
 +import org.apache.cloudstack.api.command.admin.internallb.CreateInternalLoadBalancerElementCmd;
 +import org.apache.cloudstack.api.command.admin.internallb.ListInternalLoadBalancerElementsCmd;
 +import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
 +import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
 +import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
 +import org.apache.cloudstack.api.command.admin.network.AddNetworkServiceProviderCmd;
 +import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.network.CreatePhysicalNetworkCmd;
 +import org.apache.cloudstack.api.command.admin.network.CreateStorageNetworkIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.network.DeleteNetworkDeviceCmd;
 +import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.network.DeleteNetworkServiceProviderCmd;
 +import org.apache.cloudstack.api.command.admin.network.DeletePhysicalNetworkCmd;
 +import org.apache.cloudstack.api.command.admin.network.DeleteStorageNetworkIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.network.ListNetworkDeviceCmd;
 +import org.apache.cloudstack.api.command.admin.network.ListNetworkServiceProvidersCmd;
 +import org.apache.cloudstack.api.command.admin.network.ListPhysicalNetworksCmd;
 +import org.apache.cloudstack.api.command.admin.network.ListStorageNetworkIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.network.ListSupportedNetworkServicesCmd;
 +import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.network.UpdateNetworkServiceProviderCmd;
 +import org.apache.cloudstack.api.command.admin.network.UpdatePhysicalNetworkCmd;
 +import org.apache.cloudstack.api.command.admin.network.UpdateStorageNetworkIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.pod.CreatePodCmd;
 +import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
 +import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
 +import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
 +import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
 +import org.apache.cloudstack.api.command.admin.region.RemoveRegionCmd;
 +import org.apache.cloudstack.api.command.admin.region.UpdateRegionCmd;
 +import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
 +import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
 +import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
 +import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
 +import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
 +import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
 +import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
 +import org.apache.cloudstack.api.command.admin.router.DestroyRouterCmd;
 +import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 +import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 +import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
 +import org.apache.cloudstack.api.command.admin.router.StartRouterCmd;
 +import org.apache.cloudstack.api.command.admin.router.StopRouterCmd;
 +import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
 +import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
 +import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
 +import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
 +import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
 +import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 +import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 +import org.apache.cloudstack.api.command.admin.storage.ListStorageProvidersCmd;
 +import org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd;
 +import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
 +import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
 +import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.ListSystemVMsCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.MigrateSystemVMCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.RebootSystemVmCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.StartSystemVMCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
 +import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
 +import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd;
 +import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd;
 +import org.apache.cloudstack.api.command.admin.usage.AddTrafficTypeCmd;
 +import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficMonitorCmd;
 +import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficTypeCmd;
 +import org.apache.cloudstack.api.command.admin.usage.GenerateUsageRecordsCmd;
 +import org.apache.cloudstack.api.command.admin.usage.GetUsageRecordsCmd;
 +import org.apache.cloudstack.api.command.admin.usage.ListTrafficMonitorsCmd;
 +import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 +import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypesCmd;
 +import org.apache.cloudstack.api.command.admin.usage.ListUsageTypesCmd;
 +import org.apache.cloudstack.api.command.admin.usage.UpdateTrafficTypeCmd;
 +import org.apache.cloudstack.api.command.admin.user.CreateUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.DisableUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.EnableUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.GetUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
 +import org.apache.cloudstack.api.command.admin.user.LockUserCmd;
 +import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
 +import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
 +import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
 +import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
 +import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
 +import org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd;
 +import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
 +import org.apache.cloudstack.api.command.admin.vpc.CreatePrivateGatewayCmd;
 +import org.apache.cloudstack.api.command.admin.vpc.CreateVPCOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.vpc.DeletePrivateGatewayCmd;
 +import org.apache.cloudstack.api.command.admin.vpc.DeleteVPCOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.vpc.UpdateVPCOfferingCmd;
 +import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
 +import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
 +import org.apache.cloudstack.api.command.admin.zone.MarkDefaultZoneForAccountCmd;
 +import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
 +import org.apache.cloudstack.api.command.user.account.AddAccountToProjectCmd;
 +import org.apache.cloudstack.api.command.user.account.DeleteAccountFromProjectCmd;
 +import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
 +import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
 +import org.apache.cloudstack.api.command.user.address.AssociateIPAddrCmd;
 +import org.apache.cloudstack.api.command.user.address.DisassociateIPAddrCmd;
 +import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
+ import org.apache.cloudstack.api.command.user.affinitygroup.CreateAffinityGroupCmd;
+ import org.apache.cloudstack.api.command.user.affinitygroup.DeleteAffinityGroupCmd;
+ import org.apache.cloudstack.api.command.user.affinitygroup.ListAffinityGroupTypesCmd;
+ import org.apache.cloudstack.api.command.user.affinitygroup.ListAffinityGroupsCmd;
+ import org.apache.cloudstack.api.command.user.affinitygroup.UpdateVMAffinityGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScalePolicyCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmProfileCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.CreateConditionCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.DeleteAutoScalePolicyCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.DeleteAutoScaleVmGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.DeleteAutoScaleVmProfileCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.DeleteConditionCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.DisableAutoScaleVmGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.EnableAutoScaleVmGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.ListAutoScalePoliciesCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmGroupsCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmProfilesCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.ListConditionsCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.ListCountersCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScalePolicyCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmGroupCmd;
 +import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmProfileCmd;
 +import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd;
 +import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
 +import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
 +import org.apache.cloudstack.api.command.user.event.ListEventTypesCmd;
 +import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 +import org.apache.cloudstack.api.command.user.firewall.CreateEgressFirewallRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.CreateFirewallRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.CreatePortForwardingRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.DeleteEgressFirewallRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.DeleteFirewallRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.DeletePortForwardingRuleCmd;
 +import org.apache.cloudstack.api.command.user.firewall.ListEgressFirewallRulesCmd;
 +import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd;
 +import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
 +import org.apache.cloudstack.api.command.user.firewall.UpdatePortForwardingRuleCmd;
 +import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
 +import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
 +import org.apache.cloudstack.api.command.user.iso.AttachIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.CopyIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.DetachIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.ListIsoPermissionsCmd;
 +import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
 +import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
 +import org.apache.cloudstack.api.command.user.iso.UpdateIsoPermissionsCmd;
 +import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;
 +import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.AssignToLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.CreateApplicationLoadBalancerCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBHealthCheckPolicyCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBStickinessPolicyCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.DeleteApplicationLoadBalancerCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.DeleteLBHealthCheckPolicyCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.DeleteLBStickinessPolicyCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.DeleteLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.ListApplicationLoadBalancersCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.ListLBHealthCheckPoliciesCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.ListLBStickinessPoliciesCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.ListLoadBalancerRuleInstancesCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.ListLoadBalancerRulesCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.RemoveFromLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.nat.CreateIpForwardingRuleCmd;
 +import org.apache.cloudstack.api.command.user.nat.DeleteIpForwardingRuleCmd;
 +import org.apache.cloudstack.api.command.user.nat.DisableStaticNatCmd;
 +import org.apache.cloudstack.api.command.user.nat.EnableStaticNatCmd;
 +import org.apache.cloudstack.api.command.user.nat.ListIpForwardingRulesCmd;
 +import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
 +import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 +import org.apache.cloudstack.api.command.user.network.DeleteNetworkACLCmd;
 +import org.apache.cloudstack.api.command.user.network.DeleteNetworkCmd;
 +import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
 +import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
 +import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
 +import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
 +import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
 +import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 +import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
 +import org.apache.cloudstack.api.command.user.project.ActivateProjectCmd;
 +import org.apache.cloudstack.api.command.user.project.CreateProjectCmd;
 +import org.apache.cloudstack.api.command.user.project.DeleteProjectCmd;
 +import org.apache.cloudstack.api.command.user.project.DeleteProjectInvitationCmd;
 +import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
 +import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
 +import org.apache.cloudstack.api.command.user.project.SuspendProjectCmd;
 +import org.apache.cloudstack.api.command.user.project.UpdateProjectCmd;
 +import org.apache.cloudstack.api.command.user.project.UpdateProjectInvitationCmd;
 +import org.apache.cloudstack.api.command.user.region.ListRegionsCmd;
 +import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.region.ha.gslb.ListGlobalLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd;
 +import org.apache.cloudstack.api.command.user.resource.GetCloudIdentifierCmd;
 +import org.apache.cloudstack.api.command.user.resource.ListHypervisorsCmd;
 +import org.apache.cloudstack.api.command.user.resource.ListResourceLimitsCmd;
 +import org.apache.cloudstack.api.command.user.resource.UpdateResourceCountCmd;
 +import org.apache.cloudstack.api.command.user.resource.UpdateResourceLimitCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.AuthorizeSecurityGroupEgressCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.AuthorizeSecurityGroupIngressCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.CreateSecurityGroupCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.DeleteSecurityGroupCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupEgressCmd;
 +import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupIngressCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
 +import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
 +import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
 +import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
 +import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
 +import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
 +import org.apache.cloudstack.api.command.user.tag.CreateTagsCmd;
 +import org.apache.cloudstack.api.command.user.tag.DeleteTagsCmd;
 +import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
 +import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.ListTemplatePermissionsCmd;
 +import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd;
 +import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
 +import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissionsCmd;
 +import org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd;
 +import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
 +import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
 +import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
 +import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd;
 +import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
 +import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd;
 +import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.StopVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToSnapshotCmd;
 +import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.DeleteVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 +import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
 +import org.apache.cloudstack.api.command.user.vpc.CreateStaticRouteCmd;
 +import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd;
 +import org.apache.cloudstack.api.command.user.vpc.DeleteStaticRouteCmd;
 +import org.apache.cloudstack.api.command.user.vpc.DeleteVPCCmd;
 +import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
 +import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
 +import org.apache.cloudstack.api.command.user.vpc.ListVPCOfferingsCmd;
 +import org.apache.cloudstack.api.command.user.vpc.ListVPCsCmd;
 +import org.apache.cloudstack.api.command.user.vpc.RestartVPCCmd;
 +import org.apache.cloudstack.api.command.user.vpc.UpdateVPCCmd;
 +import org.apache.cloudstack.api.command.user.vpn.AddVpnUserCmd;
 +import org.apache.cloudstack.api.command.user.vpn.CreateRemoteAccessVpnCmd;
 +import org.apache.cloudstack.api.command.user.vpn.CreateVpnConnectionCmd;
 +import org.apache.cloudstack.api.command.user.vpn.CreateVpnCustomerGatewayCmd;
 +import org.apache.cloudstack.api.command.user.vpn.CreateVpnGatewayCmd;
 +import org.apache.cloudstack.api.command.user.vpn.DeleteRemoteAccessVpnCmd;
 +import org.apache.cloudstack.api.command.user.vpn.DeleteVpnConnectionCmd;
 +import org.apache.cloudstack.api.command.user.vpn.DeleteVpnCustomerGatewayCmd;
 +import org.apache.cloudstack.api.command.user.vpn.DeleteVpnGatewayCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ListVpnConnectionsCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ListVpnCustomerGatewaysCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ListVpnGatewaysCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
 +import org.apache.cloudstack.api.command.user.vpn.RemoveVpnUserCmd;
 +import org.apache.cloudstack.api.command.user.vpn.ResetVpnConnectionCmd;
 +import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd;
 +import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
 +import org.apache.cloudstack.api.response.ExtractResponse;
 +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 +import org.apache.commons.codec.binary.Base64;
 +import org.apache.log4j.Logger;
 +
  import com.cloud.agent.AgentManager;
  import com.cloud.agent.api.GetVncPortAnswer;
  import com.cloud.agent.api.GetVncPortCommand;
@@@ -415,22 -110,11 +422,23 @@@ import com.cloud.configuration.Configur
  import com.cloud.configuration.dao.ConfigurationDao;
  import com.cloud.consoleproxy.ConsoleProxyManagementState;
  import com.cloud.consoleproxy.ConsoleProxyManager;
 -import com.cloud.dc.*;
 +import com.cloud.dc.AccountVlanMapVO;
 +import com.cloud.dc.ClusterVO;
 +import com.cloud.dc.DataCenterVO;
 +import com.cloud.dc.HostPodVO;
 +import com.cloud.dc.Pod;
 +import com.cloud.dc.PodVlanMapVO;
 +import com.cloud.dc.Vlan;
  import com.cloud.dc.Vlan.VlanType;
 -import com.cloud.dc.dao.*;
 +import com.cloud.dc.VlanVO;
 +import com.cloud.dc.dao.AccountVlanMapDao;
 +import com.cloud.dc.dao.ClusterDao;
 +import com.cloud.dc.dao.DataCenterDao;
 +import com.cloud.dc.dao.HostPodDao;
 +import com.cloud.dc.dao.PodVlanMapDao;
 +import com.cloud.dc.dao.VlanDao;
  import com.cloud.deploy.DataCenterDeployment;
+ import com.cloud.deploy.DeploymentPlanner;
  import com.cloud.deploy.DeploymentPlanner.ExcludeList;
  import com.cloud.domain.DomainVO;
  import com.cloud.domain.dao.DomainDao;
@@@ -2528,12 -2248,12 +2554,17 @@@ public class ManagementServerImpl exten
          cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
          cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
          cmdList.add(ListStorageProvidersCmd.class);
 +        cmdList.add(CreateApplicationLoadBalancerCmd.class);
 +        cmdList.add(ListApplicationLoadBalancersCmd.class);
 +        cmdList.add(DeleteApplicationLoadBalancerCmd.class);
 +        cmdList.add(ConfigureInternalLoadBalancerElementCmd.class);
 +        cmdList.add(CreateInternalLoadBalancerElementCmd.class);
 +        cmdList.add(ListInternalLoadBalancerElementsCmd.class);
+         cmdList.add(CreateAffinityGroupCmd.class);
+         cmdList.add(DeleteAffinityGroupCmd.class);
+         cmdList.add(ListAffinityGroupsCmd.class);
+         cmdList.add(UpdateVMAffinityGroupCmd.class);
+         cmdList.add(ListAffinityGroupTypesCmd.class);
 -
          return cmdList;
      }
  

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3795048f/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --cc setup/db/db/schema-410to420.sql
index d99f4c7,92b2d9c..4a4d3a0
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@@ -448,10 -471,216 +471,223 @@@ CREATE TABLE `cloud`.`vm_snapshots` 
  ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `vm_snapshot_enabled` tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Whether VM snapshot is supported by hypervisor';
  UPDATE `cloud`.`hypervisor_capabilities` SET `vm_snapshot_enabled`=1 WHERE `hypervisor_type` in ('VMware', 'XenServer');
  
 +
 +ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address` varchar(40) COMMENT 'source ip address for the load balancer rule';
 +ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address_network_id` bigint unsigned COMMENT 'the id of the network where source ip belongs to';
 +ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `scheme` varchar(40) NOT NULL COMMENT 'load balancer scheme; can be Internal or Public';
 +UPDATE `cloud`.`load_balancing_rules` SET `scheme`='Public';
 +
 +
+ 			
+ DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
+ CREATE VIEW `cloud`.`user_vm_view` AS
+     select 
+         vm_instance.id id,
+         vm_instance.name name,
+         user_vm.display_name display_name,
+         user_vm.user_data user_data,
+         account.id account_id,
+         account.uuid account_uuid,
+         account.account_name account_name,
+         account.type account_type,
+         domain.id domain_id,
+         domain.uuid domain_uuid,
+         domain.name domain_name,
+         domain.path domain_path,
+         projects.id project_id,
+         projects.uuid project_uuid,
+         projects.name project_name,
+         instance_group.id instance_group_id,
+         instance_group.uuid instance_group_uuid,
+         instance_group.name instance_group_name,
+         vm_instance.uuid uuid,
+         vm_instance.last_host_id last_host_id,
+         vm_instance.vm_type type,
+         vm_instance.vnc_password vnc_password,
+         vm_instance.limit_cpu_use limit_cpu_use,
+         vm_instance.created created,
+         vm_instance.state state,
+         vm_instance.removed removed,
+         vm_instance.ha_enabled ha_enabled,
+         vm_instance.hypervisor_type hypervisor_type,
+         vm_instance.instance_name instance_name,
+         vm_instance.guest_os_id guest_os_id,
+         guest_os.uuid guest_os_uuid,
+         vm_instance.pod_id pod_id,
+         host_pod_ref.uuid pod_uuid,
+         vm_instance.private_ip_address private_ip_address,
+         vm_instance.private_mac_address private_mac_address,
+         vm_instance.vm_type vm_type,
+         data_center.id data_center_id,
+         data_center.uuid data_center_uuid,
+         data_center.name data_center_name,
+         data_center.is_security_group_enabled security_group_enabled,
+         host.id host_id,
+         host.uuid host_uuid,
+         host.name host_name,
+         vm_template.id template_id,
+         vm_template.uuid template_uuid,
+         vm_template.name template_name,
+         vm_template.display_text template_display_text,
+         vm_template.enable_password password_enabled,
+         iso.id iso_id,
+         iso.uuid iso_uuid,
+         iso.name iso_name,
+         iso.display_text iso_display_text,
+         service_offering.id service_offering_id,
+         disk_offering.uuid service_offering_uuid,
+         service_offering.cpu cpu,
+         service_offering.speed speed,
+         service_offering.ram_size ram_size,
+         disk_offering.name service_offering_name,
+         storage_pool.id pool_id,
+         storage_pool.uuid pool_uuid,
+         storage_pool.pool_type pool_type,
+         volumes.id volume_id,
+         volumes.uuid volume_uuid,
+         volumes.device_id volume_device_id,
+         volumes.volume_type volume_type,
+         security_group.id security_group_id,
+         security_group.uuid security_group_uuid,
+         security_group.name security_group_name,
+         security_group.description security_group_description,
+         nics.id nic_id,
+         nics.uuid nic_uuid,
+         nics.network_id network_id,
+         nics.ip4_address ip_address,
+         nics.ip6_address ip6_address,
+         nics.ip6_gateway ip6_gateway,
+         nics.ip6_cidr ip6_cidr,
+         nics.default_nic is_default_nic,
+         nics.gateway gateway,
+         nics.netmask netmask,
+         nics.mac_address mac_address,
+         nics.broadcast_uri broadcast_uri,
+         nics.isolation_uri isolation_uri,
+         vpc.id vpc_id,
+         vpc.uuid vpc_uuid,
+         networks.uuid network_uuid,
+         networks.name network_name,
+         networks.traffic_type traffic_type,
+         networks.guest_type guest_type,
+         user_ip_address.id public_ip_id,
+         user_ip_address.uuid public_ip_uuid,
+         user_ip_address.public_ip_address public_ip_address,
+         ssh_keypairs.keypair_name keypair_name,
+         resource_tags.id tag_id,
+         resource_tags.uuid tag_uuid,
+         resource_tags.key tag_key,
+         resource_tags.value tag_value,
+         resource_tags.domain_id tag_domain_id,
+         resource_tags.account_id tag_account_id,
+         resource_tags.resource_id tag_resource_id,
+         resource_tags.resource_uuid tag_resource_uuid,
+         resource_tags.resource_type tag_resource_type,
+         resource_tags.customer tag_customer,
+         async_job.id job_id,
+         async_job.uuid job_uuid,
+         async_job.job_status job_status,
+         async_job.account_id job_account_id,
+ 		affinity_group.id affinity_group_id,
+         affinity_group.uuid affinity_group_uuid,
+         affinity_group.name affinity_group_name,
+         affinity_group.description affinity_group_description
+     from
+         `cloud`.`user_vm`
+             inner join
+         `cloud`.`vm_instance` ON vm_instance.id = user_vm.id
+             and vm_instance.removed is NULL
+             inner join
+         `cloud`.`account` ON vm_instance.account_id = account.id
+             inner join
+         `cloud`.`domain` ON vm_instance.domain_id = domain.id
+             left join
+         `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
+             left join
+         `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+             left join
+         `cloud`.`projects` ON projects.project_account_id = account.id
+             left join
+         `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
+             left join
+         `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
+             left join
+         `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+             left join
+         `cloud`.`host` ON vm_instance.host_id = host.id
+             left join
+         `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+             left join
+         `cloud`.`vm_template` iso ON iso.id = user_vm.iso_id
+             left join
+         `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+             left join
+         `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+             left join
+         `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
+             left join
+         `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+             left join
+         `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
+             left join
+         `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
+             left join
+         `cloud`.`nics` ON vm_instance.id = nics.instance_id
+             left join
+         `cloud`.`networks` ON nics.network_id = networks.id
+             left join
+         `cloud`.`vpc` ON networks.vpc_id = vpc.id
+             left join
+         `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
+             left join
+         `cloud`.`user_vm_details` ON user_vm_details.vm_id = vm_instance.id
+             and user_vm_details.name = 'SSH.PublicKey'
+             left join
+         `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
+             left join
+         `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
+             and resource_tags.resource_type = 'UserVm'
+             left join
+         `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+             and async_job.instance_type = 'VirtualMachine'
+             and async_job.job_status = 0
+             left join
+         `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
+ 			left join
+         `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id;
+ 
+ DROP VIEW IF EXISTS `cloud`.`affinity_group_view`;
+ CREATE VIEW `cloud`.`affinity_group_view` AS
+     select 
+         affinity_group.id id,
+         affinity_group.name name,
+         affinity_group.description description,
+         affinity_group.uuid uuid,
+         account.id account_id,
+         account.uuid account_uuid,
+         account.account_name account_name,
+         account.type account_type,
+         domain.id domain_id,
+         domain.uuid domain_uuid,
+         domain.name domain_name,
+         domain.path domain_path,
+         vm_instance.id vm_id,
+         vm_instance.uuid vm_uuid,
+         vm_instance.name vm_name,
+         vm_instance.state vm_state,
+         user_vm.display_name vm_display_name
+     from
+         `cloud`.`affinity_group`
+             inner join
+         `cloud`.`account` ON affinity_group.account_id = account.id
+             inner join
+         `cloud`.`domain` ON affinity_group.domain_id = domain.id
+             left join
+         `cloud`.`affinity_group_vm_map` ON affinity_group.id = affinity_group_vm_map.affinity_group_id
+             left join
+         `cloud`.`vm_instance` ON vm_instance.id = affinity_group_vm_map.instance_id
+             left join
+ 		`cloud`.`user_vm` ON user_vm.id = vm_instance.id;
+ 		
+ -- Re-enable foreign key checking, at the end of the upgrade path
+ SET foreign_key_checks = 1;			


Mime
View raw message