CLOUDSTACK-8672 : NCC Integration with CloudStack.

This commit is contained in:
Rajesh Battala 2015-07-23 14:14:07 +05:30 committed by Sateesh Chodapuneedi
parent 445dbe7c53
commit 884606f77b
25 changed files with 5234 additions and 18 deletions

View File

@ -545,6 +545,11 @@ public class EventTypes {
//Usage related events
public static final String EVENT_USAGE_REMOVE_USAGE_RECORDS = "USAGE.REMOVE.USAGE.RECORDS";
// Netscaler Service Package events
public static final String EVENT_NETSCALER_SERVICEPACKAGE_ADD = "NETSCALER.SERVICEPACKAGE.ADD";
public static final String EVENT_NETSCALER_SERVICEPACKAGE_DELETE = "NETSCALER.SERVICEPACKAGE.DELETE";
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@ -918,6 +923,10 @@ public class EventTypes {
//Usage
entityEventDetails.put(EVENT_USAGE_REMOVE_USAGE_RECORDS, Usage.class);
// Netscaler Service Packages
entityEventDetails.put(EVENT_NETSCALER_SERVICEPACKAGE_ADD, "NETSCALER.SERVICEPACKAGE.CREATE");
entityEventDetails.put(EVENT_NETSCALER_SERVICEPACKAGE_DELETE, "NETSCALER.SERVICEPACKAGE.DELETE");
}
public static String getEntityForEvent(String eventName) {

View File

@ -31,7 +31,7 @@ import com.cloud.utils.fsm.StateObject;
public interface Host extends StateObject<Status>, Identity, InternalIdentity {
public enum Type {
Storage(false), Routing(false), SecondaryStorage(false), SecondaryStorageCmdExecutor(false), ConsoleProxy(true), ExternalFirewall(false), ExternalLoadBalancer(
false), ExternalVirtualSwitchSupervisor(false), PxeServer(false), BaremetalPxe(false), BaremetalDhcp(false), TrafficMonitor(false),
false), ExternalVirtualSwitchSupervisor(false), PxeServer(false), BaremetalPxe(false), BaremetalDhcp(false), TrafficMonitor(false), NetScalerControlCenter(false),
ExternalDhcp(false), SecondaryStorageVM(true), LocalSecondaryStorage(false), L2Networking(false);
boolean _virtual;

View File

@ -652,6 +652,8 @@ public class ApiConstants {
public static final String OVM3_CLUSTER = "ovm3cluster";
public static final String OVM3_VIP = "ovm3vip";
public static final String CLEAN_UP_DETAILS = "cleanupdetails";
public static final String NETSCALER_CONTROLCENTER_ID = "netscalercontrolcenterid";
public static final String NETSCALER_SERVICEPACKAGE_ID = "netscalerservicepackageid";
public static final String ZONE_ID_LIST = "zoneids";
public static final String DESTINATION_ZONE_ID_LIST = "destzoneids";

View File

@ -0,0 +1,65 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
package com.cloud.agent.api;
public class NetScalerImplementNetworkCommand extends Command {
private String _networkDetails;
public NetScalerImplementNetworkCommand() {
super();
}
private Long dcId;
private Long hostId;
public NetScalerImplementNetworkCommand(Long dcId) {
super();
this.dcId = dcId;
}
public NetScalerImplementNetworkCommand(Long dcId, Long hostId, String networkDetails) {
this(dcId);
this.hostId = hostId;
this._networkDetails = networkDetails;
}
public void setDetails(String details) {
_networkDetails = details;
}
public String getDetails() {
return _networkDetails;
}
public Long getDataCenterId() {
return dcId;
}
@Override
public boolean executeInSequence() {
//TODO checkout whether we need to mark it true ??
//Marking it true is causing another guest network execution in queue
return false;
}
public Long getHostId() {
return hostId;
}
}

View File

@ -26,4 +26,7 @@ public class StartupExternalLoadBalancerCommand extends StartupCommand {
super(Host.Type.ExternalLoadBalancer);
}
public StartupExternalLoadBalancerCommand(Host.Type type) {
super(type);
}
}

View File

@ -442,7 +442,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.QuickCloudNoServices) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.QuickCloudNoServices, "Offering for QuickCloud with no services", TrafficType.Guest, null, true,
Availability.Optional, null, new HashMap<Network.Service, Set<Network.Provider>>(), true, Network.GuestType.Shared, false, null, true, null, true,
false, null, false, null, true);
false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -451,7 +451,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOfferingWithSGService) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks",
TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true,
null, true, false, null, false, null, true);
null, true, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -460,7 +460,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true,
Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null, false,
null, true);
null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -470,7 +470,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
"Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null,
defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false, null,
true);
true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
@ -480,7 +480,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Optional, null,
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true);
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -491,7 +491,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
defaultVPCOffProviders.remove(Service.Lb);
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
"Offering for Isolated VPC networks with Source Nat service enabled and LB service disabled", TrafficType.Guest, null, false, Availability.Optional,
null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true);
null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -500,7 +500,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service",
TrafficType.Guest, null, true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null,
true, null, true, false, null, false, null, true);
true, null, true, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
@ -524,7 +524,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
"Offering for Isolated VPC networks with Internal Lb support", TrafficType.Guest, null, false, Availability.Optional, null, internalLbOffProviders,
true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true);
true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
offering.setInternalLb(true);
offering.setPublicLb(false);
@ -556,7 +556,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedEIPandELBNetworkOffering) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedEIPandELBNetworkOffering,
"Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, null, true, Availability.Optional, null,
netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true);
netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true, null);
offering.setState(NetworkOffering.State.Enabled);
offering.setDedicatedLB(false);
_networkOfferingDao.update(offering.getId(), offering);

