Search in sources :

Example 11 with StartupRoutingCommand

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

the class VmwareManagerImpl method updateClusterNativeHAState.

@DB
private void updateClusterNativeHAState(Host host, StartupCommand cmd) {
    ClusterVO cluster = _clusterDao.findById(host.getClusterId());
    if (cluster.getClusterType() == ClusterType.ExternalManaged) {
        if (cmd instanceof StartupRoutingCommand) {
            StartupRoutingCommand hostStartupCmd = (StartupRoutingCommand) cmd;
            Map<String, String> details = hostStartupCmd.getHostDetails();
            if (details.get("NativeHA") != null && details.get("NativeHA").equalsIgnoreCase("true")) {
                _clusterDetailsDao.persist(host.getClusterId(), "NativeHA", "true");
            } else {
                _clusterDetailsDao.persist(host.getClusterId(), "NativeHA", "false");
            }
        }
    }
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) DB(com.cloud.utils.db.DB)

Example 12 with StartupRoutingCommand

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

the class OvmResourceBase method initialize.

@Override
public StartupCommand[] initialize() {
    try {
        StartupRoutingCommand cmd = new StartupRoutingCommand();
        fillHostInfo(cmd);
        cmd.setCaps("hvm");
        return new StartupCommand[] { cmd };
    } catch (Exception e) {
        s_logger.debug("Ovm resource initializes failed", e);
        return null;
    }
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ConfigurationException(javax.naming.ConfigurationException)

Example 13 with StartupRoutingCommand

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

the class VmwareResource method initialize.

@Override
public StartupCommand[] initialize() {
    try {
        String hostApiVersion = "4.1";
        VmwareContext context = getServiceContext();
        try {
            VmwareHypervisorHost hyperHost = getHyperHost(context);
            assert (hyperHost instanceof HostMO);
            if (!((HostMO) hyperHost).isHyperHostConnected()) {
                s_logger.info("Host " + hyperHost.getHyperHostName() + " is not in connected state");
                return null;
            }
            ((HostMO) hyperHost).enableVncOnHostFirewall();
            AboutInfo aboutInfo = ((HostMO) hyperHost).getHostAboutInfo();
            hostApiVersion = aboutInfo.getApiVersion();
        } catch (Exception e) {
            String msg = "VmwareResource intialize() failed due to : " + VmwareHelper.getExceptionMessage(e);
            s_logger.error(msg);
            invalidateServiceContext();
            return null;
        }
        StartupRoutingCommand cmd = new StartupRoutingCommand();
        fillHostInfo(cmd);
        cmd.setHypervisorType(HypervisorType.VMware);
        cmd.setCluster(_cluster);
        cmd.setHypervisorVersion(hostApiVersion);
        List<StartupStorageCommand> storageCmds = initializeLocalStorage();
        StartupCommand[] answerCmds = new StartupCommand[1 + storageCmds.size()];
        answerCmds[0] = cmd;
        for (int i = 0; i < storageCmds.size(); i++) {
            answerCmds[i + 1] = storageCmds.get(i);
        }
        return answerCmds;
    } finally {
        recycleServiceContext();
    }
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) HostMO(com.cloud.hypervisor.vmware.mo.HostMO) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) AboutInfo(com.vmware.vim25.AboutInfo) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) 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 14 with StartupRoutingCommand

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

the class SshKeysDistriMonitor method processConnect.

@Override
public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
    if (cmd instanceof StartupRoutingCommand) {
        if (((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.KVM || ((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.XenServer || ((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.LXC) {
            /*TODO: Get the private/public keys here*/
            String pubKey = _configDao.getValue("ssh.publickey");
            String prvKey = _configDao.getValue("ssh.privatekey");
            try {
                ModifySshKeysCommand cmds = new ModifySshKeysCommand(pubKey, prvKey);
                Commands c = new Commands(cmds);
                _agentMgr.send(host.getId(), c, this);
            } catch (AgentUnavailableException e) {
                s_logger.debug("Failed to send keys to agent: " + host.getId());
            }
        }
    }
}
Also used : AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ModifySshKeysCommand(com.cloud.agent.api.ModifySshKeysCommand) Commands(com.cloud.agent.manager.Commands) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 15 with StartupRoutingCommand

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

the class SimulatorDiscoverer method createHostVOForDirectConnectAgent.

@Override
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
    StartupCommand firstCmd = startup[0];
    if (!(firstCmd instanceof StartupRoutingCommand)) {
        return null;
    }
    StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
        return null;
    }
    return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Aggregations

StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)40 StartupCommand (com.cloud.agent.api.StartupCommand)27 StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ClusterVO (com.cloud.dc.ClusterVO)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)6 ConnectionException (com.cloud.exception.ConnectionException)6 HostVO (com.cloud.host.HostVO)6 DataCenterVO (com.cloud.dc.DataCenterVO)5 ConfigurationException (javax.naming.ConfigurationException)5 HostPodVO (com.cloud.dc.HostPodVO)4 Command (com.cloud.agent.api.Command)3 Commands (com.cloud.agent.manager.Commands)3 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)3 PingCommand (com.cloud.agent.api.PingCommand)2 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)2 SetupAnswer (com.cloud.agent.api.SetupAnswer)2 SetupCommand (com.cloud.agent.api.SetupCommand)2 StartCommand (com.cloud.agent.api.StartCommand)2 StoragePoolInfo (com.cloud.agent.api.StoragePoolInfo)2