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