cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [49/50] [abbrv] Merged master to vmsync
Date Tue, 14 May 2013 00:43:12 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/com/cloud/async/AsyncJob.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/async/AsyncJob.java
index 7f03388,ccdc406..41afb79
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@@ -22,17 -22,40 +22,50 @@@ import org.apache.cloudstack.api.Intern
  import java.util.Date;
  
  public interface AsyncJob extends Identity, InternalIdentity {
 +	
 +	public enum JournalType { 
 +		SUCCESS, FAILURE 
 +	};
 +	
 +    String getType();
 +    
 +    String getDispatcher();
 +
 +    int getPendingSignals();
+     public enum Type {
+         None,
+         VirtualMachine,
+         DomainRouter,
+         Volume,
+         ConsoleProxy,
+         Snapshot,
+         Template,
+         Iso,
+         SystemVm,
+         Host,
+         StoragePool,
+         IpAddress,
+         SecurityGroup,
+         PhysicalNetwork,
+         TrafficType,
+         PhysicalNetworkServiceProvider,
+         FirewallRule,
+         Account,
+         User,
+         PrivateGateway,
+         StaticRoute,
+         Counter,
+         Condition,
+         AutoScalePolicy,
+         AutoScaleVmProfile,
+         AutoScaleVmGroup,
+         GlobalLoadBalancerRule,
+         LoadBalancerRule,
+         AffinityGroup,
+         InternalLbVm,
+         DedicatedGuestVlanRange
+     }
 -
 +    
      long getUserId();
  
      long getAccountId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/ApiCommandJobType.java
index fbe22ef,0000000..5de734a
mode 100644,000000..100644
--- a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
+++ b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
@@@ -1,48 -1,0 +1,52 @@@
 +// Licensed to the Apache Software Foundation (ASF) under one
 +// or more contributor license agreements.  See the NOTICE file
 +// distributed with this work for additional information
 +// regarding copyright ownership.  The ASF licenses this file
 +// to you under the Apache License, Version 2.0 (the
 +// "License"); you may not use this file except in compliance
 +// with the License.  You may obtain a copy of the License at
 +//
 +//   http://www.apache.org/licenses/LICENSE-2.0
 +//
 +// Unless required by applicable law or agreed to in writing,
 +// software distributed under the License is distributed on an
 +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +// KIND, either express or implied.  See the License for the
 +// specific language governing permissions and limitations
 +// under the License.
 +
 +package org.apache.cloudstack.api;
 +
 +public enum ApiCommandJobType {
 +    None,
 +    VirtualMachine,
 +    DomainRouter,
 +    Volume,
 +    ConsoleProxy,
 +    Snapshot,
 +    Template,
 +    Iso,
 +    SystemVm,
 +    Host,
 +    StoragePool,
 +    IpAddress,
 +    SecurityGroup,
 +    PhysicalNetwork,
 +    TrafficType,
 +    PhysicalNetworkServiceProvider,
 +    FirewallRule,
 +    Account,
 +    User,
 +    PrivateGateway,
 +    StaticRoute,
 +    Counter,
 +    Condition,
 +    AutoScalePolicy,
 +    AutoScaleVmProfile,
 +    AutoScaleVmGroup,
-     GlobalLoadBalancerRule
++    GlobalLoadBalancerRule,
++    LoadBalancerRule,
++    AffinityGroup,
++    InternalLbVm,
++    DedicatedGuestVlanRange
 +}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
index a33407e,69c6980..ee78442
--- a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
@@@ -19,9 -19,9 +19,10 @@@ package org.apache.cloudstack.api.comma
  import java.util.ArrayList;
  import java.util.EnumSet;
  import java.util.List;
+ import java.util.Map;
  
  import org.apache.cloudstack.api.APICommand;
 +import org.apache.cloudstack.api.ApiCommandJobType;
  import org.apache.cloudstack.api.ApiConstants;
  import org.apache.cloudstack.api.ApiConstants.HostDetails;
  import org.apache.cloudstack.api.BaseListCmd;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
index 0000000,e314b32..fd1ad57
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
@@@ -1,0 -1,151 +1,152 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.internallb;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.response.DomainRouterResponse;
+ import org.apache.cloudstack.api.response.HostResponse;
+ import org.apache.cloudstack.api.response.ListResponse;
+ import org.apache.cloudstack.api.response.NetworkResponse;
+ import org.apache.cloudstack.api.response.PodResponse;
+ import org.apache.cloudstack.api.response.UserVmResponse;
+ import org.apache.cloudstack.api.response.VpcResponse;
+ import org.apache.cloudstack.api.response.ZoneResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.network.router.VirtualRouter.Role;
+ 
+ @APICommand(name = "listInternalLoadBalancerVMs", description="List internal LB VMs.", responseObject=DomainRouterResponse.class)
+ public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd {
+     public static final Logger s_logger = Logger.getLogger(ListInternalLBVMsCmd.class.getName());
+ 
+     private static final String s_name = "listinternallbvmssresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
+             description="the host ID of the Internal LB VM")
+     private Long hostId;
+ 
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
+             description="the ID of the Internal LB VM")
+     private Long id;
+ 
+     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Internal LB VM")
+     private String routerName;
+ 
+     @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+             description="the Pod ID of the Internal LB VM")
+     private Long podId;
+ 
+     @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the Internal LB VM")
+     private String state;
+ 
+     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+             description="the Zone ID of the Internal LB VM")
+     private Long zoneId;
+ 
+     @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class,
+             description="list by network id")
+     private Long networkId;
+ 
+     @Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
+             description="List Internal LB VMs by VPC")
+     private Long vpcId;
+ 
+     @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC Internal LB VMs")
+     private Boolean forVpc;
+     
+     @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
+     private String zoneType;
+     
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public Long getHostId() {
+         return hostId;
+     }
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     public String getRouterName() {
+         return routerName;
+     }
+ 
+     public Long getPodId() {
+         return podId;
+     }
+ 
+     public String getState() {
+         return state;
+     }
+ 
+     public Long getZoneId() {
+         return zoneId;
+     }
+ 
+     public Long getNetworkId() {
+         return networkId;
+     }
+ 
+     public Long getVpcId() {
+         return vpcId;
+     }
+ 
+     public Boolean getForVpc() {
+         return forVpc;
+     }
+     
+     public String getRole() {
+         return Role.INTERNAL_LB_VM.toString();
+     }
+     
+     public String getZoneType() {
+         return zoneType;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.DomainRouter;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.DomainRouter;
+     }
+ 
+     @Override
+     public void execute(){
+         ListResponse<DomainRouterResponse> response = _queryService.searchForInternalLbVms(this);
+         response.setResponseName(getCommandName());
 -        this.setResponseObject(response);
++        setResponseObject(response);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
index 0000000,31d132b..5ca4f4f
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
@@@ -1,0 -1,120 +1,123 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.internallb;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.DomainRouterResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.InsufficientCapacityException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.network.router.VirtualRouter;
+ import com.cloud.network.router.VirtualRouter.Role;
+ import com.cloud.user.UserContext;
+ 
+ @APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
+ public class StartInternalLBVMCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(StartInternalLBVMCmd.class.getName());
+     private static final String s_name = "startinternallbvmresponse";
+ 
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainRouterResponse.class,
+             required=true, description="the ID of the internal lb vm")
+     private Long id;
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     public static String getResultObjectName() {
+         return "router";
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+         if (router != null && router.getRole() == Role.INTERNAL_LB_VM) {
+             return router.getAccountId();
+         } else {
+             throw new InvalidParameterValueException("Unable to find internal lb vm by id");
 -        } 
++        }
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_INTERNAL_LB_VM_START;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return  "starting internal lb vm: " + getId();
+     }
+ 
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.InternalLbVm;
++    @Override
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.InternalLbVm;
+     }
+ 
++    @Override
+     public Long getInstanceId() {
+         return getId();
+     }
+ 
+     @Override
+     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+         UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
+         VirtualRouter result = null;
+         VirtualRouter router = _routerService.findRouter(getId());
+         if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
+             throw new InvalidParameterValueException("Can't find internal lb vm by id");
+         } else {
+             result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
+         }
+         
+         if (result != null){
+             DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
+             routerResponse.setResponseName(getCommandName());
 -            this.setResponseObject(routerResponse);
++            setResponseObject(routerResponse);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
index 0000000,f40db49..be1887e
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
@@@ -1,0 -1,123 +1,124 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.internallb;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.DomainRouterResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.network.router.VirtualRouter;
+ import com.cloud.network.router.VirtualRouter.Role;
+ import com.cloud.user.UserContext;
+ 
+ @APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
+ public class StopInternalLBVMCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(StopInternalLBVMCmd.class.getName());
+     private static final String s_name = "stopinternallbvmresponse";
+ 
+     // ///////////////////////////////////////////////////
+     // ////////////// API parameters /////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class,
+             required = true, description = "the ID of the internal lb vm")
+     private Long id;
+ 
+     @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
+     private Boolean forced;
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////////// Accessors ///////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////// API Implementation///////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         VirtualRouter vm = _entityMgr.findById(VirtualRouter.class, getId());
+         if (vm != null && vm.getRole() == Role.INTERNAL_LB_VM) {
+             return vm.getAccountId();
+         } else {
+             throw new InvalidParameterValueException("Unable to find internal lb vm by id");
+         }
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_INTERNAL_LB_VM_STOP;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "stopping internal lb vm: " + getId();
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.InternalLbVm;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.InternalLbVm;
+     }
+ 
+     @Override
+     public Long getInstanceId() {
+         return getId();
+     }
+ 
+     public boolean isForced() {
+         return (forced != null) ? forced : false;
+     }
+ 
+     @Override
+     public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
+         UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
+         VirtualRouter result = null;
+         VirtualRouter vm = _routerService.findRouter(getId());
+         if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
+             throw new InvalidParameterValueException("Can't find internal lb vm by id");
+         } else {
+             result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
 -        } 
