Search in sources :

Example 1 with RebootAnswer

use of com.cloud.agent.api.RebootAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

protected Answer execute(RebootRouterCommand cmd) {
    Long bytesSent = 0L;
    Long bytesRcvd = 0L;
    if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
        long[] stats = getNetworkStats(cmd.getPrivateIpAddress());
        bytesSent = stats[0];
        bytesRcvd = stats[1];
    }
    RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
    answer.setBytesSent(bytesSent);
    answer.setBytesReceived(bytesRcvd);
    String result = _virtRouterResource.connect(cmd.getPrivateIpAddress());
    if (result == null) {
        networkUsage(cmd.getPrivateIpAddress(), "create", null);
        return answer;
    } else {
        return new Answer(cmd, false, result);
    }
}
Also used : FenceAnswer(com.cloud.agent.api.FenceAnswer) ConsoleProxyLoadAnswer(com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer) DeleteSnapshotBackupAnswer(com.cloud.agent.api.DeleteSnapshotBackupAnswer) MaintainAnswer(com.cloud.agent.api.MaintainAnswer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) ManageSnapshotAnswer(com.cloud.agent.api.ManageSnapshotAnswer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) AttachVolumeAnswer(com.cloud.agent.api.AttachVolumeAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) MigrateAnswer(com.cloud.agent.api.MigrateAnswer) CreateVolumeFromSnapshotAnswer(com.cloud.agent.api.CreateVolumeFromSnapshotAnswer) CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) PrepareForMigrationAnswer(com.cloud.agent.api.PrepareForMigrationAnswer) SecurityGroupRuleAnswer(com.cloud.agent.api.SecurityGroupRuleAnswer) RebootCommand(com.cloud.agent.api.RebootCommand) RebootAnswer(com.cloud.agent.api.RebootAnswer)

Example 2 with RebootAnswer

use of com.cloud.agent.api.RebootAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

private Answer execute(RebootCommand cmd) {
    Long bytesReceived = null;
    Long bytesSent = null;
    synchronized (_vms) {
        _vms.put(cmd.getVmName(), State.Starting);
    }
    try {
        Connect conn = LibvirtConnection.getConnection();
        final String result = rebootVM(conn, cmd.getVmName());
        if (result == null) {
            Integer vncPort = null;
            try {
                vncPort = getVncPort(conn, cmd.getVmName());
            } catch (Exception e) {
            }
            get_rule_logs_for_vms();
            return new RebootAnswer(cmd, null, bytesSent, bytesReceived, vncPort);
        } else {
            return new RebootAnswer(cmd, result);
        }
    } catch (LibvirtException e) {
        return new RebootAnswer(cmd, e.getMessage());
    } finally {
        synchronized (_vms) {
            _vms.put(cmd.getVmName(), State.Running);
        }
    }
}
Also used : LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect) RebootAnswer(com.cloud.agent.api.RebootAnswer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) URISyntaxException(java.net.URISyntaxException) LibvirtException(org.libvirt.LibvirtException) FileNotFoundException(java.io.FileNotFoundException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException)

Example 3 with RebootAnswer

use of com.cloud.agent.api.RebootAnswer in project cloudstack by apache.

the class OvmResourceBase method execute.

