コード例 #1
0
        public async Task <string> RunCommand(SetSSHDetailsRequest request, string command)
        {
            var client = await Connect(request);

            var cmd = client?.RunCommand(command);

            return(string.IsNullOrEmpty(cmd?.Result)? cmd?.Error : cmd?.Result);
        }
コード例 #2
0
 public async Task <SshClient> Connect(SetSSHDetailsRequest request)
 {
     try
     {
         var client = new SshClient(request.Host, request.Username, request.Password);
         client.Connect();
         client.KeepAliveInterval = TimeSpan.FromSeconds(5);
         var id = Guid.NewGuid().ToString();
         return(client);
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #3
0
        public async Task <bool> TestSshDetails(SetSSHDetailsRequest request)
        {
            try
            {
                var client = await Connect(request);

                if (client == null)
                {
                    return(false);
                }

                await Disconnect(client);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #4
0
 public async Task <string> CheckDocker(SetSSHDetailsRequest request)
 {
     return(await _installerService.CheckDocker(request));
 }
コード例 #5
0
 public async Task <bool> TestSshDetails(SetSSHDetailsRequest request)
 {
     return(await _installerService.TestSshDetails(request));
 }
コード例 #6
0
 public async Task <string> CheckDocker(SetSSHDetailsRequest request)
 {
     return(await RunCommand(request, "docker ps"));
 }
コード例 #7
0
 public async Task <string> CheckSpace(SetSSHDetailsRequest request)
 {
     return(await RunCommand(request, "df -H"));
 }