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

[6/18] api_refactor: refactor loadbalancer apis

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/api/src/org/apache/cloudstack/api/user/lb/command/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/CreateLoadBalancerRuleCmd.java
new file mode 100644
index 0000000..bacf54d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/CreateLoadBalancerRuleCmd.java
@@ -0,0 +1,381 @@
+// 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.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/org/apache/cloudstack/api/user/lb/command/DeleteLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLBStickinessPolicyCmd.java
new file mode 100644
index 0000000..f68ab8c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLBStickinessPolicyCmd.java
@@ -0,0 +1,116 @@
+// 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 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/org/apache/cloudstack/api/user/lb/command/DeleteLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLoadBalancerRuleCmd.java
new file mode 100644
index 0000000..2bff86b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/DeleteLoadBalancerRuleCmd.java
@@ -0,0 +1,118 @@
+// 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 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/org/apache/cloudstack/api/user/lb/command/ListLBStickinessPoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/ListLBStickinessPoliciesCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/ListLBStickinessPoliciesCmd.java
new file mode 100644
index 0000000..b4a351c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/ListLBStickinessPoliciesCmd.java
@@ -0,0 +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.user.lb.command;
+
+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/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRuleInstancesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRuleInstancesCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRuleInstancesCmd.java
new file mode 100644
index 0000000..1b6577e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRuleInstancesCmd.java
@@ -0,0 +1,83 @@
+// 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.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/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRulesCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRulesCmd.java
new file mode 100644
index 0000000..0c1b9b0
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/ListLoadBalancerRulesCmd.java
@@ -0,0 +1,113 @@
+// 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.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/org/apache/cloudstack/api/user/lb/command/RemoveFromLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/RemoveFromLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/RemoveFromLoadBalancerRuleCmd.java
new file mode 100644
index 0000000..9aeca02
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/RemoveFromLoadBalancerRuleCmd.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="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/org/apache/cloudstack/api/user/lb/command/UpdateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/lb/command/UpdateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/user/lb/command/UpdateLoadBalancerRuleCmd.java
new file mode 100644
index 0000000..a738c65
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/lb/command/UpdateLoadBalancerRuleCmd.java
@@ -0,0 +1,116 @@
+// 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 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/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 14c79db..4893877 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -142,16 +142,16 @@ listIpForwardingRules=org.apache.cloudstack.api.user.nat.command.ListIpForwardin
 disableStaticNat=org.apache.cloudstack.api.user.nat.command.DisableStaticNatCmd;15
 
 #### load balancer commands
-createLoadBalancerRule=com.cloud.api.commands.CreateLoadBalancerRuleCmd;15
-deleteLoadBalancerRule=com.cloud.api.commands.DeleteLoadBalancerRuleCmd;15
-removeFromLoadBalancerRule=com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd;15
-assignToLoadBalancerRule=com.cloud.api.commands.AssignToLoadBalancerRuleCmd;15
-createLBStickinessPolicy=com.cloud.api.commands.CreateLBStickinessPolicyCmd;15
-deleteLBStickinessPolicy=com.cloud.api.commands.DeleteLBStickinessPolicyCmd;15
-listLoadBalancerRules=com.cloud.api.commands.ListLoadBalancerRulesCmd;15
-listLBStickinessPolicies=com.cloud.api.commands.ListLBStickinessPoliciesCmd;15
-listLoadBalancerRuleInstances=com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;15
-updateLoadBalancerRule=com.cloud.api.commands.UpdateLoadBalancerRuleCmd;15
+createLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.CreateLoadBalancerRuleCmd;15
+deleteLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.DeleteLoadBalancerRuleCmd;15
+removeFromLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.RemoveFromLoadBalancerRuleCmd;15
+assignToLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.AssignToLoadBalancerRuleCmd;15
+createLBStickinessPolicy=org.apache.cloudstack.api.user.lb.command.CreateLBStickinessPolicyCmd;15
+deleteLBStickinessPolicy=org.apache.cloudstack.api.user.lb.command.DeleteLBStickinessPolicyCmd;15
+listLoadBalancerRules=org.apache.cloudstack.api.user.lb.command.ListLoadBalancerRulesCmd;15
+listLBStickinessPolicies=org.apache.cloudstack.api.user.lb.command.ListLBStickinessPoliciesCmd;15
+listLoadBalancerRuleInstances=org.apache.cloudstack.api.user.lb.command.ListLoadBalancerRuleInstancesCmd;15
+updateLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.UpdateLoadBalancerRuleCmd;15
 
 #### autoscale commands
 createCounter = com.cloud.api.commands.CreateCounterCmd;1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
index 0dc5b14..d4cedf6 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
@@ -18,7 +18,7 @@ package com.cloud.network.lb;
 
 import java.util.List;
 
-import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
+import org.apache.cloudstack.api.user.lb.command.CreateLoadBalancerRuleCmd;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index 366070a..3ce2717 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.user.lb.command.CreateLoadBalancerRuleCmd;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
@@ -46,7 +47,6 @@ import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.agent.api.to.NicTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.manager.Commands;
-import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.DataCenter;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
index 47f1b18..c6aba41 100644
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
@@ -18,7 +18,7 @@ package com.cloud.network.lb;
 
 import java.util.List;
 
-import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
+import org.apache.cloudstack.api.user.lb.command.CreateLoadBalancerRuleCmd;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.lb.LoadBalancingRule.LbDestination;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/456b852c/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index 6d1041a..7d0acfa 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -30,14 +30,12 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.user.lb.command.*;
 import org.apache.log4j.Logger;
 
-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.CreateLBStickinessPolicyCmd;
+import org.apache.cloudstack.api.user.lb.command.ListLoadBalancerRuleInstancesCmd;
+import org.apache.cloudstack.api.user.lb.command.ListLoadBalancerRulesCmd;
 import com.cloud.api.response.ServiceResponse;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;