Search in sources :

Example 1 with IscsiDetails

use of org.ovirt.engine.api.model.IscsiDetails in project ovirt-engine by oVirt.

the class BackendHostResourceTest method testIscsiDiscover.

@Test
public void testIscsiDiscover() throws Exception {
    IscsiDetails iscsiDetails = new IscsiDetails();
    iscsiDetails.setAddress(ISCSI_SERVER_ADDRESS);
    iscsiDetails.setPort(ISCSI_PORT_INT);
    iscsiDetails.setUsername(ISCSI_USER_NAME);
    iscsiDetails.setPassword(ISCSI_USER_PASS);
    Action action = new Action();
    action.setIscsi(iscsiDetails);
    QueryReturnValue queryResult = new QueryReturnValue();
    queryResult.setSucceeded(true);
    when(backend.runQuery(eq(QueryType.DiscoverSendTargets), eqParams(DiscoverSendTargetsQueryParameters.class, addSession("VdsId", "Connection.Connection", "Connection.Port", "Connection.UserName", "Connection.Password"), addSession(GUIDS[0], ISCSI_SERVER_ADDRESS, ISCSI_PORT_STRING, ISCSI_USER_NAME, ISCSI_USER_PASS)))).thenReturn(queryResult);
    enqueueInteraction(() -> verify(backend, atLeastOnce()).runQuery(eq(QueryType.DiscoverSendTargets), eqParams(DiscoverSendTargetsQueryParameters.class, addSession("VdsId", "Connection.Connection", "Connection.Port", "Connection.UserName", "Connection.Password"), addSession(GUIDS[0], ISCSI_SERVER_ADDRESS, ISCSI_PORT_STRING, ISCSI_USER_NAME, ISCSI_USER_PASS))));
    resource.iscsiDiscover(action);
}
Also used : Action(org.ovirt.engine.api.model.Action) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) DiscoverSendTargetsQueryParameters(org.ovirt.engine.core.common.queries.DiscoverSendTargetsQueryParameters) Test(org.junit.Test)

Example 2 with IscsiDetails

use of org.ovirt.engine.api.model.IscsiDetails in project ovirt-engine by oVirt.

the class BackendHostResource method iscsiLogin.

