Search in sources :

Example 6 with ConsoleProxyVO

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

the class ConsoleProxyManagerImpl method finalizeExpunge.

@Override
public void finalizeExpunge(VirtualMachine vm) {
    ConsoleProxyVO proxy = _consoleProxyDao.findById(vm.getId());
    proxy.setPublicIpAddress(null);
    proxy.setPublicMacAddress(null);
    proxy.setPublicNetmask(null);
    proxy.setPrivateMacAddress(null);
    proxy.setPrivateIpAddress(null);
    _consoleProxyDao.update(proxy.getId(), proxy);
}
Also used : ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Example 7 with ConsoleProxyVO

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

the class ConsoleProxyManagerImpl method handleResetSuspending.

private void handleResetSuspending() {
    List<ConsoleProxyVO> runningProxies = _consoleProxyDao.getProxyListInStates(State.Running);
    for (ConsoleProxyVO proxy : runningProxies) {
        s_logger.info("Stop console proxy " + proxy.getId() + " because of we are currently in ResetSuspending management mode");
        stopProxy(proxy.getId());
    }
    // check if it is time to resume
    List<ConsoleProxyVO> proxiesInTransition = _consoleProxyDao.getProxyListInStates(State.Running, State.Starting, State.Stopping);
    if (proxiesInTransition.size() == 0) {
        s_logger.info("All previous console proxy VMs in transition mode ceased the mode, we will now resume to last management state");
        resumeLastManagementState();
    }
}
Also used : ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Example 8 with ConsoleProxyVO

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

the class ConsoleProxyDaoImpl method remove.

@Override
public boolean remove(Long id) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    ConsoleProxyVO proxy = createForUpdate();
    proxy.setPublicIpAddress(null);
    proxy.setPrivateIpAddress(null);
    UpdateBuilder ub = getUpdateBuilder(proxy);
    ub.set(proxy, "state", State.Destroyed);
    ub.set(proxy, "privateIpAddress", null);
    update(id, ub, proxy);
    boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO) UpdateBuilder(com.cloud.utils.db.UpdateBuilder)

Example 9 with ConsoleProxyVO

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

the class StoragePoolAutomationImpl method cancelMaintain.

@Override
public boolean cancelMaintain(DataStore store) {
    // Change the storage state back to up
    Long userId = CallContext.current().getCallingUserId();
    User user = _userDao.findById(userId);
    Account account = CallContext.current().getCallingAccount();
    StoragePoolVO poolVO = primaryDataStoreDao.findById(store.getId());
    StoragePool pool = (StoragePool) store;
    //Handeling the Zone wide and cluster wide primay storage
    List<HostVO> hosts = new ArrayList<HostVO>();
    // if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
    if (poolVO.getScope().equals(ScopeType.ZONE)) {
        if (HypervisorType.Any.equals(pool.getHypervisor())) {
            hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZone(pool.getDataCenterId());
        } else {
            hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());
        }
    } else {
        hosts = _resourceMgr.listHostsInClusterByStatus(pool.getClusterId(), Status.Up);
    }
    if (hosts == null || hosts.size() == 0) {
        return true;
    }
    // add heartbeat
    for (HostVO host : hosts) {
        ModifyStoragePoolCommand msPoolCmd = new ModifyStoragePoolCommand(true, pool);
        final Answer answer = agentMgr.easySend(host.getId(), msPoolCmd);
        if (answer == null || !answer.getResult()) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("ModifyStoragePool add failed due to " + ((answer == null) ? "answer null" : answer.getDetails()));
            }
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("ModifyStoragePool add secceeded");
            }
        }
    }
    // 2. Get a list of pending work for this queue
    List<StoragePoolWorkVO> pendingWork = _storagePoolWorkDao.listPendingWorkForCancelMaintenanceByPoolId(poolVO.getId());
    // 3. work through the queue
    for (StoragePoolWorkVO work : pendingWork) {
        try {
            VMInstanceVO vmInstance = vmDao.findById(work.getVmId());
            if (vmInstance == null) {
                continue;
            }
            // proxy
            if (vmInstance.getType().equals(VirtualMachine.Type.ConsoleProxy)) {
                ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(vmInstance.getId());
                vmMgr.advanceStart(consoleProxy.getUuid(), null, null);
                // update work queue
                work.setStartedAfterMaintenance(true);
                _storagePoolWorkDao.update(work.getId(), work);
            }
            // if the instance is of type ssvm, call the ssvm manager
            if (vmInstance.getType().equals(VirtualMachine.Type.SecondaryStorageVm)) {
                SecondaryStorageVmVO ssVm = _secStrgDao.findById(vmInstance.getId());
                vmMgr.advanceStart(ssVm.getUuid(), null, null);
                // update work queue
                work.setStartedAfterMaintenance(true);
                _storagePoolWorkDao.update(work.getId(), work);
            }
            // manager
            if (vmInstance.getType().equals(VirtualMachine.Type.DomainRouter)) {
                DomainRouterVO domR = _domrDao.findById(vmInstance.getId());
                vmMgr.advanceStart(domR.getUuid(), null, null);
                // update work queue
                work.setStartedAfterMaintenance(true);
                _storagePoolWorkDao.update(work.getId(), work);
            }
            // if the instance is of type user vm, call the user vm manager
            if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
                // don't allow to start vm that doesn't have a root volume
                if (volumeDao.findByInstanceAndType(vmInstance.getId(), Volume.Type.ROOT).isEmpty()) {
                    _storagePoolWorkDao.remove(work.getId());
                } else {
                    UserVmVO userVm = userVmDao.findById(vmInstance.getId());
                    vmMgr.advanceStart(userVm.getUuid(), null, null);
                    work.setStartedAfterMaintenance(true);
                    _storagePoolWorkDao.update(work.getId(), work);
                }
            }
        } catch (Exception e) {
            s_logger.debug("Failed start vm", e);
            throw new CloudRuntimeException(e.toString());
        }
    }
    return false;
}
Also used : Account(com.cloud.user.Account) SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) UserVmVO(com.cloud.vm.UserVmVO) User(com.cloud.user.User) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostVO(com.cloud.host.HostVO) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 10 with ConsoleProxyVO

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

the class ConsoleProxyDaoImpl method update.

@Override
public void update(long id, int activeSession, Date updateTime, byte[] sessionDetails) {
    ConsoleProxyVO ub = createForUpdate();
    ub.setActiveSession(activeSession);
    ub.setLastUpdateTime(updateTime);
    ub.setSessionDetails(sessionDetails);
    update(id, ub);
}
Also used : ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Aggregations

ConsoleProxyVO (com.cloud.vm.ConsoleProxyVO)21 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)4 HostVO (com.cloud.host.HostVO)4 NicProfile (com.cloud.vm.NicProfile)4 Answer (com.cloud.agent.api.Answer)3 DataCenterVO (com.cloud.dc.DataCenterVO)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)3 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 Account (com.cloud.user.Account)3 VMInstanceVO (com.cloud.vm.VMInstanceVO)3 ArrayList (java.util.ArrayList)3 ModifyStoragePoolCommand (com.cloud.agent.api.ModifyStoragePoolCommand)2 CheckSshAnswer (com.cloud.agent.api.check.CheckSshAnswer)2 DataCenter (com.cloud.dc.DataCenter)2 HostPodVO (com.cloud.dc.HostPodVO)2 Network (com.cloud.network.Network)2 NetworkOffering (com.cloud.offering.NetworkOffering)2