incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [7/50] [abbrv] Merge branch 'master' into vpc
Date Fri, 29 Jun 2012 00:45:06 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/api/ApiConstants.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/api/ApiConstants.java
index 29bae6b,00ec392..67f76ea
--- a/api/src/com/cloud/api/ApiConstants.java
+++ b/api/src/com/cloud/api/ApiConstants.java
@@@ -357,10 -357,10 +357,14 @@@ public class ApiConstants 
      public static final String VSM_CONFIG_STATE = "vsmconfigstate";
      public static final String VSM_DEVICE_STATE = "vsmdevicestate";
      public static final String ADD_VSM_FLAG = "addvsmflag";
 +    public static final String VPC_OFF_ID = "vpcofferingid";
 +    public static final String NETWORK = "network";
 +    public static final String VPC_ID = "vpcid";
 +    public static final String GATEWAY_ID = "gatewayid";
+     public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
+     public static final String RESOURCE_IDS = "resourceids";
+     public static final String RESOURCE_ID = "resourceid";
+     public static final String CUSTOMER = "customer";
      
      public enum HostDetails {
          all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/api/BaseCmd.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/api/BaseCmd.java
index 294e264,0924796..25c54e6
--- a/api/src/com/cloud/api/BaseCmd.java
+++ b/api/src/com/cloud/api/BaseCmd.java
@@@ -129,8 -129,7 +130,9 @@@ public abstract class BaseCmd 
      public static ResourceLimitService _resourceLimitService;
      public static IdentityService _identityService;
      public static StorageNetworkService _storageNetworkService;
 +    public static VpcService _vpcService;
 +    public static NetworkACLService _networkACLService;
+     public static TaggedResourceService _taggedResourceService;
  
      static void setComponents(ResponseGenerator generator) {
          ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
@@@ -158,8 -157,7 +160,9 @@@
          _resourceLimitService = locator.getManager(ResourceLimitService.class);
          _identityService = locator.getManager(IdentityService.class);
          _storageNetworkService = locator.getManager(StorageNetworkService.class);
 +        _vpcService = locator.getManager(VpcService.class);
 +        _networkACLService = locator.getManager(NetworkACLService.class);
+         _taggedResourceService = locator.getManager(TaggedResourceService.class);
      }
  
      public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/api/ResponseGenerator.java
index 5f79e19,864a9e6..35e6972
--- a/api/src/com/cloud/api/ResponseGenerator.java
+++ b/api/src/com/cloud/api/ResponseGenerator.java
@@@ -292,32 -284,10 +294,35 @@@ public interface ResponseGenerator 
      Long getIdentiyId(String tableName, String token);
  
      /**
 -     * @param resourceTag
++<<<<<<< HEAD
 +     * @param offering
       * @return
       */
 -    ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
 +    VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering);
  
 +    /**
 +     * @param vpc
 +     * @return
 +     */
 +    VpcResponse createVpcResponse(Vpc vpc);
  
 +    /**
 +     * @param networkACL
 +     * @return
 +     */
 +    NetworkACLResponse createNetworkACLResponse(NetworkACL networkACL);
 +
 +    /**
 +     * @param result
 +     * @return
 +     */
 +    PrivateGatewayResponse createPrivateGatewayResponse(PrivateGateway result);
 +
 +    /**
 +     * @param result
 +     * @return
 +     */
 +    StaticRouteResponse createStaticRouteResponse(StaticRoute result);
++
++    ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/api/commands/ListNetworksCmd.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/api/commands/ListNetworksCmd.java
index 851b0ec,8f665b9..689f1db
--- a/api/src/com/cloud/api/commands/ListNetworksCmd.java
+++ b/api/src/com/cloud/api/commands/ListNetworksCmd.java
@@@ -63,18 -63,17 +63,22 @@@ public class ListNetworksCmd extends Ba
      @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="list networks by physical network id")
      private Long physicalNetworkId;
      
-     @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list network offerings supporting certain services")
+     @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list networks supporting certain services")
      private List<String> supportedServices;
      
 -    @Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list networks by restartRequired option")
 +    @Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list networks by restartRequired")
++    
      private Boolean restartRequired;
      
      @Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if need to list only networks which support specifying ip ranges")
      private Boolean specifyIpRanges;
      
 +    @IdentityMapper(entityTableName="vpc")
 +    @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
 +    private Long vpcId;
++
+     @Parameter(name=ApiConstants.CAN_USE_FOR_DEPLOY, type=CommandType.BOOLEAN, description="list networks available for vm deployment")
+     private Boolean canUseForDeploy;
     
      /////////////////////////////////////////////////////
      /////////////////// Accessors ///////////////////////
@@@ -119,9 -118,9 +123,13 @@@
      public Boolean getSpecifyIpRanges() {
      	return specifyIpRanges;
      }
 -    
 +
 +	public Long getVpcId() {
 +        return vpcId;
++	}
++	
+ 	public Boolean canUseForDeploy() {
+         return canUseForDeploy;
      }
  
      /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/api/response/NetworkResponse.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/api/response/NetworkResponse.java
index 867895e,4c16240..38e4cd4
--- a/api/src/com/cloud/api/response/NetworkResponse.java
+++ b/api/src/com/cloud/api/response/NetworkResponse.java
@@@ -131,8 -131,8 +131,11 @@@ public class NetworkResponse extends Ba
      @SerializedName(ApiConstants.SPECIFY_IP_RANGES) @Param(description="true if network supports specifying ip ranges, false otherwise")
      private Boolean specifyIpRanges;
      
 +    @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
 +    private IdentityProxy vpcId = new IdentityProxy("vpc");
++
+     @SerializedName(ApiConstants.CAN_USE_FOR_DEPLOY) @Param(description="list networks available for vm deployment")
+     private Boolean canUseForDeploy;
      
      public void setId(Long id) {
          this.id.setValue(id);
@@@ -275,8 -275,8 +278,12 @@@
  	public void setSpecifyIpRanges(Boolean specifyIpRanges) {
  		this.specifyIpRanges = specifyIpRanges;
  	}
 -
 +	
 +    public void setVpcId(Long vpcId) {
 +        this.vpcId.setValue(vpcId);
 +    }
++    
+     public void setCanUseForDeploy(Boolean canUseForDeploy) {
+         this.canUseForDeploy = canUseForDeploy;
+     }
  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/event/EventTypes.java
index 5fbb4bf,c42db5d..9eae59d
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@@ -260,22 -260,8 +260,27 @@@ public class EventTypes 
      public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";
      public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_CONFIGURE = "PHYSICAL.FIREWALL.CONFIGURE";
      
 +    // VPC
 +    public static final String EVENT_VPC_CREATE = "VPC.CREATE";
 +    public static final String EVENT_VPC_UPDATE = "VPC.UPDATE";
 +    public static final String EVENT_VPC_DELETE = "VPC.DELETE";
 +    public static final String EVENT_VPC_RESTART = "VPC.RESTART";
 +    
 +    // VPC offerings
 +    public static final String EVENT_VPC_OFFERING_CREATE = "VPC.OFFERING.CREATE";
 +    public static final String EVENT_VPC_OFFERING_UPDATE = "VPC.OFFERING.UPDATE";
 +    public static final String EVENT_VPC_OFFERING_DELETE = "VPC.OFFERING.DELETE";
 +    
 +    // Private gateway
 +    public static final String EVENT_PRIVATE_GATEWAY_CREATE = "PRIVATE.GATEWAY.CREATE";
 +    public static final String EVENT_PRIVATE_GATEWAY_DELETE = "PRIVATE.GATEWAY.DELETE";
 +    
 +    // Static routes
 +    public static final String EVENT_STATIC_ROUTE_CREATE = "STATIC.ROUTE.CREATE";
 +    public static final String EVENT_STATIC_ROUTE_DELETE = "STATIC.ROUTE.DELETE";
++    
+     // tag related events
+     public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
+     public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
+ 
  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/network/NetworkService.java
index 3ee22a0,d7e40a9..be54e84
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@@ -132,41 -133,11 +132,45 @@@ public interface NetworkService 
      List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
  
      List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
 +    
 +    List<? extends Network> listNetworksByVpc(long vpcId);
 +    
 +    boolean isVmPartOfNetwork(long vmId, long ntwkId);
  
      /**
 +     * @param entityId
 +     * @param networkId
 +     * @param vpcId
 +     * @return
 +     * @throws ConcurrentOperationException 
 +     * @throws ResourceUnavailableException 
 +     * @throws ResourceAllocationException 
 +     * @throws InsufficientAddressCapacityException 
 +     */
 +    IpAddress associateIP(long ipId, Long networkId, Long vpcId) throws InsufficientAddressCapacityException,
 +        ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException;
 +
 +    /**
 +     * @param networkName
 +     * @param displayText
 +     * @param physicalNetworkId
 +     * @param vlan
 +     * @param startIp
 +     * @param endIP TODO
 +     * @param gateway
 +     * @param netmask
 +     * @param networkOwnerId
 +     * @return
 +     * @throws InsufficientCapacityException 
 +     * @throws ConcurrentOperationException 
 +     * @throws ResourceAllocationException 
 +     */
 +    Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
 +            String startIp, String endIP, String gateway, String netmask, long networkOwnerId) 
 +                    throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
