From: davidplunkett Date: Wed, 27 Feb 2019 03:35:35 +0000 (+0000) Subject: fixed logic in deploy verification X-Git-Tag: 1.0.0~17 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F419%2F1;p=camunda_workflow.git fixed logic in deploy verification Change-Id: Icf9398a670766e0b76bc0c1bad203cef55592862 Signed-off-by: davidplunkett --- diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java index b3335e7..c50fba5 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/RemoteDeploymentverificationServiceImpl.java @@ -36,75 +36,71 @@ import com.jcraft.jsch.Session; @Service("remoteDeploymentVerificationService") public class RemoteDeploymentverificationServiceImpl implements RemoteDeploymentVerificationService{ - private static Logger logger = LoggerFactory.getLogger(RemoteDeploymentverificationServiceImpl.class); - - public void executeScript(String remoteserver,String username,String password,int portnumber, - String filename,String fileparams,String srcdir,String destdir,int waitttime,int iterations,String command) { - - boolean issuccess=false; - //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); - ChannelExec channelExec=null; - BufferedReader reader =null; - Session session=null; - for( int i=0;i<=iterations;i++) { - try { - logger.debug("Executing the deployment verification script.............iteration : {}",i); - Thread.sleep(waitttime*1000); - JSch jsch = new JSch(); - session = jsch.getSession(username, remoteserver, portnumber); - session.setConfig("StrictHostKeyChecking", "no"); - session.setPassword(password); - session.connect(); - channelExec = (ChannelExec)session.openChannel("exec"); - InputStream in = channelExec.getInputStream(); - channelExec.setPty(true); - channelExec.setCommand(command); - channelExec.connect(); - reader = new BufferedReader(new InputStreamReader(in)); - String line; - logger.debug("Script output......................"); - while ((line = reader.readLine()) != null){ - logger.debug(line); - } - channelExec.disconnect(); - while (!channelExec.isClosed()) { + private static Logger logger = LoggerFactory.getLogger(RemoteDeploymentverificationServiceImpl.class); - } - int exitStatus = channelExec.getExitStatus(); - logger.debug("Script exit code :"+exitStatus); - if(exitStatus==0) { - issuccess=true; - } - } - catch (IOException e) { - throw new TaskExecutorException(filename + " not found."); - } catch (Exception e) { - throw new TaskExecutorException("problem while executing the script "+command); - }finally{ - if(reader!=null) { - try { - reader.close(); - }catch(Exception e) { - throw new TaskExecutorException("onap build failed"); - } - } - if(session!=null) { - session.disconnect(); - } - } - - if(issuccess) { - break; - } - - } - - if(!issuccess) { - logger.debug("verification script returned 1 "); - throw new TaskExecutorException(" verification script exit code : 1"); - } - } - - + public void executeScript(String remoteserver,String username,String password,int portnumber, + String filename,String fileparams,String srcdir,String destdir,int waitttime,int iterations,String command) { + boolean issuccess=true; + int exitStatus = 0; + //String filepath=destdir+"/"+filename+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + ChannelExec channelExec=null; + BufferedReader reader =null; + Session session=null; + + for( int i=0;i