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;
}
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);
}
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);
}
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);
}
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;
}