private void setUserDataIfSupported(Template template, CreateDropletOptions.Builder options, String userData) { @SuppressWarnings("unchecked") List<String> regionFeatures = (List<String>) template.getLocation().getMetadata().get("features"); if (regionFeatures.contains("metadata")) { options.userData(userData); } else { logger.debug(">> region %s does not support metadata, ignoring provided user data", template.getLocation() .getId()); } }
private void setUserDataIfSupported(Template template, CreateDropletOptions.Builder options, String userData) { @SuppressWarnings("unchecked") List<String> regionFeatures = (List<String>) template.getLocation().getMetadata().get("features"); if (regionFeatures.contains("metadata")) { options.userData(userData); } else { logger.debug(">> region %s does not support metadata, ignoring provided user data", template.getLocation() .getId()); } }
private Location copyLocation(Set<String> ids, org.jclouds.domain.Location l){ if(l==null) return null; if(ids.contains(l.getId())) return null; ids.add(l.getId()); LocationScope scope = l.getScope()==null?null:LocationScope.valueOf(l.getScope().name()); Location parent = copyLocation(ids, l.getParent()); return new LocationImpl(scope, l.getId(), l.getDescription(), parent, l.getIso3166Codes(), l.getMetadata()); } }
@Test public void testConvertRegion() { DigitalOcean2ProviderMetadata metadata = new DigitalOcean2ProviderMetadata(); JustProvider locationsSupplier = new JustProvider(metadata.getId(), Suppliers.<URI> ofInstance(URI .create(metadata.getEndpoint())), ImmutableSet.<String> of()); Region region = Region.create("reg1", "Region1", ImmutableList.<String> of(), true, ImmutableList.<String> of("virtio", "metadata")); Location expected = new LocationBuilder().id("reg1").description("reg1/Region 1") .parent(getOnlyElement(locationsSupplier.get())).scope(LocationScope.REGION).build(); Location location = new RegionToLocation(locationsSupplier).apply(region); assertEquals(location, expected); assertEquals(location.getMetadata().get("available"), true); assertEquals(location.getMetadata().get("features"), ImmutableList.of("virtio", "metadata")); } }
if (!metadataAndTags.isEmpty()) { @SuppressWarnings("unchecked") List<String> regionFeatures = (List<String>) template.getLocation().getMetadata().get("features"); if (regionFeatures.contains("metadata")) { options.userData(json.toJson(metadataAndTags));