Search in sources :

Example 16 with Version

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

the class HostMapper method mapOperatingSystem.

private static OperatingSystem mapOperatingSystem(VDS entity) {
    final OperatingSystem model = new OperatingSystem();
    if (StringUtils.isNotBlank(entity.getHostOs())) {
        OS hostOs = OS.fromPackageVersionString(entity.getHostOs());
        Version version = new Version();
        if (hostOs.getVersion().getMajor() != VERSION_NOT_SET) {
            version.setMajor(hostOs.getVersion().getMajor());
        }
        if (hostOs.getVersion().getMinor() != VERSION_NOT_SET) {
            version.setMinor(hostOs.getVersion().getMinor());
        }
        if (hostOs.getVersion().getBuild() != VERSION_NOT_SET) {
            version.setBuild(hostOs.getVersion().getBuild());
        }
        version.setFullVersion(hostOs.getFullVersion());
        model.setVersion(version);
        model.setType(hostOs.getName());
    }
    model.setCustomKernelCmdline(Objects.toString(entity.getCurrentKernelCmdline(), ""));
    model.setReportedKernelCmdline(entity.getKernelArgs());
    return model;
}
Also used : OperatingSystem(org.ovirt.engine.api.model.OperatingSystem) OS(org.ovirt.engine.core.utils.OS) Version(org.ovirt.engine.api.model.Version)

Example 17 with Version

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

the class BackendClustersResourceTest method setUpStoragePool.

protected StoragePool setUpStoragePool(int index) {
    StoragePool pool = mock(StoragePool.class);
    org.ovirt.engine.core.compat.Version version = new org.ovirt.engine.core.compat.Version(2, 2);
    if (index != -1) {
        when(pool.getId()).thenReturn(GUIDS[index]);
    }
    when(pool.getCompatibilityVersion()).thenReturn(version);
    return pool;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.api.model.Version)

Example 18 with Version

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

the class BackendClustersResourceTest method testAddClusterSpecificVersion.

@Test
public void testAddClusterSpecificVersion() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(QueryType.GetStoragePoolById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpStoragePool(-1));
    setUpGetEntityExpectations(QueryType.GetManagementNetwork, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, null);
    setUpCreationExpectations(ActionType.AddCluster, ManagementNetworkOnClusterOperationParameters.class, new String[] { "Cluster.CompatibilityVersion" }, new Object[] { new org.ovirt.engine.core.compat.Version(2, 3) }, true, true, GUIDS[0], QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    org.ovirt.engine.api.model.Cluster model = getModel(0);
    model.getDataCenter().setId(GUIDS[1].toString());
    model.setVersion(new Version());
    model.getVersion().setMajor(2);
    model.getVersion().setMinor(3);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof org.ovirt.engine.api.model.Cluster);
    verifyModel((org.ovirt.engine.api.model.Cluster) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Version(org.ovirt.engine.api.model.Version) Test(org.junit.Test)

Example 19 with Version

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

the class VersionMapperTest method testNoMatchDoesntCrash.

/**
 * Checks that a version string that doesn't match the version number pattern doesn't generate an exception, and
 * that the complete version string is reported in the {@code full_version} property.
 */
@Test
public void testNoMatchDoesntCrash() {
    Version version = VersionMapper.fromVersionString("ugly");
    assertNotNull(version);
    assertEquals("ugly", version.getFullVersion());
}
Also used : Version(org.ovirt.engine.api.model.Version) Test(org.junit.Test)

Example 20 with Version

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

the class VersionMapperTest method testNullStringProducesNullVersion.

/**
 * Checks that a null version string results in a null version object.
 */
@Test
public void testNullStringProducesNullVersion() {
    Version version = VersionMapper.fromVersionString(null);
    assertNull(version);
}
Also used : Version(org.ovirt.engine.api.model.Version) Test(org.junit.Test)

Aggregations

Version (org.ovirt.engine.api.model.Version)20 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)2 V3Version (org.ovirt.engine.api.v3.types.V3Version)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 BigDecimal (java.math.BigDecimal)1 Matcher (java.util.regex.Matcher)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 IscsiDetails (org.ovirt.engine.api.model.IscsiDetails)1