]>
git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java
8b1c5e5053f60f42fa4a1f07a09de67fbeff95d1
1 package org
.argeo
.slc
.lib
.linux
;
3 import org
.argeo
.slc
.SlcException
;
4 import org
.argeo
.slc
.core
.deploy
.LocalFilesDeployment
;
5 import org
.argeo
.slc
.core
.deploy
.ResourceSet
;
6 import org
.argeo
.slc
.core
.execution
.tasks
.SystemCall
;
7 import org
.argeo
.slc
.jsch
.RemoteExec
;
8 import org
.argeo
.slc
.jsch
.SshFilesDeployment
;
9 import org
.argeo
.slc
.jsch
.SshTarget
;
11 public class RedhatHostManager
{
13 private SimpleLinuxHost host
;
16 private Boolean useSsh
= true;
17 private SshTarget sshTarget
= null;
19 public void installPackages() {
20 StringBuffer cmd
= new StringBuffer("yum --nogpgcheck -y install");
21 for (String pkg
: ((RpmDistribution
) host
.getDistribution())
22 .getAdditionalPackages()) {
23 cmd
.append(' ').append(pkg
);
25 executeCommand(cmd
.toString());
27 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
29 executeCommand(rdd
.getRunlevelsScript());
32 public void deployConfig() {
33 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
35 deploy(rdd
.getConfigurationFiles());
36 executeCommand(rdd
.getPermissionsScript());
40 protected void deploy(ResourceSet resourceSet
) {
42 new SshFilesDeployment(getSshTarget(), resourceSet
).run();
44 new LocalFilesDeployment(resourceSet
).run();
48 protected void executeCommand(String command
) {
53 RemoteExec rExec
= new RemoteExec(getSshTarget(), command
);
54 rExec
.setFailOnBadExitStatus(false);
57 new SystemCall(command
).run();
60 protected SshTarget
getSshTarget() {
61 if (sshTarget
== null)
62 throw new SlcException("No SSH target defined");
66 public void setHost(SimpleLinuxHost host
) {
70 public void setUseSsh(Boolean useSsh
) {
74 public void setSshTarget(SshTarget sshTarget
) {
75 this.sshTarget
= sshTarget
;