Search in sources :

Example 6 with StartupCommand

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

the class CiscoVnmcResource method initialize.

@Override
public StartupCommand[] initialize() {
    StartupExternalFirewallCommand cmd = new StartupExternalFirewallCommand();
    cmd.setName(_name);
    cmd.setDataCenter(_zoneId);
    cmd.setPod("");
    cmd.setPrivateIpAddress(_ip);
    cmd.setStorageIpAddress("");
    cmd.setVersion(CiscoVnmcResource.class.getPackage().getImplementationVersion());
    cmd.setGuid(_guid);
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupExternalFirewallCommand(com.cloud.agent.api.StartupExternalFirewallCommand)

Example 7 with StartupCommand

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

the class JuniperSrxResource method initialize.

@Override
public StartupCommand[] initialize() {
    StartupExternalFirewallCommand cmd = new StartupExternalFirewallCommand();
    cmd.setName(_name);
    cmd.setDataCenter(_zoneId);
    cmd.setPod("");
    cmd.setPrivateIpAddress(_ip);
    cmd.setStorageIpAddress("");
    cmd.setVersion(JuniperSrxResource.class.getPackage().getImplementationVersion());
    cmd.setGuid(_guid);
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupExternalFirewallCommand(com.cloud.agent.api.StartupExternalFirewallCommand)

Example 8 with StartupCommand

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

the class ResourceManagerImpl method createHostAndAgent.

private Host createHostAndAgent(final ServerResource resource, final Map<String, String> details, final boolean old, final List<String> hostTags, final boolean forRebalance) {
    HostVO host = null;
    StartupCommand[] cmds = null;
    boolean hostExists = false;
    boolean created = false;
    try {
        cmds = resource.initialize();
        if (cmds == null) {
            s_logger.info("Unable to fully initialize the agent because no StartupCommands are returned");
            return null;
        }
        /* Generate a random version in a dev setup situation */
        if (this.getClass().getPackage().getImplementationVersion() == null) {
            for (final StartupCommand cmd : cmds) {
                if (cmd.getVersion() == null) {
                    cmd.setVersion(Long.toString(System.currentTimeMillis()));
                }
            }
        }
        if (s_logger.isDebugEnabled()) {
            new Request(-1l, -1l, cmds, true, false).logD("Startup request from directly connected host: ", true);
        }
        if (old) {
            final StartupCommand firstCmd = cmds[0];
            host = findHostByGuid(firstCmd.getGuid());
            if (host == null) {
                host = findHostByGuid(firstCmd.getGuidWithoutResource());
            }
            if (host != null && host.getRemoved() == null) {
                // host already added, no need to add again
                s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new");
                // ensures that host status is left unchanged in case of adding same one again
                hostExists = true;
                return null;
            }
        }
        // find out if the host we want to connect to is new (so we can send an event)
        boolean newHost = getNewHost(cmds) == null;
        host = createHostVO(cmds, resource, details, hostTags, ResourceStateAdapter.Event.CREATE_HOST_VO_FOR_DIRECT_CONNECT);
        if (host != null) {
            created = _agentMgr.handleDirectConnectAgent(host, cmds, resource, forRebalance, newHost);
            /* reload myself from database */
            host = _hostDao.findById(host.getId());
        }
    } catch (final Exception e) {
        s_logger.warn("Unable to connect due to ", e);
    } finally {
        if (hostExists) {
            if (cmds != null) {
                resource.disconnected();
            }
        } else {
            if (!created) {
                if (cmds != null) {
                    resource.disconnected();
                }
                markHostAsDisconnected(host, cmds);
            }
        }
    }
    return host;
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) Request(com.cloud.agent.transport.Request) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceInUseException(com.cloud.exception.ResourceInUseException) URISyntaxException(java.net.URISyntaxException) DiscoveryException(com.cloud.exception.DiscoveryException) SshException(com.cloud.utils.ssh.SshException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ConfigurationException(javax.naming.ConfigurationException) PermissionDeniedException(com.cloud.exception.PermissionDeniedException)

Example 9 with StartupCommand

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

the class DummyResource method initialize.

@Override
public StartupCommand[] initialize() {
    final List<Object> info = getHostInfo();
    final StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.KVM, RouterPrivateIpStrategy.HostLocal);
    fillNetworkInformation(cmd);
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setCluster(getConfiguredProperty("cluster", "1"));
    StoragePoolInfo pi = initializeLocalStorage();
    StartupStorageCommand sscmd = new StartupStorageCommand();
    sscmd.setPoolInfo(pi);
    sscmd.setGuid(pi.getUuid());
    sscmd.setDataCenter((String) _params.get("zone"));
    sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
    return new StartupCommand[] { cmd, sscmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 10 with StartupCommand

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

the class ConsoleProxyResource method initialize.

@Override
public synchronized StartupCommand[] initialize() {
    final StartupProxyCommand cmd = new StartupProxyCommand();
    fillNetworkInformation(cmd);
    cmd.setProxyPort(_proxyPort);
    cmd.setProxyVmId(_proxyVmId);
    if (_pubIp != null)
        cmd.setPublicIpAddress(_pubIp);
    return new StartupCommand[] { cmd };
}
Also used : StartupProxyCommand(com.cloud.agent.api.StartupProxyCommand) StartupCommand(com.cloud.agent.api.StartupCommand)

Aggregations

StartupCommand (com.cloud.agent.api.StartupCommand)60 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)28 StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ConfigurationException (javax.naming.ConfigurationException)7 Command (com.cloud.agent.api.Command)6 StartupSecondaryStorageCommand (com.cloud.agent.api.StartupSecondaryStorageCommand)6 PingCommand (com.cloud.agent.api.PingCommand)5 HostVO (com.cloud.host.HostVO)5 URISyntaxException (java.net.URISyntaxException)5 Request (com.cloud.agent.transport.Request)4 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)3 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)3 ShutdownCommand (com.cloud.agent.api.ShutdownCommand)3 StartCommand (com.cloud.agent.api.StartCommand)3 StartupProxyCommand (com.cloud.agent.api.StartupProxyCommand)3 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)3 CheckRouterCommand (com.cloud.agent.api.CheckRouterCommand)2 CheckS2SVpnConnectionsCommand (com.cloud.agent.api.CheckS2SVpnConnectionsCommand)2 CronCommand (com.cloud.agent.api.CronCommand)2