|
|
@ -36,6 +36,7 @@ public class GanymedSSH {
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = getOpenedConnection(host, username, password, port);
|
|
|
|
conn = getOpenedConnection(host, username, password, port);
|
|
|
|
|
|
|
|
otherConns=new HashMap<String,Connection>();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -81,14 +82,17 @@ public class GanymedSSH {
|
|
|
|
Session sess = null;
|
|
|
|
Session sess = null;
|
|
|
|
Connection new_conn;
|
|
|
|
Connection new_conn;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if(otherConns.containsKey(host) && otherConns.get(host)!=null){
|
|
|
|
if(Constant.hostIp.equals(host)){
|
|
|
|
|
|
|
|
new_conn=conn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(otherConns.containsKey(host) && otherConns.get(host)!=null){
|
|
|
|
new_conn=otherConns.get(host);
|
|
|
|
new_conn=otherConns.get(host);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
new_conn = getOpenedConnection(host, username, password, port);
|
|
|
|
new_conn = getOpenedConnection(host, username, password, port);
|
|
|
|
otherConns.put(host, new_conn);
|
|
|
|
otherConns.put(host, new_conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sess = conn.openSession();
|
|
|
|
sess = new_conn.openSession();
|
|
|
|
// 执锟斤拷cmd
|
|
|
|
// 执锟斤拷cmd
|
|
|
|
sess.execCommand(cmd);
|
|
|
|
sess.execCommand(cmd);
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -157,14 +161,17 @@ public class GanymedSSH {
|
|
|
|
Session sess = null;
|
|
|
|
Session sess = null;
|
|
|
|
Connection new_conn;
|
|
|
|
Connection new_conn;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if(otherConns.containsKey(host) && otherConns.get(host)!=null){
|
|
|
|
if(Constant.hostIp.equals(host)){
|
|
|
|
|
|
|
|
new_conn=conn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(otherConns.containsKey(host) && otherConns.get(host)!=null){
|
|
|
|
new_conn=otherConns.get(host);
|
|
|
|
new_conn=otherConns.get(host);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
new_conn = getOpenedConnection(host, username, password, port);
|
|
|
|
new_conn = getOpenedConnection(host, username, password, port);
|
|
|
|
otherConns.put(host, new_conn);
|
|
|
|
otherConns.put(host, new_conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sess = conn.openSession();
|
|
|
|
sess = new_conn.openSession();
|
|
|
|
// 执锟斤拷cmd
|
|
|
|
// 执锟斤拷cmd
|
|
|
|
sess.execCommand(cmd);
|
|
|
|
sess.execCommand(cmd);
|
|
|
|
|
|
|
|
|
|
|
|