You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 20:32:06 UTC

[5/18] git commit: api_refactor: refactor loadbalancer apis

api_refactor: refactor loadbalancer apis

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/api_refactoring
Commit: 456b852c0cd4d8fbd2d5dcd02181bcb7828df84e
Parents: 8773fc2
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Dec 4 11:25:20 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Dec 4 11:25:20 2012 -0800

----------------------------------------------------------------------
 .../api/commands/AssignToLoadBalancerRuleCmd.java  |  121 -----
 .../api/commands/CreateLBStickinessPolicyCmd.java  |  161 ------
 .../api/commands/CreateLoadBalancerRuleCmd.java    |  381 ---------------
 .../api/commands/DeleteLBStickinessPolicyCmd.java  |  116 -----
 .../api/commands/DeleteLoadBalancerRuleCmd.java    |  118 -----
 .../api/commands/ListLBStickinessPoliciesCmd.java  |   90 ----
 .../commands/ListLoadBalancerRuleInstancesCmd.java |   83 ----
 .../api/commands/ListLoadBalancerRulesCmd.java     |  113 -----
 .../commands/RemoveFromLoadBalancerRuleCmd.java    |  121 -----
 .../api/commands/UpdateLoadBalancerRuleCmd.java    |  116 -----
 .../network/lb/LoadBalancingRulesService.java      |   10 +-
 .../lb/command/AssignToLoadBalancerRuleCmd.java    |  121 +++++
 .../lb/command/CreateLBStickinessPolicyCmd.java    |  161 ++++++
 .../user/lb/command/CreateLoadBalancerRuleCmd.java |  381 +++++++++++++++
 .../lb/command/DeleteLBStickinessPolicyCmd.java    |  116 +++++
 .../user/lb/command/DeleteLoadBalancerRuleCmd.java |  118 +++++
 .../lb/command/ListLBStickinessPoliciesCmd.java    |   90 ++++
 .../command/ListLoadBalancerRuleInstancesCmd.java  |   83 ++++
 .../user/lb/command/ListLoadBalancerRulesCmd.java  |  113 +++++
 .../lb/command/RemoveFromLoadBalancerRuleCmd.java  |  121 +++++
 .../user/lb/command/UpdateLoadBalancerRuleCmd.java |  116 +++++
 client/tomcatconf/commands.properties.in           |   20 +-
 .../network/lb/ElasticLoadBalancerManager.java     |    2 +-
 .../network/lb/ElasticLoadBalancerManagerImpl.java |    2 +-
 .../network/lb/LoadBalancingRulesManager.java      |    2 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   10 +-
 26 files changed, 1441 insertions(+), 1445 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java
