Search in sources :

Example 1 with PingRoutingCommand

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

the class VirtualMachineManagerImpl method processCommands.

@Override
public boolean processCommands(final long agentId, final long seq, final Command[] cmds) {
    boolean processed = false;
    for (final Command cmd : cmds) {
        if (cmd instanceof PingRoutingCommand) {
            final PingRoutingCommand ping = (PingRoutingCommand) cmd;
            if (ping.getHostVmStateReport() != null) {
                _syncMgr.processHostVmStatePingReport(agentId, ping.getHostVmStateReport());
            }
            // take the chance to scan VMs that are stuck in transitional states
            // and are missing from the report
            scanStalledVMInTransitionStateOnUpHost(agentId);
            processed = true;
        }
    }
    return processed;
}
Also used : PlugNicCommand(com.cloud.agent.api.PlugNicCommand) AttachOrDettachConfigDriveCommand(com.cloud.agent.api.AttachOrDettachConfigDriveCommand) AgentControlCommand(com.cloud.agent.api.AgentControlCommand) StopCommand(com.cloud.agent.api.StopCommand) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) ClusterVMMetaDataSyncCommand(com.cloud.agent.api.ClusterVMMetaDataSyncCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) Command(com.cloud.agent.api.Command) UnregisterVMCommand(com.cloud.agent.api.UnregisterVMCommand) PrepareForMigrationCommand(com.cloud.agent.api.PrepareForMigrationCommand) StartCommand(com.cloud.agent.api.StartCommand) StartupCommand(com.cloud.agent.api.StartupCommand) CheckVirtualMachineCommand(com.cloud.agent.api.CheckVirtualMachineCommand) PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) RebootCommand(com.cloud.agent.api.RebootCommand) MigrateCommand(com.cloud.agent.api.MigrateCommand) ScaleVmCommand(com.cloud.agent.api.ScaleVmCommand) RestoreVMSnapshotCommand(com.cloud.agent.api.RestoreVMSnapshotCommand) PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand)

Example 2 with PingRoutingCommand

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

the class VmwareResource method getCurrentStatus.

@Override
public PingCommand getCurrentStatus(long id) {
    try {
        gcAndKillHungWorkerVMs();
        VmwareContext context = getServiceContext();
        VmwareHypervisorHost hyperHost = getHyperHost(context);
        try {
            if (!hyperHost.isHyperHostConnected()) {
                return null;
            }
        } catch (Exception e) {
            s_logger.error("Unexpected exception", e);
            return null;
        }
        return new PingRoutingCommand(getType(), id, syncHostVmStates());
    } finally {
        recycleServiceContext();
    }
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Example 3 with PingRoutingCommand

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

the class HypervDirectConnectResource method getCurrentStatus.

@Override
public final PingCommand getCurrentStatus(final long id) {
    final PingCommand pingCmd = new PingRoutingCommand(getType(), id, getHostVmStateReport());
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Ping host " + _name + " (IP " + _agentIp + ")");
    }
    final Answer pingAns = executeRequest(pingCmd);
    if (pingAns == null || !pingAns.getResult()) {
        s_logger.info("Cannot ping host " + _name + " (IP " + _agentIp + "), pingAns (blank means null) is:" + pingAns);
        return null;
    }
    return pingCmd;
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) SetPortForwardingRulesAnswer(com.cloud.agent.api.routing.SetPortForwardingRulesAnswer) SetSourceNatAnswer(com.cloud.agent.api.routing.SetSourceNatAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) GetVmConfigAnswer(com.cloud.agent.api.GetVmConfigAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) SetStaticNatRulesAnswer(com.cloud.agent.api.routing.SetStaticNatRulesAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) SetFirewallRulesAnswer(com.cloud.agent.api.routing.SetFirewallRulesAnswer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) SetStaticRouteAnswer(com.cloud.agent.api.routing.SetStaticRouteAnswer) PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) PingCommand(com.cloud.agent.api.PingCommand)

Example 4 with PingRoutingCommand

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

the class Ovm3HypervisorResource method getCurrentStatus.

@Override
public PingCommand getCurrentStatus(long id) {
    try {
        /* feels useless somehow */
        Common test = new Common(c);
        String ping = "put";
        String pong = test.echo(ping);
        if (pong.contains(ping)) {
            hypervisorsupport.syncState();
            CloudstackPlugin cSp = new CloudstackPlugin(c);
            if (!cSp.dom0CheckStorageHealthCheck(configuration.getAgentScriptsDir(), configuration.getAgentCheckStorageScript(), configuration.getCsHostGuid(), configuration.getAgentStorageCheckTimeout(), configuration.getAgentStorageCheckInterval()) && !cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check not running on " + configuration.getAgentHostname());
            } else if (cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check started on " + configuration.getAgentHostname());
            } else {
                LOGGER.debug("Storage health check running on " + configuration.getAgentHostname());
            }
            return new PingRoutingCommand(getType(), id, hypervisorsupport.hostVmStateReport());
        } else {
            LOGGER.debug("Agent did not respond correctly: " + ping + " but got " + pong);
        }
    } catch (Ovm3ResourceException | NullPointerException e) {
        LOGGER.debug("Check agent status failed", e);
        return null;
    }
    return null;
}
Also used : PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin) Common(com.cloud.hypervisor.ovm3.objects.Common)

Aggregations

PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)4 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)1 Answer (com.cloud.agent.api.Answer)1 AttachOrDettachConfigDriveCommand (com.cloud.agent.api.AttachOrDettachConfigDriveCommand)1 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)1 CheckVirtualMachineCommand (com.cloud.agent.api.CheckVirtualMachineCommand)1 ClusterVMMetaDataSyncCommand (com.cloud.agent.api.ClusterVMMetaDataSyncCommand)1 Command (com.cloud.agent.api.Command)1 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)1 GetVmConfigAnswer (com.cloud.agent.api.GetVmConfigAnswer)1 MigrateCommand (com.cloud.agent.api.MigrateCommand)1 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)1 PingCommand (com.cloud.agent.api.PingCommand)1 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)1 PlugNicCommand (com.cloud.agent.api.PlugNicCommand)1 PrepareForMigrationCommand (com.cloud.agent.api.PrepareForMigrationCommand)1 RebootCommand (com.cloud.agent.api.RebootCommand)1 RestoreVMSnapshotCommand (com.cloud.agent.api.RestoreVMSnapshotCommand)1 ScaleVmCommand (com.cloud.agent.api.ScaleVmCommand)1