- 
++    /**
+      * @param network
+      * @return
+      */
+     boolean canUseForDeploy(Network network);
 -
  }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/commands.properties.in
index fef9f52,08c175b..82aeb73
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@@ -331,37 -331,9 +331,43 @@@ updateStorageNetworkIpRange=com.cloud.a
  ### Network Devices commands
  addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
  listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
 +deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
 +
++<<<<<<< HEAD
 +### Network Devices commands
 +addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
 +listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
  deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
  
 +### VPC commands
 +createVPC=com.cloud.api.commands.CreateVPCCmd;15
 +listVPCs=com.cloud.api.commands.ListVPCsCmd;15
 +deleteVPC=com.cloud.api.commands.DeleteVPCCmd;15
 +updateVPC=com.cloud.api.commands.UpdateVPCCmd;15
 +restartVPC=com.cloud.api.commands.RestartVPCCmd;15
 +
 +#### VPC offering commands
 +createVPCOffering=com.cloud.api.commands.CreateVPCOfferingCmd;1
 +updateVPCOffering=com.cloud.api.commands.UpdateVPCOfferingCmd;1
 +deleteVPCOffering=com.cloud.api.commands.DeleteVPCOfferingCmd;1
 +listVPCOfferings=com.cloud.api.commands.ListVPCOfferingsCmd;15
 +
 +#### Private gateway commands
 +createPrivateGateway=com.cloud.api.commands.CreatePrivateGatewayCmd;1
 +listPrivateGateways=com.cloud.api.commands.ListPrivateGatewaysCmd;1
 +deletePrivateGateway=com.cloud.api.commands.DeletePrivateGatewayCmd;1
 +
 +#### Network ACL commands
 +createNetworkACL=com.cloud.api.commands.CreateNetworkACLCmd;15
 +deleteNetworkACL=com.cloud.api.commands.DeleteNetworkACLCmd;15
 +listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15
 +
 +#### Static route commands
 +createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
 +deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
- listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15
++listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15
++
+ #### Tags commands
+ createTags=com.cloud.api.commands.CreateTagsCmd;15
+ deleteTags=com.cloud.api.commands.DeleteTagsCmd;15
+ listTags=com.cloud.api.commands.ListTagsCmd;15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/client/tomcatconf/components.xml.in
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
index 0000000,0473291..1aa23da
mode 000000,100644..100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
@@@ -1,0 -1,545 +1,546 @@@
+ // Copyright 2012 Citrix Systems, Inc. Licensed under the
+ // Apache License, Version 2.0 (the "License"); you may not use this
+ // file except in compliance with the License.  Citrix Systems, Inc.
+ // reserves all rights not expressly granted by 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.
+ // 
+ // Automatically generated by addcopyright.py at 04/03/2012
+ package com.cloud.network.element;
+ 
+ import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
+ 
+ import javax.ejb.Local;
+ 
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.api.commands.AddExternalFirewallCmd;
+ import com.cloud.api.commands.AddSrxFirewallCmd;
+ import com.cloud.api.commands.ConfigureSrxFirewallCmd;
+ import com.cloud.api.commands.DeleteExternalFirewallCmd;
+ import com.cloud.api.commands.DeleteSrxFirewallCmd;
+ import com.cloud.api.commands.ListExternalFirewallsCmd;
+ import com.cloud.api.commands.ListSrxFirewallNetworksCmd;
+ import com.cloud.api.commands.ListSrxFirewallsCmd;
+ import com.cloud.api.response.SrxFirewallResponse;
+ import com.cloud.configuration.Config;
+ import com.cloud.configuration.ConfigurationManager;
+ import com.cloud.configuration.dao.ConfigurationDao;
+ import com.cloud.dc.DataCenter;
+ import com.cloud.dc.DataCenter.NetworkType;
+ import com.cloud.dc.DataCenterVO;
+ import com.cloud.dc.dao.DataCenterDao;
+ import com.cloud.deploy.DeployDestination;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.InsufficientCapacityException;
+ import com.cloud.exception.InsufficientNetworkCapacityException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.host.Host;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.host.dao.HostDetailsDao;
+ import com.cloud.network.ExternalFirewallDeviceManagerImpl;
+ import com.cloud.network.ExternalFirewallDeviceVO;
+ import com.cloud.network.ExternalFirewallDeviceVO.FirewallDeviceState;
+ import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
+ import com.cloud.network.Network;
+ import com.cloud.network.Network.Capability;
+ import com.cloud.network.Network.Provider;
+ import com.cloud.network.Network.Service;
+ import com.cloud.network.NetworkExternalFirewallVO;
+ import com.cloud.network.NetworkManager;
+ import com.cloud.network.NetworkVO;
+ import com.cloud.network.PhysicalNetworkServiceProvider;
+ import com.cloud.network.PhysicalNetworkVO;
+ import com.cloud.network.PublicIpAddress;
+ import com.cloud.network.RemoteAccessVpn;
+ import com.cloud.network.VpnUser;
+ import com.cloud.network.dao.ExternalFirewallDeviceDao;
+ import com.cloud.network.dao.NetworkDao;
+ import com.cloud.network.dao.NetworkExternalFirewallDao;
+ import com.cloud.network.dao.NetworkServiceMapDao;
+ import com.cloud.network.dao.PhysicalNetworkDao;
+ import com.cloud.network.resource.JuniperSrxResource;
+ import com.cloud.network.rules.FirewallRule;
+ import com.cloud.network.rules.PortForwardingRule;
+ import com.cloud.offering.NetworkOffering;
+ import com.cloud.offerings.dao.NetworkOfferingDao;
+ import com.cloud.resource.ServerResource;
+ import com.cloud.server.api.response.ExternalFirewallResponse;
+ import com.cloud.utils.NumbersUtil;
+ import com.cloud.utils.component.Inject;
+ import com.cloud.utils.exception.CloudRuntimeException;
+ import com.cloud.vm.NicProfile;
+ import com.cloud.vm.ReservationContext;
+ import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.VirtualMachineProfile;
+ 
+ @Local(value = NetworkElement.class)
+ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceManagerImpl implements SourceNatServiceProvider, FirewallServiceProvider,
+         PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, JuniperSRXFirewallElementService {
+ 
+     private static final Logger s_logger = Logger.getLogger(JuniperSRXExternalFirewallElement.class);
+ 
+     private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
+ 
+     @Inject
+     NetworkManager _networkManager;
+     @Inject
+     HostDao _hostDao;
+     @Inject
+     ConfigurationManager _configMgr;
+     @Inject
+     NetworkOfferingDao _networkOfferingDao;
+     @Inject
+     NetworkDao _networksDao;
+     @Inject
+     DataCenterDao _dcDao;
+     @Inject
+     PhysicalNetworkDao _physicalNetworkDao;
+     @Inject
+     ExternalFirewallDeviceDao _fwDevicesDao;
+     @Inject
+     NetworkExternalFirewallDao _networkFirewallDao;
+     @Inject
+     NetworkDao _networkDao;
+     @Inject
+     NetworkServiceMapDao _ntwkSrvcDao;
+     @Inject
+     HostDetailsDao _hostDetailDao;
+     @Inject
+     ConfigurationDao _configDao;
+ 
+     private boolean canHandle(Network network, Service service) {
+         DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+         if ((zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() != Network.GuestType.Isolated) || (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
+             s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType());
+             return false;
+         }
+ 
+         if (service == null) {
+             if (!_networkManager.isProviderForNetwork(getProvider(), network.getId())) {
+                 s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network);
+                 return false;
+             }
+         } else {
+             if (!_networkManager.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
+                 s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network);
+                 return false;
+             }
+         }
+ 
+         return true;
+     }
+ 
+     @Override
+     public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
+             InsufficientNetworkCapacityException {
+         DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+ 
+         // don't have to implement network is Basic zone
+         if (zone.getNetworkType() == NetworkType.Basic) {
+             s_logger.debug("Not handling network implement in zone of type " + NetworkType.Basic);
+             return false;
+         }
+ 
+         if (!canHandle(network, null)) {
+             return false;
+         }
+ 
+         try {
+             return manageGuestNetworkWithExternalFirewall(true, network);
+         } catch (InsufficientCapacityException capacityException) {
+             // TODO: handle out of capacity exception in more gracefule manner when multiple providers are present for
+             // the network
+             s_logger.error("Fail to implement the JuniperSRX for network " + network, capacityException);
+             return false;
+         }
+     }
+ 
+     @Override
+     public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+             InsufficientNetworkCapacityException, ResourceUnavailableException {
+         return true;
+     }
+ 
+     @Override
+     public boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
+         return true;
+     }
+ 
+     @Override
+     public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
+         DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+ 
+         // don't have to implement network is Basic zone
+         if (zone.getNetworkType() == NetworkType.Basic) {
+             s_logger.debug("Not handling network shutdown in zone of type " + NetworkType.Basic);
+             return false;
+         }
+ 
+         if (!canHandle(network, null)) {
+             return false;
+         }
+         try {
+             return manageGuestNetworkWithExternalFirewall(false, network);
+         } catch (InsufficientCapacityException capacityException) {
+             // TODO: handle out of capacity exception
+             return false;
+         }
+     }
+ 
+     @Override
+     public boolean destroy(Network config) {
+         return true;
+     }
+ 
+     @Override
+     public boolean applyFWRules(Network config, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
+         if (!canHandle(config, Service.Firewall)) {
+             return false;
+         }
+ 
+         return applyFirewallRules(config, rules);
+     }
+ 
+     @Override
+     public boolean startVpn(Network config, RemoteAccessVpn vpn) throws ResourceUnavailableException {
+         if (!canHandle(config, Service.Vpn)) {
+             return false;
+         }
+ 
+         return manageRemoteAccessVpn(true, config, vpn);
+ 
+     }
+ 
+     @Override
+     public boolean stopVpn(Network config, RemoteAccessVpn vpn) throws ResourceUnavailableException {
+         if (!canHandle(config, Service.Vpn)) {
+             return false;
+         }
+ 
+         return manageRemoteAccessVpn(false, config, vpn);
+     }
+ 
+     @Override
+     public String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws ResourceUnavailableException {
+         Network config = _networksDao.findById(vpn.getNetworkId());
+ 
+         if (!canHandle(config, Service.Vpn)) {
+             return null;
+         }
+ 
+         boolean result = manageRemoteAccessVpnUsers(config, vpn, users);
+         String[] results = new String[users.size()];
+         for (int i = 0; i < results.length; i++) {
+             results[i] = String.valueOf(result);
+         }
+ 
+         return results;
+     }
+ 
+     @Override
+     public Provider getProvider() {
+         return Provider.JuniperSRX;
+     }
+ 
+     @Override
+     public Map<Service, Map<Capability, String>> getCapabilities() {
+         return capabilities;
+     }
+ 
+     private static Map<Service, Map<Capability, String>> setCapabilities() {
+         Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
+ 
+         // Set capabilities for Firewall service
+         Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();
+         firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
+         firewallCapabilities.put(Capability.MultipleIps, "true");
+         firewallCapabilities.put(Capability.TrafficStatistics, "per public ip");
++        firewallCapabilities.put(Capability.FirewallType, "perpublicip");
+         capabilities.put(Service.Firewall, firewallCapabilities);
+ 
+         // Disabling VPN for Juniper in Acton as it 1) Was never tested 2) probably just doesn't work
+ // // Set VPN capabilities
+ // Map<Capability, String> vpnCapabilities = new HashMap<Capability, String>();
+ // vpnCapabilities.put(Capability.SupportedVpnTypes, "ipsec");
+ // capabilities.put(Service.Vpn, vpnCapabilities);
+ 
+         capabilities.put(Service.Gateway, null);
+ 
+         Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
+         // Specifies that this element supports either one source NAT rule per account, or no source NAT rules at all;
+         // in the latter case a shared interface NAT rule will be used
+         sourceNatCapabilities.put(Capability.SupportedSourceNatTypes, "peraccount, perzone");
+         capabilities.put(Service.SourceNat, sourceNatCapabilities);
+ 
+         // Specifies that port forwarding rules are supported by this element
+         capabilities.put(Service.PortForwarding, null);
+ 
+         // Specifies that static NAT rules are supported by this element
+         capabilities.put(Service.StaticNat, null);
+ 
+         return capabilities;
+     }
+ 
+     @Override
+     public boolean applyPFRules(Network network, List<PortForwardingRule> rules) throws ResourceUnavailableException {
+         if (!canHandle(network, Service.PortForwarding)) {
+             return false;
+         }
+ 
+         return applyFirewallRules(network, rules);
+     }
+ 
+     @Override
+     public boolean isReady(PhysicalNetworkServiceProvider provider) {
+ 
+         List<ExternalFirewallDeviceVO> fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.JuniperSRX.getName());
+         // true if at-least one SRX device is added in to physical network and is in configured (in enabled state) state
+         if (fwDevices != null && !fwDevices.isEmpty()) {
+             for (ExternalFirewallDeviceVO fwDevice : fwDevices) {
+                 if (fwDevice.getDeviceState() == FirewallDeviceState.Enabled) {
+                     return true;
+                 }
+             }
+         }
+         return false;
+     }
+ 
+     @Override
+     public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
+             ResourceUnavailableException {
+         // TODO Auto-generated method stub
+         return true;
+     }
+ 
+     @Override
+     public boolean canEnableIndividualServices() {
+         return false;
+     }
+ 
+     @Override
+     @Deprecated
+     // should use more generic addNetworkDevice command to add firewall
+     public Host addExternalFirewall(AddExternalFirewallCmd cmd) {
+         Long zoneId = cmd.getZoneId();
+         DataCenterVO zone = null;
+         PhysicalNetworkVO pNetwork = null;
+         HostVO fwHost = null;
+ 
+         zone = _dcDao.findById(zoneId);
+         if (zone == null) {
+             throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
+         }
+ 
+         List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
+         if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
+             throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: "
+                     + zoneId + " to add this device.");
+         }
+         pNetwork = physicalNetworks.get(0);
+ 
+         String deviceType = NetworkDevice.JuniperSRXFirewall.getName();
+         ExternalFirewallDeviceVO fwDeviceVO = addExternalFirewall(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceType, (ServerResource) new JuniperSrxResource());
+         if (fwDeviceVO != null) {
+             fwHost = _hostDao.findById(fwDeviceVO.getHostId());
+         }
+ 
+         return fwHost;
+     }
+ 
+     @Override
+     public boolean deleteExternalFirewall(DeleteExternalFirewallCmd cmd) {
+         return deleteExternalFirewall(cmd.getId());
+     }
+ 
+     @Override
+     @Deprecated
+     // should use more generic listNetworkDevice command
+     public List<Host> listExternalFirewalls(ListExternalFirewallsCmd cmd) {
+         List<Host> firewallHosts = new ArrayList<Host>();
+         Long zoneId = cmd.getZoneId();
+         DataCenterVO zone = null;
+         PhysicalNetworkVO pNetwork = null;
+ 
+         if (zoneId != null) {
+             zone = _dcDao.findById(zoneId);
+             if (zone == null) {
+                 throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
+             }
+ 
+             List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
+             if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
+                 throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: "
+                         + zoneId + " to add this device.");
+             }
+             pNetwork = physicalNetworks.get(0);
+         }
+ 
+         firewallHosts.addAll(listExternalFirewalls(pNetwork.getId(), NetworkDevice.JuniperSRXFirewall.getName()));
+         return firewallHosts;
+     }
+ 
+     public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall) {
+         return super.createExternalFirewallResponse(externalFirewall);
+     }
+ 
+     @Override
+     public String getPropertiesFile() {
+         return "junipersrx_commands.properties";
+     }
+ 
+     @Override
+     public ExternalFirewallDeviceVO addSrxFirewall(AddSrxFirewallCmd cmd) {
+         String deviceName = cmd.getDeviceType();
+         if (!deviceName.equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
+             throw new InvalidParameterValueException("Invalid SRX firewall device type");
+         }
+         return addExternalFirewall(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName,
+                 (ServerResource) new JuniperSrxResource());
+     }
+ 
+     @Override
+     public boolean deleteSrxFirewall(DeleteSrxFirewallCmd cmd) {
+         Long fwDeviceId = cmd.getFirewallDeviceId();
+ 
+         ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
+         if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
+             throw new InvalidParameterValueException("No SRX firewall device found with ID: " + fwDeviceId);
+         }
+         return deleteExternalFirewall(fwDeviceVO.getHostId());
+     }
+ 
+     @Override
+     public ExternalFirewallDeviceVO configureSrxFirewall(ConfigureSrxFirewallCmd cmd) {
+         Long fwDeviceId = cmd.getFirewallDeviceId();
+         Long deviceCapacity = cmd.getFirewallCapacity();
+ 
+         ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
+         if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
+             throw new InvalidParameterValueException("No SRX firewall device found with ID: " + fwDeviceId);
+         }
+ 
+         if (deviceCapacity != null) {
+             // check if any networks are using this SRX device
+             List<NetworkExternalFirewallVO> networks = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
+             if ((networks != null) && !networks.isEmpty()) {
+                 if (deviceCapacity < networks.size()) {
+                     throw new CloudRuntimeException("There are more number of networks already using this SRX firewall device than configured capacity");
+                 }
+             }
+             if (deviceCapacity != null) {
+                 fwDeviceVO.setCapacity(deviceCapacity);
+             }
+         }
+ 
+         fwDeviceVO.setDeviceState(FirewallDeviceState.Enabled);
+         _fwDevicesDao.update(fwDeviceId, fwDeviceVO);
+         return fwDeviceVO;
+     }
+ 
+     @Override
+     public List<ExternalFirewallDeviceVO> listSrxFirewalls(ListSrxFirewallsCmd cmd) {
+         Long physcialNetworkId = cmd.getPhysicalNetworkId();
+         Long fwDeviceId = cmd.getFirewallDeviceId();
+         PhysicalNetworkVO pNetwork = null;
+         List<ExternalFirewallDeviceVO> fwDevices = new ArrayList<ExternalFirewallDeviceVO>();
+ 
+         if (physcialNetworkId == null && fwDeviceId == null) {
+             throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
+         }
+ 
+         if (fwDeviceId != null) {
+             ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
+             if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
+                 throw new InvalidParameterValueException("Could not find SRX firewall device with ID: " + fwDeviceId);
+             }
+             fwDevices.add(fwDeviceVo);
+         }
+ 
+         if (physcialNetworkId != null) {
+             pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
+             if (pNetwork == null) {
+                 throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
+             }
+             fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.JuniperSRX.getName());
+         }
+ 
+         return fwDevices;
+     }
+ 
+     @Override
+     public List<? extends Network> listNetworks(ListSrxFirewallNetworksCmd cmd) {
+         Long fwDeviceId = cmd.getFirewallDeviceId();
+         List<NetworkVO> networks = new ArrayList<NetworkVO>();
+ 
+         ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
+         if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
+             throw new InvalidParameterValueException("Could not find SRX firewall device with ID " + fwDeviceId);
+         }
+ 
+         List<NetworkExternalFirewallVO> networkFirewallMaps = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
+         if (networkFirewallMaps != null && !networkFirewallMaps.isEmpty()) {
+             for (NetworkExternalFirewallVO networkFirewallMap : networkFirewallMaps) {
+                 NetworkVO network = _networkDao.findById(networkFirewallMap.getNetworkId());
+                 networks.add(network);
+             }
+         }
+ 
+         return networks;
+     }
+ 
+     @Override
+     public SrxFirewallResponse createSrxFirewallResponse(ExternalFirewallDeviceVO fwDeviceVO) {
+         SrxFirewallResponse response = new SrxFirewallResponse();
+         Map<String, String> fwDetails = _hostDetailDao.findDetails(fwDeviceVO.getHostId());
+         Host fwHost = _hostDao.findById(fwDeviceVO.getHostId());
+ 
+         response.setId(fwDeviceVO.getId());
+         response.setPhysicalNetworkId(fwDeviceVO.getPhysicalNetworkId());
+         response.setDeviceName(fwDeviceVO.getDeviceName());
+         if (fwDeviceVO.getCapacity() == 0) {
+             long defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50);
+             response.setDeviceCapacity(defaultFwCapacity);
+         } else {
+             response.setDeviceCapacity(fwDeviceVO.getCapacity());
+         }
+         response.setProvider(fwDeviceVO.getProviderName());
+         response.setDeviceState(fwDeviceVO.getDeviceState().name());
+         response.setIpAddress(fwHost.getPrivateIpAddress());
+         response.setPublicInterface(fwDetails.get("publicInterface"));
+         response.setUsageInterface(fwDetails.get("usageInterface"));
+         response.setPrivateInterface(fwDetails.get("privateInterface"));
+         response.setPublicZone(fwDetails.get("publicZone"));
+         response.setPrivateZone(fwDetails.get("privateZone"));
+         response.setNumRetries(fwDetails.get("numRetries"));
+         response.setTimeout(fwDetails.get("timeout"));
+         response.setObjectName("srxfirewall");
+         return response;
+     }
+ 
+     @Override
+     public boolean verifyServicesCombination(List<String> services) {
+         return true;
+     }
+ 
+     @Override
+     public IpDeployer getIpDeployer(Network network) {
+         return this;
+     }
+ 
+     @Override
+     public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
+         // TODO Auto-generated method stub
+         return false;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --cc plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index 0000000,7fcb6d0..b24a251
mode 000000,100644..100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@@ -1,0 -1,784 +1,784 @@@
+ // Copyright 2012 Citrix Systems, Inc. Licensed under the
+ // Apache License, Version 2.0 (the "License"); you may not use this
+ // file except in compliance with the License.  Citrix Systems, Inc.
+ // reserves all rights not expressly granted by 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.
+ // 
+ // Automatically generated by addcopyright.py at 04/03/2012
+ package com.cloud.network.element;
+ 
+ import java.net.URI;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
+ 
+ import javax.ejb.Local;
+ 
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.agent.AgentManager;
+ import com.cloud.agent.api.Answer;
+ import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
+ import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
+ import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
+ import com.cloud.agent.api.to.LoadBalancerTO;
+ import com.cloud.agent.api.to.StaticNatRuleTO;
+ import com.cloud.api.ApiConstants;
+ import com.cloud.api.commands.AddNetscalerLoadBalancerCmd;
+ import com.cloud.api.commands.ConfigureNetscalerLoadBalancerCmd;
+ import com.cloud.api.commands.DeleteNetscalerLoadBalancerCmd;
+ import com.cloud.api.commands.ListNetscalerLoadBalancerNetworksCmd;
+ import com.cloud.api.commands.ListNetscalerLoadBalancersCmd;
+ import com.cloud.api.response.NetscalerLoadBalancerResponse;
+ import com.cloud.configuration.Config;
+ import com.cloud.configuration.ConfigurationManager;
+ import com.cloud.configuration.dao.ConfigurationDao;
+ import com.cloud.dc.DataCenter;
++import com.cloud.dc.DataCenter.NetworkType;
+ import com.cloud.dc.DataCenterIpAddressVO;
+ import com.cloud.dc.HostPodVO;
 -import com.cloud.dc.DataCenter.NetworkType;
