Package org.platformlayer.ops

Examples of org.platformlayer.ops.OpsException


      throws OpsException {
    ProjectId projectId;
    try {
      projectId = opsContextBuilder.getRunAsProjectId(auth);
    } catch (OpsException e) {
      throw new OpsException("Error getting projectId", e);
    }

    JobData jobData = new JobData();
    jobData.action = action;
    jobData.targetId = targetItem;

    try {
      String jobId = repository.insertJob(projectId, jobData);
      jobData.key = JobData.buildKey(projectId, new ManagedItemId(jobId));
    } catch (RepositoryException e) {
      throw new OpsException("Error inserting job", e);
    }

    operationQueue.submit(auth, jobData);

    return jobData;
View Full Code Here


      if (log != null) {
        log.execution = execution;
      }
      return log;
    } catch (IOException e) {
      throw new OpsException("Error reading job log", e);
    }
  }
View Full Code Here

  @Override
  public List<JobExecutionData> listExecutions(PlatformLayerKey jobKey) throws OpsException {
    try {
      return repository.listExecutions(jobKey);
    } catch (RepositoryException e) {
      throw new OpsException("Error retrieving job executions", e);
    }
  }
View Full Code Here

  @Override
  public JobExecutionData findExecution(PlatformLayerKey jobKey, String runId) throws OpsException {
    try {
      return repository.findExecution(jobKey, runId);
    } catch (RepositoryException e) {
      throw new OpsException("Error retrieving job execution", e);
    }
  }
View Full Code Here

  @Override
  public JobData getJob(PlatformLayerKey jobKey) throws OpsException {
    try {
      return repository.findJob(jobKey);
    } catch (RepositoryException e) {
      throw new OpsException("Error retrieving job", e);
    }
  }
View Full Code Here

        String xml = ResourceUtils.find(contextClass, resourceName);
        if (xml != null) {
          return JaxbHelper.deserializeXmlObject(xml, clazz);
        }
      } catch (Exception e) {
        throw new OpsException("Error reading resource: " + resourceName, e);
      }
    }

    {
      String resourceName = key + ".json";
      try {
        String json = ResourceUtils.find(contextClass, resourceName);
        if (json != null) {
          ObjectMapper mapper = new ObjectMapper();

          // Use JAXB annotations
          AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
          mapper = mapper.setAnnotationIntrospector(introspector);

          mapper = mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
          mapper = mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
          mapper = mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);

          if (!json.startsWith("{")) {
            // Be tolerant
            json = "{ " + json + "}";
            // json = jsonHelper.wrapJson(json);
          }

          return mapper.readValue(json, clazz);
          // return jsonHelper.unmarshal(json);
        }
      } catch (Exception e) {
        throw new OpsException("Error reading resource: " + resourceName, e);
      }
    }

    return null;
  }
View Full Code Here

          continue;
        }

        List<String> tokens = Lists.newArrayList(keyValueSpliter.split(line));
        if (tokens.size() != 2) {
          throw new OpsException("Cannot parse PSK line: " + line);
        }

        String key = tokens.get(0);
        String value = tokens.get(1);

        if (psks.containsKey(key)) {
          // (We could check to see if they're the same, but this is generally not good)
          throw new OpsException("Found duplicate PSK");
        }
        psks.put(key, value);

        if (!key.equals(id)) {
          continue;
View Full Code Here

      if (!installedPackages.contains(packageName)) {
        log.info("Package not installed: " + packageName);

        if (OpsContext.isValidate()) {
          throw new OpsException("Package not installed: " + packageName);
        }

        if (repositoryKey != null) {
          apt.addRepositoryKeyUrl(target, repositoryKey.getUrl());
        }
View Full Code Here

      target.executeCommand(command);
    } catch (ProcessExecutionException e) {
      String debootstrapLog = target.readTextFile(new File(rootfsDir, "debootstrap/debootstrap.log"));
      log.warn("Debootstrap log: " + debootstrapLog);

      throw new OpsException("Error running debootstrap", e);
    }

    // TODO: Switch to ChrootOpsTarget, so we can move this stuff into utility functions
    ChrootOpsTarget chrootTarget = new ChrootOpsTarget(rootfsDir, new File("/tmp"), target);
View Full Code Here

    try {
      log.info("Sleeping in the hope of avoiding (not fully understood) SSH issue");
      Thread.sleep(15000);
    } catch (InterruptedException e) {
      ExceptionUtils.handleInterrupted(e);
      throw new OpsException("Interrupted", e);
    }

    try {
      return TimeoutPoll.poll(TimeSpan.FIVE_MINUTES, TimeSpan.TEN_SECONDS, new PollFunction<String>() {
        @Override
        public String call() throws Exception {
          try {
            ProcessExecution execution = target.executeCommand("uname -srp");
            return execution.getStdOut();
          } catch (ProcessExecutionException e) {
            log.info("Waiting for machine; got process execution error", e);
            return null;
          }
        }
      });
    } catch (ExecutionException e) {
      throw new OpsException("Error while waiting for machine", e);
    } catch (TimeoutException e) {
      throw new OpsException("Timeout while waiting for machine", e);
    }
  }
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.