use of com.cloud.network.resource.NetScalerControlCenterResource 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.resource.NetScalerControlCenterResource 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());
}
}
Aggregations