@Override
public Response iscsiLogin(Action action) {
    validateParameters(action, "iscsi.address", "iscsi.target");
    StorageServerConnections cnx = new StorageServerConnections();
    IscsiDetails iscsiDetails = action.getIscsi();
    cnx.setConnection(iscsiDetails.getAddress());
    cnx.setIqn(iscsiDetails.getTarget());
    cnx.setStorageType(StorageType.ISCSI);
    if (iscsiDetails.isSetPort()) {
        cnx.setPort(iscsiDetails.getPort().toString());
    } else {
        cnx.setPort(DEFAULT_ISCSI_PORT);
    }
    if (iscsiDetails.isSetPortal()) {
        cnx.setPortal(iscsiDetails.getPortal());
    }
    if (iscsiDetails.isSetUsername()) {
        cnx.setUserName(iscsiDetails.getUsername());
    }
    if (iscsiDetails.isSetPassword()) {
        cnx.setPassword(iscsiDetails.getPassword());
    }
    StorageServerConnectionParametersBase connectionParms = new StorageServerConnectionParametersBase(cnx, guid, false);
    return doAction(ActionType.ConnectStorageToVds, connectionParms, action);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 3 with IscsiDetails

use of org.ovirt.engine.api.model.IscsiDetails in project ovirt-engine by oVirt.

the class BackendHostResource method mapLogicalUnitToIscsiDetails.

private IscsiDetails mapLogicalUnitToIscsiDetails(LogicalUnit logicalUnit) {
    IscsiDetails iscsiDetails = new IscsiDetails();
    iscsiDetails.setAddress(logicalUnit.getAddress());
    iscsiDetails.setPort(logicalUnit.getPort());
    iscsiDetails.setTarget(logicalUnit.getTarget());
    iscsiDetails.setPortal(logicalUnit.getPortal());
    iscsiDetails.setPaths(logicalUnit.getPaths());
    iscsiDetails.setVendorId(logicalUnit.getVendorId());
    iscsiDetails.setProductId(logicalUnit.getProductId());
    iscsiDetails.setSerial(logicalUnit.getSerial());
    return iscsiDetails;
}
Also used : IscsiDetails(org.ovirt.engine.api.model.IscsiDetails)

Example 4 with IscsiDetails

use of org.ovirt.engine.api.model.IscsiDetails in project ovirt-engine by oVirt.

the class HostMapper method map.

@Mapping(from = VDS.class, to = Host.class)
public static Host map(VDS entity, Host template) {
    Host model = template != null ? template : new Host();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    model.setComment(entity.getComment());
    if (entity.getClusterId() != null) {
        Cluster cluster = new Cluster();
        cluster.setId(entity.getClusterId().toString());
        model.setCluster(cluster);
    }
    model.setAddress(entity.getHostName());
    if (entity.getPort() > 0) {
        model.setPort(entity.getPort());
    }
    // We return always STOMP because support for XML-RPC was removed in version 4.1 of the engine.
    model.setProtocol(HostProtocol.STOMP);
    HostStatus status = map(entity.getStatus(), null);
    model.setStatus(status);
    if (entity.getExternalStatus() != null) {
        ExternalStatus externalStatus = ExternalStatusMapper.map(entity.getExternalStatus());
        model.setExternalStatus(externalStatus);
    }
    if (status == HostStatus.NON_OPERATIONAL) {
        model.setStatusDetail(entity.getNonOperationalReason().name().toLowerCase());
    } else if (status == HostStatus.MAINTENANCE || status == HostStatus.PREPARING_FOR_MAINTENANCE) {
        model.setStatusDetail(entity.getMaintenanceReason());
    }
    Spm spm = new Spm();
    spm.setPriority(entity.getVdsSpmPriority());
    if (entity.getSpmStatus() != null) {
        spm.setStatus(mapSpmStatus(entity.getSpmStatus()));
    }
    model.setSpm(spm);
    if (entity.getVersion() != null && entity.getVersion().getMajor() != -1 && entity.getVersion().getMinor() != -1 && entity.getVersion().getRevision() != -1 && entity.getVersion().getBuild() != -1) {
        Version version = new Version();
        version.setMajor(entity.getVersion().getMajor());
        version.setMinor(entity.getVersion().getMinor());
        version.setRevision(entity.getVersion().getRevision());
        version.setBuild(entity.getVersion().getBuild());
        version.setFullVersion(entity.getVersion().getRpmName());
        model.setVersion(version);
    }
    model.setOs(mapOperatingSystem(entity));
    model.setKsm(new Ksm());
    model.getKsm().setEnabled(Boolean.TRUE.equals(entity.getKsmState()));
    model.setTransparentHugepages(new TransparentHugePages());
    model.getTransparentHugepages().setEnabled(!(entity.getTransparentHugePagesState() == null || entity.getTransparentHugePagesState() == VdsTransparentHugePagesState.Never));
    if (entity.getIScsiInitiatorName() != null) {
        model.setIscsi(new IscsiDetails());
        model.getIscsi().setInitiator(entity.getIScsiInitiatorName());
    }
    model.setPowerManagement(map(entity, (PowerManagement) null));
    model.setHardwareInformation(map(entity, (HardwareInformation) null));
    model.setSsh(map(entity.getStaticData(), null));
    Cpu cpu = new Cpu();
    CpuTopology cpuTopology = new CpuTopology();
    if (entity.getCpuSockets() != null) {
        cpuTopology.setSockets(entity.getCpuSockets());
        if (entity.getCpuCores() != null) {
            cpuTopology.setCores(entity.getCpuCores() / entity.getCpuSockets());
            if (entity.getCpuThreads() != null) {
                cpuTopology.setThreads(entity.getCpuThreads() / entity.getCpuCores());
            }
        }
    }
    cpu.setTopology(cpuTopology);
    cpu.setName(entity.getCpuModel());
    if (entity.getCpuSpeedMh() != null) {
        cpu.setSpeed(new BigDecimal(entity.getCpuSpeedMh()));
    }
    model.setCpu(cpu);
    VmSummary vmSummary = new VmSummary();
    vmSummary.setActive(entity.getVmActive());
    vmSummary.setMigrating(entity.getVmMigrating());
    vmSummary.setTotal(entity.getVmCount());
    model.setSummary(vmSummary);
    if (entity.getVdsType() != null) {
        HostType type = map(entity.getVdsType(), null);
        model.setType(type);
    }
    model.setMemory(Long.valueOf(entity.getPhysicalMemMb() == null ? 0 : entity.getPhysicalMemMb() * BYTES_IN_MEGABYTE));
    model.setMaxSchedulingMemory((int) entity.getMaxSchedulingMemory() * BYTES_IN_MEGABYTE);
    if (entity.getLibvirtVersion() != null && entity.getLibvirtVersion().getMajor() != -1 && entity.getLibvirtVersion().getMinor() != -1 && entity.getLibvirtVersion().getRevision() != -1 && entity.getLibvirtVersion().getBuild() != -1) {
        Version version = new Version();
        version.setMajor(entity.getLibvirtVersion().getMajor());
        version.setMinor(entity.getLibvirtVersion().getMinor());
        version.setRevision(entity.getLibvirtVersion().getRevision());
        version.setBuild(entity.getLibvirtVersion().getBuild());
        version.setFullVersion(entity.getLibvirtVersion().getRpmName());
        model.setLibvirtVersion(version);
    }
    if (entity.getConsoleAddress() != null && !"".equals(entity.getConsoleAddress())) {
        model.setDisplay(new Display());
        model.getDisplay().setAddress(entity.getConsoleAddress());
    }
    model.setKdumpStatus(map(entity.getKdumpStatus(), null));
    model.setSeLinux(map(entity, (SeLinux) null));
    model.setAutoNumaStatus(map(entity.getAutoNumaBalancing(), null));
    model.setNumaSupported(entity.isNumaSupport());
    if (entity.getHostProviderId() != null) {
        model.setExternalHostProvider(new ExternalHostProvider());
        model.getExternalHostProvider().setId(entity.getHostProviderId().toString());
    }
    model.setUpdateAvailable(entity.isUpdateAvailable());
    HostDevicePassthrough devicePassthrough = model.getDevicePassthrough();
    if (devicePassthrough == null) {
        devicePassthrough = new HostDevicePassthrough();
        model.setDevicePassthrough(devicePassthrough);
    }
    devicePassthrough.setEnabled(entity.isHostDevicePassthroughEnabled());
    if (entity.getHostName() != null) {
        String subject = CertificateSubjectHelper.getCertificateSubject(entity.getHostName());
        model.setCertificate(new Certificate());
        model.getCertificate().setSubject(subject);
        model.getCertificate().setOrganization(subject.split(",")[0].replace("O=", ""));
    }
    return model;
}
Also used : ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Ksm(org.ovirt.engine.api.model.Ksm) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) HostDevicePassthrough(org.ovirt.engine.api.model.HostDevicePassthrough) TransparentHugePages(org.ovirt.engine.api.model.TransparentHugePages) Cluster(org.ovirt.engine.api.model.Cluster) Cpu(org.ovirt.engine.api.model.Cpu) Host(org.ovirt.engine.api.model.Host) HardwareInformation(org.ovirt.engine.api.model.HardwareInformation) BigDecimal(java.math.BigDecimal) ExternalStatus(org.ovirt.engine.api.model.ExternalStatus) CpuTopology(org.ovirt.engine.api.model.CpuTopology) Spm(org.ovirt.engine.api.model.Spm) PowerManagement(org.ovirt.engine.api.model.PowerManagement) HostType(org.ovirt.engine.api.model.HostType) VmSummary(org.ovirt.engine.api.model.VmSummary) Version(org.ovirt.engine.api.model.Version) HostStatus(org.ovirt.engine.api.model.HostStatus) SeLinux(org.ovirt.engine.api.model.SeLinux) Display(org.ovirt.engine.api.model.Display) Certificate(org.ovirt.engine.api.model.Certificate)

