Search in sources :

Example 6 with StartupStorageCommand

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

the class LibvirtComputingResource method initialize.

@Override
public StartupCommand[] initialize() {
    final List<Object> info = getHostInfo();
    _totalMemory = (Long) info.get(2);
    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, RouterPrivateIpStrategy.HostLocal);
    cmd.setCpuSockets((Integer) info.get(5));
    fillNetworkInformation(cmd);
    _privateIp = cmd.getPrivateIpAddress();
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setPool(_pool);
    cmd.setCluster(_clusterId);
    cmd.setGatewayIpAddress(_localGateway);
    cmd.setIqn(getIqn());
    StartupStorageCommand sscmd = null;
    try {
        final KVMStoragePool localStoragePool = _storagePoolMgr.createStoragePool(_localStorageUUID, "localhost", -1, _localStoragePath, "", StoragePoolType.Filesystem);
        final com.cloud.agent.api.StoragePoolInfo pi = new com.cloud.agent.api.StoragePoolInfo(localStoragePool.getUuid(), cmd.getPrivateIpAddress(), _localStoragePath, _localStoragePath, StoragePoolType.Filesystem, localStoragePool.getCapacity(), localStoragePool.getAvailable());
        sscmd = new StartupStorageCommand();
        sscmd.setPoolInfo(pi);
        sscmd.setGuid(pi.getUuid());
        sscmd.setDataCenter(_dcId);
        sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
    } catch (final CloudRuntimeException e) {
        s_logger.debug("Unable to initialize local storage pool: " + e);
    }
    if (sscmd != null) {
        return new StartupCommand[] { cmd, sscmd };
    } else {
        return new StartupCommand[] { cmd };
    }
}
Also used : StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StartupCommand(com.cloud.agent.api.StartupCommand) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 7 with StartupStorageCommand

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

the class HypervDirectConnectResourceTest method testJson.

// @Test
public final void testJson() {
    StartupStorageCommand sscmd = null;
    com.cloud.agent.api.StoragePoolInfo pi = new com.cloud.agent.api.StoragePoolInfo("test123", "192.168.0.1", "c:\\", "c:\\", StoragePoolType.Filesystem, 100L, 50L);
    sscmd = new StartupStorageCommand();
    sscmd.setPoolInfo(pi);
    sscmd.setGuid(pi.getUuid());
    sscmd.setDataCenter("foo");
    sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
    s_logger.debug("StartupStorageCommand fromJson is " + s_gson.toJson(sscmd));
}
Also used : StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand)

Example 8 with StartupStorageCommand

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

the class DummySecondaryStorageResource method initialize.

@Override
public StartupCommand[] initialize() {
    final StartupStorageCommand cmd = new StartupStorageCommand("dummy", StoragePoolType.NetworkFilesystem, 1024 * 1024 * 1024 * 100L, new HashMap<String, TemplateProp>());
    cmd.setResourceType(Storage.StorageResourceType.SECONDARY_STORAGE);
    cmd.setIqn(null);
    cmd.setNfsShare(_guid);
    fillNetworkInformation(cmd);
    cmd.setDataCenter(_dc);
    cmd.setPod(_pod);
    cmd.setGuid(_guid);
    cmd.setName(_guid);
    cmd.setVersion(DummySecondaryStorageResource.class.getPackage().getImplementationVersion());
    /* gather TemplateInfo in second storage */
    cmd.setTemplateInfo(getDefaultSystemVmTemplateInfo());
    cmd.getHostDetails().put("mount.parent", "dummy");
    cmd.getHostDetails().put("mount.path", "dummy");
    cmd.getHostDetails().put("orig.url", _guid);
    String[] tok = _dummyPath.split(":");
    cmd.setPrivateIpAddress(tok[0]);
    return new StartupCommand[] { cmd };
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) StartupCommand(com.cloud.agent.api.StartupCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand)

Example 9 with StartupStorageCommand

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

the class StorageCapacityListener method processConnect.

@Override
public void processConnect(Host server, StartupCommand startup, boolean forRebalance) throws ConnectionException {
    if (!(startup instanceof StartupStorageCommand)) {
        return;
    }
    StartupStorageCommand ssCmd = (StartupStorageCommand) startup;
    if (ssCmd.getResourceType() == Storage.StorageResourceType.STORAGE_HOST) {
        BigDecimal overProvFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.value());
        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 : StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) BigDecimal(java.math.BigDecimal)

Example 10 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand 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)

Aggregations

StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)22 StartupCommand (com.cloud.agent.api.StartupCommand)14 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)12 StoragePoolInfo (com.cloud.agent.api.StoragePoolInfo)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 HashMap (java.util.HashMap)3 Command (com.cloud.agent.api.Command)2 PingCommand (com.cloud.agent.api.PingCommand)2 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)2 VmState (com.cloud.agent.api.StartupRoutingCommand.VmState)2 CloudException (com.cloud.exception.CloudException)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)2 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)2 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)2 RouterPrivateIpStrategy (com.cloud.network.Networks.RouterPrivateIpStrategy)2 MockVMVO (com.cloud.simulator.MockVMVO)2 TemplateProp (com.cloud.storage.template.TemplateProp)2 State (com.cloud.vm.VirtualMachine.State)2 IOException (java.io.IOException)2