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);
}
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;
}
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;
}
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;
}
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());
}
Aggregations