コード例 #1
0
 @Override
 public void destroyNode(String id) {
   ServerInfo server = getNode(id);
   if (server != null) {
     client.stopServer(id);
     client.destroyServer(id);
     for (Device dev : server.getDevices().values()) client.destroyDrive(dev.getDriveUuid());
   }
 }
コード例 #2
0
  /** look up the current standard images and do not error out, if they are not found. */
  @Override
  public Iterable<DriveInfo> listImages() {
    Iterable<? extends DriveInfo> drives =
        transformParallel(
            client.listStandardDrives(),
            new Function<String, Future<? extends DriveInfo>>() {

              @Override
              public Future<DriveInfo> apply(String input) {
                try {
                  return Futures.immediateFuture(cache.getUnchecked(input));
                } catch (CacheLoader.InvalidCacheLoadException e) {
                  logger.debug("drive %s not found", input);
                } catch (UncheckedExecutionException e) {
                  logger.warn(e, "error finding drive %s: %s", input, e.getMessage());
                }
                return Futures.immediateFuture(null);
              }

              @Override
              public String toString() {
                return "seedDriveCache()";
              }
            },
            executor,
            null,
            logger,
            "drives");
    return Iterables2.concreteCopy(filter(drives, PREINSTALLED_DISK));
  }
コード例 #3
0
  @Override
  public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(
      String tag, String name, Template template) {
    long bootSize =
        (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
    AffinityType affinityType = AffinityType.HDD;
    if (template.getOptions() instanceof CloudSigmaTemplateOptions) {
      CloudSigmaTemplateOptions options =
          CloudSigmaTemplateOptions.class.cast(template.getOptions());
      affinityType = options.getDiskDriveAffinity();
    }
    logger.debug(
        ">> imaging boot drive source(%s) bytes(%d) affinityType(%s)",
        template.getImage().getId(), bootSize, affinityType);
    DriveInfo drive =
        client.cloneDrive(
            template.getImage().getId(),
            template.getImage().getId(),
            new CloneDriveOptions().size(bootSize).affinity(affinityType));
    boolean success = driveNotClaimed.apply(drive);
    logger.debug("<< image(%s) complete(%s)", drive.getUuid(), success);
    if (!success) {
      client.destroyDrive(drive.getUuid());
      throw new IllegalStateException("could not image drive in time!");
    }

    Server toCreate =
        Servers.small(name, drive.getUuid(), defaultVncPassword)
            .mem(template.getHardware().getRam())
            .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed()))
            .build();

    logger.debug(">> creating server");
    ServerInfo from = client.createServer(toCreate);
    logger.debug("<< created server(%s)", from.getUuid());
    logger.debug(">> starting server(%s)", from.getUuid());
    client.startServer(from.getUuid());
    return new NodeAndInitialCredentials<ServerInfo>(
        from,
        from.getUuid(),
        LoginCredentials.builder().password(defaultVncPassword).authenticateSudo(true).build());
  }
コード例 #4
0
 @Override
 public void suspendNode(String id) {
   client.stopServer(id);
 }
コード例 #5
0
 @Override
 public void resumeNode(String id) {
   client.startServer(id);
 }
コード例 #6
0
 @Override
 public void rebootNode(String id) {
   client.resetServer(id);
 }
コード例 #7
0
 @Override
 public DriveInfo getImage(String id) {
   return client.getDriveInfo(id);
 }
コード例 #8
0
 @Override
 public ServerInfo getNode(String id) {
   return client.getServerInfo(id);
 }
コード例 #9
0
 @SuppressWarnings("unchecked")
 @Override
 public Iterable<ServerInfo> listNodes() {
   return (Iterable<ServerInfo>) client.listServerInfo();
 }