View File

@ -642,7 +642,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
SearchCriteria<HostVO> sc = UnmanagedApplianceSearch.create();
sc.setParameters("lastPinged", lastPingSecondsAfter);
sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.BaremetalDhcp, Type.BaremetalPxe, Type.TrafficMonitor,
Type.L2Networking);
Type.L2Networking, Type.NetScalerControlCenter);
List<HostVO> hosts = lockRows(sc, null, true);
for (HostVO host : hosts) {

View File

@ -37,5 +37,10 @@
<artifactId>sdx_nitro</artifactId>
<version>${cs.nitro.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
</project>

View File

@ -26,7 +26,8 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
>
<bean id="netScalerServicePackageDaoImpl" class="com.cloud.network.dao.NetScalerServicePackageDaoImpl" />
<bean id="netScalerControlCenterDaoImpl" class="com.cloud.network.dao.NetScalerControlCenterDaoImpl" />
<bean id="netScalerPodDaoImpl" class="com.cloud.network.dao.NetScalerPodDaoImpl" />
<bean id="netscalerElement" class="com.cloud.network.element.NetscalerElement" >
<property name="name" value="Netscaler"/>

View File

@ -0,0 +1,144 @@
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.cloud.api.commands;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.context.CallContext;
import com.cloud.api.response.NetscalerLoadBalancerResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetScalerControlCenterVO;
import com.cloud.network.element.NetscalerLoadBalancerElementService;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "registerNetscalerControlCenter", responseObject = NetscalerLoadBalancerResponse.class, description = "Adds a netscaler control center device",
requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
public class RegisterNetscalerControlCenterCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(RegisterNetscalerControlCenterCmd.class.getName());
private static final String s_name = "registernetscalercontrolcenterrresponse";
@Inject
NetscalerLoadBalancerElementService _netsclarLbService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.IP_ADDRESS , type = CommandType.STRING, required = true, description = "URL of the netscaler controlcenter appliance.")
private String ipaddress;
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Credentials to reach netscaler controlcenter device")
private String username;
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "Credentials to reach netscaler controlcenter device")
private String password;
@Parameter(name = ApiConstants.NUM_RETRIES , type = CommandType.INTEGER, required = true, description = "Credentials to reach netscaler controlcenter device")
private int numretries;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public static Logger getsLogger() {
return s_logger;
}
public static String getsName() {
return s_name;
}
public NetscalerLoadBalancerElementService get_netsclarLbService() {
return _netsclarLbService;
}
public String getIpaddress() {
return ipaddress;
}
public int getNumretries() {
return numretries;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException {
try {
NetScalerControlCenterVO nccVO = _netsclarLbService.registerNetscalerControlCenter(this);
if (nccVO != null) {
/*NetscalerLoadBalancerResponse response = _netsclarLbService.createNetscalerLoadBalancerResponse(lbDeviceVO);
response.setObjectName("netscalerloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);*/
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add netscaler load balancer due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
@Override
public String getEventDescription() {
return "Adding a netscaler load balancer device";
}
@Override
public String getEventType() {
return EventTypes.EVENT_EXTERNAL_LB_DEVICE_ADD;
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
}

View File

@ -0,0 +1,107 @@
//Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.cloud.api.commands;
import javax.inject.Inject;
import javax.persistence.EntityExistsException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.context.CallContext;
import com.cloud.api.response.NetScalerServicePackageResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.element.NetscalerLoadBalancerElementService;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "registerNetscalerServicePackage", responseObject = NetScalerServicePackageResponse.class,
description = "Registers NCC Service Package")
public class RegisterServicePackageCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(RegisterServicePackageCmd.class.getName());
private static final String s_name = "registerNetscalerServicePackage";
@Inject
NetscalerLoadBalancerElementService _netsclarLbService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Name of the service Package.")
private String spName;
@Parameter(name = ApiConstants.DESCRIPTION , type = CommandType.STRING, required = true, description = "Description of Service Package")
private String description;
/* @Override
public String getEventType() {
return EventTypes.EVENT_NETSCALER_SERVICEPACKAGE_ADD;
}
@Override
public String getEventDescription() {
return "Adding Netscaler Service Package";
}
*/
@Override
public void execute() throws ServerApiException, ConcurrentOperationException, EntityExistsException {
try {
NetScalerServicePackageResponse response = _netsclarLbService.registerNetscalerServicePackage(this);
if (response != null) {
//NetScalerServicePackageResponse response = _netsclarLbService.createNetscalerServicePackageResponse(servicePackageVO);
response.setObjectName("netscalerservicepackage");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Service Package due to internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
} catch (EntityExistsException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR , "Service Pacakge Already Exists with Name " + getSpName() );
}
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
public String getSpName() {
return spName;
}
public String getDescription() {
return description;
}
}

View File

@ -0,0 +1,71 @@
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.cloud.api.response;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.network.NetScalerServicePackageVO;
import com.cloud.serializer.Param;
public class NetScalerServicePackageResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "Service Package UUID")
private String id;
@SerializedName(ApiConstants.NAME)
@Param(description = "Service Package Name")
private String name;
@SerializedName(ApiConstants.DESCRIPTION)
@Param(description = "Description of Service Package")
private String description;
public NetScalerServicePackageResponse() {}
public NetScalerServicePackageResponse(NetScalerServicePackageVO servicePackage) {
this.id = servicePackage.getUuid();
this.name = servicePackage.getName();
this.description = servicePackage.getDescription();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,129 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
/**
* NetScalerPodVO contains information about a EIP deployment where on datacenter L3 router a PBR (policy
* based routing) is setup between a POD's subnet IP range to a NetScaler device. This VO object
* represents a mapping between a POD and NetScaler device where PBR is setup.
*
*/
@Entity
@Table(name = "external_netscaler_controlcenter")
public class NetScalerControlCenterVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "username")
private String username;
@Column(name = "password")
private String password;
@Column(name = "uuid")
private String uuid;
@Column(name = "ncc_ip")
private String nccip;
@Column(name = "num_retries")
private int numRetries;
public NetScalerControlCenterVO() {
}
public NetScalerControlCenterVO(long hostId, String username, String password, String nccip, int retries) {
this.username = username;
this.password = password;
this.uuid = UUID.randomUUID().toString();
this.nccip = nccip;
this.numRetries = retries;
}
public NetScalerControlCenterVO(String username, String password, String nccip, int retries) {
this.username = username;
this.password = password;
this.uuid = UUID.randomUUID().toString();
this.nccip = nccip;
this.numRetries = retries;
}
public String getUuid() {
return uuid;
}
public String getNccip() {
return nccip;
}
public void setNccip(String nccip) {
this.nccip = nccip;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setId(long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getNumRetries() {
return numRetries;
}
public void setNumRetries(int numRetries) {
this.numRetries = numRetries;
}
@Override
public long getId() {
// TODO Auto-generated method stub
return id;
}
}

View File

@ -0,0 +1,107 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.api.commands.RegisterServicePackageCmd;
/**
* NetScalerPodVO contains information about a EIP deployment where on datacenter L3 router a PBR (policy
* based routing) is setup between a POD's subnet IP range to a NetScaler device. This VO object
* represents a mapping between a POD and NetScaler device where PBR is setup.
*
*/
@Entity
@Table(name = " netscaler_servicepackages")
public class NetScalerServicePackageVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Column(name = "uuid")
private String uuid;
public NetScalerServicePackageVO() {
}
public NetScalerServicePackageVO(RegisterServicePackageCmd cmd) {
this.name = cmd.getSpName();
this.description = cmd.getDescription();
this.uuid = UUID.randomUUID().toString();
}
@Override
public long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setDescription(String description) {
this.description = description;
}
public void setId(long id) {
this.id = id;
}
}

View File

@ -0,0 +1,28 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.dao;
import java.util.List;
import com.cloud.network.NetScalerControlCenterVO;
import com.cloud.utils.db.GenericDao;
public interface NetScalerControlCenterDao extends GenericDao<NetScalerControlCenterVO, Long> {
NetScalerControlCenterVO findByPodId(long podId);
List<NetScalerControlCenterVO> listByNetScalerDeviceId(long netscalerDeviceId);
}

View File

@ -0,0 +1,46 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.dao;
import java.util.List;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.network.NetScalerControlCenterVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
@Component
@Local(value = NetScalerControlCenterDao.class)
@DB
public class NetScalerControlCenterDaoImpl extends GenericDaoBase<NetScalerControlCenterVO, Long> implements NetScalerControlCenterDao {
@Override
public NetScalerControlCenterVO findByPodId(long podId) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<NetScalerControlCenterVO> listByNetScalerDeviceId(long netscalerDeviceId) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,29 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.dao;
import java.util.List;
import com.cloud.network.NetScalerServicePackageVO;
import com.cloud.utils.db.GenericDao;
public interface NetScalerServicePackageDao extends GenericDao<NetScalerServicePackageVO, Long> {
NetScalerServicePackageVO findByPodId(long podId);
List<NetScalerServicePackageVO> listByNetScalerDeviceId(long netscalerDeviceId);
}

View File

@ -0,0 +1,65 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.dao;
import java.util.List;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.network.NetScalerServicePackageVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Component
@Local(value = NetScalerServicePackageDao.class)
@DB
public class NetScalerServicePackageDaoImpl extends GenericDaoBase<NetScalerServicePackageVO, Long> implements NetScalerServicePackageDao {
final SearchBuilder<NetScalerServicePackageVO> podIdSearch;
final SearchBuilder<NetScalerServicePackageVO> deviceIdSearch;
protected NetScalerServicePackageDaoImpl() {
super();
podIdSearch = createSearchBuilder();
//podIdSearch.and("pod_id", podIdSearch.entity().getPodId(), Op.EQ);
podIdSearch.done();
deviceIdSearch = createSearchBuilder();
//deviceIdSearch.and("netscalerDeviceId", deviceIdSearch.entity().getNetscalerDeviceId(), Op.EQ);
deviceIdSearch.done();
}
@Override
public NetScalerServicePackageVO findByPodId(long podId) {
SearchCriteria<NetScalerServicePackageVO> sc = podIdSearch.create();
sc.setParameters("pod_id", podId);
return findOneBy(sc);
}
@Override
public List<NetScalerServicePackageVO> listByNetScalerDeviceId(long netscalerDeviceId) {
SearchCriteria<NetScalerServicePackageVO> sc = deviceIdSearch.create();
sc.setParameters("netscalerDeviceId", netscalerDeviceId);
return search(sc, null);
}
}

View File

@ -23,20 +23,26 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.gson.Gson;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import org.apache.cloudstack.region.gslb.GslbServiceProvider;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.NetScalerImplementNetworkCommand;
import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand;
import com.cloud.agent.api.routing.HealthCheckLBConfigAnswer;
import com.cloud.agent.api.routing.HealthCheckLBConfigCommand;
@ -51,12 +57,16 @@ 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.commands.RegisterNetscalerControlCenterCmd;
import com.cloud.api.commands.RegisterServicePackageCmd;
import com.cloud.api.response.NetScalerServicePackageResponse;
import com.cloud.api.response.NetscalerLoadBalancerResponse;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.DataCenterIpAddressVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DataCenterIpAddressDao;
@ -67,13 +77,17 @@ import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
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.IpAddress;
import com.cloud.network.IpAddressManager;
import com.cloud.network.NetScalerControlCenterVO;
import com.cloud.network.NetScalerPodVO;
import com.cloud.network.NetScalerServicePackageVO;
import com.cloud.network.Network;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
@ -88,7 +102,9 @@ import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterType;
import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState;
import com.cloud.network.dao.NetScalerControlCenterDao;
import com.cloud.network.dao.NetScalerPodDao;
import com.cloud.network.dao.NetScalerServicePackageDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
import com.cloud.network.dao.NetworkExternalLoadBalancerVO;
@ -98,6 +114,7 @@ import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkVO;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
import com.cloud.network.resource.NetScalerControlCenterResource;
import com.cloud.network.resource.NetscalerResource;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.LbStickinessMethod;
@ -105,9 +122,13 @@ import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
import com.cloud.network.rules.LoadBalancerContainer;
import com.cloud.network.rules.StaticNat;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.resource.ResourceManager;
import com.cloud.resource.ServerResource;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
@ -155,9 +176,25 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
DataCenterIpAddressDao _privateIpAddressDao;
@Inject
ExternalLoadBalancerDeviceDao _externalLoadBalancerDeviceDao;
@Inject
NetScalerServicePackageDao _netscalerServicePackageDao;
@Inject
NetScalerControlCenterDao _netscalerControlCenterDao;
@Inject
ResourceManager _resourceMgr;
@Inject
HostDetailsDao _hostDetailDao;
@Inject
IpAddressManager _ipAddrMgr;
@Inject
NetworkOrchestrationService _networkService;
@Inject
NetworkOfferingDao _networkOfferingDao = null;
private boolean canHandle(Network config, Service service) {
DataCenter zone = _dcDao.findById(config.getDataCenterId());
// Create a NCC Resource on Demand for the zone.
boolean handleInAdvanceZone =
(zone.getNetworkType() == NetworkType.Advanced && (config.getGuestType() == Network.GuestType.Isolated || config.getGuestType() == Network.GuestType.Shared) && config.getTrafficType() == TrafficType.Guest);
boolean handleInBasicZone =
@ -193,13 +230,217 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
try {
return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
if(offering.getServicePackage() == null) {
return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
} else {
// if the network offering has service package implement it with Netscaler Control Center
manageGuestNetworkWithNetscalerControlCenter(true, guestConfig, offering);
return true;
}
} 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());
} catch (ConfigurationException e) {
throw new ResourceUnavailableException("There are no NetScaler load balancer devices with the free capacity for implementing this network : " + e.getMessage(), DataCenter.class,
guestConfig.getDataCenterId());
}
}
public HostVO getNetScalerControlCenterForNetwork(Network guestConfig) {
long zoneId = guestConfig.getDataCenterId();
return _hostDao.findByTypeNameAndZoneId(zoneId, "NetscalerControlCenter", Type.NetScalerControlCenter);
}
public HostVO allocateNCCResourceForNetwork(Network guestConfig) throws ConfigurationException {
Map<String, String> _configs;
List<NetScalerControlCenterVO> ncc = _netscalerControlCenterDao.listAll();
HostVO hostVO = null;
Map<String, Object> params ;
if(ncc.size() > 0) {
NetScalerControlCenterVO nccVO = ncc.get(0);
String ipAddress = nccVO.getNccip();
Map hostDetails = new HashMap<String, String>();
String hostName = "NetscalerControlCenter";
hostDetails.put("name", hostName);
hostDetails.put("guid", UUID.randomUUID().toString());
hostDetails.put("zoneId", Long.toString(guestConfig.getDataCenterId()));
hostDetails.put("ip", ipAddress);
hostDetails.put("username", nccVO.getUsername());
hostDetails.put("password", nccVO.getPassword());
hostDetails.put("deviceName", "netscaler control center");
hostDetails.put("cmdTimeOut", Long.toString(NumbersUtil.parseInt(_configDao.getValue(Config.NCCCmdTimeOut.key()), 600000)));
ServerResource resource = new NetScalerControlCenterResource();
resource.configure(hostName, hostDetails);
final Host host = _resourceMgr.addHost(guestConfig.getDataCenterId(), resource, Host.Type.NetScalerControlCenter, hostDetails);
hostVO = _hostDao.findById(host.getId());
}
return hostVO;
}
public boolean manageGuestNetworkWithNetscalerControlCenter(boolean add, Network guestConfig, NetworkOffering offering) throws ResourceUnavailableException, InsufficientCapacityException, ConfigurationException {
if (guestConfig.getTrafficType() != TrafficType.Guest) {
s_logger.trace("External load balancer can only be used for guest networks.");
return false;
}
long zoneId = guestConfig.getDataCenterId();
DataCenterVO zone = _dcDao.findById(zoneId);
HostVO netscalerControlCenter = null;
if (add) {
HostVO lbDeviceVO = null;
// on restart network, device could have been allocated already, skip allocation if a device is assigned
lbDeviceVO = getNetScalerControlCenterForNetwork(guestConfig);
if (lbDeviceVO == null) {
// allocate a load balancer device for the network
lbDeviceVO = allocateNCCResourceForNetwork(guestConfig);
if (lbDeviceVO == null) {
String msg = "failed to allocate Netscaler ControlCenter Resource for the zone in the network " + guestConfig.getId();
s_logger.error(msg);
throw new InsufficientNetworkCapacityException(msg, DataCenter.class, guestConfig.getDataCenterId());
}
}
netscalerControlCenter = _hostDao.findById(lbDeviceVO.getId());
s_logger.debug("Allocated Netscaler Control Center device:" + lbDeviceVO.getId() + " for the network: " + guestConfig.getId());
} else {
// find the load balancer device allocated for the network
HostVO lbDeviceVO = null;
// on restart network, device could have been allocated already, skip allocation if a device is assigned
lbDeviceVO = getNetScalerControlCenterForNetwork(guestConfig);
if (lbDeviceVO == null) {
s_logger.warn("Network shutdwon requested on external load balancer element, which did not implement the network."
+ " Either network implement failed half way through or already network shutdown is completed. So just returning.");
return true;
}
netscalerControlCenter = _hostDao.findById(lbDeviceVO.getId());
assert (netscalerControlCenter != null) : "There is no device assigned to this network how did shutdown network ended up here??";
}
JSONObject networkDetails = new JSONObject();
JSONObject networkPayload = new JSONObject();
String selfIp = null;
try {
networkDetails.put("id", guestConfig.getId());
networkDetails.put("vlan", guestConfig.getBroadcastUri());
networkDetails.put("cidr", guestConfig.getCidr());
networkDetails.put("gateway", guestConfig.getGateway());
networkDetails.put("servicepackage_id", offering.getServicePackage());
networkDetails.put("zone_id", zoneId);
networkDetails.put("account_id", guestConfig.getAccountId());
networkDetails.put("add", Boolean.toString(add));
selfIp = _ipAddrMgr.acquireGuestIpAddress(guestConfig, null);
if (selfIp == null) {
String msg = "failed to acquire guest IP address so not implementing the network on the NetscalerControlCenter";
s_logger.error(msg);
throw new InsufficientNetworkCapacityException(msg, Network.class, guestConfig.getId());
}
networkDetails.put("snip", selfIp);
//TODO region is hardcoded make it dynamic
networkDetails.put("region_id", 1);
networkDetails.put("name", guestConfig.getName());
networkPayload.put("network", networkDetails);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
NetScalerImplementNetworkCommand cmd = new NetScalerImplementNetworkCommand(zoneId, netscalerControlCenter.getId(), networkPayload.toString());
Answer answer = _agentMgr.easySend(netscalerControlCenter.getId(), cmd);
if(add) {
//TODO After getting the answer check with the job id and do poll on the job and then save the selfip or acquired guest ip to the Nics table
if(answer != null ) {
if (add) {
// Insert a new NIC for this guest network to reserve the self IP
_networkService.savePlaceholderNic(guestConfig, selfIp, null, null);
}
}
} else {
// release the self-ip obtained from guest network
/*Nic selfipNic = getPlaceholderNic(guestConfig);
_nicDao.remove(selfipNic.getId());*/
// release the load balancer allocated for the network
return true;
//write code to remove the self nic or the clean up work
}
// Send a command to the external load balancer to implement or shutdown the guest network
/* long guestVlanTag = Long.parseLong(BroadcastDomainType.getValue(guestConfig.getBroadcastUri()));
String selfIp = null;
String guestVlanNetmask = NetUtils.cidr2Netmask(guestConfig.getCidr());
Integer networkRate = _networkModel.getNetworkRate(guestConfig.getId(), null);
if (add) {
// on restart network, network could have already been implemented. If already implemented then return
Nic selfipNic = getPlaceholderNic(guestConfig);
if (selfipNic != null) {
return true;
}
// Acquire a self-ip address from the guest network IP address range
selfIp = _ipAddrMgr.acquireGuestIpAddress(guestConfig, null);
if (selfIp == null) {
String msg = "failed to acquire guest IP address so not implementing the network on the external load balancer ";
s_logger.error(msg);
throw new InsufficientNetworkCapacityException(msg, Network.class, guestConfig.getId());
}
} else {
// get the self-ip used by the load balancer
Nic selfipNic = getPlaceholderNic(guestConfig);
if (selfipNic == null) {
s_logger.warn("Network shutdwon requested on external load balancer element, which did not implement the network."
+ " Either network implement failed half way through or already network shutdown is completed. So just returning.");
return true;
}
selfIp = selfipNic.getIp4Address();
}
*/
// It's a hack, using isOneToOneNat field for indicate if it's inline or not
/* boolean inline = _networkMgr.isNetworkInlineMode(guestConfig);
IpAddressTO ip =
new IpAddressTO(guestConfig.getAccountId(), null, add, false, true, String.valueOf(guestVlanTag), selfIp, guestVlanNetmask, null, networkRate, inline);
IpAddressTO[] ips = new IpAddressTO[1];
ips[0] = ip;
IpAssocCommand cmd = new IpAssocCommand(ips);
Answer answer = _agentMgr.easySend(netscalerControlCenter.getId(), cmd);
*/
/* if (answer == null || !answer.getResult()) {
String action = add ? "implement" : "shutdown";
String answerDetails = (answer != null) ? answer.getDetails() : null;
answerDetails = (answerDetails != null) ? " due to " + answerDetails : "";
String msg = "External load balancer was unable to " + action + " the guest network on the external load balancer in zone " + zone.getName() + answerDetails;
s_logger.error(msg);
throw new ResourceUnavailableException(msg, Network.class, guestConfig.getId());
}
if (add) {
// Insert a new NIC for this guest network to reserve the self IP
_networkMgr.savePlaceholderNic(guestConfig, selfIp, null, null);
} else {
// release the self-ip obtained from guest network
Nic selfipNic = getPlaceholderNic(guestConfig);
_nicDao.remove(selfipNic.getId());
// release the load balancer allocated for the network
boolean releasedLB = freeLoadBalancerForNetwork(guestConfig);
if (!releasedLB) {
String msg = "Failed to release the external load balancer used for the network: " + guestConfig.getId();
s_logger.error(msg);
}
}
if (s_logger.isDebugEnabled()) {
Account account = _accountDao.findByIdIncludingRemoved(guestConfig.getAccountId());
String action = add ? "implemented" : "shut down";
s_logger.debug("External load balancer has " + action + " the guest network for account " + account.getAccountName() + "(id = " + account.getAccountId() +
") with VLAN tag " + guestVlanTag);
}*/
return true;
}
@Override
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
@ -218,11 +459,24 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
try {
return manageGuestNetworkWithExternalLoadBalancer(false, guestConfig);
NetworkOffering networkOffering = _networkOfferingDao.findById(guestConfig.getNetworkOfferingId());
if(networkOffering.getServicePackage() == null) {
return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
} else {
// if the network offering has service package implement it with Netscaler Control Center
return manageGuestNetworkWithNetscalerControlCenter(false, guestConfig, networkOffering);
//return true;
}
//return manageGuestNetworkWithExternalLoadBalancer(false, guestConfig);
} catch (InsufficientCapacityException capacityException) {
// TODO: handle out of capacity exception gracefully in case of multple providers available
return false;
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
@Override
@ -528,6 +782,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
cmdList.add(DeleteNetscalerLoadBalancerCmd.class);
cmdList.add(ListNetscalerLoadBalancerNetworksCmd.class);
cmdList.add(ListNetscalerLoadBalancersCmd.class);
cmdList.add(RegisterServicePackageCmd.class);
cmdList.add(RegisterNetscalerControlCenterCmd.class);
return cmdList;
}
@ -645,7 +901,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
}
}
return false;
return true;
}
@Override
@ -1046,4 +1302,71 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
return true;
}
@Override
public NetScalerServicePackageResponse registerNetscalerServicePackage(RegisterServicePackageCmd cmd) {
NetScalerServicePackageVO servicePackage = new NetScalerServicePackageVO(cmd);
NetScalerServicePackageResponse response = null;
_netscalerServicePackageDao.persist(servicePackage);
response = new NetScalerServicePackageResponse(servicePackage);
return response;
}
@Override
public NetScalerServicePackageResponse deleteNetscalerServicePackage(RegisterServicePackageCmd cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public NetScalerServicePackageResponse listNetscalerServicePackage(RegisterServicePackageCmd cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public NetScalerServicePackageResponse createNetscalerServicePackageResponse(NetScalerServicePackageVO servicePackageVO) {
// TODO Auto-generated method stub
return null;
}
@Override
@DB
public NetScalerControlCenterVO registerNetscalerControlCenter(RegisterNetscalerControlCenterCmd cmd) {
final RegisterNetscalerControlCenterCmd cmdinfo = cmd;
String ipAddress = cmd.getIpaddress();
Map hostDetails = new HashMap<String, String>();
String hostName = "NetscalerControlCenter";
hostDetails.put("name", hostName);
hostDetails.put("guid", UUID.randomUUID().toString());
List<DataCenterVO> dcVO = _dcDao.listEnabledZones();
if(dcVO.size() == 0) {
throw new CloudRuntimeException("There is no single enabled zone. Please add a zone, enable it and then add Netscaler ControlCenter");
}
hostDetails.put("zoneId", "1");
hostDetails.put("ip", ipAddress);
hostDetails.put("username", cmd.getUsername());
hostDetails.put("password", cmd.getPassword());
hostDetails.put("deviceName", "Netscaler ControlCenter");
ServerResource resource = new NetScalerControlCenterResource();
try {
resource.configure(hostName, hostDetails);
return Transaction.execute(new TransactionCallback<NetScalerControlCenterVO>() {
@Override
public NetScalerControlCenterVO doInTransaction(TransactionStatus status) {
NetScalerControlCenterVO nccVO = new NetScalerControlCenterVO(cmdinfo.getUsername(), cmdinfo.getPassword(),
cmdinfo.getIpaddress(), cmdinfo.getNumretries());
_netscalerControlCenterDao.persist(nccVO);
/*DetailVO hostDetail = new DetailVO(host.getId(), ApiConstants.NETSCALER_CONTROLCENTER_ID , String.valueOf(nccVO.getId()));
_hostDetailDao.persist(hostDetail);*/
return nccVO;
}
});
} catch (ConfigurationException e) {
resource = null;
throw new CloudRuntimeException(e.getMessage());
}
}
}

View File

@ -23,7 +23,12 @@ 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.commands.RegisterNetscalerControlCenterCmd;
import com.cloud.api.commands.RegisterServicePackageCmd;
import com.cloud.api.response.NetscalerLoadBalancerResponse;
import com.cloud.api.response.NetScalerServicePackageResponse;
import com.cloud.network.NetScalerControlCenterVO;
import com.cloud.network.NetScalerServicePackageVO;
import com.cloud.network.Network;
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
import com.cloud.utils.component.PluggableService;
@ -71,4 +76,19 @@ public interface NetscalerLoadBalancerElementService extends PluggableService {
* @return NetscalerLoadBalancerResponse
*/
public NetscalerLoadBalancerResponse createNetscalerLoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO);
/**
* creates API response object for netscaler load balancers
* @param lbDeviceVO external load balancer VO object
* @return NetscalerLoadBalancerResponse
*/
public NetScalerServicePackageResponse registerNetscalerServicePackage(RegisterServicePackageCmd cmd);
public NetScalerServicePackageResponse deleteNetscalerServicePackage(RegisterServicePackageCmd cmd);
public NetScalerServicePackageResponse listNetscalerServicePackage(RegisterServicePackageCmd cmd);
public NetScalerServicePackageResponse createNetscalerServicePackageResponse(NetScalerServicePackageVO servicePackageVO);
public NetScalerControlCenterVO registerNetscalerControlCenter(RegisterNetscalerControlCenterCmd registerNetscalerControlCenterCmd);
}

View File

@ -811,7 +811,14 @@ public enum Config {
"600",
"Time Interval to fetch the LB health check states (in sec)",
null),
NCCCmdTimeOut(
"Advanced",
ManagementServer.class,
Long.class,
"ncc.command.timeout",
"600000", // 10 minutes
"Command Timeout Interval (in millisec)",
null),
DirectAttachNetworkEnabled(
"Advanced",
ManagementServer.class,

View File

@ -1112,7 +1112,12 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
if (!(startup[0] instanceof StartupExternalLoadBalancerCommand)) {
return null;
}
host.setType(Host.Type.ExternalLoadBalancer);
if(host.getName().equalsIgnoreCase("NetScalerControlCenter")) {
host.setType(Host.Type.NetScalerControlCenter);
}
else {
host.setType(Host.Type.ExternalLoadBalancer);
}
return host;
}

View File

@ -396,6 +396,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.SecondaryStorageVM.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.ExternalFirewall.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.ExternalLoadBalancer.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.NetScalerControlCenter.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.L2Networking.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.BaremetalDhcp.toString());
sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.BaremetalPxe.toString());

View File

@ -254,4 +254,27 @@ CREATE TABLE `cloud`.`firewall_rules_dcidrs`(
UNIQUE KEY `unique_rule_dcidrs` (`firewall_rule_id`, `destination_cidr`),
KEY `fk_firewall_dcidrs_firewall_rules` (`firewall_rule_id`),
CONSTRAINT `fk_firewall_dcidrs_firewall_rules` FOREIGN KEY (`firewall_rule_id`) REFERENCES `firewall_rules` (`id`) ON DELETE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `cloud`.`netscaler_servicepackages`;
CREATE TABLE `cloud`.`netscaler_servicepackages` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(255) UNIQUE,
`name` varchar(255) UNIQUE COMMENT 'name of the service package',
`description` varchar(255) COMMENT 'description of the service package',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `cloud`.`external_netscaler_controlcenter`;
CREATE TABLE `cloud`.`external_netscaler_controlcenter` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(255) UNIQUE,
`username` varchar(255) COMMENT 'username of the NCC',
`password` varchar(255) COMMENT 'password of NCC',
`ncc_ip` varchar(255) COMMENT 'IP of NCC Manager',
`num_retries` bigint unsigned NOT NULL default 2 COMMENT 'Number of retries in ncc for command failure',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`sslcerts` ADD COLUMN `name` varchar(255) NULL default NULL COMMENT 'Name of the Certificate';
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `service_package_id` varchar(255) NULL default NULL COMMENT 'Netscaler ControlCenter Service Package';