use of com.cloud.network.NetScalerControlCenterVO in project cloudstack by apache.
the class RegisterNetscalerControlCenterCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
NetScalerControlCenterVO nccVO = _netsclarLbService.registerNetscalerControlCenter(this);
if (nccVO != null) {
NetscalerControlCenterResponse response = _netsclarLbService.createNetscalerControlCenterResponse(nccVO);
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());
}
}
use of com.cloud.network.NetScalerControlCenterVO in project cloudstack by apache.
the class NetscalerElement method deleteNetscalerControlCenter.
@DB
@Override
public boolean deleteNetscalerControlCenter(DeleteNetscalerControlCenterCmd cmd) throws CloudRuntimeException {
NetScalerControlCenterVO result = _netscalerControlCenterDao.findByUuid(cmd.getId());
if (result == null) {
throw new CloudRuntimeException("External Netscaler Control Center Table does not contain record with this ID");
} else {
// ID list of Network Offering which are not removed and have service Package Uuid field not null.
List<Long> servicePackageId_list = _networkOfferingDao.listNetworkOfferingID();
if (servicePackageId_list.size() != 0) {
// VO list of Networks which are using Network Offering.
List<NetworkVO> networkVO_list = _networkDao.listNetworkVO(servicePackageId_list);
if (networkVO_list != null && networkVO_list.size() != 0) {
throw new CloudRuntimeException("ServicePackages published by NetScalerControlCenter are being used by NetworkOfferings. Try deleting NetworkOffering with ServicePackages and then delete NetScalerControlCenter.");
}
}
}
try {
_netscalerServicePackageDao.removeAll();
} catch (CloudRuntimeException ce) {
throw new CloudRuntimeException("Service Package is being used by Network Offering, Try deleting Network Offering and then delete Service Package.");
}
// delete Netscaler Control Center
_netscalerControlCenterDao.remove(result.getId());
// Removal of NCC from Host Table
List<HostVO> ncc_list = _hostDao.listAll();
if (ncc_list == null) {
throw new CloudRuntimeException("Could not find Netscaler Control Center in Database");
}
for (HostVO ncc : ncc_list) {
if (ncc.getType().equals(Host.Type.NetScalerControlCenter)) {
try {
// put the host in maintenance state in order for it to be deleted
ncc.setResourceState(ResourceState.Maintenance);
_hostDao.update(ncc.getId(), ncc);
_resourceMgr.deleteHost(ncc.getId(), false, false);
} catch (Exception e) {
s_logger.debug(e);
return false;
}
}
}
return true;
}
use of com.cloud.network.NetScalerControlCenterVO in project cloudstack by apache.
the class NetscalerElement method allocateNCCResourceForNetwork.
public HostVO allocateNCCResourceForNetwork(Network guestConfig) throws ConfigurationException {
Map<String, String> _configs;
List<NetScalerControlCenterVO> ncc = _netscalerControlCenterDao.listAll();
HostVO hostVO = null;
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", DBEncryptionUtil.decrypt(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;
}
use of com.cloud.network.NetScalerControlCenterVO in project cloudstack by apache.
the class NetscalerElement method registerNetscalerControlCenter.
@Override
@DB
public NetScalerControlCenterVO registerNetscalerControlCenter(RegisterNetscalerControlCenterCmd cmd) {
if (_netscalerControlCenterDao.listAll() != null && _netscalerControlCenterDao.listAll().size() != 0) {
throw new CloudRuntimeException("One Netscaler Control Center already exist in the DataBase. At a time only one Netscaler Control Center is allowed");
}
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(), DBEncryptionUtil.encrypt(cmdinfo.getPassword()), cmdinfo.getIpaddress(), cmdinfo.getNumretries());
_netscalerControlCenterDao.persist(nccVO);
return nccVO;
}
});
} catch (ConfigurationException e) {
resource = null;
throw new CloudRuntimeException(e.getMessage());
}
}
use of com.cloud.network.NetScalerControlCenterVO in project cloudstack by apache.
the class ListNetscalerControlCenterCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<NetScalerControlCenterVO> lncCenters = _netsclarLbService.listNetscalerControlCenter(this);
if (lncCenters != null) {
ListResponse<NetscalerControlCenterResponse> response = new ListResponse<NetscalerControlCenterResponse>();
List<NetscalerControlCenterResponse> lncCentersResponse = new ArrayList<NetscalerControlCenterResponse>();
if (lncCenters != null && !lncCenters.isEmpty()) {
for (NetScalerControlCenterVO lncCentersVO : lncCenters) {
NetscalerControlCenterResponse lncCentreResponse = _netsclarLbService.createNetscalerControlCenterResponse(lncCentersVO);
lncCentersResponse.add(lncCentreResponse);
}
}
response.setResponses(lncCentersResponse);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list Net scalar Control Center due to some internal error.");
}
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
Aggregations