]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/linux/RedhatHostManager.java
f4e0076b3e657229c220e594d7bbc7a293e6a8a1
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.lib
.linux
;
19 import org
.argeo
.slc
.SlcException
;
20 import org
.argeo
.slc
.core
.deploy
.LocalFilesDeployment
;
21 import org
.argeo
.slc
.core
.deploy
.ResourceSet
;
22 import org
.argeo
.slc
.core
.execution
.tasks
.SystemCall
;
23 import org
.argeo
.slc
.jsch
.RemoteExec
;
24 import org
.argeo
.slc
.jsch
.SshFilesDeployment
;
25 import org
.argeo
.slc
.jsch
.SshTarget
;
27 public class RedhatHostManager
{
29 private SimpleLinuxHost host
;
32 private Boolean useSsh
= true;
33 private SshTarget sshTarget
= null;
35 public void installPackages() {
36 StringBuffer cmd
= new StringBuffer("yum --nogpgcheck -y install");
37 for (String pkg
: ((RpmDistribution
) host
.getDistribution())
38 .getAdditionalPackages()) {
39 cmd
.append(' ').append(pkg
);
41 executeCommand(cmd
.toString());
43 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
45 executeCommand(rdd
.getRunlevelsScript());
48 public void deployConfig() {
49 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
51 deploy(rdd
.getConfigurationFiles());
52 executeCommand(rdd
.getPermissionsScript());
56 protected void deploy(ResourceSet resourceSet
) {
58 new SshFilesDeployment(getSshTarget(), resourceSet
).run();
60 new LocalFilesDeployment(resourceSet
).run();
64 protected void executeCommand(String command
) {
69 RemoteExec rExec
= new RemoteExec(getSshTarget(), command
);
70 rExec
.setFailOnBadExitStatus(false);
73 new SystemCall(command
).run();
76 protected SshTarget
getSshTarget() {
77 if (sshTarget
== null)
78 throw new SlcException("No SSH target defined");
82 public void setHost(SimpleLinuxHost host
) {
86 public void setUseSsh(Boolean useSsh
) {
90 public void setSshTarget(SshTarget sshTarget
) {
91 this.sshTarget
= sshTarget
;