org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId类的一些代码示例,展示了ZoneAndId类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneAndId类的具体详情如下:
包路径:org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId
类名称:ZoneAndId

ZoneAndId介绍

暂无

代码示例

代码示例来源:origin: jclouds/legacy-jclouds

@Override
 public boolean apply(T input) {
   return input.getId().equals(ZoneAndId.fromZoneAndId(serverInZone.getZone(), objectId).slashEncode());
 }
});

代码示例来源:origin: jclouds/legacy-jclouds

public static ZoneAndId fromZoneAndId(String zoneId, String id) {
 return new ZoneAndId(zoneId, id);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public void rebootNode(String id) {
 ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
 novaApi.getServerApiForZone(zoneAndId.getZone()).reboot(zoneAndId.getId(), RebootType.HARD);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public ListenableFuture<Image> createImage(ImageTemplate template) {
 checkState(template instanceof CloneImageTemplate,
      " openstack-nova only supports creating images through cloning.");
 CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
 ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
 String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
      cloneTemplate.getName(), sourceImageZoneAndId.getId());
 final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
 logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
 
 final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
    .location(find(locations.get(), idEquals(targetImageZoneAndId.getZone())))
    .id(targetImageZoneAndId.slashEncode())
    .providerId(targetImageZoneAndId.getId())
    .description(cloneTemplate.getName())
    .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
    .status(Image.Status.PENDING).build());
 return userExecutor.submit(new Callable<Image>() {
   @Override
   public Image call() throws Exception {
    if (imageAvailablePredicate.apply(image))
      return image.get();
    // TODO: get rid of the expectation that the image will be available, as it is very brittle
    throw new UncheckedTimeoutException("Image was not created within the time limit: " + image.get());
   }
 });
}

代码示例来源:origin: jclouds/legacy-jclouds

addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
builder.hardware(findHardwareForServerOrNull(serverInZone));

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public ZoneAndId apply(ZoneAndId id) {
 FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
 for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
   logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
   floatingIpApi.removeFromServer(ip.getIp(), id.getId());
   logger.debug(">> deallocating floatingIp(%s)", ip);
   floatingIpApi.delete(ip.getId());
 }
 floatingIpCache.invalidate(id);
 return id;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testReturnsNullWhenNotFound() throws Exception {
 NovaApi api = createMock(NovaApi.class);
 FloatingIPApi ipApi = createMock(FloatingIPApi.class);
 expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
 expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of()))
 .atLeastOnce();
 replay(api);
 replay(ipApi);
 LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
 assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
 verify(api);
 verify(ipApi);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public boolean apply(FloatingIP input) {
   return key.getId().equals(input.getInstanceId());
  }
});

代码示例来源:origin: jclouds/legacy-jclouds

public String slashEncode() {
 return slashEncodeZoneAndId(zoneId, id);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
   String zone = key.getZone();
   Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
   if (ipApiOptional.isPresent()) {
     return ipApiOptional.get().list().filter(
         new Predicate<FloatingIP>() {
           @Override
           public boolean apply(FloatingIP input) {
            return key.getId().equals(input.getInstanceId());
           }
         });
   }
   return ImmutableSet.of();
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
return input;

代码示例来源:origin: org.jclouds.api/openstack-nova

@Override
public ListenableFuture<Image> createImage(ImageTemplate template) {
 checkState(template instanceof CloneImageTemplate,
      " openstack-nova only supports creating images through cloning.");
 CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
 ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
 String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
      cloneTemplate.getName(), sourceImageZoneAndId.getId());
 final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
 logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
 
 final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
    .location(find(locations.get(), idEquals(targetImageZoneAndId.getZone())))
    .id(targetImageZoneAndId.slashEncode())
    .providerId(targetImageZoneAndId.getId())
    .description(cloneTemplate.getName())
    .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
    .status(Image.Status.PENDING).build());
 return userExecutor.submit(new Callable<Image>() {
   @Override
   public Image call() throws Exception {
    if (imageAvailablePredicate.apply(image))
      return image.get();
    // TODO: get rid of the expectation that the image will be available, as it is very brittle
    throw new UncheckedTimeoutException("Image was not created within the time limit: " + image.get());
   }
 });
}

代码示例来源:origin: org.jclouds.api/openstack-nova

addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
builder.hardware(findHardwareForServerOrNull(serverInZone));

代码示例来源:origin: org.jclouds.api/openstack-nova

@Override
public ZoneAndId apply(ZoneAndId id) {
 FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
 for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
   logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
   floatingIpApi.removeFromServer(ip.getIp(), id.getId());
   logger.debug(">> deallocating floatingIp(%s)", ip);
   floatingIpApi.delete(ip.getId());
 }
 floatingIpCache.invalidate(id);
 return id;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testReturnsNullWhenNotAssigned() throws Exception {
 NovaApi api = createMock(NovaApi.class);
 FloatingIPApi ipApi = createMock(FloatingIPApi.class);
 expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
 expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build())))
 .atLeastOnce();
 replay(api);
 replay(ipApi);
 LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
 assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
 verify(api);
 verify(ipApi);
}

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

@Override
  public boolean apply(FloatingIP input) {
   return key.getId().equals(input.getInstanceId());
  }
});

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

public String slashEncode() {
 return slashEncodeZoneAndId(zoneId, id);
}

代码示例来源:origin: org.jclouds.api/openstack-nova

@Override
  public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
   String zone = key.getZone();
   Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
   if (ipApiOptional.isPresent()) {
     return ipApiOptional.get().list().filter(
         new Predicate<FloatingIP>() {
           @Override
           public boolean apply(FloatingIP input) {
            return key.getId().equals(input.getInstanceId());
           }
         });
   }
   return ImmutableSet.of();
  }
}

代码示例来源:origin: org.jclouds.api/openstack-nova

floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
return input;

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public boolean deleteImage(String id) {
 ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
 try {
   this.novaApi.getImageApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
 } catch (Exception e) {
   return false;
 }
 return true;
}

相关文章