Search in sources :

Example 21 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class ListVmwareDcsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends VmwareDatacenter> vmwareDcList = null;
    try {
        vmwareDcList = _vmwareDatacenterService.listVmwareDatacenters(this);
    } catch (InvalidParameterValueException ie) {
        throw new InvalidParameterValueException("Invalid zone id " + getZoneId());
    } catch (Exception e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to find associated VMware DCs associated with zone " + getZoneId());
    }
    ListResponse<VmwareDatacenterResponse> response = new ListResponse<VmwareDatacenterResponse>();
    List<VmwareDatacenterResponse> vmwareDcResponses = new ArrayList<VmwareDatacenterResponse>();
    if (vmwareDcList != null && vmwareDcList.size() > 0) {
        for (VmwareDatacenter vmwareDc : vmwareDcList) {
            VmwareDatacenterResponse vmwareDcResponse = new VmwareDatacenterResponse();
            vmwareDcResponse.setId(vmwareDc.getUuid());
            vmwareDcResponse.setVcenter(vmwareDc.getVcenterHost());
            vmwareDcResponse.setName(vmwareDc.getVmwareDatacenterName());
            vmwareDcResponse.setZoneId(getZoneId());
            vmwareDcResponse.setObjectName("VMwareDC");
            vmwareDcResponses.add(vmwareDcResponse);
        }
    }
    response.setResponses(vmwareDcResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VmwareDatacenterResponse(org.apache.cloudstack.api.response.VmwareDatacenterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) VmwareDatacenter(com.cloud.hypervisor.vmware.VmwareDatacenter) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 22 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class CiscoNexusVSMDeviceManagerImpl method addCiscoNexusVSM.

@DB
public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, String vCenterIpaddr, String vCenterDcName) {
    // In this function, we associate this VSM with each host
    // in the clusterId specified.
    // First check if the cluster is of type vmware. If not,
    // throw an exception. VSMs are tightly integrated with vmware clusters.
    ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null) {
        throw new InvalidParameterValueException("Cluster with specified ID not found!");
    }
    if (cluster.getHypervisorType() != HypervisorType.VMware) {
        InvalidParameterValueException ex = new InvalidParameterValueException("Cluster with specified id is not a VMWare hypervisor cluster");
        throw ex;
    }
    if (_clusterVSMDao.findByClusterId(clusterId) != null) {
        // We can't have two VSMs for the same cluster. Throw exception.
        throw new InvalidParameterValueException("Cluster with specified id already has a VSM tied to it. Please remove that first and retry the operation.");
    }
    // TODO: Confirm whether we should be checking for VSM reachability here.
    // Next, check if this VSM is reachable. Use the XML-RPC VSM API Java bindings to talk to
    // the VSM.
    //NetconfHelper (String ip, String username, String password)
    NetconfHelper netconfClient;
    try {
        netconfClient = new NetconfHelper(ipaddress, username, password);
    } catch (CloudRuntimeException e) {
        String msg = "Failed to connect to Nexus VSM " + ipaddress + " with credentials of user " + username;
        s_logger.error(msg);
        throw new CloudRuntimeException(msg);
    }
    // Disconnect from the VSM. A VSM has a default of 8 maximum parallel connections that it allows.
    netconfClient.disconnect();
    // Now, go ahead and associate the cluster with this VSM.
    // First, check if VSM already exists in the table "virtual_supervisor_module".
    // If it's not there already, create it.
    // If it's there already, return success.
    // TODO - Right now, we only check if the ipaddress matches for both requests.
    // We must really check whether every field of the VSM matches. Anyway, the
    // advantage of our approach for now is that existing infrastructure using
    // the existing VSM won't be affected if the new request to add the VSM
    // assumed different information on the VSM (mgmt vlan, username, password etc).
    CiscoNexusVSMDeviceVO VSMObj;
    try {
        VSMObj = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(ipaddress);
    } catch (Exception e) {
        throw new CloudRuntimeException(e.getMessage());
    }
    if (VSMObj == null) {
        // Create the VSM record. For now, we aren't using the vsmName field.
        VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password);
        _ciscoNexusVSMDeviceDao.persist(VSMObj);
    }
    // At this stage, we have a VSM record for sure. Connect the VSM to the cluster Id.
    long vsmId = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(ipaddress).getId();
    ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsmId);
    _clusterVSMDao.persist(connectorObj);
    return VSMObj;
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) ClusterVSMMapVO(com.cloud.dc.ClusterVSMMapVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NetconfHelper(com.cloud.utils.cisco.n1kv.vsm.NetconfHelper) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceInUseException(com.cloud.exception.ResourceInUseException) DB(com.cloud.utils.db.DB)

Example 23 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class CiscoVnmcElement method listCiscoVnmcResources.

@Override
public List<CiscoVnmcControllerVO> listCiscoVnmcResources(ListCiscoVnmcResourcesCmd cmd) {
    Long physicalNetworkId = cmd.getPhysicalNetworkId();
    Long ciscoVnmcResourceId = cmd.getCiscoVnmcResourceId();
    List<CiscoVnmcControllerVO> responseList = new ArrayList<CiscoVnmcControllerVO>();
    if (physicalNetworkId == null && ciscoVnmcResourceId == null) {
        throw new InvalidParameterValueException("Either physical network Id or vnmc device Id must be specified");
    }
    if (ciscoVnmcResourceId != null) {
        CiscoVnmcControllerVO ciscoVnmcResource = _ciscoVnmcDao.findById(ciscoVnmcResourceId);
        if (ciscoVnmcResource == null) {
            throw new InvalidParameterValueException("Could not find Cisco Vnmc device with id: " + ciscoVnmcResource);
        }
        responseList.add(ciscoVnmcResource);
    } else {
        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
        if (physicalNetwork == null) {
            throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
        }
        responseList = _ciscoVnmcDao.listByPhysicalNetwork(physicalNetworkId);
    }
    return responseList;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) CiscoVnmcControllerVO(com.cloud.network.cisco.CiscoVnmcControllerVO)

Example 24 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class CiscoVnmcElement method addCiscoAsa1000vResource.

@Override
public CiscoAsa1000vDevice addCiscoAsa1000vResource(AddCiscoAsa1000vResourceCmd cmd) {
    Long physicalNetworkId = cmd.getPhysicalNetworkId();
    CiscoAsa1000vDevice ciscoAsa1000vResource = null;
    PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
    if (physicalNetwork == null) {
        throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId);
    }
    ciscoAsa1000vResource = new CiscoAsa1000vDeviceVO(physicalNetworkId, cmd.getManagementIp().trim(), cmd.getInPortProfile(), cmd.getClusterId());
    try {
        _ciscoAsa1000vDao.persist((CiscoAsa1000vDeviceVO) ciscoAsa1000vResource);
    } catch (EntityExistsException e) {
        throw new InvalidParameterValueException("An ASA 1000v appliance already exists with same configuration");
    }
    return ciscoAsa1000vResource;
}
Also used : CiscoAsa1000vDeviceVO(com.cloud.network.cisco.CiscoAsa1000vDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) CiscoAsa1000vDevice(com.cloud.network.cisco.CiscoAsa1000vDevice) EntityExistsException(javax.persistence.EntityExistsException)

