Exemple #1
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (ServerJob job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch
                {
                    OutputTextBox.AppendText("Falha ao atualizar status dos Jobs\n");
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Exemple #2
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (var job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch (Exception ex)
                {
                    OutputTextBox.AppendText(string.Format("Falha ao obter dados de {0} {1}\n", job.Server, ex.Message));
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Exemple #3
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 #4
0
        private async void LoopJobAsync()
        {
            var idrac = new JobController(server);
            var time  = DateTime.Now;

            while (true)
            {
                try
                {
                    job = await idrac.GetJobAsync(job.Id);

                    UpdateProgressBar(job);

                    if (job.JobState.Contains("Completed"))
                    {
                        break;
                    }

                    else if (job.JobState.Contains("Failed"))
                    {
                        throw new Exception(string.Format("Falha ao executar o Job: {0}", job.Message));
                    }

                    else if (DateTime.Now >= time.AddMinutes(JobController.JobTimeout))
                    {
                        throw new TimeoutException("Excedido tempo limite do Job");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            Close();
        }