Package com.alu.e3.installer.command

Examples of com.alu.e3.installer.command.ShellCommandResult


    if(allowedHttpMethods==null || allowedHttpMethods.isEmpty())
      return;

    Object methodheader = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
    if(methodheader == null){
      throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "No HTTP Method");
    }
   
    for(String m : allowedHttpMethods){
      if(m.equals(methodheader.toString().toLowerCase())){
        return;
      }
    }
   
    throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "Method "+methodheader.toString()+" not allowed");
  }
View Full Code Here


    this.apiId = apiId;
  }

  @Override
  public Producer createProducer() throws Exception {
    return new IpWhiteListProducer(this, dataManager, apiId);
  }
View Full Code Here

  {
    ServletContextHandler context = new ServletContextHandler(server, "/",
        ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    context.setConnectorNames(new String[] {connector.getName()});

    DispatchingContinuationServlet servlet = new DispatchingContinuationServlet();
    servlet.setDispatcher(new TreeDispatcher<HttpConsumer>());
    Long timeout = endpoint.getContinuationTimeout() != null ? endpoint
        .getContinuationTimeout() : getContinuationTimeout();
    if (timeout != null) {
      servlet.setContinuationTimeout(timeout);
    }

    ServletHolder holder = new ServletHolder();
    holder.setServlet(servlet);
    context.addServlet(holder, "/*");
 
View Full Code Here

      findCmd = "find " + remoteDirPath + " -maxdepth 1 -user " + remoteUsername + " -perm -664 -type f";
    } else {
      findCmd = "find " + remoteDirPath + " -maxdepth 1 -type f"
    }
    findCmd = findCmd + " -printf '%T@\t%s\t%p\n' 2> /dev/null";
    ShellCommandResult sshResult = sshCommand.execShellCommand(findCmd);
    String[] allFiles = sshResult.getResult().split("\n");
    LogFileFilter baseFileFilter = new LogFileFilter(baseName);
   
    for (String remoteFileItem : allFiles) {
      String[] remoteFileItems = remoteFileItem.split("\t");
      if (remoteFileItems.length != 3) {
View Full Code Here

    } else if (numLines == 0) {
      return "";
    }

    String tailCmd = "/usr/bin/tail -n " + numLinesArg + " " + remoteFilePath;
    ShellCommandResult sshResult = sshCommand.execShellCommand(tailCmd);
    if(logger.isDebugEnabled()) {
      logger.debug("Remote tail process exited with code {}", String.valueOf(sshResult.getExitStatus()));
    }
    String logLines = sshResult.getResult();
    return logLines;
  }
View Full Code Here

                if(logger.isDebugEnabled()) {
                  logger.debug("command type: " + cmd.getImplementationType());
                }
               
                /* check if the destination directory already exists. */
                ShellCommandResult dirExistResult = cmd.execShellCommand("ls "+ config.getRemotePath() + "/bin/install.sh");
                if (dirExistResult.getExitStatus() != 0)
                {
                  /* Create the destination directory */
                  ShellCommandResult dirCreateResult = cmd.execShellCommand("mkdir -p -m 755 "+ config.getRemotePath());
                  if (dirCreateResult.getExitStatus() != 0)
                  {
                    throw new InstallerDeployException("Unable to create remote destination directory "+ config.getRemotePath() + ".");
                  }
               
                  /* Remote copy the package. */
                  if(logger.isDebugEnabled()) {
                    logger.debug("package url: " + config.getPackageUrl());
                  }
                  URL urlPackage = new URL(config.getPackageUrl());
                  String strFilename;
                  if (urlPackage.getProtocol().equals("file"))
                  {
                    strFilename = new File(urlPackage.getFile()).getName();
                    cmd.copy(urlPackage.getFile(), config.getRemotePath() + "/" + strFilename);
                   
                  } else {
                    /* TODO: handle HTTP package URL ? */
                    if(logger.isDebugEnabled()) {
                      logger.debug("URL type " + urlPackage.getProtocol() + " is not supported yet.");
                    }
                    continue;
                  }
               
                  /* Unzip TODO: instaler filename and install location in config */
                  ShellCommandResult cmdRes = cmd.execShellCommand("tar xfz " + strFilename, config.getRemotePath());
                  if (cmdRes.getExitStatus() != 0)
                  {
                    /* unzip has failed, display output. TODO: handle failure */
                    throw new InstallerDeployException("Unzip archive" + strFilename + " failed (returned code: "+ cmdRes + ")");
                  }
                } else{
                  // version already installed in the gateway                 
                  if(logger.isErrorEnabled()) {
                    logger.error("WARNING: " + config.getRemotePath() + " already exist on gateway " + localizedGatewayIP);
                  }
                 
                  report.append("WARNING: " + config.getRemotePath() + " already exist on gateway " + localizedGatewayIP + ". " +
                      "Be carefull this existing binary was used. Remove it first to use the new binary content !!! \n");

                }
               
                String fullyQualifiedInstallerCmd = replaceManagerIPPattern(config.getInstallerCmd(), managerIP);
                if(logger.isDebugEnabled()) {
                  logger.debug("Executing shell command '" + fullyQualifiedInstallerCmd + "'");
                }
               
                /* Launch Install. */
                ShellCommandResult cmdResInstallation = cmd.execShellCommand(fullyQualifiedInstallerCmd, config.getRemotePath());
                if (cmdResInstallation.getExitStatus() != 0)
                {
                  /* remote installation has failed, display output. */
                  throw new InstallerDeployException("Installation has failed while executing command [" + fullyQualifiedInstallerCmd + "]\ndetails:"+ cmdResInstallation);
                }
                 
                /* Launch sanity check. */
                ShellCommandResult cmdResSanityCheck = cmd.execShellCommand(config.getSanityCheckCmd(), config.getRemotePath());
                if (cmdResSanityCheck.getExitStatus() != 0)
                {
                  /* remote installation has failed, display output. TODO: handle failure */
                  throw new InstallerDeployException("Sanity check has failed  while executing command ["+ config.getSanityCheckCmd() + "] in the folder [" + config.getRemotePath() + "]\nDetails:"+ cmdResSanityCheck);
                }
              }
              else { // Local
                //if ("E3Gateway".equals(instance.getType())) {
               
                String generateNatureCmd = config.getGenerateNatureCmd();
                if (generateNatureCmd != null && !generateNatureCmd.isEmpty())
                {
               
                  String fullyQualifiedGenerateNatureCmd = replaceManagerIPPattern(generateNatureCmd, managerIP);
                  if(logger.isDebugEnabled()) {
                    logger.debug("Executing shell command '" + fullyQualifiedGenerateNatureCmd + "'");
                  }
                 
                  /* Get the ssh key. TODO: handle case without sshkey (eg. if user/password provided) */
                  SSHKey key = instance.getSSHKey();
                  if (key != null) {
                    if(logger.isDebugEnabled()) {
                      logger.debug("using key: " + key.getName());
                    }
                  }
                  /* Connect via ssh. */
                  SSHCommand sshCommand = (SSHCommand) cmd;
                  sshCommand.connect(key, localizedGatewayIP, 22, instance.getUser(), instance.getPassword());
                 
                  if (!sshCommand.isConnected())
                  {
                    String errorSshMsg = "Error: ssh connection to" + localizedGatewayIP+  " failed (sshkey=";
                    errorSshMsg += (key == null) ? "not defined " : key.getName();
                    errorSshMsg += "user=" + instance.getUser() + ")";
                    throw new InstallerDeployException(errorSshMsg);
                  }
                 
                  // And we need to update the configuration.properties file directly
                  ShellCommandResult cmdGenerateNature = cmd.execShellCommand(fullyQualifiedGenerateNatureCmd, config.getRemotePath());
                  if (cmdGenerateNature.getExitStatus() != 0)
                  {
                   
                    /* Update nature failed */
                    throw new InstallerDeployException("Update nature has failed while executing command ["+ fullyQualifiedGenerateNatureCmd + "] in the folder [" + config.getRemotePath() + "]\nDetails:"+ cmdGenerateNature);
                  }
View Full Code Here

    if (LOG.isDebugEnabled())
      LOG.debug("Update API ID: {}", apiId);

    // check API ID same in Pay-load/URL
    if (api == null || api.getId() == null)
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_NOT_PROVIDED, "API ID missing in the body for Update operation"));

    if (!api.getId().equals(apiId))
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_MISMATCH, "API ID not the same in URL vs Body for Update operation: +" + apiId + "/" + apiId));

    Action action = new Action() {
      protected Object doAction(Object... params) {
        try {
          apiService.update(api);
View Full Code Here

    Action action = new Action() {

      protected Object doAction(Object... params) {
        try {
          Api api = apiService.get(apiId);
          return new ApiResponse(ApiResponse.SUCCESS, api);

        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
View Full Code Here

    provisionData.setValidation(fromDataModel(api.getValidation()));
    provisionData.setHeaderTransEnabled(api.getHeaderTransEnabled());
    provisionData.setInternal(api.getInternal());
   
    ApiProxySettings proxySettings = null;
   
    if(api.isUseGlobalProxy()){
      proxySettings = new ApiProxySettings();
      proxySettings.setGlobalProxy(new ApiProxySettings.GlobalProxy());
    }else if(api.getForwardProxy() != null){
      proxySettings = new ApiProxySettings();
      proxySettings.setLocalProxy(fromDataModel(api.getForwardProxy()));
    }
    provisionData.setProxySettings(proxySettings);
   
    return provisionData;
  }
View Full Code Here

        try {
          apiService.create(api);
        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
        return new ApiResponse(ApiResponse.SUCCESS, api.getId());
      }
    };

    return execute(action, (Object) null);
   
View Full Code Here

TOP

Related Classes of com.alu.e3.installer.command.ShellCommandResult

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.