From: Narendervemula Date: Mon, 10 Sep 2018 16:15:06 +0000 (+0000) Subject: corrected akraino dir path X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=878d464779d96bb1292eb08391f185bf7c6a78f7;p=camunda_workflow.git corrected akraino dir path Change-Id: I6b1827e11ba624b3fea22e6ada13b6dc6b71bdf8 Signed-off-by: Narendervemula --- diff --git a/akraino/.classpath b/akraino/.classpath deleted file mode 100644 index 8024414..0000000 --- a/akraino/.classpath +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java b/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java index a6e6cba..80c7140 100644 --- a/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java +++ b/akraino/src/main/java/com/akraino/bpm/controller/CamundaRestController.java @@ -33,6 +33,7 @@ import com.akraino.bpm.model.BuildResponse; import com.akraino.bpm.model.Deploy; import com.akraino.bpm.model.Onap; import com.akraino.bpm.model.Tempest; +import com.akraino.bpm.model.MultiNodeDeploy; import com.akraino.bpm.service.AsyncProcessExecutorService; import io.swagger.annotations.Api; @@ -50,7 +51,7 @@ public class CamundaRestController { @PostMapping("/build/") public ResponseEntity build(@RequestBody Build build) { - logger.debug("Request received for Build ",build.toString()); + logger.debug("Request received for Build {}",build.toString()); asyncProcessExecutorService.executeBuildProcess(build); return new ResponseEntity(new BuildResponse("in progress",null,null,null,null,build.getSitename(),null,null,null),HttpStatus.OK); @@ -61,12 +62,18 @@ public class CamundaRestController { @PostMapping("/deploy/") public ResponseEntity deploy(@RequestBody Deploy deploy) { - logger.debug("Request received for executing {} and targetDirectory {} ",deploy.toString()); + logger.debug("Request received for deploy {} ",deploy.toString()); asyncProcessExecutorService.executeDeployProcess(deploy); return new ResponseEntity(new BuildResponse(null,"in progress","not started","not started","not started",deploy.getSitename(),null,null,null),HttpStatus.OK); } + @PostMapping("/multinodedeploy/") + public ResponseEntity multiNodeDeploy(@RequestBody MultiNodeDeploy multiNodeDeploy) { + logger.debug("Request received for multi node deploy {} ",multiNodeDeploy.toString()); + asyncProcessExecutorService.executeMultiNodeDeployProcess(multiNodeDeploy); + return new ResponseEntity(new BuildResponse(null,"in progress","not started","not started","not started",multiNodeDeploy.getSitename(),null,null,null),HttpStatus.OK); + } @PostMapping("/airship/") @@ -80,7 +87,7 @@ public class CamundaRestController { @PostMapping("/tempest/") public ResponseEntity tempest(@RequestBody Tempest tempest) { - logger.debug("Request received for onap ",tempest.toString()); + logger.debug("Request received for tempest {}",tempest.toString()); asyncProcessExecutorService.executeTempestProcess(tempest); return new ResponseEntity(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"in progress"),HttpStatus.OK); } @@ -90,7 +97,7 @@ public class CamundaRestController { @PostMapping("/apache/") public ResponseEntity apache(@RequestBody Apache apache) { - logger.debug("Request received for onap ",apache.toString()); + logger.debug("Request received for apache{} ",apache.toString()); asyncProcessExecutorService.executeApacheProcess(apache); return new ResponseEntity(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"in progress",null),HttpStatus.OK); } diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript1ExecutorTaskDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript1ExecutorTaskDelegate.java new file mode 100644 index 0000000..554a592 --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript1ExecutorTaskDelegate.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.akraino.bpm.service.DeployResponseSenderService; +import com.akraino.bpm.service.RemoteScriptExecutionService; + + + +@Component +public class MultiNodeDeployRemoteScript1ExecutorTaskDelegate implements JavaDelegate { + + + private static Logger logger = LoggerFactory.getLogger(MultiNodeDeployRemoteScript1ExecutorTaskDelegate.class); + + @Autowired + RemoteScriptExecutionService remoteScriptExecutionService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + + public void execute(DelegateExecution ctx) throws Exception { + + + String remotserver=(String)ctx.getVariable("remotserver"); + int portnumner=(Integer)ctx.getVariable("port"); + String username=(String)ctx.getVariable("username"); + String password=(String)ctx.getVariable("password"); + String filename=(String)ctx.getVariable("remotefile1"); + String fileparams=(String)ctx.getVariable("remotefile1params"); + String destdir=(String)ctx.getVariable("destdir1"); + + logger.debug("task execution started remotserver {} , portnumner {},username {}, password {},filename : {} ,fileparams={},dest dir={}", + remotserver,portnumner,username,password,filename,fileparams,destdir); + String command="cd "+destdir+ ";" +" bash "+filename+" "+ (fileparams!=null?fileparams:" ") ; + logger.debug("Execution command {}",command); + remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,null,destdir,command); + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript2ExecutorTaskDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript2ExecutorTaskDelegate.java new file mode 100644 index 0000000..02ded79 --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeDeployRemoteScript2ExecutorTaskDelegate.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.service.DeployResponseSenderService; +import com.akraino.bpm.service.RemoteScriptExecutionService; + + + +@Component +public class MultiNodeDeployRemoteScript2ExecutorTaskDelegate implements JavaDelegate { + + + private static Logger logger = LoggerFactory.getLogger(MultiNodeDeployRemoteScript2ExecutorTaskDelegate.class); + + @Autowired + RemoteScriptExecutionService remoteScriptExecutionService; + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + + public void execute(DelegateExecution ctx) throws Exception { + String remotserver=(String)ctx.getVariable("remotserver"); + int portnumner=(Integer)ctx.getVariable("port"); + String username=(String)ctx.getVariable("username"); + String password=(String)ctx.getVariable("password"); + String filename=(String)ctx.getVariable("remotefile2"); + String fileparams=(String)ctx.getVariable("remotefile2params"); + String destdir=(String)ctx.getVariable("destdir2"); + String sitename=(String)ctx.getVariable("sitename"); + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "inprogress","not started",sitename,null,null,null)); + + logger.debug("task execution started remotserver {} , portnumner {},username {}, password {},filename : {} ,fileparams={},dest dir={}", + remotserver,portnumner,username,password,filename,fileparams,destdir); + + String command="cd "+destdir+ ";" +" bash "+filename+" "+ (fileparams!=null?fileparams:" ") ; + logger.debug("Execution command {}",command); + remoteScriptExecutionService.executeRemoteScript(remotserver,username,password,portnumner,filename,fileparams,null,destdir,command); + + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "completed", "completed","completed",sitename,null,null,null)); + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeScript1ExecutorTaskDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeScript1ExecutorTaskDelegate.java new file mode 100644 index 0000000..47a4020 --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeScript1ExecutorTaskDelegate.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +import com.akraino.bpm.service.ScriptExecutionService; + + +@Component +public class MultiNodeScript1ExecutorTaskDelegate implements JavaDelegate { + + @Autowired + RuntimeService runtimeService; + + private static Logger logger = LoggerFactory.getLogger(MultiNodeScript1ExecutorTaskDelegate.class); + + @Autowired + ScriptExecutionService scriptExecutionService; + + public void execute(DelegateExecution ctx) throws Exception { + String filename=(String)ctx.getVariable("file1"); + String fileparams=(String)ctx.getVariable("file1params"); + + int lastindex=filename.lastIndexOf("/"); + String srcdir=filename.substring(0,lastindex); + String task=filename.substring(lastindex+1,filename.length()); + + String file= task+" "+(fileparams!=null?fileparams.replaceAll(",", " "):" "); + + + logger.debug("task execution started filename:{}, directory:{}",file,srcdir); + scriptExecutionService.executeCDBashScript(srcdir, file); + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeWinScpScriptDelegate.java b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeWinScpScriptDelegate.java new file mode 100644 index 0000000..c8c58d1 --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/delegate/MultiNodeWinScpScriptDelegate.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.delegate; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.akraino.bpm.model.BuildResponse; +import com.akraino.bpm.service.DeployResponseSenderService; +import com.akraino.bpm.service.ScriptExecutionService; + + +@Component +public class MultiNodeWinScpScriptDelegate implements JavaDelegate { + + private static Logger logger = LoggerFactory.getLogger(MultiNodeWinScpScriptDelegate.class); + + @Autowired + DeployResponseSenderService deployResponseSenderService; + + @Autowired + ScriptExecutionService scriptExecutionService; + + public void execute(DelegateExecution ctx) throws Exception { + + String sitename=(String)ctx.getVariable("sitename"); + deployResponseSenderService.sendResponse(new BuildResponse("completed", "completed", "inprogress", "not started","not started",sitename,null,null,null)); + String filename=(String)ctx.getVariable("scpfilename"); + String dir=(String)ctx.getVariable("winscpdir"); + logger.debug("Win SCP task execution started filename:{},directory:{}",filename,dir); + + scriptExecutionService.executeCDBashScript(dir, filename); + + + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java b/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java index c463fec..39ce79c 100644 --- a/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java +++ b/akraino/src/main/java/com/akraino/bpm/model/BuildResponse.java @@ -28,6 +28,7 @@ public class BuildResponse { private String vCDNStatus; private String tempestStatus; + public BuildResponse(String buildStatus, String createTarStatus, String genesisNodeStatus, String deployToolsStatus,String deployStatus, String siteName,String onapStatus,String vCDNStatus,String tempestStatus) { super(); @@ -41,8 +42,7 @@ public class BuildResponse { this.vCDNStatus=vCDNStatus; this.tempestStatus=tempestStatus; } - - + public String getBuildStatus() { return buildStatus; } @@ -131,7 +131,6 @@ public class BuildResponse { this.tempestStatus = tempestStatus; } - @Override public String toString() { return "BuildResponse [siteName=" + siteName + ", buildStatus=" + buildStatus + ", createTarStatus=" @@ -140,7 +139,9 @@ public class BuildResponse { + vCDNStatus + ", tempestStatus=" + tempestStatus + "]"; } + + } diff --git a/akraino/src/main/java/com/akraino/bpm/model/MultiNodeDeploy.java b/akraino/src/main/java/com/akraino/bpm/model/MultiNodeDeploy.java new file mode 100644 index 0000000..ab656fa --- /dev/null +++ b/akraino/src/main/java/com/akraino/bpm/model/MultiNodeDeploy.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.akraino.bpm.model; + +public class MultiNodeDeploy { + + private String sitename; + private String file1; + private String file1params; + private String winscpfilepath; + private String winscpfileparams; + private String remotserver; + private int port; + private String username; + private String password; + private String destdir1; + private String remotefile1; + private String remotefile1params; + private String destdir2; + private String remotefile2; + private String remotefile2params; + public String getSitename() { + return sitename; + } + public void setSitename(String sitename) { + this.sitename = sitename; + } + public String getFile1() { + return file1; + } + public void setFile1(String file1) { + this.file1 = file1; + } + public String getFile1params() { + return file1params; + } + public void setFile1params(String file1params) { + this.file1params = file1params; + } + public String getWinscpfilepath() { + return winscpfilepath; + } + public void setWinscpfilepath(String winscpfilepath) { + this.winscpfilepath = winscpfilepath; + } + public String getWinscpfileparams() { + return winscpfileparams; + } + public void setWinscpfileparams(String winscpfileparams) { + this.winscpfileparams = winscpfileparams; + } + public String getRemotserver() { + return remotserver; + } + public void setRemotserver(String remotserver) { + this.remotserver = remotserver; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + public String getRemotefile1() { + return remotefile1; + } + public void setRemotefile1(String remotefile1) { + this.remotefile1 = remotefile1; + } + public String getRemotefile1params() { + return remotefile1params; + } + public void setRemotefile1params(String remotefile1params) { + this.remotefile1params = remotefile1params; + } + public String getRemotefile2() { + return remotefile2; + } + public void setRemotefile2(String remotefile2) { + this.remotefile2 = remotefile2; + } + public String getRemotefile2params() { + return remotefile2params; + } + public void setRemotefile2params(String remotefile2params) { + this.remotefile2params = remotefile2params; + } + public String getDestdir1() { + return destdir1; + } + public void setDestdir1(String destdir1) { + this.destdir1 = destdir1; + } + public String getDestdir2() { + return destdir2; + } + public void setDestdir2(String destdir2) { + this.destdir2 = destdir2; + } + + + @Override + public String toString() { + return "MultiNodeDeploy [sitename=" + sitename + ", file1=" + file1 + ", file1params=" + file1params + + ", winscpfilepath=" + winscpfilepath + ", winscpfileparams=" + winscpfileparams + ", remotserver=" + + remotserver + ", port=" + port + ", username=" + username + ", password=" + password + ", destdir1=" + + destdir1 + ", remotefile1=" + remotefile1 + ", remotefile1params=" + remotefile1params + ", destdir2=" + + destdir2 + ", remotefile2=" + remotefile2 + ", remotefile2params=" + remotefile2params + "]"; + } + + + + } diff --git a/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java b/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java index 0a78b78..ad05507 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java +++ b/akraino/src/main/java/com/akraino/bpm/service/AsyncProcessExecutorService.java @@ -20,6 +20,7 @@ import com.akraino.bpm.model.Airship; import com.akraino.bpm.model.Apache; import com.akraino.bpm.model.Build; import com.akraino.bpm.model.Deploy; +import com.akraino.bpm.model.MultiNodeDeploy; import com.akraino.bpm.model.Onap; import com.akraino.bpm.model.Tempest; @@ -36,4 +37,6 @@ public interface AsyncProcessExecutorService { public void executeTempestProcess(Tempest tempest); public void executeApacheProcess(Apache apache); + + public void executeMultiNodeDeployProcess(MultiNodeDeploy multiNodeDeploy); } diff --git a/akraino/src/main/java/com/akraino/bpm/service/ScriptExecutionService.java b/akraino/src/main/java/com/akraino/bpm/service/ScriptExecutionService.java index 446e97e..2588a18 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/ScriptExecutionService.java +++ b/akraino/src/main/java/com/akraino/bpm/service/ScriptExecutionService.java @@ -22,9 +22,6 @@ public interface ScriptExecutionService { public void executeCDScript(String dir,String cmd); + public void executeCDBashScript(String dir,String cmd); - - //public void executeAirshipScript(String cmd); - - } diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java index 5179c51..d2e303b 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/AsyncProcessExecutorServiceImpl.java @@ -31,6 +31,7 @@ import com.akraino.bpm.model.Apache; import com.akraino.bpm.model.Build; import com.akraino.bpm.model.BuildResponse; import com.akraino.bpm.model.Deploy; +import com.akraino.bpm.model.MultiNodeDeploy; import com.akraino.bpm.model.Onap; import com.akraino.bpm.model.Tempest; import com.akraino.bpm.service.AsyncProcessExecutorService; @@ -57,7 +58,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"exception: "+ex.getMessage(),airship.getSitename(),null,null,null)); return; } - logger.debug("Airship execution sucess "); + logger.debug("Airship execution success "); deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"success",airship.getSitename(),null,null,null)); @@ -87,7 +88,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse("exception: "+ex.getMessage(),null,null,null,null,build.getSitename(),null,null,null)); return; } - logger.debug("Build execution sucess "); + logger.debug("Build execution success "); deployResponseSenderService.sendResponse(new BuildResponse("success",null,null,null,null,build.getSitename(),null,null,null)); } @@ -109,7 +110,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"exception: "+ex.getMessage(),deploy.getSitename(),null,null,null)); return; } - logger.debug("deploy execution sucess "); + logger.debug("deploy execution success "); deployResponseSenderService.sendResponse(new BuildResponse("success","success","success","success","success",deploy.getSitename(),null,null,null)); } @@ -150,7 +151,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,onap.getSitename(),"exception: "+ex.getMessage(),null,null)); return; } - logger.debug("Onap execution sucess "); + logger.debug("Onap execution success "); deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,onap.getSitename(),"succes",null,null)); @@ -187,7 +188,7 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"exception: "+ex.getMessage())); return; } - logger.debug("Tempest execution sucess "); + logger.debug("Tempest execution success "); deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,tempest.getSitename(),null,null,"success")); } @@ -221,13 +222,12 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"exception: "+ex.getMessage(),null)); return; } - logger.debug("Apache execution sucess "); + logger.debug("Apache execution success "); deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,null,apache.getSitename(),null,"success",null)); } - private ProcessInstance executeApacheService(Apache apache) { int lastindex=apache.getFiletrasferscript().lastIndexOf("/"); @@ -249,5 +249,41 @@ public class AsyncProcessExecutorServiceImpl implements AsyncProcessExecutorServ } - - } + @Async + public void executeMultiNodeDeployProcess(MultiNodeDeploy multiNodeDeploy) { + try { + executeMultiNodeDeployService(multiNodeDeploy); + }catch(TaskExecutorException ex) { + logger.error("MultiNodeDeploy execution failed ",ex); + deployResponseSenderService.sendResponse(new BuildResponse(null,null,null,null,"exception: "+ex.getMessage(),multiNodeDeploy.getSitename(),null,null,null)); + return; + } + logger.debug("MultiNodeDeploy execution success "); + deployResponseSenderService.sendResponse(new BuildResponse("success","success","success","success","success",multiNodeDeploy.getSitename(),null,null,null)); + + } + + private ProcessInstance executeMultiNodeDeployService(MultiNodeDeploy multiNodeDeploy) { + + int lastindex=multiNodeDeploy.getWinscpfilepath().lastIndexOf("/"); + String scpSrcDir=multiNodeDeploy.getWinscpfilepath().substring(0,lastindex); + String scpfilename=multiNodeDeploy.getWinscpfilepath().substring(lastindex+1,multiNodeDeploy.getWinscpfilepath().length()); + + String transferfile= scpfilename+" "+(multiNodeDeploy.getWinscpfileparams()!=null?multiNodeDeploy.getWinscpfileparams().replaceAll(",", " "):" "); + + return camunda.getRuntimeService().startProcessInstanceByKey("multinodedeploy", + Variables.putValue("file1", multiNodeDeploy.getFile1()).putValue("file1params", multiNodeDeploy.getFile1params()) + .putValue("winscpdir", scpSrcDir) + .putValue("scpfilename", transferfile) + .putValue("remotserver", multiNodeDeploy.getRemotserver()) + .putValue("username", multiNodeDeploy.getUsername()) + .putValue("password", multiNodeDeploy.getPassword()) + .putValue("port", multiNodeDeploy.getPort()) + .putValue("destdir1",multiNodeDeploy.getDestdir1()).putValue("destdir2", multiNodeDeploy.getDestdir2()) + .putValue("remotefile1", multiNodeDeploy.getRemotefile1()).putValue("remotefile1params", multiNodeDeploy.getRemotefile1params()) + .putValue("sitename", multiNodeDeploy.getSitename()).putValue("remotefile2", multiNodeDeploy.getRemotefile2()).putValue("remotefile2params", multiNodeDeploy.getRemotefile2params()) + ); + + } + +} diff --git a/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java b/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java index 7462607..3cc853b 100644 --- a/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java +++ b/akraino/src/main/java/com/akraino/bpm/service/impl/ScriptExecutionServiceImpl.java @@ -46,7 +46,7 @@ public class ScriptExecutionServiceImpl implements ScriptExecutionService{ p.waitFor(); logger.debug("Script exit code :"+p.exitValue()); if(p.exitValue()!=0) { - throw new TaskExecutorException("problem while executing the script . exist code :"+p.exitValue()); + throw new TaskExecutorException("problem while executing the script . exit code :"+p.exitValue()); } @@ -85,6 +85,36 @@ public class ScriptExecutionServiceImpl implements ScriptExecutionService{ } + public void executeCDBashScript(String dir,String cmd) { + + try { + logger.debug("Executing the script.............dir:{},command:{}",dir,cmd); + + String[] command = { "/bin/bash", "-c", "bash "+cmd }; + Process p = Runtime.getRuntime().exec(command, null, new File(dir)); + p.waitFor(); + BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = ""; + while ((line = input.readLine()) != null) { + logger.debug(line); + } + logger.debug("Script exit code :"+p.exitValue()); + if(p.exitValue()!=0) { + throw new TaskExecutorException("problem while executing the script . exist code :"+p.exitValue()); + } + + + } catch (IOException e) { + throw new TaskExecutorException(cmd + " not found."); + } catch (InterruptedException e) { + throw new TaskExecutorException("problem while executing the script "+cmd); + } + + } + + + + /*public void executeAirshipScript(String cmd) { try { diff --git a/akraino/src/main/resources/multinodedeploy.bpmn b/akraino/src/main/resources/multinodedeploy.bpmn new file mode 100644 index 0000000..cfe83e4 --- /dev/null +++ b/akraino/src/main/resources/multinodedeploy.bpmn @@ -0,0 +1,128 @@ + + + + + + SequenceFlow_125l5l0 + + + SequenceFlow_125l5l0 + SequenceFlow_05ubysv + + + SequenceFlow_05ubysv + SequenceFlow_1jh4nm3 + + + + SequenceFlow_1jh4nm3 + SequenceFlow_1b4e6j2 + + + + SequenceFlow_1b4e6j2 + + + + Rest + + + + Script 1 execution Task + + + + Win Scp Script Executor + + + + Remote Script 1 Executor + + + + Remote Script 2 executor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/multinodedeploy.bpmn b/config/multinodedeploy.bpmn new file mode 100644 index 0000000..cfe83e4 --- /dev/null +++ b/config/multinodedeploy.bpmn @@ -0,0 +1,128 @@ + + + + + + SequenceFlow_125l5l0 + + + SequenceFlow_125l5l0 + SequenceFlow_05ubysv + + + SequenceFlow_05ubysv + SequenceFlow_1jh4nm3 + + + + SequenceFlow_1jh4nm3 + SequenceFlow_1b4e6j2 + + + + SequenceFlow_1b4e6j2 + + + + Rest + + + + Script 1 execution Task + + + + Win Scp Script Executor + + + + Remote Script 1 Executor + + + + Remote Script 2 executor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +