Exemple #1
0
 private async Task RunScriptAsync(string path)
 {
     foreach (Server server in ServersListBox.Items)
     {
         if (!await NetworkHelper.CheckConnectionAsync(server.Host))
         {
             OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel.\n", server.Host));
             continue;
         }
         try
         {
             OutputTextBox.AppendText(string.Format("Aplicando script para {0}\n", server.Host));
             var      idrac  = new IdracSshController(server);
             string[] script = File.ReadAllLines(path);
             foreach (var command in script)
             {
                 idrac.RunCommand(command);
             }
         }
         catch (Exception ex)
         {
             OutputTextBox.AppendText(string.Format("Falha ao executar o script para {0} : {1}\n", server.Host, ex.Message));
         }
     }
     ApplyButton.IsEnabled = true;
     ClearButton.IsEnabled = true;
 }
Exemple #2
0
        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;
        }
Exemple #3
0
        private async Task ExportScpFileAsync(Server server, string target, string exportUse)
        {
            if (!await NetworkHelper.CheckConnectionAsync(server.Host))
            {
                MessageBox.Show("Servidor inacessivel", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                ScpController idrac = new ScpController(server);
                ExportButton.IsEnabled = false;
                OutputTextBox.AppendText(string.Format("Exportando configurações de {0}...\n", server.Host));
                IdracJob job = await idrac.ExportScpFileAsync(target, exportUse);

                var load = new LoadWindow(server, job)
                {
                    Title = server.Host
                };
                load.Closed += async(object sender, EventArgs e) =>
                {
                    var window = (LoadWindow)sender;
                    job = window.Job;
                    if (job.JobState.Contains("Completed"))
                    {
                        await SaveFileAsync(server, job);
                    }
                };
                load.Show();
            }
            catch (Exception ex)
            {
                OutputTextBox.AppendText(string.Format("Falha ao exportar arquivo: {0}\n", ex.Message));
                ExportButton.IsEnabled = true;
            }
        }
Exemple #4
0
        private async void ConnectAsync(Server server)
        {
            if (!await NetworkHelper.CheckConnectionAsync(server.Host))
            {
                MessageBox.Show("Servidor inacessivel", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                var idrac = new StorageController(server);
                if (await idrac.CheckRedfishSupportAsync(StorageController.Controllers) == false)
                {
                    MessageBox.Show(string.Format("O servidor {0} não suporta a API Redfish", server), "Aviso", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Falha ao conectar: {0}", ex.Message), "Aviso", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            var storageWindow = new StorageWindow(server)
            {
                Title = server.Host
            };

            storageWindow.Show();
        }
Exemple #5
0
        private async Task RunAsync(string type)
        {
            List <Task> tasks = new List <Task>();

            foreach (Server server in ServersListBox.Items)
            {
                if (!await NetworkHelper.CheckConnectionAsync(server.Host))
                {
                    OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel.\n", server.Host));
                    continue;
                }
                tasks.Add(CollectAsync(server, type));
            }
            await Task.WhenAll(tasks);
        }
Exemple #6
0
        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;
        }
Exemple #7
0
        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;
        }