Search in sources :

Example 1 with StartupStorageCommand

use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.

the class StorageCapacityListener method processConnect.

@Override
public void processConnect(final Host server, final StartupCommand[] startupCommands, final boolean forRebalance) {
    for (final StartupCommand startupCommand : startupCommands) {
        if (!(startupCommand instanceof StartupStorageCommand)) {
            return;
        }
        final StartupStorageCommand ssCmd = (StartupStorageCommand) startupCommand;
        if (ssCmd.getResourceType() == StorageResourceType.STORAGE_HOST) {
            final BigDecimal overProvFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.value());
            final CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L, (overProvFactor.multiply(new BigDecimal(server.getTotalSize()))).longValue(), Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
            _capacityDao.persist(capacity);
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) BigDecimal(java.math.BigDecimal)

Example 2 with StartupStorageCommand

use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method initialize.

@Override
public StartupCommand[] initialize() throws IllegalArgumentException {
    final Connection conn = getConnection();
    if (!getHostInfo(conn)) {
        s_logger.warn("Unable to get host information for " + this._host.getIp());
        return null;
    }
    final StartupRoutingCommand cmd = new StartupRoutingCommand();
    fillHostInfo(conn, cmd);
    cmd.setHypervisorType(HypervisorType.XenServer);
    cmd.setCluster(this._cluster);
    cmd.setPoolSync(false);
    try {
        final Pool pool = Pool.getByUuid(conn, this._host.getPool());
        final Pool.Record poolr = pool.getRecord(conn);
        poolr.master.getRecord(conn);
    } catch (final XmlRpcException | XenAPIException e) {
        s_logger.warn("Check for master failed, failing the FULL Cluster sync command");
    }
    final StartupStorageCommand sscmd = initializeLocalSR(conn);
    if (sscmd != null) {
        return new StartupCommand[] { cmd, sscmd };
    }
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) Connection(com.xensource.xenapi.Connection) URLConnection(java.net.URLConnection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Pool(com.xensource.xenapi.Pool) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 3 with StartupStorageCommand

use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.

the class AgentManagerImpl method connectAgent.

protected void connectAgent(final Link link, final Command[] cmds, final Request request) {
    // send startupanswer to agent in the very beginning, so agent can move on without waiting for the answer for an undetermined time, if we put this logic into another
    // thread pool.
    final StartupAnswer[] answers = new StartupAnswer[cmds.length];
    Command cmd;
    for (int i = 0; i < cmds.length; i++) {
        cmd = cmds[i];
        if (cmd instanceof StartupRoutingCommand || cmd instanceof StartupProxyCommand || cmd instanceof StartupSecondaryStorageCommand || cmd instanceof StartupStorageCommand) {
            answers[i] = new StartupAnswer((StartupCommand) cmds[i], 0, getPingInterval());
            break;
        }
    }
    Response response = null;
    response = new Response(request, answers[0], this._nodeId, -1);
    try {
        link.send(response.toBytes());
    } catch (final ClosedChannelException e) {
        s_logger.debug("Failed to send startupanswer: " + e.toString());
    }
    this._connectExecutor.execute(new HandleAgentConnectTask(link, cmds, request));
}
Also used : StartupAnswer(com.cloud.legacymodel.communication.answer.StartupAnswer) StartupProxyCommand(com.cloud.legacymodel.communication.command.startup.StartupProxyCommand) StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Response(com.cloud.common.transport.Response) ClosedChannelException(java.nio.channels.ClosedChannelException) ReadyCommand(com.cloud.legacymodel.communication.command.ReadyCommand) PingCommand(com.cloud.legacymodel.communication.command.PingCommand) StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) Command(com.cloud.legacymodel.communication.command.Command) AgentControlCommand(com.cloud.legacymodel.communication.command.agentcontrol.AgentControlCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) PingRoutingCommand(com.cloud.legacymodel.communication.command.PingRoutingCommand) ShutdownCommand(com.cloud.legacymodel.communication.command.ShutdownCommand) StartupProxyCommand(com.cloud.legacymodel.communication.command.startup.StartupProxyCommand) StartupSecondaryStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Example 4 with StartupStorageCommand

use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.

the class UploadListener method processConnect.

@Override
public void processConnect(final Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) {
    for (final StartupCommand startupCommand : startupCommands) {
        if (!(startupCommand instanceof StartupStorageCommand)) {
            return;
        }
        final long agentId = agent.getId();
        final StartupStorageCommand storage = (StartupStorageCommand) startupCommand;
        if (storage.getResourceType() == StorageResourceType.STORAGE_HOST || storage.getResourceType() == StorageResourceType.SECONDARY_STORAGE) {
            this.uploadMonitor.handleUploadSync(agentId);
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)

Example 5 with StartupStorageCommand

use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method initializeLocalSR.

protected StartupStorageCommand initializeLocalSR(final Connection conn) {
    final SR lvmsr = getLocalLVMSR(conn);
    if (lvmsr != null) {
        try {
            this._host.setLocalSRuuid(lvmsr.getUuid(conn));
            final String lvmuuid = lvmsr.getUuid(conn);
            final long cap = lvmsr.getPhysicalSize(conn);
            if (cap > 0) {
                final long avail = cap - lvmsr.getPhysicalUtilisation(conn);
                lvmsr.setNameLabel(conn, lvmuuid);
                final String name = "Cloud Stack Local LVM Storage Pool for " + this._host.getUuid();
                lvmsr.setNameDescription(conn, name);
                final Host host = Host.getByUuid(conn, this._host.getUuid());
                final String address = host.getAddress(conn);
                final StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
                final StartupStorageCommand cmd = new StartupStorageCommand();
                cmd.setPoolInfo(pInfo);
                cmd.setGuid(this._host.getUuid());
                cmd.setDataCenter(Long.toString(this._dcId));
                cmd.setResourceType(StorageResourceType.STORAGE_POOL);
                return cmd;
            }
        } catch (final XenAPIException e) {
            final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.toString();
            s_logger.warn(msg);
        } catch (final XmlRpcException e) {
            final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.getMessage();
            s_logger.warn(msg);
        }
    }
    final SR extsr = getLocalEXTSR(conn);
    if (extsr != null) {
        try {
            final String extuuid = extsr.getUuid(conn);
            this._host.setLocalSRuuid(extuuid);
            final long cap = extsr.getPhysicalSize(conn);
            if (cap > 0) {
                final long avail = cap - extsr.getPhysicalUtilisation(conn);
                extsr.setNameLabel(conn, extuuid);
                final String name = "Cloud Stack Local EXT Storage Pool for " + this._host.getUuid();
                extsr.setNameDescription(conn, name);
                final Host host = Host.getByUuid(conn, this._host.getUuid());
                final String address = host.getAddress(conn);
                final StoragePoolInfo pInfo = new StoragePoolInfo(extuuid, address, SRType.EXT.toString(), SRType.EXT.toString(), StoragePoolType.EXT, cap, avail);
                final StartupStorageCommand cmd = new StartupStorageCommand();
                cmd.setPoolInfo(pInfo);
                cmd.setGuid(this._host.getUuid());
                cmd.setDataCenter(Long.toString(this._dcId));
                cmd.setResourceType(StorageResourceType.STORAGE_POOL);
                return cmd;
            }
        } catch (final XenAPIException e) {
            final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.toString();
            s_logger.warn(msg);
        } catch (final XmlRpcException e) {
            final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.getMessage();
            s_logger.warn(msg);
        }
    }
    return null;
}
Also used : StartupStorageCommand(com.cloud.legacymodel.communication.command.startup.StartupStorageCommand) StoragePoolInfo(com.cloud.legacymodel.storage.StoragePoolInfo) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Host(com.xensource.xenapi.Host) XmlRpcException(org.apache.xmlrpc.XmlRpcException) SR(com.xensource.xenapi.SR)

Aggregations

StartupStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupStorageCommand)6 StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)5 StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 Response (com.cloud.common.transport.Response)1 StartupAnswer (com.cloud.legacymodel.communication.answer.StartupAnswer)1 CheckHealthCommand (com.cloud.legacymodel.communication.command.CheckHealthCommand)1 Command (com.cloud.legacymodel.communication.command.Command)1 PingCommand (com.cloud.legacymodel.communication.command.PingCommand)1 PingRoutingCommand (com.cloud.legacymodel.communication.command.PingRoutingCommand)1 ReadyCommand (com.cloud.legacymodel.communication.command.ReadyCommand)1 ShutdownCommand (com.cloud.legacymodel.communication.command.ShutdownCommand)1 AgentControlCommand (com.cloud.legacymodel.communication.command.agentcontrol.AgentControlCommand)1 StartupProxyCommand (com.cloud.legacymodel.communication.command.startup.StartupProxyCommand)1 StartupSecondaryStorageCommand (com.cloud.legacymodel.communication.command.startup.StartupSecondaryStorageCommand)1 StoragePoolInfo (com.cloud.legacymodel.storage.StoragePoolInfo)1 Connection (com.xensource.xenapi.Connection)1 Host (com.xensource.xenapi.Host)1 Pool (com.xensource.xenapi.Pool)1