Example 25 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class F5ExternalLoadBalancerElement method deleteF5LoadBalancer.

@Override
public boolean deleteF5LoadBalancer(DeleteF5LoadBalancerCmd cmd) {
    Long lbDeviceId = cmd.getLoadBalancerDeviceId();
    ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
    if ((lbDeviceVo == null) || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
        throw new InvalidParameterValueException("No F5 load balancer device found with ID: " + lbDeviceId);
    }
    return deleteExternalLoadBalancer(lbDeviceVo.getHostId());
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Aggregations

InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)725 Account (com.cloud.user.Account)242 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)229 ArrayList (java.util.ArrayList)186 ActionEvent (com.cloud.event.ActionEvent)171 DB (com.cloud.utils.db.DB)139 ServerApiException (org.apache.cloudstack.api.ServerApiException)110 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)94 TransactionStatus (com.cloud.utils.db.TransactionStatus)88 List (java.util.List)80 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)69 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)63 Network (com.cloud.network.Network)58 HashMap (java.util.HashMap)58 ConfigurationException (javax.naming.ConfigurationException)53 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)52 Pair (com.cloud.utils.Pair)50 HostVO (com.cloud.host.HostVO)46 NetworkVO (com.cloud.network.dao.NetworkVO)46 DataCenterVO (com.cloud.dc.DataCenterVO)44