++        }
+         
+         if (result != null) {
+             DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
+             response.setResponseName(getCommandName());
 -            this.setResponseObject(response);
++            setResponseObject(response);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop internal lb vm");
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
index 0000000,76cb42d..c06bd51
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
@@@ -1,0 -1,94 +1,99 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ 
+ package org.apache.cloudstack.api.command.admin.network;
+ 
 -import com.cloud.async.AsyncJob;
++import org.apache.log4j.Logger;
++
++import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
++import org.apache.cloudstack.api.ApiConstants;
++import org.apache.cloudstack.api.ApiErrorCode;
++import org.apache.cloudstack.api.BaseAsyncCmd;
++import org.apache.cloudstack.api.Parameter;
++import org.apache.cloudstack.api.ServerApiException;
++import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
++import org.apache.cloudstack.api.response.SuccessResponse;
++
+ import com.cloud.event.EventTypes;
 -import com.cloud.exception.ResourceInUseException;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
 -import org.apache.cloudstack.api.*;
 -import org.apache.cloudstack.api.response.CounterResponse;
 -import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
 -import org.apache.cloudstack.api.response.SuccessResponse;
 -import org.apache.log4j.Logger;
+ 
+ @APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class)
+ public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedGuestVlanRangeCmd.class.getName());
+     private static final String s_name = "releasededicatedguestvlanrangeresponse";
+ 
+     // ///////////////////////////////////////////////////
+     // ////////////// API parameters /////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
+             required=true, description="the ID of the dedicated guest vlan range")
+     private Long id;
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////////// Accessors ///////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.DedicatedGuestVlanRange;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.DedicatedGuestVlanRange;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         return Account.ACCOUNT_ID_SYSTEM;
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "Releasing a dedicated guest vlan range.";
+     }
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////// API Implementation///////////////////
+     // ///////////////////////////////////////////////////
+ 
+ 
+     @Override
+     public void execute(){
+         UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
+         boolean result = _networkService.releaseDedicatedGuestVlanRange(getId());
+         if (result) {
+             SuccessResponse response = new SuccessResponse(getCommandName());
 -            this.setResponseObject(response);
++            setResponseObject(response);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release dedicated guest vlan range");
+         }
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
index 94480e0,78c3554..c21102c
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
@@@ -115,7 -122,11 +123,11 @@@ public class ListRoutersCmd extends Bas
      public Boolean getForVpc() {
          return forVpc;
      }
 -    
 +
+     public String getRole() {
+         return Role.VIRTUAL_ROUTER.toString();
+     }
+ 
      /////////////////////////////////////////////////////
      /////////////// API Implementation///////////////////
      /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java
index 0000000,37d007c..e8c7447
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java
@@@ -1,0 -1,98 +1,100 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.storage;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ 
 -import org.apache.cloudstack.api.APICommand;
+ import org.apache.log4j.Logger;
+ 
++import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.BaseListCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.response.ListResponse;
+ import org.apache.cloudstack.api.response.StoragePoolForMigrationResponse;
+ import org.apache.cloudstack.api.response.VolumeResponse;
 -import com.cloud.async.AsyncJob;
++
+ import com.cloud.storage.StoragePool;
+ import com.cloud.utils.Pair;
+ 
+ @APICommand(name = "findStoragePoolsForMigration", description="Lists storage pools available for migration of a volume.",
+     responseObject=StoragePoolForMigrationResponse.class)
+ public class FindStoragePoolsForMigrationCmd extends BaseListCmd {
+     public static final Logger s_logger = Logger.getLogger(FindStoragePoolsForMigrationCmd.class.getName());
+ 
+     private static final String s_name = "findstoragepoolsformigrationresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VolumeResponse.class, required=true,
+             description="the ID of the volume")
+     private Long id;
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.StoragePool;
++    @Override
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.StoragePool;
+     }
+ 
+     @Override
+     public void execute() {
+         Pair<List<? extends StoragePool>, List<? extends StoragePool>> pools =
+                 _mgr.listStoragePoolsForMigrationOfVolume(getId());
+         ListResponse<StoragePoolForMigrationResponse> response = new ListResponse<StoragePoolForMigrationResponse>();
+         List<StoragePoolForMigrationResponse> poolResponses = new ArrayList<StoragePoolForMigrationResponse>();
+ 
+         List<? extends StoragePool> allPools = pools.first();
+         List<? extends StoragePool> suitablePoolList = pools.second();
+         for (StoragePool pool : allPools) {
+             StoragePoolForMigrationResponse poolResponse = _responseGenerator.createStoragePoolForMigrationResponse(pool);
+             Boolean suitableForMigration = false;
+             for (StoragePool suitablePool : suitablePoolList) {
+                 if (suitablePool.getId() == pool.getId()) {
+                     suitableForMigration = true;
+                     break;
+                 }
+             }
+             poolResponse.setSuitableForMigration(suitableForMigration);
+             poolResponse.setObjectName("storagepool");
+             poolResponses.add(poolResponse);
+         }
+ 
+         response.setResponses(poolResponses);
+         response.setResponseName(getCommandName());
 -        this.setResponseObject(response);
++        setResponseObject(response);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
index 0000000,96de4aa..a160892
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
@@@ -1,0 -1,167 +1,168 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.affinitygroup;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.affinity.AffinityGroup;
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.DomainResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.ResourceAllocationException;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+ 
+ @APICommand(name = "createAffinityGroup", responseObject = AffinityGroupResponse.class, description = "Creates an affinity/anti-affinity group")
+ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
+     public static final Logger s_logger = Logger.getLogger(CreateAffinityGroupCmd.class.getName());
+ 
+     private static final String s_name = "createaffinitygroupresponse";
+ 
+     // ///////////////////////////////////////////////////
+     // ////////////// API parameters /////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the affinity group. Must be used with domainId.")
+     private String accountName;
+ 
+     @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the affinity group", entityType = DomainResponse.class)
+     private Long domainId;
+ 
+     @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the affinity group")
+     private String description;
+ 
+     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the affinity group")
+     private String affinityGroupName;
+ 
+     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, description = "Type of the affinity group from the available affinity/anti-affinity group types")
+     private String affinityGroupType;
+ 
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////////// Accessors ///////////////////////
+     // ///////////////////////////////////////////////////
+ 
+     public String getAccountName() {
+         return accountName;
+     }
+ 
+     public String getDescription() {
+         return description;
+     }
+ 
+     public Long getDomainId() {
+         return domainId;
+     }
+ 
+     public String getAffinityGroupName() {
+         return affinityGroupName;
+     }
+ 
+     public String getAffinityGroupType() {
+         return affinityGroupType;
+     }
+ 
+     // ///////////////////////////////////////////////////
+     // ///////////// API Implementation///////////////////
+     // ///////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         Account account = UserContext.current().getCaller();
+         if ((account == null) || isAdmin(account.getType())) {
+             if ((domainId != null) && (accountName != null)) {
+                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+                 if (userAccount != null) {
+                     return userAccount.getId();
+                 }
+             }
+         }
+ 
+         if (account != null) {
+             return account.getId();
+         }
+ 
+         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this
+                                           // command to SYSTEM so ERROR events
+                                           // are tracked
+     }
+ 
+     @Override
+     public void execute() {
+         AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
+         if (group != null) {
+             AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group);
+             response.setResponseName(getCommandName());
 -            this.setResponseObject(response);
++            setResponseObject(response);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group:"
+                     + affinityGroupName);
+         }
+     }
+ 
+     @Override
+     public void create() throws ResourceAllocationException {
+         AffinityGroup result = _affinityGroupService.createAffinityGroup(accountName, domainId, affinityGroupName,
+                 affinityGroupType, description);
+         if (result != null) {
+             setEntityId(result.getId());
+             setEntityUuid(result.getUuid());
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group entity" + affinityGroupName);
+         }
+ 
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_AFFINITY_GROUP_CREATE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "creating Affinity Group";
+     }
+ 
+     @Override
+     public String getCreateEventType() {
+         return EventTypes.EVENT_AFFINITY_GROUP_CREATE;
+     }
+ 
+     @Override
+     public String getCreateEventDescription() {
+         return "creating Affinity Group";
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.AffinityGroup;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.AffinityGroup;
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
index 0000000,ea4a010..0eb6a4c
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
@@@ -1,0 -1,154 +1,155 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.affinitygroup;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.DomainResponse;
+ import org.apache.cloudstack.api.response.SuccessResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceInUseException;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+ 
+ @APICommand(name = "deleteAffinityGroup", description = "Deletes affinity group", responseObject = SuccessResponse.class)
+ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(DeleteAffinityGroupCmd.class.getName());
+     private static final String s_name = "deleteaffinitygroupresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account of the affinity group. Must be specified with domain ID")
+     private String accountName;
+ 
+     @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "the domain ID of account owning the affinity group", entityType = DomainResponse.class)
+     private Long domainId;
+ 
+     @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the affinity group. Mutually exclusive with name parameter", entityType = AffinityGroupResponse.class)
+     private Long id;
+ 
+     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the affinity group. Mutually exclusive with id parameter")
+     private String name;
+ 
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public String getAccountName() {
+         return accountName;
+     }
+ 
+     public Long getDomainId() {
+         return domainId;
+     }
+ 
+ 
+     public Long getId() {
+         if (id != null && name != null) {
+             throw new InvalidParameterValueException("name and id parameters are mutually exclusive");
+         }
+ 
+         if (name != null) {
+             id = _responseGenerator.getAffinityGroupId(name, getEntityOwnerId());
+             if (id == null) {
+                 throw new InvalidParameterValueException("Unable to find affinity group by name " + name
+                         + " for the account id=" + getEntityOwnerId());
+             }
+         }
+ 
+         if (id == null) {
+             throw new InvalidParameterValueException(
+                     "Either id or name parameter is requred by deleteAffinityGroup command");
+         }
+ 
+         return id;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         Account account = UserContext.current().getCaller();
+         if ((account == null) || isAdmin(account.getType())) {
+             if ((domainId != null) && (accountName != null)) {
+                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+                 if (userAccount != null) {
+                     return userAccount.getId();
+                 }
+             }
+         }
+ 
+         if (account != null) {
+             return account.getId();
+         }
+ 
+         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this
+                                           // command to SYSTEM so ERROR events
+                                           // are tracked
+ 
+     }
+ 
+     @Override
+     public void execute(){
+         try{
+             boolean result = _affinityGroupService.deleteAffinityGroup(id, accountName, domainId, name);
+             if (result) {
+                 SuccessResponse response = new SuccessResponse(getCommandName());
 -                this.setResponseObject(response);
++                setResponseObject(response);
+             } else {
+                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete affinity group");
+             }
+         } catch (ResourceInUseException ex) {
+             s_logger.warn("Exception: ", ex);
+             throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
+         }
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_AFFINITY_GROUP_DELETE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "Deleting Affinity Group";
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.AffinityGroup;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.AffinityGroup;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
index 0000000,9310fb9..f92c53e
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
@@@ -1,0 -1,90 +1,90 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.affinitygroup;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.BaseListCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.response.ListResponse;
+ import org.apache.cloudstack.api.response.UserVmResponse;
 -import org.apache.log4j.Logger;
 -
 -import com.cloud.async.AsyncJob;
+ 
+ @APICommand(name = "listAffinityGroups", description = "Lists affinity groups", responseObject = AffinityGroupResponse.class)
+ public class ListAffinityGroupsCmd extends BaseListCmd {
+     public static final Logger s_logger = Logger.getLogger(ListAffinityGroupsCmd.class.getName());
+ 
+     private static final String s_name = "listaffinitygroupsresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists affinity groups by name")
+     private String affinityGroupName;
+ 
+     @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, description = "lists affinity groups by virtual machine id", entityType = UserVmResponse.class)
+     private Long virtualMachineId;
+ 
+     @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the affinity group by the id provided", entityType = AffinityGroupResponse.class)
+     private Long id;
+ 
+     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "lists affinity groups by type")
+     private String affinityGroupType;
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+     public String getAffinityGroupName() {
+         return affinityGroupName;
+     }
+ 
+     public Long getVirtualMachineId() {
+         return virtualMachineId;
+     }
+ 
+     public Long getId(){
+         return id;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public void execute(){
+ 
+         ListResponse<AffinityGroupResponse> response = _queryService.listAffinityGroups(id, affinityGroupName,
 -                affinityGroupType, virtualMachineId, this.getStartIndex(), this.getPageSizeVal());
++                affinityGroupType, virtualMachineId, getStartIndex(), getPageSizeVal());
+         response.setResponseName(getCommandName());
 -        this.setResponseObject(response);
++        setResponseObject(response);
+ 
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.AffinityGroup;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.AffinityGroup;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java
index 0000000,44d017b..ae8b682
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java
@@@ -1,0 -1,164 +1,165 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.affinitygroup;
+ 
+ import java.util.ArrayList;
+ import java.util.EnumSet;
+ import java.util.List;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
+ import org.apache.cloudstack.api.ACL;
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
++import org.apache.cloudstack.api.ApiConstants.VMDetails;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
 -import org.apache.cloudstack.api.ApiConstants.VMDetails;
+ import org.apache.cloudstack.api.response.UserVmResponse;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.InsufficientCapacityException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+ import com.cloud.uservm.UserVm;
+ 
+ 
+ @APICommand(name = "updateVMAffinityGroup", description = "Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the "
+         + "new properties to take effect.", responseObject = UserVmResponse.class)
+ public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(UpdateVMAffinityGroupCmd.class.getName());
+     private static final String s_name = "updatevirtualmachineresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+ 
+     @ACL
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
+             required=true, description="The ID of the virtual machine")
+     private Long id;
+ 
+     @ACL
+     @Parameter(name = ApiConstants.AFFINITY_GROUP_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups id that are going to be applied to the virtual machine. "
+             + "Should be passed only when vm is created from a zone with Basic Network support."
+             + " Mutually exclusive with securitygroupnames parameter")
+     private List<Long> affinityGroupIdList;
+ 
+     @ACL
+     @Parameter(name = ApiConstants.AFFINITY_GROUP_NAMES, type = CommandType.LIST, collectionType = CommandType.STRING, entityType = AffinityGroupResponse.class, description = "comma separated list of affinity groups names that are going to be applied to the virtual machine."
+             + " Should be passed only when vm is created from a zone with Basic Network support. "
+             + "Mutually exclusive with securitygroupids parameter")
+     private List<String> affinityGroupNameList;
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+ 
+     public List<Long> getAffinityGroupIdList() {
+         if (affinityGroupNameList != null && affinityGroupIdList != null) {
+             throw new InvalidParameterValueException(
+                     "affinitygroupids parameter is mutually exclusive with affinitygroupnames parameter");
+         }
+ 
+         // transform group names to ids here
+         if (affinityGroupNameList != null) {
+             List<Long> affinityGroupIds = new ArrayList<Long>();
+             for (String groupName : affinityGroupNameList) {
+                 Long groupId = _responseGenerator.getAffinityGroupId(groupName, getEntityOwnerId());
+                 if (groupId == null) {
+                     throw new InvalidParameterValueException("Unable to find group by name " + groupName
+                             + " for account " + getEntityOwnerId());
+                 } else {
+                     affinityGroupIds.add(groupId);
+                 }
+             }
+             return affinityGroupIds;
+         } else {
+             return affinityGroupIdList;
+         }
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     public static String getResultObjectName() {
+         return "virtualmachine";
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         UserVm userVm = _entityMgr.findById(UserVm.class, getId());
+         if (userVm != null) {
+             return userVm.getAccountId();
+         }
+ 
+         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+     }
+ 
+     @Override
+     public void execute() throws ResourceUnavailableException,
+             InsufficientCapacityException, ServerApiException {
+         UserContext.current().setEventDetails("Vm Id: "+getId());
+         UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList());
+         ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
+         dc.add(VMDetails.valueOf("affgrp"));
+         EnumSet<VMDetails> details = EnumSet.copyOf(dc);
+ 
+         if (result != null){
+             UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0);
+             response.setResponseName(getCommandName());
 -            this.setResponseObject(response);
++            setResponseObject(response);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups");
+         }
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_VM_AFFINITY_GROUP_UPDATE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "updating VM Affinity Group";
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.AffinityGroup;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.AffinityGroup;
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
index 0000000,17ae959..2dee1ff
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
@@@ -1,0 -1,218 +1,219 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.loadbalancer;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
+ import org.apache.cloudstack.api.response.NetworkResponse;
+ import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.InsufficientAddressCapacityException;
+ import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.NetworkRuleConflictException;
+ import com.cloud.exception.ResourceAllocationException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.network.Network;
+ import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+ import com.cloud.user.UserContext;
+ import com.cloud.utils.net.NetUtils;
+ 
+ @APICommand(name = "createLoadBalancer", description="Creates a Load Balancer", responseObject=ApplicationLoadBalancerResponse.class, since="4.2.0")
+ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
+     public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName());
+ 
+     private static final String s_name = "createloadbalancerresponse";
+ 
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the Load Balancer")
+     private String loadBalancerName;
+     
+     @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the Load Balancer", length=4096)
+     private String description;
+     
+     @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, required=true, entityType = NetworkResponse.class,
+             description="The guest network the Load Balancer will be created for")
+     private Long networkId;
+     
+     @Parameter(name=ApiConstants.SOURCE_PORT, type=CommandType.INTEGER, required=true, description="the source port the network traffic will be load balanced from")
+     private Integer sourcePort;
+ 
+     @Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required=true, description="load balancer algorithm (source, roundrobin, leastconn)")
+     private String algorithm;
+ 
+     @Parameter(name=ApiConstants.INSTANCE_PORT, type=CommandType.INTEGER, required=true, description="the TCP port of the virtual machine where the network traffic will be load balanced to")
+     private Integer instancePort;
+ 
+     @Parameter(name=ApiConstants.SOURCE_IP, type=CommandType.STRING, description="the source ip address the network traffic will be load balanced from")
+     private String sourceIp;
+     
+     @Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, required=true,
+             description="the network id of the source ip address")
+     private Long sourceIpNetworkId;
+     
+     @Parameter(name=ApiConstants.SCHEME, type=CommandType.STRING, required=true, description="the load balancer scheme. Supported value in this release is Internal")
+     private String scheme;
+ 
+ 
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public String getAlgorithm() {
+         return algorithm;
+     }
+ 
+     public String getDescription() {
+         return description;
+     }
+ 
+     public String getLoadBalancerName() {
+         return loadBalancerName;
+     }
+ 
+     public Integer getPrivatePort() {
+         return instancePort;
+     }
+ 
+     public long getNetworkId() {
+         return networkId;
+     }
+ 
+     public String getName() {
+         return loadBalancerName;
+     }
+     
+     public Integer getSourcePort() {
+         return sourcePort.intValue();
+     }
+ 
+     public String getProtocol() {
+         return NetUtils.TCP_PROTO;
+     }
+ 
+     public long getAccountId() {
+         //get account info from the network object
+         Network ntwk = _networkService.getNetwork(networkId);
+         if (ntwk == null) {
+             throw new InvalidParameterValueException("Invalid network id specified");
+         }
+        
+         return ntwk.getAccountId();
+         
+     }
+ 
+     public int getInstancePort() {
+         return instancePort.intValue();
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_LOAD_BALANCER_CREATE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "creating load balancer: " + getName() + " account: " + getAccountId();
+ 
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.LoadBalancerRule;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.LoadBalancerRule;
+     }
+     
+     public String getSourceIp() {
+         return sourceIp;
+     }
+ 
+     public long getSourceIpNetworkId() {
+         return sourceIpNetworkId;
+     }
+ 
+     public Scheme getScheme() {
+         if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
+             return Scheme.Internal;
+         } else {
+             throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
+         }
+     }
+     
+     @Override
+     public long getEntityOwnerId() {
+        return getAccountId();
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public void execute() throws ResourceAllocationException, ResourceUnavailableException {
+         ApplicationLoadBalancerRule rule = null;
+         try {
+             UserContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
+             // State might be different after the rule is applied, so get new object here
+             rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
+             ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
+             setResponseObject(lbResponse);
+             lbResponse.setResponseName(getCommandName());
+         } catch (Exception ex) {
+             s_logger.warn("Failed to create Load Balancer due to exception ", ex);
+         } finally {
+             if (rule == null) {
+                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer");
+             }
+         }
+     }
+ 
+     @Override
+     public void create() {
+         try {
+             
+             ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(),
+                     getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId());
 -            this.setEntityId(result.getId());
 -            this.setEntityUuid(result.getUuid());
++            setEntityId(result.getId());
++            setEntityUuid(result.getUuid());
+         }catch (NetworkRuleConflictException e) {
+             s_logger.warn("Exception: ", e);
+             throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
+         } catch (InsufficientAddressCapacityException e) {
+             s_logger.warn("Exception: ", e);
+             throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+         } catch (InsufficientVirtualNetworkCapcityException e) {
+             s_logger.warn("Exception: ", e);
+             throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+         }
+     }
+ }
+ 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
index 0000000,bc6cd09..08159fb
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
@@@ -1,0 -1,116 +1,117 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.user.loadbalancer;
+ 
++import org.apache.log4j.Logger;
++
+ import org.apache.cloudstack.api.APICommand;
++import org.apache.cloudstack.api.ApiCommandJobType;
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.FirewallRuleResponse;
+ import org.apache.cloudstack.api.response.SuccessResponse;
+ import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 -import org.apache.log4j.Logger;
+ 
 -import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.user.UserContext;
