Search in sources :

Example 1 with NetScalerControlCenterResource

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;
}
Also used : HashMap(java.util.HashMap) NetScalerControlCenterVO(com.cloud.network.NetScalerControlCenterVO) ServerResource(com.cloud.resource.ServerResource) Host(com.cloud.host.Host) Map(java.util.Map) HashMap(java.util.HashMap) NetScalerControlCenterResource(com.cloud.network.resource.NetScalerControlCenterResource) HostVO(com.cloud.host.HostVO)

Example 2 with NetScalerControlCenterResource

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());
    }
}
Also used : RegisterNetscalerControlCenterCmd(com.cloud.api.commands.RegisterNetscalerControlCenterCmd) DataCenterVO(com.cloud.dc.DataCenterVO) HashMap(java.util.HashMap) NetScalerControlCenterVO(com.cloud.network.NetScalerControlCenterVO) ServerResource(com.cloud.resource.ServerResource) TransactionStatus(com.cloud.utils.db.TransactionStatus) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Map(java.util.Map) HashMap(java.util.HashMap) NetScalerControlCenterResource(com.cloud.network.resource.NetScalerControlCenterResource) DB(com.cloud.utils.db.DB)

Aggregations

NetScalerControlCenterVO (com.cloud.network.NetScalerControlCenterVO)2 NetScalerControlCenterResource (com.cloud.network.resource.NetScalerControlCenterResource)2 ServerResource (com.cloud.resource.ServerResource)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 RegisterNetscalerControlCenterCmd (com.cloud.api.commands.RegisterNetscalerControlCenterCmd)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 Host (com.cloud.host.Host)1 HostVO (com.cloud.host.HostVO)1 DB (com.cloud.utils.db.DB)1 TransactionStatus (com.cloud.utils.db.TransactionStatus)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ConfigurationException (javax.naming.ConfigurationException)1