Search in sources :

Example 66 with ResourceUnavailableException

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

the class ListBaremetalRctCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        ListResponse<BaremetalRctResponse> response = new ListResponse<>();
        List<BaremetalRctResponse> rctResponses = new ArrayList<>();
        BaremetalRctResponse rsp = vlanMgr.listRct();
        if (rsp != null) {
            rctResponses.add(rsp);
        }
        response.setResponses(rctResponses);
        response.setResponseName(getCommandName());
        response.setObjectName("baremetalrcts");
        this.setResponseObject(response);
    } catch (Exception e) {
        s_logger.debug("Exception happened while executing ListBaremetalRctCmd", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) BaremetalRctResponse(com.cloud.baremetal.networkservice.BaremetalRctResponse) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 67 with ResourceUnavailableException

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

the class BaremetalDhcpManagerImpl method addVirtualMachineIntoNetwork.

@Override
public boolean addVirtualMachineIntoNetwork(Network network, NicProfile nic, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException {
    Long zoneId = profile.getVirtualMachine().getDataCenterId();
    Long podId = profile.getVirtualMachine().getPodIdToDeployIn();
    List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Type.BaremetalDhcp, null, podId, zoneId);
    if (hosts.size() == 0) {
        throw new CloudRuntimeException("No external Dhcp found in zone " + zoneId + " pod " + podId);
    }
    if (hosts.size() > 1) {
        throw new CloudRuntimeException("Something wrong, more than 1 external Dhcp found in zone " + zoneId + " pod " + podId);
    }
    HostVO h = hosts.get(0);
    String dns = nic.getIPv4Dns1();
    if (dns == null) {
        dns = nic.getIPv4Dns2();
    }
    DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIPv4Address(), profile.getVirtualMachine().getHostName(), null, dns, nic.getIPv4Gateway(), null, _ntwkModel.getExecuteInSeqNtwkElmtCmd());
    String errMsg = String.format("Set dhcp entry on external DHCP %1$s failed(ip=%2$s, mac=%3$s, vmname=%4$s)", h.getPrivateIpAddress(), nic.getIPv4Address(), nic.getMacAddress(), profile.getVirtualMachine().getHostName());
    // prepareBareMetalDhcpEntry(nic, dhcpCommand);
    try {
        Answer ans = _agentMgr.send(h.getId(), dhcpCommand);
        if (ans.getResult()) {
            s_logger.debug(String.format("Set dhcp entry on external DHCP %1$s successfully(ip=%2$s, mac=%3$s, vmname=%4$s)", h.getPrivateIpAddress(), nic.getIPv4Address(), nic.getMacAddress(), profile.getVirtualMachine().getHostName()));
            return true;
        } else {
            s_logger.debug(errMsg + " " + ans.getDetails());
            throw new ResourceUnavailableException(errMsg, DataCenter.class, zoneId);
        }
    } catch (Exception e) {
        s_logger.debug(errMsg, e);
        throw new ResourceUnavailableException(errMsg + e.getMessage(), DataCenter.class, zoneId);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) DataCenter(com.cloud.dc.DataCenter) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DhcpEntryCommand(com.cloud.agent.api.routing.DhcpEntryCommand) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) HostVO(com.cloud.host.HostVO) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnableDeleteHostException(com.cloud.resource.UnableDeleteHostException)

Example 68 with ResourceUnavailableException

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

the class AddBaremetalPxeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        BaremetalPxeVO vo = pxeMgr.addPxeServer(this);
        BaremetalPxeResponse rsp = pxeMgr.getApiResponse(vo);
        rsp.setResponseName(getCommandName());
        this.setResponseObject(rsp);
    } catch (Exception e) {
        s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : BaremetalPxeResponse(com.cloud.baremetal.networkservice.BaremetalPxeResponse) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) BaremetalPxeVO(com.cloud.baremetal.database.BaremetalPxeVO)

Example 69 with ResourceUnavailableException

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

the class AddBaremetalRctCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        BaremetalRctResponse rsp = vlanMgr.addRct(this);
        this.setResponseObject(rsp);
    } catch (Exception e) {
        s_logger.warn(String.format("unable to add baremetal RCT[%s]", getRctUrl()), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : BaremetalRctResponse(com.cloud.baremetal.networkservice.BaremetalRctResponse) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Example 70 with ResourceUnavailableException

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

the class DeleteBaremetalRctCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        vlanMgr.deleteRct(this);
        SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } catch (Exception e) {
        s_logger.warn(String.format("unable to delete baremetal RCT[%s]", getId()), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage(), e);
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Aggregations

ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)446 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)191 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)175 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)153 ArrayList (java.util.ArrayList)99 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)91 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)74 Account (com.cloud.user.Account)62 DomainRouterVO (com.cloud.vm.DomainRouterVO)60 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)59 ConfigurationException (javax.naming.ConfigurationException)53 DB (com.cloud.utils.db.DB)52 ServerApiException (org.apache.cloudstack.api.ServerApiException)51 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)47 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)47 ActionEvent (com.cloud.event.ActionEvent)46 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)46 DataCenter (com.cloud.dc.DataCenter)45 ServerApiException (com.cloud.api.ServerApiException)43 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)42