+ 
+ @APICommand(name = "deleteLoadBalancer", description="Deletes a load balancer", responseObject=SuccessResponse.class, since="4.2.0")
+ public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
+     public static final Logger s_logger = Logger.getLogger(DeleteApplicationLoadBalancerCmd.class.getName());
+     private static final String s_name = "deleteloadbalancerresponse";
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
+             required=true, description="the ID of the Load Balancer")
+     private Long id;
+ 
+ 
+     /////////////////////////////////////////////////////
+     /////////////////// Accessors ///////////////////////
+     /////////////////////////////////////////////////////
+ 
+     public Long getId() {
+         return id;
+     }
+ 
+     /////////////////////////////////////////////////////
+     /////////////// API Implementation///////////////////
+     /////////////////////////////////////////////////////
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId());
+         if (lb != null) {
+             return lb.getAccountId();
+         } else {
+             throw new InvalidParameterValueException("Can't find load balancer by id specified");
+         }
+     }
+ 
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_LOAD_BALANCER_DELETE;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return  "deleting load balancer: " + getId();
+     }
+ 
+     @Override
+     public void execute(){
+         UserContext.current().setEventDetails("Load balancer Id: " + getId());
+         boolean result = _appLbService.deleteApplicationLoadBalancer(getId());
+ 
+         if (result) {
+             SuccessResponse response = new SuccessResponse(getCommandName());
 -            this.setResponseObject(response);
++            setResponseObject(response);
+         } else {
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer");
+         }
+     }
+ 
+     @Override
+     public String getSyncObjType() {
+         return BaseAsyncCmd.networkSyncObject;
+     }
+ 
+     @Override
+     public Long getSyncObjId() {
+         ApplicationLoadBalancerRule lb = _appLbService.getApplicationLoadBalancer(id);
+         if(lb == null){
+             throw new InvalidParameterValueException("Unable to find load balancer by id ");
+         }
+         return lb.getNetworkId();
+     }
+ 
+     @Override
 -    public AsyncJob.Type getInstanceType() {
 -        return AsyncJob.Type.FirewallRule;
++    public ApiCommandJobType getInstanceType() {
++        return ApiCommandJobType.FirewallRule;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
index 04e627c,d7e6bc8..fa71c05
--- a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
@@@ -59,7 -58,10 +59,10 @@@ public class ListSnapshotsCmd extends B
      @Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.UUID, entityType = VolumeResponse.class,
              description="the ID of the disk volume")
      private Long volumeId;
 -    
 +
+     @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
+     private String zoneType;
+ 
      /////////////////////////////////////////////////////
      /////////////////// Accessors ///////////////////////
      /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 28a623a,3ed08d2..ffed07e
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@@ -25,9 -25,9 +25,10 @@@ import java.util.List
  import java.util.Map;
  
  import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
  import org.apache.cloudstack.api.ACL;
  import org.apache.cloudstack.api.APICommand;
 +import org.apache.cloudstack.api.ApiCommandJobType;
  import org.apache.cloudstack.api.ApiConstants;
  import org.apache.cloudstack.api.ApiErrorCode;
  import org.apache.cloudstack.api.BaseAsyncCreateCmd;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
index c73e570,b2a2ce0..0748209
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java
@@@ -20,8 -20,8 +20,9 @@@ import java.util.ArrayList
  import java.util.EnumSet;
  import java.util.List;
  
+ import org.apache.cloudstack.affinity.AffinityGroupResponse;
  import org.apache.cloudstack.api.APICommand;
 +import org.apache.cloudstack.api.ApiCommandJobType;
  import org.apache.cloudstack.api.ApiConstants;
  import org.apache.cloudstack.api.ApiConstants.VMDetails;
  import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/client/pom.xml
----------------------------------------------------------------------
diff --cc client/pom.xml
index 066f6f0,197ba27..4a54e6a
--- a/client/pom.xml
+++ b/client/pom.xml
@@@ -85,8 -85,13 +85,13 @@@
        <artifactId>cloud-plugin-network-midonet</artifactId>
        <version>${project.version}</version>
      </dependency>
 -  <dependency>
 +    <dependency>
        <groupId>org.apache.cloudstack</groupId>
+       <artifactId>cloud-plugin-network-internallb</artifactId>
+       <version>${project.version}</version>
+     </dependency>
+     <dependency>
+       <groupId>org.apache.cloudstack</groupId>
        <artifactId>cloud-plugin-hypervisor-xen</artifactId>
        <version>${project.version}</version>
      </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4039743/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/applicationContext.xml.in
index 2c6f0f2,67c8ccf..9e6748a
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@@ -165,9 -165,11 +165,9 @@@
    <bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
    <bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
    <bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
+   <bean id="accountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
    <bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
-   <bean id="agentUpgradeDaoImpl" class="com.cloud.maint.dao.AgentUpgradeDaoImpl" />
    <bean id="alertDaoImpl" class="com.cloud.alert.dao.AlertDaoImpl" />
 -  <bean id="asyncJobDaoImpl" class="com.cloud.async.dao.AsyncJobDaoImpl" />
 -  <bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
    <bean id="autoScalePolicyConditionMapDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyConditionMapDaoImpl" />
    <bean id="autoScalePolicyDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyDaoImpl" />
    <bean id="autoScaleVmGroupDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupDaoImpl" />
@@@ -605,8 -617,9 +613,9 @@@
      <property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
      <property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
      <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+ 	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
    </bean>
 -  
 +
    <bean id="storageManagerImpl" class="com.cloud.storage.StorageManagerImpl">
      <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
    </bean>
@@@ -690,9 -705,9 +699,8 @@@
    <bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" />
    <bean id="storageNetworkManagerImpl" class="com.cloud.network.StorageNetworkManagerImpl" />
    <bean id="swiftManagerImpl" class="com.cloud.storage.swift.SwiftManagerImpl" />
 -  <bean id="syncQueueManagerImpl" class="com.cloud.async.SyncQueueManagerImpl" />
    <bean id="taggedResourceManagerImpl" class="com.cloud.tags.TaggedResourceManagerImpl" />
    <bean id="templateManagerImpl" class="com.cloud.template.TemplateManagerImpl" />
-   <bean id="upgradeManagerImpl" class="com.cloud.maint.UpgradeManagerImpl" />
    <bean id="uploadMonitorImpl" class="com.cloud.storage.upload.UploadMonitorImpl" />
    <bean id="usageServiceImpl" class="com.cloud.usage.UsageServiceImpl" />
    <bean id="virtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VirtualNetworkApplianceManagerImpl" />
@@@ -779,9 -794,9 +788,11 @@@
    <bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
    <bean id="volumeManagerImpl" class="com.cloud.storage.VolumeManagerImpl" />
    <bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl" />
+   <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
+   <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
  
 +  <bean id="VirtualMachinePowerStateSyncImpl" class="com.cloud.vm.VirtualMachinePowerStateSyncImpl" />
 +
  
  <!--=======================================================================================================-->
  <!--                                                                                                       -->
@@@ -857,5 -847,18 +868,18 @@@
    <bean id="baremetalDhcpDaoImpl" class="com.cloud.baremetal.database.BaremetalDhcpDaoImpl" />
    <bean id="baremetalPxeDaoImpl" class="com.cloud.baremetal.database.BaremetalPxeDaoImpl" />
  -->
 -
 +  
+   <bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl"/>
+   <bean id="DeploymentPlanningManager" class="com.cloud.deploy.DeploymentPlanningManagerImpl">
+     <property name="Planners" value="#{deploymentPlanners.Adapters}" />
+ 	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
+   </bean>
+   
+   <bean id="AffinityGroupJoinDaoImpl" class="com.cloud.api.query.dao.AffinityGroupJoinDaoImpl">
+   </bean>
+   <bean id="AffinityGroupDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl">
+   </bean>
+   <bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl">
+   </bean>
+   
  </beans>


Mime
View raw message