]>
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
2 * Copyright (C) 2007-2012 Argeo GmbH
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.
16 package org
.argeo
.slc
.lib
.linux
;
18 import org
.argeo
.slc
.SlcException
;
19 import org
.argeo
.slc
.core
.deploy
.LocalFilesDeployment
;
20 import org
.argeo
.slc
.core
.deploy
.ResourceSet
;
21 import org
.argeo
.slc
.core
.execution
.tasks
.SystemCall
;
22 import org
.argeo
.slc
.jsch
.RemoteExec
;
23 import org
.argeo
.slc
.jsch
.SshFilesDeployment
;
24 import org
.argeo
.slc
.jsch
.SshTarget
;
26 public class RedhatHostManager
{
28 private SimpleLinuxHost host
;
31 private Boolean useSsh
= true;
32 private SshTarget sshTarget
= null;
34 public void installPackages() {
35 StringBuffer cmd
= new StringBuffer("yum --nogpgcheck -y install");
36 for (String pkg
: ((RpmDistribution
) host
.getDistribution())
37 .getAdditionalPackages()) {
38 cmd
.append(' ').append(pkg
);
40 executeCommand(cmd
.toString());
42 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
44 executeCommand(rdd
.getRunlevelsScript());
47 public void deployConfig() {
48 RedhatDeploymentData rdd
= (RedhatDeploymentData
) host
50 deploy(rdd
.getConfigurationFiles());
51 executeCommand(rdd
.getPermissionsScript());
55 protected void deploy(ResourceSet resourceSet
) {
57 new SshFilesDeployment(getSshTarget(), resourceSet
).run();
59 new LocalFilesDeployment(resourceSet
).run();
63 protected void executeCommand(String command
) {
68 RemoteExec rExec
= new RemoteExec(getSshTarget(), command
);
69 rExec
.setFailOnBadExitStatus(false);
72 new SystemCall(command
).run();
75 protected SshTarget
getSshTarget() {
76 if (sshTarget
== null)
77 throw new SlcException("No SSH target defined");
81 public void setHost(SimpleLinuxHost host
) {
85 public void setUseSsh(Boolean useSsh
) {
89 public void setSshTarget(SshTarget sshTarget
) {
90 this.sshTarget
= sshTarget
;