Search in sources :

Example 1 with HostDevice

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

the class HostDeviceMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.HostDevice.class, to = HostDevice.class)
public static HostDevice map(org.ovirt.engine.core.common.businessentities.HostDevice entity, HostDevice model) {
    if (model == null) {
        model = new HostDevice();
    }
    if (!model.isSetHost()) {
        model.setHost(new Host());
    }
    model.getHost().setId(entity.getHostId().toString());
    model.setId(HexUtils.string2hex(entity.getDeviceName()));
    model.setName(entity.getDeviceName());
    model.setCapability(entity.getCapability());
    model.setParentDevice(getSameHostDeviceReference(entity.getHostId(), entity.getParentDeviceName()));
    model.setDriver(entity.getDriver());
    if (entity.getProductId() != null || entity.getProductName() != null) {
        if (!model.isSetProduct()) {
            model.setProduct(new Product());
        }
        model.getProduct().setId(entity.getProductId());
        model.getProduct().setName(entity.getProductName());
    }
    if (entity.getVendorId() != null || entity.getVendorName() != null) {
        if (!model.isSetVendor()) {
            model.setVendor(new Vendor());
        }
        model.getVendor().setId(entity.getVendorId());
        model.getVendor().setName(entity.getVendorName());
    }
    model.setIommuGroup(entity.getIommuGroup());
    if (entity.getParentPhysicalFunction() != null) {
        model.setPhysicalFunction(getSameHostDeviceReference(entity.getHostId(), entity.getParentPhysicalFunction()));
    }
    model.setVirtualFunctions(entity.getTotalVirtualFunctions());
    if (entity.getVmId() != null) {
        model.setVm(new Vm());
        model.getVm().setId(entity.getVmId().toString());
    }
    return model;
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Vm(org.ovirt.engine.api.model.Vm) Product(org.ovirt.engine.api.model.Product) Host(org.ovirt.engine.api.model.Host) Vendor(org.ovirt.engine.api.model.Vendor)

Example 2 with HostDevice

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

the class BackendVmHostDeviceResourceTest method testGet.

@Test
public void testGet() {
    setUpGetVmHostDevicesExpectations();
    HostDevice device = resource.get();
    verifyHostDevice(device);
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Test(org.junit.Test)

Example 3 with HostDevice

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

the class BackendVmHostDevicesResourceTest method testAdd.

@Test
public void testAdd() throws Exception {
    resource.setUriInfo(setUpBasicUriExpectations());
    setUpGetVmHostDevicesExpectations();
    setUpActionExpectations(ActionType.AddVmHostDevices, VmHostDevicesParameters.class, new String[] { "VmId", "DeviceNames" }, new Object[] { VM_ID, Collections.singletonList(DEVICE_NAME) }, true, true);
    HostDevice device = new HostDevice();
    device.setName(DEVICE_NAME);
    resource.add(device);
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Test(org.junit.Test)

Example 4 with HostDevice

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

the class BackendHostDeviceResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUpGetEntityExpectations(QueryType.GetHostDeviceByHostIdAndDeviceName, HostDeviceParameters.class, new String[] { "HostId", "DeviceName" }, new Object[] { HOST_ID, DEVICE_NAME }, getEntity(0));
    HostDevice device = resource.get();
    verifyHostDevice(device);
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Test(org.junit.Test)

Example 5 with HostDevice

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

the class HostDeviceMapper method getSameHostDeviceReference.

private static HostDevice getSameHostDeviceReference(Guid hostId, String deviceName) {
    HostDevice device = new HostDevice();
    device.setHost(new Host());
    device.getHost().setId(hostId.toString());
    device.setId(HexUtils.string2hex(deviceName));
    device.setName(deviceName);
    return device;
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Host(org.ovirt.engine.api.model.Host)

Aggregations

HostDevice (org.ovirt.engine.api.model.HostDevice)5 Test (org.junit.Test)3 Host (org.ovirt.engine.api.model.Host)2 Product (org.ovirt.engine.api.model.Product)1 Vendor (org.ovirt.engine.api.model.Vendor)1 Vm (org.ovirt.engine.api.model.Vm)1