use of org.apache.cloudstack.api.response.UnmanagedInstanceDiskResponse in project cloudstack by apache.
the class UnmanagedVMsManagerImpl method createUnmanagedInstanceResponse.
private UnmanagedInstanceResponse createUnmanagedInstanceResponse(UnmanagedInstanceTO instance, Cluster cluster, Host host) {
UnmanagedInstanceResponse response = new UnmanagedInstanceResponse();
response.setName(instance.getName());
if (cluster != null) {
response.setClusterId(cluster.getUuid());
}
if (host != null) {
response.setHostId(host.getUuid());
response.setHostName(host.getName());
}
response.setPowerState(instance.getPowerState().toString());
response.setCpuCores(instance.getCpuCores());
response.setCpuSpeed(instance.getCpuSpeed());
response.setCpuCoresPerSocket(instance.getCpuCoresPerSocket());
response.setMemory(instance.getMemory());
response.setOperatingSystemId(instance.getOperatingSystemId());
response.setOperatingSystem(instance.getOperatingSystem());
response.setObjectName("unmanagedinstance");
if (instance.getDisks() != null) {
for (UnmanagedInstanceTO.Disk disk : instance.getDisks()) {
UnmanagedInstanceDiskResponse diskResponse = new UnmanagedInstanceDiskResponse();
diskResponse.setDiskId(disk.getDiskId());
if (StringUtils.isNotEmpty(disk.getLabel())) {
diskResponse.setLabel(disk.getLabel());
}
diskResponse.setCapacity(disk.getCapacity());
diskResponse.setController(disk.getController());
diskResponse.setControllerUnit(disk.getControllerUnit());
diskResponse.setPosition(disk.getPosition());
diskResponse.setImagePath(disk.getImagePath());
diskResponse.setDatastoreName(disk.getDatastoreName());
diskResponse.setDatastoreHost(disk.getDatastoreHost());
diskResponse.setDatastorePath(disk.getDatastorePath());
diskResponse.setDatastoreType(disk.getDatastoreType());
response.addDisk(diskResponse);
}
}
if (instance.getNics() != null) {
for (UnmanagedInstanceTO.Nic nic : instance.getNics()) {
NicResponse nicResponse = new NicResponse();
nicResponse.setId(nic.getNicId());
nicResponse.setNetworkName(nic.getNetwork());
nicResponse.setMacAddress(nic.getMacAddress());
if (StringUtils.isNotEmpty(nic.getAdapterType())) {
nicResponse.setAdapterType(nic.getAdapterType());
}
if (!CollectionUtils.isEmpty(nic.getIpAddress())) {
nicResponse.setIpAddresses(nic.getIpAddress());
}
nicResponse.setVlanId(nic.getVlan());
nicResponse.setIsolatedPvlanId(nic.getPvlan());
nicResponse.setIsolatedPvlanType(nic.getPvlanType());
response.addNic(nicResponse);
}
}
return response;
}
Aggregations