Package org.platformlayer.ops

Examples of org.platformlayer.ops.OpsException


      }

      List<String> tokens = Lists.newArrayList(Splitter.on(':').split(line));

      if (tokens.size() != 4) {
        throw new OpsException("Error parsing groups line: " + line);
      }

      Group group = new Group();
      group.name = tokens.get(0);
      // tokens[1] is password, but normally 'x'
View Full Code Here


  private Action deserializeAction(String xml) throws OpsException {
    try {
      JaxbHelper jaxbHelper = JaxbHelper.get(Action.class);
      return (Action) jaxbHelper.unmarshal(xml);
    } catch (JAXBException e) {
      throw new OpsException("Error deserializing action", e);
    }
  }
View Full Code Here

  private String serializeAction(Action action) throws OpsException {
    try {
      return JaxbHelper.toXml(action, false);
    } catch (JAXBException e) {
      throw new OpsException("Error serializing action", e);
    }
  }
View Full Code Here

      kvm.minimumMemoryMB = model.minimumMemoryMb;
      kvm.recipeId = model.recipeId;
      try {
        kvm.sshPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
      } catch (IOException e) {
        throw new OpsException("Error deserializing SSH key", e);
      }

      addChild(kvm);

      // TODO: Remove this... it's only supposed to be a hint
View Full Code Here

  // }

  public <T> T getItem(PlatformLayerKey path, Class<T> itemClass) throws OpsException {
    T item = findItem(path, itemClass);
    if (item == null) {
      throw new OpsException("Item not found: " + path);
    }
    return item;
  }
View Full Code Here

  }

  public <T> T getItem(PlatformLayerKey path) throws OpsException {
    T item = findItem(path);
    if (item == null) {
      throw new OpsException("Item not found: " + path);
    }
    return item;
  }
View Full Code Here

      ImageStore imageStore = cloudHelpers.getImageStore(cloud);
      MachineProvider machineProvider = providers.toInterface(cloud, MachineProvider.class);
      CloudImage imageInfo = imageFactory.getOrCreateImageId(machineProvider, imageFormats, recipeKey);

      if (imageStore == null) {
        throw new OpsException("Image store not configured");
      }

      String fileName = imageInfo.getId() + ".image." + imageInfo.getFormat().name();

      // TODO: We don't need rawImage; delete or just request a read-only version
      File rawImage = new File(IMAGES_DIR, fileName);
      target.mkdir(IMAGES_DIR);
      // TODO: Caching / reuse ... need to check md5 though
      imageStore.bringToMachine(imageInfo.getId(), target, rawImage);

      ImageFormat imageFormat = imageInfo.getFormat();
      switch (imageFormat) {
      case Tar: {
        target.mkdir(imageFile);
        target.executeCommand(Command.build("cd {0}; tar jxf {1}", imageFile, rawImage).setTimeout(
            TimeSpan.FIVE_MINUTES));
        break;
      }

      case DiskRaw: {
        Command expand = Command.build("gunzip -c {0} | cp --sparse=always /proc/self/fd/0 {1}", rawImage,
            imageFile);
        target.executeCommand(expand.setTimeout(TimeSpan.FIVE_MINUTES));
        break;
      }

      case DiskQcow2: {
        Command expand = Command.build("cp {0} {1}", rawImage, imageFile);
        target.executeCommand(expand.setTimeout(TimeSpan.FIVE_MINUTES));
        break;
      }

      default:
        throw new OpsException("Unknown image format: " + imageFormat);
      }
    }
  }
View Full Code Here

    Tag tag = Tag.build(Tag.ASSIGNED, instance.getKey().getUrl());
    List<DirectHost> hosts = Lists.newArrayList(platformLayer.listItems(DirectHost.class, TagFilter.byTag(tag)));

    if (hosts.size() > 1) {
      // Huh?
      throw new OpsException("Multiple hosts already assigned");
    }

    DirectHost host;
    if (hosts.isEmpty()) {
      if (OpsContext.isDelete()) {
        host = null;
      } else {
        if (createInstance) {
          DirectCloudHost cloudHost = cloudMap.pickHost(instance);
          host = cloudHost.getModel();

          platformLayer.addTag(host.getKey(), tag);
        } else {
          throw new OpsException("Instance not yet assigned");
        }
      }
    } else {
      host = hosts.get(0);
    }
View Full Code Here

    }
    if (instances.size() == 1) {
      return instances.get(0);
    }

    throw new OpsException("Found multiple instances for " + item.getKey());

    //
    // // We have to connect to the underlying machine not-via-DNS for Dns service => use instance id
    // // TODO: Should we always use the instance id??
    // {
View Full Code Here

  }

  public Machine getMachine(ItemBase item, boolean required) throws OpsException {
    Machine machine = findMachine(item);
    if (required && machine == null) {
      throw new OpsException("Could not determine instance for: " + item);
    }
    return machine;
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.OpsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.