+ import com.cloud.dc.dao.DataCenterDao;
+ import com.cloud.dc.dao.DataCenterIpAddressDao;
+ import com.cloud.deploy.DeployDestination;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.InsufficientCapacityException;
+ import com.cloud.exception.InsufficientNetworkCapacityException;
+ import com.cloud.exception.InvalidParameterValueException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.host.Host;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.host.dao.HostDetailsDao;
+ import com.cloud.network.ExternalLoadBalancerDeviceManager;
+ import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
+ import com.cloud.network.ExternalLoadBalancerDeviceVO;
+ import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState;
+ import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
+ import com.cloud.network.IpAddress;
+ import com.cloud.network.NetScalerPodVO;
+ import com.cloud.network.Network;
+ import com.cloud.network.Network.Capability;
+ import com.cloud.network.Network.Provider;
+ import com.cloud.network.Network.Service;
+ import com.cloud.network.NetworkExternalLoadBalancerVO;
+ import com.cloud.network.NetworkManager;
+ import com.cloud.network.NetworkVO;
+ import com.cloud.network.Networks.TrafficType;
+ import com.cloud.network.PhysicalNetworkServiceProvider;
+ import com.cloud.network.PhysicalNetworkVO;
+ import com.cloud.network.PublicIpAddress;
+ import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
+ import com.cloud.network.dao.NetScalerPodDao;
+ import com.cloud.network.dao.NetworkDao;
+ import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
+ import com.cloud.network.dao.NetworkServiceMapDao;
+ import com.cloud.network.dao.PhysicalNetworkDao;
+ import com.cloud.network.lb.LoadBalancingRule;
+ import com.cloud.network.lb.LoadBalancingRule.LbDestination;
+ import com.cloud.network.resource.NetscalerResource;
+ import com.cloud.network.rules.FirewallRule;
+ import com.cloud.network.rules.FirewallRule.Purpose;
+ import com.cloud.network.rules.LbStickinessMethod;
+ import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
+ import com.cloud.network.rules.StaticNat;
+ import com.cloud.offering.NetworkOffering;
+ import com.cloud.resource.ServerResource;
+ import com.cloud.utils.NumbersUtil;
+ import com.cloud.utils.component.Inject;
+ import com.cloud.utils.db.DB;
+ import com.cloud.utils.db.Transaction;
+ import com.cloud.utils.exception.CloudRuntimeException;
+ import com.cloud.utils.net.UrlUtil;
+ import com.cloud.vm.NicProfile;
+ import com.cloud.vm.ReservationContext;
+ import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.VirtualMachineProfile;
+ import com.google.gson.Gson;
+ 
+ @Local(value = NetworkElement.class)
+ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer,
+         StaticNatServiceProvider {
+ 
+     private static final Logger s_logger = Logger.getLogger(NetscalerElement.class);
+ 
+     @Inject
+     NetworkManager _networkManager;
+     @Inject
+     ConfigurationManager _configMgr;
+     @Inject
+     NetworkServiceMapDao _ntwkSrvcDao;
+     @Inject
+     AgentManager _agentMgr;
+     @Inject
+     NetworkManager _networkMgr;
+     @Inject
+     HostDao _hostDao;
+     @Inject
+     DataCenterDao _dcDao;
+     @Inject
+     ExternalLoadBalancerDeviceDao _lbDeviceDao;
+     @Inject
+     NetworkExternalLoadBalancerDao _networkLBDao;
+     @Inject
+     PhysicalNetworkDao _physicalNetworkDao;
+     @Inject
+     NetworkDao _networkDao;
+     @Inject
+     HostDetailsDao _detailsDao;
+     @Inject
+     ConfigurationDao _configDao;
+     @Inject
+     NetScalerPodDao _netscalerPodDao;
+     @Inject
+     DataCenterIpAddressDao _privateIpAddressDao;
+    
+     private boolean canHandle(Network config, Service service) {
+         DataCenter zone = _dcDao.findById(config.getDataCenterId());
+         boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced && config.getGuestType() == Network.GuestType.Isolated && config.getTrafficType() == TrafficType.Guest);
+         boolean handleInBasicZone = (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest);
+ 
+         if (!(handleInAdvanceZone || handleInBasicZone)) {
+             s_logger.trace("Not handling network with Type  " + config.getGuestType() + " and traffic type " + config.getTrafficType() + " in zone of type " + zone.getNetworkType());
+             return false;
+         }
+ 
+         return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), service, Network.Provider.Netscaler));
+     }
+ 
+     private boolean isBasicZoneNetwok(Network config) {
+         DataCenter zone = _dcDao.findById(config.getDataCenterId());
+         return (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest);
+     }
+ 
+     @Override
+     public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
+             InsufficientNetworkCapacityException {
+ 
+         if (!canHandle(guestConfig, Service.Lb)) {
+             return false;
+         }
+ 
+         if (_ntwkSrvcDao.canProviderSupportServiceInNetwork(guestConfig.getId(), Service.StaticNat, Network.Provider.Netscaler) && !isBasicZoneNetwok(guestConfig)) {
+             s_logger.error("NetScaler provider can not be Static Nat service provider for the network " + guestConfig.getGuestType() + 
+                     " and traffic type " + guestConfig.getTrafficType());
+             return false;
+         }
+ 
+         try {
+             return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
+         } catch (InsufficientCapacityException capacityException) {
+             throw new ResourceUnavailableException("There are no NetScaler load balancer devices with the free capacity for implementing this network", DataCenter.class, guestConfig.getDataCenterId());
+         }
+     }
+ 
+     @Override
+     public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+             InsufficientNetworkCapacityException, ResourceUnavailableException {
+         return true;
+     }
+ 
+     @Override
+     public boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
+         return true;
+     }
+ 
+     @Override
+     public boolean shutdown(Network guestConfig, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
+         if (!canHandle(guestConfig, Service.Lb)) {
+             return false;
+         }
+ 
+         try {
+             return manageGuestNetworkWithExternalLoadBalancer(false, guestConfig);
+         } catch (InsufficientCapacityException capacityException) {
+             // TODO: handle out of capacity exception gracefully in case of multple providers available
+             return false;
+         }
+     }
+ 
+     @Override
+     public boolean destroy(Network config) {
+         return true;
+     }
+ 
+     @Override
+     public boolean validateLBRule(Network network, LoadBalancingRule rule) {
+         return true;
+     }
+ 
+     @Override
+     public boolean applyLBRules(Network config, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
+         if (!canHandle(config, Service.Lb)) {
+             return false;
+         }
+ 
+         if (isBasicZoneNetwok(config)) {
+             return applyElasticLoadBalancerRules(config, rules);
+         } else {
+             return applyLoadBalancerRules(config, rules);
+         }
+     }
+ 
+     @Override
+     public Map<Service, Map<Capability, String>> getCapabilities() {
+         Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
+ 
+         // Set capabilities for LB service
+         Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
+ 
+         // Specifies that the RoundRobin and Leastconn algorithms are supported for load balancing rules
+         lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn");
+ 
+         // specifies that Netscaler network element can provided both shared and isolation modes
+         lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated, shared");
+ 
+         // Specifies that load balancing rules can be made for either TCP or UDP traffic
+         lbCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
+ 
+         // Specifies that this element can measure network usage on a per public IP basis
+         lbCapabilities.put(Capability.TrafficStatistics, "per public ip");
+ 
+         // Specifies that load balancing rules can only be made with public IPs that aren't source NAT IPs
+         lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
+ 
+         LbStickinessMethod method;
+         List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();
+         method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is cookie based sticky method, can be used only for http");
+         methodList.add(method);
+         method.addParam("holdtime", false, "time period in minutes for which persistence is in effect.", false);
+ 
+         method = new LbStickinessMethod(StickinessMethodType.AppCookieBased, "This is app session based sticky method, can be used only for http");
+         methodList.add(method);
+         method.addParam("name", true, "cookie name passed in http header by apllication to the client", false);
+ 
+         method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based sticky method, can be used for any type of protocol.");
+         methodList.add(method);
+         method.addParam("holdtime", false, "time period for which persistence is in effect.", false);
+ 
+         Gson gson = new Gson();
+         String stickyMethodList = gson.toJson(methodList);
+         lbCapabilities.put(Capability.SupportedStickinessMethods, stickyMethodList);
+ 
+         lbCapabilities.put(Capability.ElasticLb, "true");
+ 
+         capabilities.put(Service.Lb, lbCapabilities);
+ 
+         Map<Capability, String> staticNatCapabilities = new HashMap<Capability, String>();
+         staticNatCapabilities.put(Capability.ElasticIp, "true");
+         capabilities.put(Service.StaticNat, staticNatCapabilities);
+ 
+         // TODO - Murali, please put correct capabilities here
+         Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();
+         firewallCapabilities.put(Capability.TrafficStatistics, "per public ip");
+         firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp,icmp");
+         firewallCapabilities.put(Capability.MultipleIps, "true");
 -
++        firewallCapabilities.put(Capability.FirewallType, "perpublicip");
+         capabilities.put(Service.Firewall, firewallCapabilities);
+ 
+         return capabilities;
+     }
+ 
+     @Override
+     public ExternalLoadBalancerDeviceVO addNetscalerLoadBalancer(AddNetscalerLoadBalancerCmd cmd) {
+         String deviceName = cmd.getDeviceType();
+ 
+         if (!isNetscalerDevice(deviceName)) {
+             throw new InvalidParameterValueException("Invalid Netscaler device type");
+         }
+ 
+         URI uri;
+         try {
+             uri = new URI(cmd.getUrl());
+         } catch (Exception e) {
+             String msg = "Error parsing the url parameter specified in addNetscalerLoadBalancer command due to " + e.getMessage();
+             s_logger.debug(msg);
+             throw new InvalidParameterValueException(msg);
+         }
+         Map<String, String> configParams = new HashMap<String, String>();
+         UrlUtil.parseQueryParameters(uri.getQuery(), false, configParams);
+         boolean dedicatedUse = (configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)) : false;
+ 
+         if (dedicatedUse && !deviceName.equals(NetworkDevice.NetscalerVPXLoadBalancer.getName())) {
+             String msg = "Only Netscaler VPX load balancers can be specified for dedicated use";
+             s_logger.debug(msg);
+             throw new InvalidParameterValueException(msg);
+         }
+ 
+         ExternalLoadBalancerDeviceVO lbDeviceVO = addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, (ServerResource) new NetscalerResource());
+         return lbDeviceVO;
+     }
+ 
+     @Override
+     public boolean deleteNetscalerLoadBalancer(DeleteNetscalerLoadBalancerCmd cmd) {
+         Long lbDeviceId = cmd.getLoadBalancerDeviceId();
+ 
+         ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
+         if ((lbDeviceVo == null) || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
+             throw new InvalidParameterValueException("No netscaler device found with ID: " + lbDeviceId);
+         }
+ 
+         return deleteExternalLoadBalancer(lbDeviceVo.getHostId());
+     }
+ 
+     @Override
+     public ExternalLoadBalancerDeviceVO configureNetscalerLoadBalancer(ConfigureNetscalerLoadBalancerCmd cmd) {
+         Long lbDeviceId = cmd.getLoadBalancerDeviceId();
+         Boolean dedicatedUse = cmd.getLoadBalancerDedicated();
+         Boolean inline = cmd.getLoadBalancerInline();
+         Long capacity = cmd.getLoadBalancerCapacity();
+         List<Long> podIds = cmd.getPodIds();
+         try {
+             return configureNetscalerLoadBalancer(lbDeviceId, capacity, inline, dedicatedUse, podIds);
+         } catch (Exception e) {
+             throw new CloudRuntimeException("failed to configure netscaler device due to " + e.getMessage());
+         }
+     }
+ 
+     @DB
+     private ExternalLoadBalancerDeviceVO configureNetscalerLoadBalancer(long lbDeviceId, Long capacity, Boolean inline, Boolean dedicatedUse, List<Long> newPodsConfig) {
+         ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
+         Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVo.getHostId());
+ 
+         if ((lbDeviceVo == null) || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
+             throw new InvalidParameterValueException("No netscaler device found with ID: " + lbDeviceId);
+         }
+ 
+         List<Long> currentPodsConfig = new ArrayList<Long>();
+         List<NetScalerPodVO> currentPodVOs = _netscalerPodDao.listByNetScalerDeviceId(lbDeviceVo.getId());
+         if (currentPodVOs != null && currentPodVOs.size() > 0) {
+             for (NetScalerPodVO nsPodVo: currentPodVOs) {
+                 currentPodsConfig.add(nsPodVo.getPodId());
+             }
+         }
+ 
+         List<Long> podsToAssociate = new ArrayList<Long>();
+         if (newPodsConfig != null && newPodsConfig.size() > 0) {
+             for (Long podId: newPodsConfig) {
+                 HostPodVO pod = _podDao.findById(podId);
+                 if (pod == null) {
+                     throw new InvalidParameterValueException("Can't find pod by id " + podId);
+                 }
+             }
+ 
+             for (Long podId: newPodsConfig) {
+                 if (!currentPodsConfig.contains(podId)) {
+                     podsToAssociate.add(podId);
+                 }
+             }
+         }
+ 
+         List<Long> podsToDeassociate = new ArrayList<Long>();
+         for (Long podId: currentPodsConfig) {
+             if (!newPodsConfig.contains(podId)) {
+                 podsToDeassociate.add(podId);
+             }
+         }
+ 
+         String deviceName = lbDeviceVo.getDeviceName();
+         if (dedicatedUse != null || capacity != null || inline != null) {
+             if (NetworkDevice.NetscalerSDXLoadBalancer.getName().equalsIgnoreCase(deviceName) ||
+                     NetworkDevice.NetscalerMPXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
+                 if (dedicatedUse != null && dedicatedUse == true) {
+                     throw new InvalidParameterValueException("Netscaler MPX and SDX device should be shared and can not be dedicated to a single account.");
+                 }
+             }
+ 
+             // check if any networks are using this netscaler device
+             List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
+             if ((networks != null) && !networks.isEmpty()) {
+                 if (capacity != null && capacity < networks.size()) {
+                     throw new CloudRuntimeException("There are more number of networks already using this netscaler device than configured capacity");
+                 }
+ 
+                 if (dedicatedUse != null && dedicatedUse == true) {
+                     throw new CloudRuntimeException("There are networks already using this netscaler device to make device dedicated");
+                 }
+ 
+                 if (inline != null) {
+                     boolean _setInline = Boolean.parseBoolean((String) lbDetails.get("inline"));
+                     if (inline != _setInline) {
+                         throw new CloudRuntimeException("There are networks already using this netscaler device to change the device inline or side-by-side configuration");
+                     }
+                 }
+             }
+         }
+ 
+         if (!NetworkDevice.NetscalerSDXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
+             if (capacity != null) {
+                 lbDeviceVo.setCapacity(capacity);
+             }
+         } else {
+             // FIXME how to interpret configured capacity of the SDX device
+         }
+ 
+         if (dedicatedUse != null) {
+             lbDeviceVo.setIsDedicatedDevice(dedicatedUse);
+         }
+ 
+         if (inline != null && inline == true) {
+             lbDeviceVo.setIsInlineMode(true);
+             lbDetails.put("inline", "true");
+         } else {
+             lbDeviceVo.setIsInlineMode(false);
+             lbDetails.put("inline", "false");
+         }
+ 
+         Transaction txn = Transaction.currentTxn();
+         txn.start();
+ 
+         _lbDeviceDao.update(lbDeviceId, lbDeviceVo);
+ 
+         for (Long podId: podsToAssociate) {
+             NetScalerPodVO nsPodVo = new NetScalerPodVO(lbDeviceId, podId);
+             _netscalerPodDao.persist(nsPodVo);
+         }
+ 
+         for (Long podId: podsToDeassociate) {
+             NetScalerPodVO nsPodVo = _netscalerPodDao.findByPodId(podId);
+             _netscalerPodDao.remove(nsPodVo.getId());
+         }
+ 
+         // FIXME get the row lock to avoid race condition
+         _detailsDao.persist(lbDeviceVo.getHostId(), lbDetails);
+         HostVO host = _hostDao.findById(lbDeviceVo.getHostId());
+         txn.commit();
+ 
+         _agentMgr.reconnect(host.getId());
+         return lbDeviceVo;
+     }
+ 
+     @Override
+     public String getPropertiesFile() {
+         return "netscalerloadbalancer_commands.properties";
+     }
+ 
+     @Override
+     public List<? extends Network> listNetworks(ListNetscalerLoadBalancerNetworksCmd cmd) {
+         Long lbDeviceId = cmd.getLoadBalancerDeviceId();
+         List<NetworkVO> networks = new ArrayList<NetworkVO>();
+ 
+         ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
+         if (lbDeviceVo == null || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
+             throw new InvalidParameterValueException("Could not find Netscaler load balancer device with ID " + lbDeviceId);
+         }
+ 
+         List<NetworkExternalLoadBalancerVO> networkLbMaps = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
+         if (networkLbMaps != null && !networkLbMaps.isEmpty()) {
+             for (NetworkExternalLoadBalancerVO networkLbMap : networkLbMaps) {
+                 NetworkVO network = _networkDao.findById(networkLbMap.getNetworkId());
+                 networks.add(network);
+             }
+         }
+ 
+         return networks;
+     }
+ 
+     @Override
+     public List<ExternalLoadBalancerDeviceVO> listNetscalerLoadBalancers(ListNetscalerLoadBalancersCmd cmd) {
+         Long physcialNetworkId = cmd.getPhysicalNetworkId();
+         Long lbDeviceId = cmd.getLoadBalancerDeviceId();
+         PhysicalNetworkVO pNetwork = null;
+         List<ExternalLoadBalancerDeviceVO> lbDevices = new ArrayList<ExternalLoadBalancerDeviceVO>();
+ 
+         if (physcialNetworkId == null && lbDeviceId == null) {
+             throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
+         }
+ 
+         if (lbDeviceId != null) {
+             ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
+             if (lbDeviceVo == null || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
+                 throw new InvalidParameterValueException("Could not find Netscaler load balancer device with ID: " + lbDeviceId);
+             }
+             lbDevices.add(lbDeviceVo);
+             return lbDevices;
+         }
+ 
+         if (physcialNetworkId != null) {
+             pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
+             if (pNetwork == null) {
+                 throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
+             }
+             lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.Netscaler.getName());
+             return lbDevices;
+         }
+ 
+         return null;
+     }
+ 
+     @Override
+     public NetscalerLoadBalancerResponse createNetscalerLoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
+         NetscalerLoadBalancerResponse response = new NetscalerLoadBalancerResponse();
+         Host lbHost = _hostDao.findById(lbDeviceVO.getHostId());
+         Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId());
+ 
+         response.setId(lbDeviceVO.getId());
+         response.setIpAddress(lbHost.getPrivateIpAddress());
+         response.setPhysicalNetworkId(lbDeviceVO.getPhysicalNetworkId());
+         response.setPublicInterface(lbDetails.get("publicInterface"));
+         response.setPrivateInterface(lbDetails.get("privateInterface"));
+         response.setDeviceName(lbDeviceVO.getDeviceName());
+         if (lbDeviceVO.getCapacity() == 0) {
+             long defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50);
+             response.setDeviceCapacity(defaultLbCapacity);
+         } else {
+             response.setDeviceCapacity(lbDeviceVO.getCapacity());
+         }
+         response.setInlineMode(lbDeviceVO.getIsInLineMode());
+         response.setDedicatedLoadBalancer(lbDeviceVO.getIsDedicatedDevice());
+         response.setProvider(lbDeviceVO.getProviderName());
+         response.setDeviceState(lbDeviceVO.getState().name());
+         response.setObjectName("netscalerloadbalancer");
+         
+         List<Long> associatedPods = new ArrayList<Long>();
+         List<NetScalerPodVO> currentPodVOs = _netscalerPodDao.listByNetScalerDeviceId(lbDeviceVO.getId());
+         if (currentPodVOs != null && currentPodVOs.size() > 0) {
+         	for (NetScalerPodVO nsPodVo: currentPodVOs) {
+         		associatedPods.add(nsPodVo.getPodId());
+         	}
+         }
+         response.setAssociatedPods(associatedPods);
+         return response;
+     }
+ 
+     @Override
+     public Provider getProvider() {
+         return Provider.Netscaler;
+     }
+ 
+     @Override
+     public boolean isReady(PhysicalNetworkServiceProvider provider) {
+         List<ExternalLoadBalancerDeviceVO> lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.Netscaler.getName());
+ 
+         // true if at-least one Netscaler device is added in to physical network and is in configured (in enabled state)
+ // state
+         if (lbDevices != null && !lbDevices.isEmpty()) {
+             for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
+                 if (lbDevice.getState() == LBDeviceState.Enabled) {
+                     return true;
+                 }
+             }
+         }
+         return false;
+     }
+ 
+     @Override
+     public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
+             ResourceUnavailableException {
+         // TODO reset the configuration on all of the netscaler devices in this physical network
+         return true;
+     }
+ 
+     @Override
+     public boolean canEnableIndividualServices() {
+         return true;
+     }
+ 
+     private boolean isNetscalerDevice(String deviceName) {
+         if ((deviceName == null) || ((!deviceName.equalsIgnoreCase(NetworkDevice.NetscalerMPXLoadBalancer.getName())) &&
+                 (!deviceName.equalsIgnoreCase(NetworkDevice.NetscalerSDXLoadBalancer.getName())) &&
+                 (!deviceName.equalsIgnoreCase(NetworkDevice.NetscalerVPXLoadBalancer.getName())))) {
+             return false;
+         } else {
+             return true;
+         }
+     }
+ 
+     @Override
+     public boolean verifyServicesCombination(List<String> services) {
+         List<String> netscalerServices = new ArrayList<String>();
+         netscalerServices.add(Service.Lb.getName());
+         netscalerServices.add(Service.StaticNat.getName());
+ 
+         // NetScaler can only act as Lb and Static Nat service provider
+         if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) {
+             s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " 
+                 + services + " is not supported.");
+             return false;
+         }
+ 
+         return true;
+     }
+ 
+     @Override
+     public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
+         // return true, as IP will be associated as part of LB rule configuration
+         return false;
+     }
+ 
+     @Override
+     public IpDeployer getIpDeployer(Network network) {
+         return this;
+     }
+ 
+     public boolean applyElasticLoadBalancerRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
+ 
+         List<LoadBalancingRule> loadBalancingRules = new ArrayList<LoadBalancingRule>();
+         for (FirewallRule rule : rules) {
+             if (rule.getPurpose().equals(Purpose.LoadBalancing)) {
+                 loadBalancingRules.add((LoadBalancingRule) rule);
+             }
+         }
+ 
+         if (loadBalancingRules == null || loadBalancingRules.isEmpty()) {
+             return true;
+         }
+ 
+         String errMsg = null;
+         ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
+         if (lbDeviceVO == null) {
+             try {
+                 lbDeviceVO = allocateLoadBalancerForNetwork(network);
+             } catch (Exception e) {
+                 errMsg = "Could not allocate a NetSclaer load balancer for configuring elastic load balancer rules due to " + e.getMessage();
+                 s_logger.error(errMsg);
+                 throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+             }
+         }
+ 
+         if (!isNetscalerDevice(lbDeviceVO.getDeviceName())) {
+             errMsg = "There are no NetScaler load balancer assigned for this network. So NetScaler element can not be handle elastic load balancer rules.";
+             s_logger.error(errMsg);
+             throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+         }
+ 
+         List<LoadBalancerTO> loadBalancersToApply = new ArrayList<LoadBalancerTO>();
+         for (int i = 0; i < loadBalancingRules.size(); i++) {
+             LoadBalancingRule rule = loadBalancingRules.get(i);
+             boolean revoked = (rule.getState().equals(FirewallRule.State.Revoke));
+             String protocol = rule.getProtocol();
+             String algorithm = rule.getAlgorithm();
+             String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
+             int srcPort = rule.getSourcePortStart();
+             List<LbDestination> destinations = rule.getDestinations();
+ 
+             if (destinations != null && !destinations.isEmpty()) {
+                 LoadBalancerTO loadBalancer = new LoadBalancerTO(srcIp, srcPort, protocol, algorithm, revoked, false, destinations, rule.getStickinessPolicies());
+                 loadBalancersToApply.add(loadBalancer);
+             }
+         }
+ 
+         if (loadBalancersToApply.size() > 0) {
+             int numLoadBalancersForCommand = loadBalancersToApply.size();
+             LoadBalancerTO[] loadBalancersForCommand = loadBalancersToApply.toArray(new LoadBalancerTO[numLoadBalancersForCommand]);
 -            LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand);
