private static Guid createGuidFromStringWithDefault(String candidate, Guid defaultValue) { if (candidate == null) { return defaultValue; } return new Guid(candidate); }
public static Guid asGuid(byte[] guid) { try { return new Guid(guid); } catch (IllegalArgumentException e) { throw new MalformedIdException(e); } }
protected Guid asGuid(byte[] guid) { try { return new Guid(guid); } catch (IllegalArgumentException e) { throw new MalformedIdException(e); } }
protected Guid asGuid(String id) { try { return new Guid(id); }catch (IllegalArgumentException e) { throw new MalformedIdException(e); } }
@Override public List<Pair<Guid, String>> getAllDevicesHashes() { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource(); return getCallsHandler().executeReadList("GetAllHashesFromVmDynamic", (rs, i) -> new Pair<>(new Guid(rs.getString("vm_guid")), rs.getString("hash")), parameterSource); }
public static void setupMemoryBalloon(VmBase vmBase, BackendResource parentResource) { Boolean balloonEnabled = parentResource.getEntity(Boolean.class, QueryType.IsBalloonEnabled, new IdQueryParameters(new Guid(vmBase.getId())), null, true); if (!vmBase.isSetMemoryPolicy()) { vmBase.setMemoryPolicy(new MemoryPolicy()); } vmBase.getMemoryPolicy().setBallooning(balloonEnabled); } }
public static void setVirtioScsiController(BackendResource resouce, Vm vm) { if (!vm.isSetVirtioScsi()) { vm.setVirtioScsi(new VirtioScsi()); } vm.getVirtioScsi().setEnabled(!VmHelper.getVirtioScsiControllersForEntity(resouce, new Guid(vm.getId())).isEmpty()); }
private Guid getDataCenterId(Action action) { String dcIdFromAction = action.getDataCenter().getId(); if (dcIdFromAction != null) { return new Guid(dcIdFromAction); } return getDataCenterIdByName(action.getDataCenter().getName()); }
public static void setConsoleDevice(BackendResource resouce, Vm vm) { if (!vm.isSetConsole()) { vm.setConsole(new Console()); } vm.getConsole().setEnabled(!getConsoleDevicesForEntity(resouce, new Guid(vm.getId())).isEmpty()); }
@Override public Response doImport(Action action) { validateParameters(action, "dataCenter.id|name"); Guid dataCenterId = getDataCenterId(action); ProviderNetwork providerNetwork = new ProviderNetwork(new Guid(providerId), id); Network network = new Network(); network.setProvidedBy(providerNetwork); network.setDataCenterId(dataCenterId); network.setName(getNetwork().getName()); AddNetworkStoragePoolParameters parameters = new AddNetworkStoragePoolParameters(dataCenterId, network); return doAction(ActionType.AddNetwork, parameters, action); }
public DbGroup(DirectoryGroup directoryGroup) { externalId = directoryGroup.getId(); setId(new Guid(directoryGroup.getId().getBytes())); namespace = directoryGroup.getNamespace(); setDomain(directoryGroup.getDirectoryName()); setName(directoryGroup.getName()); distinguishedName = ""; }
private Guid getTempalteId(Template template) { Guid result = null; if (template.isSetId()) { result = new Guid(template.getId()); } else if (template.isSetName()) { result = lookupTemplateByName(template.getName()).getId(); } return result; }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); // create some test data new_bookmark = new Bookmark(); Random r = new Random(System.currentTimeMillis()); new_bookmark.setName("newbookmarkname" + (r.nextInt() % BOOKMARK_MAX_RANDOM_NUMBER)); new_bookmark.setValue("newbookmarkvalue"); existing_bookmark = dao.get(new Guid("a4affabf-7b45-4a6c-b0a9-107d0bbe265e")); }
@Test public void testSelfAndIdentifyEquality() { Guid vmId = new Guid("b23ad6d7-0df8-4d69-b4e5-d5b5e90c2463"); Guid deviceId = new Guid("b23ad6d7-0df8-4d69-b4e5-d5b5e90c2464"); VmDevice device1 = createVmDevice(deviceId, vmId); assertEquals(0, device1.compareTo(device1)); VmDevice device2 = createVmDevice(deviceId, vmId); assertEquals(0, device1.compareTo(device2)); }
private Guid getHostId(Host host) { // presence of host ID or name already validated return host.isSetId() ? new Guid(host.getId()) : host.isSetName() ? getEntity(VdsStatic.class, QueryType.GetVdsStaticByName, new NameQueryParameters(host.getName()), "Hosts: name=" + host.getName()).getId() : null; } }
@Test public void testGetBySlaveHostAndVolume() { GlusterGeoRepSession session = dao.getGeoRepSession(FixturesTool.GLUSTER_VOLUME_UUID1, new Guid("44f645f6-3fe9-4b35-a30c-be0d1a835ea8"), "slave-replica"); assertNotNull(session); assertEquals(FixturesTool.GLUSTER_GEOREP_SESSION_ID, session.getId()); }
private void completeSlaveNames(BusinessEntityMap<VdsNetworkInterface> nicsFromBackend, HostNic bond) { if (bond.isSetBonding() && bond.getBonding().isSetSlaves()) { for (HostNic slave : bond.getBonding().getSlaves().getHostNics()) { if (!slave.isSetName() && slave.isSetId()){ Guid slaveId = new Guid(slave.getId()); String slaveNameFromBackend = nicsFromBackend.get(slaveId).getName(); slave.setName(slaveNameFromBackend); } } } }
@Test @Override public void testRoundtrip() throws Exception { Application model = Application.class.cast(populate(Application.class)); model = postPopulate(model); model.setName(NAMES[0]); model.setId(new Guid(NAMES[0].getBytes()).toString()); Mapper<String, Application> back = getMappingLocator().getMapper(String.class, Application.class); Application transform = back.map(NAMES[0], null); verify(model, transform); }
private Guid getHostId(StorageDomain storageDomain) { // presence of host ID or name already validated return storageDomain.getHost().isSetId() ? new Guid(storageDomain.getHost().getId()) : storageDomain.getHost().isSetName() ? getEntity(VdsStatic.class, QueryType.GetVdsStaticByName, new NameQueryParameters(storageDomain.getHost().getName()), "Hosts: name=" + storageDomain.getHost().getName()).getId() : null; }
@Test public void testUpdateAll() { DiskImageDynamic existingEntity2 = dao.get(new Guid("42058975-3d5e-484a-80c1-01c31207f579")); existingEntity.setActualSize(100); existingEntity2.setReadRate(120); existingEntity.setReadLatency(100d); existingEntity2.setReadLatency(0.00001d); dao.updateAll(Arrays.asList(existingEntity, existingEntity2)); assertEquals(existingEntity, dao.get(existingEntity.getId())); assertEquals(existingEntity2, dao.get(existingEntity2.getId())); }