Example 5 with IscsiDetails

use of org.ovirt.engine.api.model.IscsiDetails in project ovirt-engine by oVirt.

the class BackendHostResourceTest method testIscsiLogin.

@Test
public void testIscsiLogin() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.ConnectStorageToVds, StorageServerConnectionParametersBase.class, new String[] { "VdsId", "StorageServerConnection.Connection", "StorageServerConnection.Portal", "StorageServerConnection.Iqn", "StorageServerConnection.Port", "StorageServerConnection.StorageType", "StorageServerConnection.UserName", "StorageServerConnection.Password" }, new Object[] { GUIDS[0], ISCSI_SERVER_ADDRESS, // TODO: right now hard-coded, but this should change when VDSM and Backend support portal
    StorageServerConnections.DEFAULT_TPGT, ISCSI_IQN, ISCSI_PORT_STRING, ISCSI_STORAGE_TYPE, ISCSI_USER_NAME, ISCSI_USER_PASS }));
    Action action = new Action();
    IscsiDetails iscsiDetails = new IscsiDetails();
    iscsiDetails.setAddress(ISCSI_SERVER_ADDRESS);
    iscsiDetails.setPort(ISCSI_PORT_INT);
    iscsiDetails.setTarget(ISCSI_IQN);
    iscsiDetails.setUsername(ISCSI_USER_NAME);
    iscsiDetails.setPassword(ISCSI_USER_PASS);
    action.setIscsi(iscsiDetails);
    verifyActionResponse(resource.iscsiLogin(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) Test(org.junit.Test)

Aggregations

IscsiDetails (org.ovirt.engine.api.model.IscsiDetails)6 Test (org.junit.Test)2 Action (org.ovirt.engine.api.model.Action)2 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)2 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)2 BigDecimal (java.math.BigDecimal)1 Certificate (org.ovirt.engine.api.model.Certificate)1 Cluster (org.ovirt.engine.api.model.Cluster)1 Cpu (org.ovirt.engine.api.model.Cpu)1 CpuTopology (org.ovirt.engine.api.model.CpuTopology)1 Display (org.ovirt.engine.api.model.Display)1 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)1 ExternalStatus (org.ovirt.engine.api.model.ExternalStatus)1 HardwareInformation (org.ovirt.engine.api.model.HardwareInformation)1 Host (org.ovirt.engine.api.model.Host)1 HostDevicePassthrough (org.ovirt.engine.api.model.HostDevicePassthrough)1 HostStatus (org.ovirt.engine.api.model.HostStatus)1 HostType (org.ovirt.engine.api.model.HostType)1 Ksm (org.ovirt.engine.api.model.Ksm)1 PowerManagement (org.ovirt.engine.api.model.PowerManagement)1