++            LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand, null);
+ 
+             HostVO externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
+             Answer answer = _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
+             if (answer == null || !answer.getResult()) {
+                 String details = (answer != null) ? answer.getDetails() : "details unavailable";
+                 String msg = "Unable to apply elastic load balancer rules to the external load balancer appliance in zone " + network.getDataCenterId() + " due to: " + details + ".";
+                 s_logger.error(msg);
+                 throw new ResourceUnavailableException(msg, DataCenter.class, network.getDataCenterId());
+             }
+         }
+ 
+         return true;
+     }
+ 
+     @Override
+     public boolean applyStaticNats(Network config, List<? extends StaticNat> rules) throws ResourceUnavailableException {
+ 
+         if (!canHandle(config, Service.StaticNat)) {
+             return false;
+         }
+ 
+         boolean multiNetScalerDeployment = Boolean.valueOf(_configDao.getValue(Config.EIPWithMultipleNetScalersEnabled.key()));
+ 
+         try {
+             if (!multiNetScalerDeployment) {
+                 String errMsg;
+                 ExternalLoadBalancerDeviceVO lbDevice = getExternalLoadBalancerForNetwork(config);
+                 if (lbDevice == null) {
+                     try {
+                         lbDevice = allocateLoadBalancerForNetwork(config);
+                     } catch (Exception e) {
+                         errMsg = "Could not allocate a NetSclaer load balancer for configuring static NAT rules due to" + e.getMessage();
+                         s_logger.error(errMsg);
+                         throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+                     }
+                 }
+ 
+                 if (!isNetscalerDevice(lbDevice.getDeviceName())) {
+                     errMsg = "There are no NetScaler load balancer assigned for this network. So NetScaler element will not be handling the static nat rules.";
+                     s_logger.error(errMsg);
+                     throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+                 }
+                 SetStaticNatRulesAnswer answer = null;
+                 List<StaticNatRuleTO> rulesTO = null;
+                 if (rules != null) {
+                     rulesTO = new ArrayList<StaticNatRuleTO>();
+                     for (StaticNat rule : rules) {
+                         IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                         StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null, null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
+                         rulesTO.add(ruleTO);
+                     }
+                 }
+ 
 -                SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
++                SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, null);
+                 answer = (SetStaticNatRulesAnswer) _agentMgr.send(lbDevice.getHostId(), cmd);
+                 if (answer == null) {
+                     return false;
+                 } else {
+                     return answer.getResult();
+                 }
+             } else {
+                 if (rules != null) {
+                     for (StaticNat rule : rules) {
+                         // validate if EIP rule can be configured. 
+                         ExternalLoadBalancerDeviceVO lbDevice = getNetScalerForEIP(rule);
+                         if (lbDevice == null) {
+                             String errMsg = "There is no NetScaler device configured to perform EIP to guest IP address: " + rule.getDestIpAddress();
+                             s_logger.error(errMsg);
+                             throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+                         }
+ 
+                         List<StaticNatRuleTO> rulesTO = new ArrayList<StaticNatRuleTO>();
+                         IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                         StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null, null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
+                         rulesTO.add(ruleTO);
 -                        SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
++                        SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, null);
+ 
+                         // send commands to configure INAT rule on the NetScaler device
+                         SetStaticNatRulesAnswer answer = (SetStaticNatRulesAnswer) _agentMgr.send(lbDevice.getHostId(), cmd);
+                         if (answer == null) {
+                             String errMsg = "Failed to configure INAT rule on NetScaler device " + lbDevice.getHostId();
+                             s_logger.error(errMsg);
+                             throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
+                         }
+                     }
+                     return true;
+                 }
+             }
+             return true;
+         } catch (Exception e) {
+             s_logger.error("Failed to configure StaticNat rule due to " + e.getMessage());
+             return false;
+         }
+     }
+ 
+     // returns configured NetScaler device that is associated with the pod that owns guest IP
+     private ExternalLoadBalancerDeviceVO getNetScalerForEIP(StaticNat rule) {
+         String guestIP = rule.getDestIpAddress();
+         List <DataCenterIpAddressVO> dcGuestIps =  _privateIpAddressDao.listAll();
+         if (dcGuestIps != null) {
+             for (DataCenterIpAddressVO dcGuestIp: dcGuestIps) {
+                 if (dcGuestIp.getIpAddress().equalsIgnoreCase(guestIP)) {
+                     long podId = dcGuestIp.getPodId();
+                     NetScalerPodVO  nsPodVO = _netscalerPodDao.findByPodId(podId);
+                     if (nsPodVO != null) {
+                         ExternalLoadBalancerDeviceVO lbDeviceVO = _lbDeviceDao.findById(nsPodVO.getNetscalerDeviceId());
+                         return lbDeviceVO;
+                     }
+                 }
+            }
+         }
+         return null;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/network/domr/router_proxy.sh
----------------------------------------------------------------------
diff --cc scripts/network/domr/router_proxy.sh
index ac0c9cb,0000000..bcac412
mode 100755,000000..100755
--- a/scripts/network/domr/router_proxy.sh
+++ b/scripts/network/domr/router_proxy.sh
@@@ -1,54 -1,0 +1,58 @@@
- #!/usr/bin/env bash
- # Copyright 2012 Citrix Systems, Inc. Licensed under the
- # Apache License, Version 2.0 (the "License"); you may not use this
- # file except in compliance with the License.  Citrix Systems, Inc.
- # reserves all rights not expressly granted by 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.
++#!/bin/bash
++# 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
 +# 
- # Automatically generated by addcopyright.py at 04/03/2012
++#   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.
 +
 +
 +
 +# used as a proxy to call script inside virtual router 
 +
 +#set -x
 +
 +check_gw() {
 +  ping -c 1 -n -q $1 > /dev/null
 +  if [ $? -gt 0 ]
 +  then
 +    sleep 1
 +    ping -c 1 -n -q $1 > /dev/null
 +  fi
 +  if [ $? -gt 0 ]
 +  then
 +    exit 1
 +  fi
 +}
 +
 +cert="/root/.ssh/id_rsa.cloud"
 +
 +script=$1
 +shift
 +
 +domRIp=$1
 +shift
 +
 +check_gw "$domRIp"
 +
 +ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/opt/cloud/bin/$script $*"
 +exit $?
 +
 +
 +
 +
 +
 +
 +
 +
 +

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/vm/hypervisor/xenserver/vmops
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/vm/hypervisor/xenserver/xcpserver/patch
----------------------------------------------------------------------
diff --cc scripts/vm/hypervisor/xenserver/xcpserver/patch
index 7171635,bc2ba33..68f7ed8
--- a/scripts/vm/hypervisor/xenserver/xcpserver/patch
+++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch
@@@ -1,5 -1,21 +1,22 @@@
+ # 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.
+ 
  # This file specifies the files that need
 +#
  # to be transferred over to the XenServer.
  # The format of this file is as follows:
  # [Name of file]=[source path],[file permission],[destination path]

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/vm/hypervisor/xenserver/xenserver56/patch
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/scripts/vm/hypervisor/xenserver/xenserver60/patch
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/634cd78b/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDBUtils.java
index 855bd74,2a0eaaf..dd1b253
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@@ -190,7 -191,7 +192,8 @@@ public class ApiDBUtils 
      private static AccountDetailsDao _accountDetailsDao;
      private static NetworkDomainDao _networkDomainDao;
      private static HighAvailabilityManager _haMgr;
 +    private static VpcManager _vpcMgr;
+     private static TaggedResourceService _taggedResourceService;
  
      static {
          _ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
@@@ -244,7 -245,7 +247,8 @@@
          _accountDetailsDao = locator.getDao(AccountDetailsDao.class);
          _networkDomainDao = locator.getDao(NetworkDomainDao.class);
          _haMgr = locator.getManager(HighAvailabilityManager.class);
 +        _vpcMgr = locator.getManager(VpcManager.class);
+         _taggedResourceService = locator.getManager(TaggedResourceService.class);
  
          // Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
          _statsCollector = StatsCollector.getInstance();
@@@ -752,12 -753,13 +756,21 @@@
      public static String getHaTag() {
          return _haMgr.getHaTag();
      }
 -
 +    
 +    public static Map<Service, Set<Provider>> listVpcOffServices(long vpcOffId) {
 +        return _vpcMgr.getVpcOffSvcProvidersMap(vpcOffId);
 +    }
 +    
 +    public static List<? extends Network> listVpcNetworks(long vpcId) {
 +        return _networkMgr.listNetworksByVpc(vpcId);
 +    }
++    
+     public static boolean canUseForDeploy(Network network) {
+         return _networkMgr.canUseForDeploy(network);
+     }
+     
+     public static String getUuid(String resourceId, TaggedResourceType resourceType) {
+         return _taggedResourceService.getUuid(resourceId, resourceType);
+     }
+ 
  }


Mime
View raw message