private async Task ImportScpAsync(string path, string target, string shutdown) { foreach (Server server in ServersListBox.Items) { if (!await NetworkHelper.CheckConnectionAsync(server.Host)) { OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel, verifique a conexão e tente novamente.\n", server.Host)); continue; } try { OutputTextBox.AppendText(string.Format("Importando configurações para {0}...\n", server.Host)); ScpController idrac = new ScpController(server); IdracJob job = await idrac.ImportScpFileAsync(path, target, shutdown, "On"); OutputTextBox.AppendText(string.Format("Job {0} criado para servidor {1}\n", job.Id, server)); var chassisIdrac = new ChassisController(server); var chassis = await chassisIdrac.GetChassisAsync(); currentJobs.TryAdd(job.Id, new ServerJob() { Job = job, SerialNumber = chassis.SKU, Server = server }); } catch (Exception ex) { OutputTextBox.AppendText(string.Format("Falha ao importar arquivo para {0} {1}\n", server.Host, ex.Message)); } } ImportButton.IsEnabled = true; }
private async Task UpdateFirmwareAsync(string repository, string catalog, string reboot) { foreach (Server server in ServersListBox.Items) { if (!await NetworkHelper.CheckConnectionAsync(server.Host)) { OutputTextBox.AppendText(string.Format("Servidor {0} ínacessivel.\n", server)); continue; } try { OutputTextBox.AppendText(string.Format("Atualizando firmwares de {0}...\n", server)); string jobId = ""; var idrac = new IdracSshController(server); string command = string.Format(@"racadm update -f {0} -e {1} -a {2} -t FTP", catalog, repository, reboot); string response = idrac.RunCommand(command); foreach (var item in response.Split(' ')) { if (item.Contains("JID")) { jobId = item.Split('"').FirstOrDefault(); break; } } if (String.IsNullOrEmpty(jobId)) // Caso Haja problema na criação do Job ele retorna "" { continue; } var idracJob = new JobController(server); var idracChassis = new ChassisController(server); IdracJob job = await idracJob.GetJobAsync(jobId); Chassis chassis = await idracChassis.GetChassisAsync(); currentJobs.TryAdd(job.Id, new ServerJob() { Server = server, Job = job, SerialNumber = chassis.SKU }); OutputTextBox.AppendText(string.Format("Criado {0} para atualizaçao do servidor {1}\n", jobId, server)); } catch (Exception ex) { OutputTextBox.AppendText(string.Format("Falha ao atualizar {0} {1}\n", server, ex.Message)); } } UpdateButton.IsEnabled = true; }
private async Task UpdateFirmwareAsync(string path, string option) { foreach (Server server in ServersListBox.Items) { if (!await NetworkHelper.CheckConnectionAsync(server.Host)) { OutputTextBox.AppendText(string.Format("O servidor {0} não está acessivel, verifique a conexão e tente novamente\n", server.Host)); continue; } try { UpdateController idrac = new UpdateController(server); if (!await idrac.CheckRedfishSupportAsync(UpdateController.FirmwareInventory)) { OutputTextBox.AppendText(string.Format("A versão da Idrac do {0} servidor não possui suporte a função de update de firmware\n", server.Host)); continue; } OutputTextBox.AppendText(string.Format("Iniciando upload do firmware para {0}...\n", server.Host)); ChassisController chassisIdrac = new ChassisController(server); IdracJob job = await idrac.UpdateFirmwareAsync(path, option); Chassis chassis = await chassisIdrac.GetChassisAsync(); currentJobs.TryAdd(job.Id, new ServerJob() { Job = job, Server = server, SerialNumber = chassis.SKU }); OutputTextBox.AppendText(string.Format("Upload concluido, criado Job {0} para update\n", job.Id)); } catch (Exception ex) { OutputTextBox.AppendText(string.Format("Erro ao atualizar {0} {1}\n", server.Host, ex.Message)); } } UpdateButton.IsEnabled = true; }