Search in sources :

Example 1 with StorageSubSystemCommand

use of com.cloud.storage.command.StorageSubSystemCommand in project cosmic by MissionCriticalCloud.

the class KVMGuru method getCommandHostDelegation.

@Override
public Pair<Boolean, Long> getCommandHostDelegation(final long hostId, final Command cmd) {
    if (cmd instanceof StorageSubSystemCommand) {
        final StorageSubSystemCommand c = (StorageSubSystemCommand) cmd;
        c.setExecuteInSequence(false);
    }
    if (cmd instanceof CopyCommand) {
        final CopyCommand c = (CopyCommand) cmd;
        final DataTO srcData = c.getSrcTO();
        boolean inSeq = true;
        if (c.getSrcTO().getObjectType() == DataObjectType.SNAPSHOT || c.getDestTO().getObjectType() == DataObjectType.SNAPSHOT) {
            inSeq = false;
        } else if (c.getDestTO().getDataStore().getRole() == DataStoreRole.Image || c.getDestTO().getDataStore().getRole() == DataStoreRole.ImageCache) {
            inSeq = false;
        }
        c.setExecuteInSequence(inSeq);
        if (srcData.getHypervisorType() == HypervisorType.KVM) {
            return new Pair<>(true, new Long(hostId));
        }
    }
    return new Pair<>(false, new Long(hostId));
}
Also used : StorageSubSystemCommand(com.cloud.storage.command.StorageSubSystemCommand) DataTO(com.cloud.agent.api.to.DataTO) CopyCommand(com.cloud.storage.command.CopyCommand) Pair(com.cloud.utils.Pair)

Example 2 with StorageSubSystemCommand

use of com.cloud.storage.command.StorageSubSystemCommand in project cosmic by MissionCriticalCloud.

the class XenServerGuru method getCommandHostDelegation.

@Override
public Pair<Boolean, Long> getCommandHostDelegation(final long hostId, final Command cmd) {
    LOGGER.debug("getCommandHostDelegation: " + cmd.getClass());
    if (cmd instanceof StorageSubSystemCommand) {
        final StorageSubSystemCommand c = (StorageSubSystemCommand) cmd;
        c.setExecuteInSequence(true);
    }
    if (cmd instanceof CopyCommand) {
        final CopyCommand cpyCommand = (CopyCommand) cmd;
        final DataTO srcData = cpyCommand.getSrcTO();
        final DataTO destData = cpyCommand.getDestTO();
        if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) {
            final DataStoreTO srcStore = srcData.getDataStore();
            final DataStoreTO destStore = destData.getDataStore();
            if (srcStore instanceof NfsTO && destStore instanceof NfsTO) {
                HostVO host = hostDao.findById(hostId);
                final EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId()));
                host = hostDao.findById(ep.getId());
                hostDao.loadDetails(host);
                final String hypervisorVersion = host.getHypervisorVersion();
                final String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix);
                if (hypervisorVersion != null && !hypervisorVersion.equalsIgnoreCase("6.1.0")) {
                    if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") && !(snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) {
                        return new Pair<>(Boolean.TRUE, new Long(ep.getId()));
                    }
                }
            }
        }
    }
    return new Pair<>(Boolean.FALSE, new Long(hostId));
}
Also used : ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) StorageSubSystemCommand(com.cloud.storage.command.StorageSubSystemCommand) DataTO(com.cloud.agent.api.to.DataTO) CopyCommand(com.cloud.storage.command.CopyCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) NfsTO(com.cloud.agent.api.to.NfsTO) HostVO(com.cloud.host.HostVO) Pair(com.cloud.utils.Pair)

Aggregations

DataTO (com.cloud.agent.api.to.DataTO)2 CopyCommand (com.cloud.storage.command.CopyCommand)2 StorageSubSystemCommand (com.cloud.storage.command.StorageSubSystemCommand)2 Pair (com.cloud.utils.Pair)2 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)1 NfsTO (com.cloud.agent.api.to.NfsTO)1 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)1 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)1 HostVO (com.cloud.host.HostVO)1