Search in sources :

Example 21 with UserVmVO

use of com.cloud.vm.UserVmVO in project cloudstack by apache.

the class VMSnapshotManagerImpl method getVMBySnapshotId.

@Override
public VirtualMachine getVMBySnapshotId(Long id) {
    VMSnapshotVO vmSnapshot = _vmSnapshotDao.findById(id);
    if (vmSnapshot == null) {
        throw new InvalidParameterValueException("unable to find the vm snapshot with id " + id);
    }
    Long vmId = vmSnapshot.getVmId();
    UserVmVO vm = _userVMDao.findById(vmId);
    return vm;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 22 with UserVmVO

use of com.cloud.vm.UserVmVO in project cloudstack by apache.

the class VMSnapshotManagerImpl method syncVMSnapshot.

@Override
public boolean syncVMSnapshot(VMInstanceVO vm, Long hostId) {
    try {
        UserVmVO userVm = _userVMDao.findById(vm.getId());
        if (userVm == null)
            return false;
        List<VMSnapshotVO> vmSnapshotsInExpungingStates = _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Reverting, VMSnapshot.State.Creating);
        for (VMSnapshotVO vmSnapshotVO : vmSnapshotsInExpungingStates) {
            VMSnapshotStrategy strategy = findVMSnapshotStrategy(vmSnapshotVO);
            if (vmSnapshotVO.getState() == VMSnapshot.State.Expunging) {
                return strategy.deleteVMSnapshot(vmSnapshotVO);
            } else if (vmSnapshotVO.getState() == VMSnapshot.State.Creating) {
                return strategy.takeVMSnapshot(vmSnapshotVO) != null;
            } else if (vmSnapshotVO.getState() == VMSnapshot.State.Reverting) {
                return strategy.revertVMSnapshot(vmSnapshotVO);
            }
        }
    } catch (Exception e) {
        s_logger.error(e.getMessage(), e);
        if (_vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging).size() == 0)
            return true;
        else
            return false;
    }
    return false;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) VMSnapshotStrategy(org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) TransactionCallbackWithException(com.cloud.utils.db.TransactionCallbackWithException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) ManagementServerException(com.cloud.exception.ManagementServerException)

Example 23 with UserVmVO

use of com.cloud.vm.UserVmVO in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
    final VirtualRouter router = userdata.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final VirtualMachineProfile profile = userdata.getProfile();
    final NicVO nicVo = userdata.getNicVo();
    final UserVmVO userVM = userdata.getUserVM();
    final DeployDestination destination = userdata.getDestination();
    if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
        return _networkGeneralHelper.sendCommandsToRouter(router, commands);
    }
    return true;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 24 with UserVmVO

use of com.cloud.vm.UserVmVO in project cloudstack by apache.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final DhcpEntryRules dhcp) throws ResourceUnavailableException {
    final VirtualRouter router = dhcp.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final NicVO nicVo = dhcp.getNicVo();
    final UserVmVO userVM = dhcp.getUserVM();
    _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, commands);
    return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) Commands(com.cloud.agent.manager.Commands) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 25 with UserVmVO

use of com.cloud.vm.UserVmVO in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final DhcpEntryRules dhcp) throws ResourceUnavailableException {
    final VirtualRouter router = dhcp.getRouter();
    final Commands commands = new Commands(Command.OnError.Stop);
    final NicVO nicVo = dhcp.getNicVo();
    final UserVmVO userVM = dhcp.getUserVM();
    final DeployDestination destination = dhcp.getDestination();
    if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
        _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, commands);
        return _networkGeneralHelper.sendCommandsToRouter(router, commands);
    }
    return true;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

UserVmVO (com.cloud.vm.UserVmVO)88 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)32 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)30 Account (com.cloud.user.Account)23 ArrayList (java.util.ArrayList)21 HostVO (com.cloud.host.HostVO)14 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)13 VMSnapshotVO (com.cloud.vm.snapshot.VMSnapshotVO)13 DataCenterVO (com.cloud.dc.DataCenterVO)12 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)12 VolumeVO (com.cloud.storage.VolumeVO)10 NicVO (com.cloud.vm.NicVO)10 VMInstanceVO (com.cloud.vm.VMInstanceVO)10 ActionEvent (com.cloud.event.ActionEvent)9 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)9 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)9 DomainRouterVO (com.cloud.vm.DomainRouterVO)9 Commands (com.cloud.agent.manager.Commands)8 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)8 VirtualRouter (com.cloud.network.router.VirtualRouter)8