2024-03-23 23:28:02 +03:00
|
|
|
package Visual_DVM_2021.Passes.SSH;
|
2024-03-24 01:54:52 +03:00
|
|
|
import Common.Constants;
|
2024-03-23 23:28:02 +03:00
|
|
|
import Common.Current;
|
|
|
|
|
import Common.Global;
|
2024-03-24 01:54:52 +03:00
|
|
|
import Common.Utils.Utils;
|
2024-03-23 23:28:02 +03:00
|
|
|
import GlobalData.Machine.Machine;
|
|
|
|
|
import GlobalData.Machine.MachineType;
|
2024-03-24 01:54:52 +03:00
|
|
|
import GlobalData.RemoteFile.RemoteFile;
|
2024-03-23 23:28:02 +03:00
|
|
|
import GlobalData.User.User;
|
2024-03-24 01:54:52 +03:00
|
|
|
|
|
|
|
|
import java.util.Date;
|
2024-03-23 23:28:02 +03:00
|
|
|
public class TestingServerSSHPass extends ConnectionPass {
|
2024-03-24 01:54:52 +03:00
|
|
|
protected RemoteFile userHome;
|
|
|
|
|
protected RemoteFile testingHome;
|
2024-03-23 23:28:02 +03:00
|
|
|
@Override
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void Connect() throws Exception {
|
2024-03-24 01:54:52 +03:00
|
|
|
userHome =null;
|
|
|
|
|
testingHome =null;
|
|
|
|
|
//--
|
2024-03-23 23:28:02 +03:00
|
|
|
machine = new Machine("alex", Global.properties.ServerAddress,Global.properties.ServerUserSHHPort,MachineType.Server);
|
|
|
|
|
user = new User(Global.properties.ServerUserName, "mprit_2011");
|
|
|
|
|
super.Connect();
|
2024-03-24 01:54:52 +03:00
|
|
|
//--
|
|
|
|
|
userHome = new RemoteFile(user.connection.sftpChannel.getHome(), true);
|
|
|
|
|
testingHome = new RemoteFile(userHome, Constants.testingSystemHomeName);
|
|
|
|
|
//-
|
|
|
|
|
System.out.println("userHome="+ Utils.Brackets(userHome.full_name));
|
|
|
|
|
System.out.println("testingHome="+Utils.Brackets(testingHome.full_name));
|
|
|
|
|
}
|
|
|
|
|
//--
|
|
|
|
|
protected void Shutdown() throws Exception{
|
|
|
|
|
//--
|
|
|
|
|
RemoteFile INTERRUPT = new RemoteFile(testingHome, Constants.INTERRUPT);
|
|
|
|
|
RemoteFile ABORTED = new RemoteFile(testingHome, Constants.ABORTED);
|
|
|
|
|
//--
|
|
|
|
|
ShowMessage1("Создание файла INTERRUPT..");
|
|
|
|
|
user.connection.writeToFile("+", INTERRUPT);
|
|
|
|
|
ShowMessage1("Ожидание остановки сервера тестирования");
|
|
|
|
|
do {
|
|
|
|
|
Utils.sleep(1000);
|
|
|
|
|
ShowMessage2("Проверка признака остановки..");
|
|
|
|
|
} while (!user.connection.Exists(ABORTED));
|
|
|
|
|
//--
|
|
|
|
|
ShowMessage2("");
|
|
|
|
|
ShowMessage1("Журнализация");
|
|
|
|
|
RemoteFile AbortLog = new RemoteFile(testingHome, Constants.ABORTED+
|
|
|
|
|
"_by_"+
|
|
|
|
|
Current.getAccount().email+
|
|
|
|
|
"_"+
|
|
|
|
|
new Date().toString()
|
|
|
|
|
);
|
|
|
|
|
user.connection.sftpChannel.rename(ABORTED.full_name, AbortLog.full_name);
|
|
|
|
|
System.out.println("Done");
|
2024-03-23 23:28:02 +03:00
|
|
|
}
|
|
|
|
|
}
|