deleted file mode 100644
index fc99113..0000000
--- a/api/src/com/cloud/api/commands/AssignToLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,121 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-import com.cloud.utils.StringUtils;
-
-@Implementation(description="Assigns virtual machine or a list of virtual machines to a load balancer rule.", responseObject=SuccessResponse.class)
-public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(AssignToLoadBalancerRuleCmd.class.getName());
-
-    private static final String s_name = "assigntoloadbalancerruleresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the load balancer rule")
-    private Long id;
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, required=true, description="the list of IDs of the virtual machine that are being assigned to the load balancer rule(i.e. virtualMachineIds=1,2,3)")
-    private List<Long> virtualMachineIds;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getLoadBalancerId() {
-        return id;
-    }
-
-    public List<Long> getVirtualMachineIds() {
-        return virtualMachineIds;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLoadBalancerId());
-        if (lb == null) {
-            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
-        }
-        return lb.getAccountId();
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_ASSIGN_TO_LOAD_BALANCER_RULE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "applying instances for load balancer: " + getLoadBalancerId() + " (ids: " + StringUtils.join(getVirtualMachineIds(), ",") + ")";
-    }
-
-    @Override
-    public void execute(){
-        UserContext.current().setEventDetails("Load balancer Id: "+getLoadBalancerId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
-        boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds);
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign load balancer rule");
-        }
-    }
-
-    @Override
-    public String getSyncObjType() {
-        return BaseAsyncCmd.networkSyncObject;
-    }
-
-    @Override
-    public Long getSyncObjId() {
-        LoadBalancer lb = _lbService.findById(id);
-        if(lb == null){
-            throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
-        }
-        return lb.getNetworkId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java b/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
deleted file mode 100644
index 2ea726e..0000000
--- a/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
+++ /dev/null
@@ -1,161 +0,0 @@
-// 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 com.cloud.api.commands;
-
-
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCreateCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.api.response.LBStickinessResponse;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-
-@Implementation(description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since="3.0.0")
-@SuppressWarnings("rawtypes")
-public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
-    public static final Logger s_logger = Logger
-            .getLogger(CreateLBStickinessPolicyCmd.class.getName());
-
-    private static final String s_name = "createLBStickinessPolicy";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
-    private Long lbRuleId;
-
-    @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the LB Stickiness policy")
-    private String description;
-
-    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the LB Stickiness policy")
-    private String lbStickinessPolicyName;
-
-    @Parameter(name = ApiConstants.METHOD_NAME, type = CommandType.STRING, required = true, description = "name of the LB Stickiness policy method, possible values can be obtained from ListNetworks API ")
-    private String stickinessMethodName;
-
-    @Parameter(name = ApiConstants.PARAM_LIST, type = CommandType.MAP, description = "param list. Example: param[0].name=cookiename&param[0].value=LBCookie ")
-    private Map paramList;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getLbRuleId() {
-        return lbRuleId;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public String getLBStickinessPolicyName() {
-        return lbStickinessPolicyName;
-    }
-
-    public String getStickinessMethodName() {
-        return stickinessMethodName;
-    }
-
-    public Map getparamList() {
-        return paramList;
-    }
-
-    public String getEntityTable() {
-        return "firewall_rules";
-    }
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Account account = UserContext.current().getCaller();
-        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() throws ResourceAllocationException, ResourceUnavailableException {
-        StickinessPolicy policy = null;
-        boolean success = false;
-
-        try {
-            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
-            success = _lbService.applyLBStickinessPolicy(this);
-            if (success) {
-                // State might be different after the rule is applied, so get new object here
-                policy = _entityMgr.findById(StickinessPolicy.class, getEntityId());
-                LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
-                LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
-                setResponseObject(spResponse);
-                spResponse.setResponseName(getCommandName());
-            }
-        } finally {
-            if (!success || (policy == null)) {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
-            }
-        }
-    }
-
-    @Override
-    public void create() {
-        try {
-            StickinessPolicy result = _lbService.createLBStickinessPolicy(this);
-            this.setEntityId(result.getId());
-        } catch (NetworkRuleConflictException e) {
-            s_logger.warn("Exception: ", e);
-            throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
-        }
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_LB_STICKINESSPOLICY_CREATE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "creating a Load Balancer Stickiness policy: " + getLBStickinessPolicyName();
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
deleted file mode 100644
index 0402709..0000000
--- a/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,381 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCreateCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.LoadBalancerResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
-import com.cloud.network.Network;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-import com.cloud.utils.net.NetUtils;
-
-@Implementation(description="Creates a load balancer rule", responseObject=LoadBalancerResponse.class)
-public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd  /*implements LoadBalancer */{
-    public static final Logger s_logger = Logger.getLogger(CreateLoadBalancerRuleCmd.class.getName());
-
-    private static final String s_name = "createloadbalancerruleresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required=true, description="load balancer algorithm (source, roundrobin, leastconn)")
-    private String algorithm;
-
-    @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the load balancer rule", length=4096)
-    private String description;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the load balancer rule")
-    private String loadBalancerRuleName;
-
-    @Parameter(name=ApiConstants.PRIVATE_PORT, type=CommandType.INTEGER, required=true, description="the private port of the private ip address/virtual machine where the network traffic will be load balanced to")
-    private Integer privatePort;
-
-    @IdentityMapper(entityTableName="user_ip_address")
-    @Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, description="public ip address id from where the network traffic will be load balanced from")
-    private Long publicIpId;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=false, description="zone where the load balancer is going to be created. This parameter is required when LB service provider is ElasticLoadBalancerVm")
-    private Long zoneId;
-
-    @Parameter(name=ApiConstants.PUBLIC_PORT, type=CommandType.INTEGER, required=true, description="the public port from where the network traffic will be load balanced from")
-    private Integer publicPort;
-
-    @Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for" +
-            " source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB" +
-                    " rule is being created for VPC guest network 2) in all other cases defaulted to true")
-    private Boolean openFirewall;
-
-    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the load balancer. Must be used with the domainId parameter.")
-    private String accountName;
-
-    @IdentityMapper(entityTableName="domain")
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the load balancer")
-    private Long domainId;
-
-    @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from")
-    private List<String> cidrlist;
-
-    @IdentityMapper(entityTableName="networks")
-    @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The guest network this " +
-            "rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)")
-    private Long networkId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public String getLoadBalancerRuleName() {
-        return loadBalancerRuleName;
-    }
-
-    public Integer getPrivatePort() {
-        return privatePort;
-    }
-
-    public String getEntityTable() {
-        return "firewall_rules";
-    }
-
-    public Long getSourceIpAddressId() {
-        if (publicIpId != null) {
-            IpAddress ipAddr = _networkService.getIp(publicIpId);
-            if (ipAddr == null || !ipAddr.readyToUse()) {
-                throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
-            }
-        } else if (getEntityId() != null) {
-            LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
-            return rule.getSourceIpAddressId();
-        }
-
-        return publicIpId;
-    }
-
-    private Long getVpcId() {
-        if (publicIpId != null) {
-            IpAddress ipAddr = _networkService.getIp(publicIpId);
-            if (ipAddr == null || !ipAddr.readyToUse()) {
-                throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
-            } else {
-                return ipAddr.getVpcId();
-            }
-        }
-        return null;
-    }
-
-
-    public Long getNetworkId() {
-        if (networkId != null) {
-            return networkId;
-        }
-        Long zoneId = getZoneId();
-
-        if (zoneId == null) {
-            Long ipId = getSourceIpAddressId();
-            if (ipId == null) {
-                throw new InvalidParameterValueException("Either networkId or zoneId or publicIpId has to be specified");
-            }
-        }
-
-        if (zoneId != null) {
-            DataCenter zone = _configService.getZone(zoneId);
-            if (zone.getNetworkType() == NetworkType.Advanced) {
-                List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
-                if (networks.size() == 0) {
-                    String domain = _domainService.getDomain(getDomainId()).getName();
-                    throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
-                }
-
-                if (networks.size() < 1) {
-                    throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
-                } else if (networks.size() > 1) {
-                    throw new InvalidParameterValueException("Account has more than one Isolated network in the zone");
-                }
-
-                return networks.get(0).getId();
-            } else {
-                Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId);
-                if (defaultGuestNetwork == null) {
-                    throw new InvalidParameterValueException("Unable to find a default Guest network for account " + getAccountName() + " in domain id=" + getDomainId());
-                } else {
-                    return defaultGuestNetwork.getId();
-                }
-            }
-        } else {
-            IpAddress ipAddr = _networkService.getIp(publicIpId);
-            if (ipAddr.getAssociatedWithNetworkId() != null) {
-                return ipAddr.getAssociatedWithNetworkId();
-            } else {
-                throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network");
-            }
-        }
-    }
-
-    public Integer getPublicPort() {
-        return publicPort;
-    }
-
-    public String getName() {
-        return loadBalancerRuleName;
-    }
-
-    public Boolean getOpenFirewall() {
-        boolean isVpc = getVpcId() == null ? false : true;
-        if (openFirewall != null) {
-            if (isVpc && openFirewall) {
-                throw new InvalidParameterValueException("Can't have openFirewall=true when IP address belongs to VPC");
-            }
-            return openFirewall;
-        } else {
-            if (isVpc) {
-                return false;
-            }
-            return true;
-        }
-    }
-
-    public List<String> getSourceCidrList() {
-        if (cidrlist != null) {
-            throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
-        }
-        return null;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public void execute() throws ResourceAllocationException, ResourceUnavailableException {
-
-        UserContext callerContext = UserContext.current();
-        boolean success = true;
-        LoadBalancer rule = null;
-        try {
-            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
-
-            if (getOpenFirewall()) {
-                success = success && _firewallService.applyFirewallRules(getSourceIpAddressId(), callerContext.getCaller());
-            }
-
-            // State might be different after the rule is applied, so get new object here
-            rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
-            LoadBalancerResponse lbResponse = new LoadBalancerResponse();
-            if (rule != null) {
-                lbResponse = _responseGenerator.createLoadBalancerResponse(rule);
-                setResponseObject(lbResponse);
-            }
-            lbResponse.setResponseName(getCommandName());
-        } catch (Exception ex) {
-            s_logger.warn("Failed to create LB rule due to exception ", ex);
-        }finally {
-            if (!success || rule == null) {
-
-                if (getOpenFirewall()) {
-                    _firewallService.revokeRelatedFirewallRule(getEntityId(), true);
-                }
-                // no need to apply the rule on the backend as it exists in the db only
-                _lbService.deleteLoadBalancerRule(getEntityId(), false);
-
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create load balancer rule");
-            }
-        }
-    }
-
-    @Override
-    public void create() {
-        //cidr list parameter is deprecated
-        if (cidrlist != null) {
-            throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
-        }
-        try {
-            LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
-            this.setEntityId(result.getId());
-        } catch (NetworkRuleConflictException e) {
-            s_logger.warn("Exception: ", e);
-            throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
-        } catch (InsufficientAddressCapacityException e) {
-            s_logger.warn("Exception: ", e);
-            throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
-        }
-    }
-
-    public Integer getSourcePortStart() {
-        return publicPort.intValue();
-    }
-
-    public Integer getSourcePortEnd() {
-        return publicPort.intValue();
-    }
-
-    public String getProtocol() {
-        return NetUtils.TCP_PROTO;
-    }
-
-    public long getAccountId() {
-        if (publicIpId != null)
-            return _networkService.getIp(getSourceIpAddressId()).getAccountId();
-
-        Account account = null;
-        if ((domainId != null) && (accountName != null)) {
-            account = _responseGenerator.findAccountByNameDomain(accountName, domainId);
-            if (account != null) {
-                return account.getId();
-            } else {
-                throw new InvalidParameterValueException("Unable to find account " + account + " in domain id=" + domainId);
-            }
-        } else {
-            throw new InvalidParameterValueException("Can't define IP owner. Either specify account/domainId or publicIpId");
-        }
-    }
-
-    public long getDomainId() {
-        if (publicIpId != null)
-            return _networkService.getIp(getSourceIpAddressId()).getDomainId();
-        if (domainId != null) {
-            return domainId;
-        }
-        return UserContext.current().getCaller().getDomainId();
-    }
-
-    public int getDefaultPortStart() {
-        return privatePort.intValue();
-    }
-
-    public int getDefaultPortEnd() {
-        return privatePort.intValue();
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-       return getAccountId();
-    }
-
-    public String getAccountName() {
-        return accountName;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public void setPublicIpId(Long publicIpId) {
-        this.publicIpId = publicIpId;
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_LOAD_BALANCER_CREATE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "creating load balancer: " + getName() + " account: " + getAccountName();
-
-    }
-
-    public String getXid() {
-        /*FIXME*/
-        return null;
-    }
-
-    public void setSourceIpAddressId(Long ipId) {
-        this.publicIpId = ipId;
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.FirewallRule;
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java b/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
deleted file mode 100644
index dd79330..0000000
--- a/api/src/com/cloud/api/commands/DeleteLBStickinessPolicyCmd.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since="3.0.0")
-public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(DeleteLBStickinessPolicyCmd.class.getName());
-    private static final String s_name = "deleteLBstickinessrruleresponse";
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="load_balancer_stickiness_policies")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the LB stickiness policy")
-    private Long id;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Account account = UserContext.current().getCaller();
-        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 String getEventType() {
-        return EventTypes.EVENT_LB_STICKINESSPOLICY_DELETE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "deleting load balancer stickiness policy: " + getId();
-    }
-
-    @Override
-    public void execute() {
-        UserContext.current().setEventDetails("Load balancer stickiness policy Id: " + getId());
-        boolean result = _lbService.deleteLBStickinessPolicy(getId(), true);
-
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer stickiness policy");
-        }
-    }
-
-    @Override
-    public String getSyncObjType() {
-        return BaseAsyncCmd.networkSyncObject;
-    }
-
-    @Override
-    public Long getSyncObjId() {
-        StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class,
-                getId());
-        if (policy == null) {
-            throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
-        }
-        LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
-        if (lb == null) {
-            throw new InvalidParameterValueException("Unable to find load balancer rule for stickiness rule: " + id);
-        }
-        return lb.getNetworkId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
deleted file mode 100644
index 5a00b22..0000000
--- a/api/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,118 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Deletes a load balancer rule.", responseObject=SuccessResponse.class)
-public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerRuleCmd.class.getName());
-    private static final String s_name = "deleteloadbalancerruleresponse";
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the load balancer rule")
-    private Long id;
-
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getId());
-        if (lb != null) {
-            return lb.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @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 = _firewallService.revokeRelatedFirewallRule(id, true);
-        result = result && _lbService.deleteLoadBalancerRule(id, true);
-
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer");
-        }
-    }
-
-    @Override
-    public String getSyncObjType() {
-        return BaseAsyncCmd.networkSyncObject;
-    }
-
-    @Override
-    public Long getSyncObjId() {
-        LoadBalancer lb = _lbService.findById(id);
-        if(lb == null){
-            throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
-        }
-        return lb.getNetworkId();
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.FirewallRule;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/ListLBStickinessPoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListLBStickinessPoliciesCmd.java b/api/src/com/cloud/api/commands/ListLBStickinessPoliciesCmd.java
deleted file mode 100644
index 92a27bc..0000000
--- a/api/src/com/cloud/api/commands/ListLBStickinessPoliciesCmd.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.LBStickinessResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Lists LBStickiness policies.", responseObject = LBStickinessResponse.class, since="3.0.0")
-public class ListLBStickinessPoliciesCmd extends BaseListCmd {
-    public static final Logger s_logger = Logger
-            .getLogger(ListLBStickinessPoliciesCmd.class.getName());
-
-    private static final String s_name = "listlbstickinesspoliciesresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
-    private Long lbRuleId;
-
-
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-    public Long getLbRuleId() {
-        return lbRuleId;
-    }
-
-
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public void execute() {
-        List<LBStickinessResponse> spResponses = new ArrayList<LBStickinessResponse>();
-        LoadBalancer lb = _lbService.findById(getLbRuleId());
-        ListResponse<LBStickinessResponse> response = new ListResponse<LBStickinessResponse>();
-
-        if (lb != null) {
-            //check permissions
-            Account caller = UserContext.current().getCaller();
-            _accountService.checkAccess(caller, null, true, lb);
-            List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
-            LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);
-            spResponses.add(spResponse);
-            response.setResponses(spResponses);
-        }
-
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java b/api/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java
deleted file mode 100644
index 49f066b..0000000
--- a/api/src/com/cloud/api/commands/ListLoadBalancerRuleInstancesCmd.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.UserVmResponse;
-import com.cloud.uservm.UserVm;
-
-@Implementation(description="List all virtual machine instances that are assigned to a load balancer rule.", responseObject=UserVmResponse.class)
-public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
-    public static final Logger s_logger = Logger.getLogger (ListLoadBalancerRuleInstancesCmd.class.getName());
-
-    private static final String s_name = "listloadbalancerruleinstancesresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.APPLIED, type=CommandType.BOOLEAN, description="true if listing all virtual machines currently applied to the load balancer rule; default is true")
-    private Boolean applied;
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the load balancer rule")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Boolean isApplied() {
-        return applied;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public void execute(){
-        List<? extends UserVm> result = _lbService.listLoadBalancerInstances(this);
-        ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
-        List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
-        if (result != null) {
-            vmResponses = _responseGenerator.createUserVmResponse("loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
-        }
-        response.setResponses(vmResponses);
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java b/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
deleted file mode 100644
index c7f5e18..0000000
--- a/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.LoadBalancerResponse;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.utils.Pair;
-
-@Implementation(description = "Lists load balancer rules.", responseObject = LoadBalancerResponse.class)
-public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
-    public static final Logger s_logger = Logger.getLogger(ListLoadBalancerRulesCmd.class.getName());
-
-    private static final String s_name = "listloadbalancerrulesresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the ID of the load balancer rule")
-    private Long id;
-
-    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the load balancer rule")
-    private String loadBalancerRuleName;
-
-    @IdentityMapper(entityTableName="user_ip_address")
-    @Parameter(name = ApiConstants.PUBLIC_IP_ID, type = CommandType.LONG, description = "the public IP address id of the load balancer rule ")
-    private Long publicIpId;
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.LONG, description = "the ID of the virtual machine of the load balancer rule")
-    private Long virtualMachineId;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.LONG, description = "the availability zone ID")
-    private Long zoneId;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getLoadBalancerRuleName() {
-        return loadBalancerRuleName;
-    }
-
-    public Long getPublicIpId() {
-        return publicIpId;
-    }
-
-    public Long getVirtualMachineId() {
-        return virtualMachineId;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public void execute() {
-        Pair<List<? extends LoadBalancer>, Integer> loadBalancers = _lbService.searchForLoadBalancers(this);
-        ListResponse<LoadBalancerResponse> response = new ListResponse<LoadBalancerResponse>();
-        List<LoadBalancerResponse> lbResponses = new ArrayList<LoadBalancerResponse>();
-        if (loadBalancers != null) {
-            for (LoadBalancer loadBalancer : loadBalancers.first()) {
-                LoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerResponse(loadBalancer);
-                lbResponse.setObjectName("loadbalancerrule");
-                lbResponses.add(lbResponse);
-            }
-        }
-        response.setResponses(lbResponses, loadBalancers.second());
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java
deleted file mode 100644
index 5d5d700..0000000
--- a/api/src/com/cloud/api/commands/RemoveFromLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,121 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-import com.cloud.utils.StringUtils;
-
-@Implementation(description="Removes a virtual machine or a list of virtual machines from a load balancer rule.", responseObject=SuccessResponse.class)
-public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(RemoveFromLoadBalancerRuleCmd.class.getName());
-
-    private static final String s_name = "removefromloadbalancerruleresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the load balancer rule")
-    private Long id;
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_IDS, type=CommandType.LIST, required = true, collectionType=CommandType.LONG, description="the list of IDs of the virtual machines that are being removed from the load balancer rule (i.e. virtualMachineIds=1,2,3)")
-    private List<Long> virtualMachineIds;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public List<Long> getVirtualMachineIds() {
-        return virtualMachineIds;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getId());
-        if (lb == null) {
-            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
-        }
-        return lb.getAccountId();
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_REMOVE_FROM_LOAD_BALANCER_RULE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "removing instances from load balancer: " + getId() + " (ids: " + StringUtils.join(getVirtualMachineIds(), ",") + ")";
-    }
-
-    @Override
-    public void execute(){
-        UserContext.current().setEventDetails("Load balancer Id: "+getId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
-        boolean result = _lbService.removeFromLoadBalancer(id, virtualMachineIds);
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove instance from load balancer rule");
-        }
-    }
-
-    @Override
-    public String getSyncObjType() {
-        return BaseAsyncCmd.networkSyncObject;
-    }
-
-    @Override
-    public Long getSyncObjId() {
-        LoadBalancer lb = _lbService.findById(id);
-        if(lb == null){
-            throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
-        }
-        return lb.getNetworkId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java
deleted file mode 100644
index 91ed7d3..0000000
--- a/api/src/com/cloud/api/commands/UpdateLoadBalancerRuleCmd.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.LoadBalancerResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Updates load balancer", responseObject=LoadBalancerResponse.class)
-public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(UpdateLoadBalancerRuleCmd.class.getName());
-    private static final String s_name = "updateloadbalancerruleresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, description="load balancer algorithm (source, roundrobin, leastconn)")
-    private String algorithm;
-
-    @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the load balancer rule", length=4096)
-    private String description;
-
-    @IdentityMapper(entityTableName="firewall_rules")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the load balancer rule to update")
-    private Long id;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the load balancer rule")
-    private String loadBalancerName;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getLoadBalancerName() {
-        return loadBalancerName;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getId());
-        if (lb == null) {
-            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
-        }
-        return lb.getAccountId();
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_LOAD_BALANCER_UPDATE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "updating load balancer rule";
-    }
-
-    @Override
-    public void execute(){
-        UserContext.current().setEventDetails("Load balancer Id: "+getId());
-        LoadBalancer result = _lbService.updateLoadBalancerRule(this);
-        if (result != null){
-            LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update load balancer rule");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index c5e6b5c..3aec832 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -18,12 +18,9 @@ package com.cloud.network.lb;
 
 import java.util.List;
 
-import com.cloud.api.commands.CreateLBStickinessPolicyCmd;
-import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
-import com.cloud.api.commands.ListLBStickinessPoliciesCmd;
-import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;
-import com.cloud.api.commands.ListLoadBalancerRulesCmd;
-import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
+import org.apache.cloudstack.api.user.lb.command.*;
+import org.apache.cloudstack.api.user.lb.command.CreateLBStickinessPolicyCmd;
+import org.apache.cloudstack.api.user.lb.command.UpdateLoadBalancerRuleCmd;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
@@ -31,6 +28,7 @@ import com.cloud.network.rules.LoadBalancer;
 import com.cloud.network.rules.StickinessPolicy;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
+import org.apache.cloudstack.api.user.lb.command.ListLoadBalancerRulesCmd;
 
 
 public interface LoadBalancingRulesService {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/org/apache/cloudstack/api/user/lb/command/AssignToLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/AssignToLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/AssignToLoadBalancerRuleCmd.java
new file mode 100644
index 0000000..fae88a6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/AssignToLoadBalancerRuleCmd.java
@@ -0,0 +1,121 @@
+// 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.user.lb.command;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.rules.LoadBalancer;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.utils.StringUtils;
+
+@Implementation(description="Assigns virtual machine or a list of virtual machines to a load balancer rule.", responseObject=SuccessResponse.class)
+public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(AssignToLoadBalancerRuleCmd.class.getName());
+
+    private static final String s_name = "assigntoloadbalancerruleresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="firewall_rules")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the load balancer rule")
+    private Long id;
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, required=true, description="the list of IDs of the virtual machine that are being assigned to the load balancer rule(i.e. virtualMachineIds=1,2,3)")
+    private List<Long> virtualMachineIds;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getLoadBalancerId() {
+        return id;
+    }
+
+    public List<Long> getVirtualMachineIds() {
+        return virtualMachineIds;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLoadBalancerId());
+        if (lb == null) {
+            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
+        }
+        return lb.getAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_ASSIGN_TO_LOAD_BALANCER_RULE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "applying instances for load balancer: " + getLoadBalancerId() + " (ids: " + StringUtils.join(getVirtualMachineIds(), ",") + ")";
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Load balancer Id: "+getLoadBalancerId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
+        boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign load balancer rule");
+        }
+    }
+
+    @Override
+    public String getSyncObjType() {
+        return BaseAsyncCmd.networkSyncObject;
+    }
+
+    @Override
+    public Long getSyncObjId() {
+        LoadBalancer lb = _lbService.findById(id);
+        if(lb == null){
+            throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
+        }
+        return lb.getNetworkId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/org/apache/cloudstack/api/user/lb/command/CreateLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/CreateLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/CreateLBStickinessPolicyCmd.java
new file mode 100644
index 0000000..866422a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/CreateLBStickinessPolicyCmd.java
@@ -0,0 +1,161 @@
+// 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.user.lb.command;
+
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.rules.StickinessPolicy;
+import com.cloud.api.response.LBStickinessResponse;
+import com.cloud.network.rules.LoadBalancer;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+
+@Implementation(description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since="3.0.0")
+@SuppressWarnings("rawtypes")
+public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger
+            .getLogger(CreateLBStickinessPolicyCmd.class.getName());
+
+    private static final String s_name = "createLBStickinessPolicy";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="firewall_rules")
+    @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
+    private Long lbRuleId;
+
+    @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the LB Stickiness policy")
+    private String description;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the LB Stickiness policy")
+    private String lbStickinessPolicyName;
+
+    @Parameter(name = ApiConstants.METHOD_NAME, type = CommandType.STRING, required = true, description = "name of the LB Stickiness policy method, possible values can be obtained from ListNetworks API ")
+    private String stickinessMethodName;
+
+    @Parameter(name = ApiConstants.PARAM_LIST, type = CommandType.MAP, description = "param list. Example: param[0].name=cookiename&param[0].value=LBCookie ")
+    private Map paramList;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getLbRuleId() {
+        return lbRuleId;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getLBStickinessPolicyName() {
+        return lbStickinessPolicyName;
+    }
+
+    public String getStickinessMethodName() {
+        return stickinessMethodName;
+    }
+
+    public Map getparamList() {
+        return paramList;
+    }
+
+    public String getEntityTable() {
+        return "firewall_rules";
+    }
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        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() throws ResourceAllocationException, ResourceUnavailableException {
+        StickinessPolicy policy = null;
+        boolean success = false;
+
+        try {
+            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
+            success = _lbService.applyLBStickinessPolicy(this);
+            if (success) {
+                // State might be different after the rule is applied, so get new object here
+                policy = _entityMgr.findById(StickinessPolicy.class, getEntityId());
+                LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
+                LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
+                setResponseObject(spResponse);
+                spResponse.setResponseName(getCommandName());
+            }
+        } finally {
+            if (!success || (policy == null)) {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
+            }
+        }
+    }
+
+    @Override
+    public void create() {
+        try {
+            StickinessPolicy result = _lbService.createLBStickinessPolicy(this);
+            this.setEntityId(result.getId());
+        } catch (NetworkRuleConflictException e) {
+            s_logger.warn("Exception: ", e);
+            throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_LB_STICKINESSPOLICY_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating a Load Balancer Stickiness policy: " + getLBStickinessPolicyName();
+    }
+
+}
+