@Override
public RebootAnswer execute(RebootCommand cmd) {
    String vmName = cmd.getVmName();
    try {
        Map<String, String> res = OvmVm.reboot(_conn, vmName);
        Integer vncPort = Integer.parseInt(res.get("vncPort"));
        return new RebootAnswer(cmd, null, vncPort);
    } catch (Exception e) {
        s_logger.debug("Reboot " + vmName + " failed", e);
        return new RebootAnswer(cmd, e.getMessage(), false);
    }
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ConfigurationException(javax.naming.ConfigurationException)

Example 4 with RebootAnswer

use of com.cloud.agent.api.RebootAnswer in project CloudStack-archive by CloudStack-extras.

the class FakeComputingResource method execute.

protected Answer execute(RebootCommand cmd) {
    VmMgr vmMgr = getVmManager();
    vmMgr.rebootVM(cmd.getVmName());
    return new RebootAnswer(cmd, "success", 0L, 0L);
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) VmMgr(com.cloud.agent.mockvm.VmMgr) MockVmMgr(com.cloud.agent.mockvm.MockVmMgr)

Example 5 with RebootAnswer

use of com.cloud.agent.api.RebootAnswer in project cloudstack by apache.

the class VirtualMachineManagerImpl method orchestrateReboot.

private void orchestrateReboot(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
    final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
    // if there are active vm snapshots task, state change is not allowed
    if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) {
        s_logger.error("Unable to reboot VM " + vm + " due to: " + vm.getInstanceName() + " has active VM snapshots tasks");
        throw new CloudRuntimeException("Unable to reboot VM " + vm + " due to: " + vm.getInstanceName() + " has active VM snapshots tasks");
    }
    final DataCenter dc = _entityMgr.findById(DataCenter.class, vm.getDataCenterId());
    final Host host = _hostDao.findById(vm.getHostId());
    if (host == null) {
        // Should findById throw an Exception is the host is not found?
        throw new CloudRuntimeException("Unable to retrieve host with id " + vm.getHostId());
    }
    final Cluster cluster = _entityMgr.findById(Cluster.class, host.getClusterId());
    final Pod pod = _entityMgr.findById(Pod.class, host.getPodId());
    final DeployDestination dest = new DeployDestination(dc, pod, cluster, host);
    try {
        final Commands cmds = new Commands(Command.OnError.Stop);
        cmds.addCommand(new RebootCommand(vm.getInstanceName(), getExecuteInSequence(vm.getHypervisorType())));
        _agentMgr.send(host.getId(), cmds);
        final Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class);
        if (rebootAnswer != null && rebootAnswer.getResult()) {
            return;
        }
        s_logger.info("Unable to reboot VM " + vm + " on " + dest.getHost() + " due to " + (rebootAnswer == null ? " no reboot answer" : rebootAnswer.getDetails()));
    } catch (final OperationTimedoutException e) {
        s_logger.warn("Unable to send the reboot command to host " + dest.getHost() + " for the vm " + vm + " due to operation timeout", e);
        throw new CloudRuntimeException("Failed to reboot the vm on host " + dest.getHost());
    }
}
Also used : AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) RestoreVMSnapshotAnswer(com.cloud.agent.api.RestoreVMSnapshotAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) ClusterVMMetaDataSyncAnswer(com.cloud.agent.api.ClusterVMMetaDataSyncAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) DataCenter(com.cloud.dc.DataCenter) RebootCommand(com.cloud.agent.api.RebootCommand) Pod(com.cloud.dc.Pod) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DeployDestination(com.cloud.deploy.DeployDestination) Commands(com.cloud.agent.manager.Commands) Cluster(com.cloud.org.Cluster) Host(com.cloud.host.Host)

Aggregations

RebootAnswer (com.cloud.agent.api.RebootAnswer)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 ConfigurationException (javax.naming.ConfigurationException)4 Answer (com.cloud.agent.api.Answer)3 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)3 RebootCommand (com.cloud.agent.api.RebootCommand)3 StartAnswer (com.cloud.agent.api.StartAnswer)3 StopAnswer (com.cloud.agent.api.StopAnswer)3 BackupSnapshotAnswer (com.cloud.agent.api.BackupSnapshotAnswer)2 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)2 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)2 CreateVolumeFromSnapshotAnswer (com.cloud.agent.api.CreateVolumeFromSnapshotAnswer)2 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)2 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)2 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)2 GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)2 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)2 ManageSnapshotAnswer (com.cloud.agent.api.ManageSnapshotAnswer)2 MigrateAnswer (com.cloud.agent.api.MigrateAnswer)2 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)2