public Datastore( final Machine machine, final String name, final String rootPath, final String directory) { setRootPath(rootPath); setName(name); setDirectory(directory); addToMachines(machine); }
/** * Returns a list of virtual machines builded from a virtual system list * * @param vsc VirtualSystemCollectionDto list to transform * @return list of virtual machines builded from a virtual system list */ private List<VirtualMachine> transportVSCollectionToVMs(final VirtualSystemCollectionDto vsc) { long MEGABYTE = 1024L * 1024L; List<VirtualMachine> vms = new ArrayList<VirtualMachine>(); for (VirtualSystemDto vs : vsc.getVirtualSystems()) { VirtualMachine vm = new VirtualMachine( vs.getName(), null, null, null, null, UUID.fromString(vs.getUuid()), VirtualMachine.NOT_MANAGED); vm.setCpu(new Long(vs.getCpu()).intValue()); vm.setRam(new Long(vs.getRam() / MEGABYTE).intValue()); vm.setVdrpPort(new Long(vs.getVport()).intValue()); vm.setState(VirtualMachineState.valueOf(vs.getStatus().value())); for (ResourceType rt : vs.getResources()) { if (rt.getResourceType().equals(ResourceEnumType.STORAGE_DISK)) { long bytesHD = rt.getUnits(); vm.setHdInBytes(bytesHD); if (StringUtils.hasText(rt.getAddress()) && StringUtils.hasText(rt.getConnection())) { Datastore ds = new Datastore(); ds.setDirectory(rt.getAddress()); ds.setRootPath(rt.getConnection()); ds.setName(rt.getElementName()); vm.setDatastore(ds); } if (rt.getResourceSubType() != null) { VirtualImage vi = new VirtualImage(null); VirtualDiskEnumType diskFormatType = VirtualDiskEnumType.fromValue(rt.getResourceSubType().toString()); if (diskFormatType.equals(VirtualDiskEnumType.STATEFUL)) { vi.setStateful(1); } vi.setDiskFormatType(DiskFormatType.fromURI(diskFormatType.value())); vm.setVirtualImage(vi); } } } vms.add(vm); } return vms; }