Ejemplo n.º 1
0
        // This method used to initiate start of DDT on remote machine
        public static void StartDdt(ListView listview, List <Server> serversList, DdtParameters ddtparameters)
        {
            var selectedServers = listview.Items.Cast <ListViewItem>().Where(item => item.Checked).ToList(); // Creating list of selected servers

            foreach (var server in selectedServers)
            {
                for (var y = 0; y < serversList.Count; y++)
                {
                    if (server.SubItems[1].Text != serversList[y].ServerCredentials.Ip)
                    {
                        continue;
                    }
                    var index = y;

                    if (serversList[y].Task != null)
                    {
                        serversList[y].Cts.Cancel();
                    }

                    serversList[y].ServerGeneratorStatus = Server.GeneratorStatus.Running;
                    serversList[y].Cts           = new CancellationTokenSource();
                    serversList[y].DdtParameters = ddtparameters;

                    serversList[y].Task = new Task(() => serversList[index].Runddt());
                    serversList[y].Task.Start();
                }
            }
        }
Ejemplo n.º 2
0
        // This method runs DDT tool with specific parameters on remote server using WMI
        public static void Runddtremotely(ServerConnectionCredentials serverCreds, DdtParameters ddtParameters, CancellationToken token)
        {
            var remotePath = "\\\\" + serverCreds.Ip + "\\" + HelperMethods.SeparateVolumeAndFolder(ddtParameters.Filepath, HelperMethods.FilepathParts.Volume)
                             + "$\\" + HelperMethods.SeparateVolumeAndFolder(ddtParameters.Filepath, HelperMethods.FilepathParts.Folder);

            WmiKillDdt(serverCreds);

            CopyDdTtoRemoteMachine(serverCreds);

            CreateTargetDirectory(serverCreds, remotePath);

            Logger.Log("Data generation started on remote server " + serverCreds.Ip, Logger.LogLevel.Info, serverCreds.Ip);

            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    Logger.Log("DDT operation has been canceled by user", Logger.LogLevel.Info, serverCreds.Ip);
                    break;
                }

                if (!ddtParameters.FillingGeneration)
                {
                    CleanFilepathRemotely(serverCreds, remotePath);
                }

                WmiRunDdt(serverCreds, ddtParameters);

                Thread.Sleep(ddtParameters.Interval * 60000);
            }
        }
Ejemplo n.º 3
0
        private void btn_startDDT_Click(object sender, EventArgs e)
        {
            var failedValidation = false;
            var textBoxValidate  = new List <TextBox> {
                tb_Size, tb_Path, tb_Compression, tb_Interval
            };

            foreach (var textBox in textBoxValidate)
            {
                if (!string.IsNullOrWhiteSpace(textBox.Text))
                {
                    continue;
                }
                errorProvider1.SetError(textBox, "Field cannot be empty");
                failedValidation = true;
            }

            if (failedValidation)
            {
                return;
            }



            _ddtParameters = new DdtParameters()
            {
                Filesize          = Convert.ToInt32(tb_Size.Text),
                Compression       = Convert.ToInt32(tb_Compression.Text),
                Interval          = Convert.ToInt32(tb_Interval.Text),
                Filepath          = tb_Path.Text,
                FillingGeneration = cb_fillingGeneration.Checked
            };

            _ddtParameters.SerizalizeDdtParamsToFile();

            // Start DDT for selected servers with specific parameters
            if (cb_UseCustomCredentials.Checked)
            {
                DdtWrapper.StartDdt(lv_AgentsList, ServerWrapper.ServersList, _ddtParameters, tb_customUsername.Text, tb_customPassword.Text);
            }
            else
            {
                DdtWrapper.StartDdt(lv_AgentsList, ServerWrapper.ServersList, _ddtParameters);
            }

            // Update ListView
            ServerWrapper.UpdateListView(lv_AgentsList, lbl_ChangeRateValue, lbl_totalAgentsRunningValue);
        }
Ejemplo n.º 4
0
        public static void StartDdt(ListView listview, List <Server> serversList, DdtParameters ddtparameters, string username, string password)
        {
            var selectedServers = listview.Items.Cast <ListViewItem>().Where(item => item.Checked).ToList(); // Creating list of selected servers

            foreach (var server in selectedServers)
            {
                foreach (var t in serversList)
                {
                    if (server.SubItems[1].Text != t.ServerCredentials.Ip)
                    {
                        continue;
                    }

                    t.ServerCredentials.Username = username;
                    t.ServerCredentials.Password = password;
                }
            }

            StartDdt(listview, serversList, ddtparameters);
        }
Ejemplo n.º 5
0
        // This methdo starts DDT on remote machine using WMI
        private static void WmiRunDdt(ServerConnectionCredentials serverCreds, DdtParameters ddtParameters)
        {
            var seed = new Random().Next();

            object[] processToTun = { @"C:\DDT\ddt.exe op=write threads=1 filename=" + ddtParameters.Filepath + seed + " filesize=" + ddtParameters.Filesize
                                      + " blocksize=512 dup-percentage=" + ddtParameters.Compression + " buffering=direct io=sequential seed=" + seed + " no-ddt-hdr=yes" };
            var      options = new ConnectionOptions
            {
                Username = serverCreds.Username,
                Password = serverCreds.Password
            };


            var scope = new ManagementScope("\\\\" + serverCreds.Ip + "\\root\\cimv2", options);

            var theClass = new ManagementClass(scope, new ManagementPath("Win32_Process"), new ObjectGetOptions());

            var retryCount = 0;

            while (true)
            {
                try
                {
                    theClass.InvokeMethod("Create", processToTun);
                    break;
                }
                catch (COMException e)
                {
                    if (retryCount < 3)
                    {
                        retryCount++;
                    }
                    else
                    {
                        Logger.LogError("Starting DDT on remote machine failed with:", serverCreds.Ip, e);
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void GetGenParamsFromFileToGui()
        {
            var ddtParams = DdtParameters.DeserializeDdtParamsFromFile();

            if (ddtParams != null)
            {
                tb_Size.Text        = ddtParams.Filesize.ToString();
                tb_Compression.Text = ddtParams.Compression.ToString();
                tb_Path.Text        = ddtParams.Filepath;
                tb_Interval.Text    = ddtParams.Interval.ToString();
            }

            var exchangeParams = ExchangeGeneratorParameters.DeserializeExchangeParamsFromFile();

            if (exchangeParams != null)
            {
                var i = 0;
                foreach (var item in cb_MailSize.Items)
                {
                    if ((item.ToString()).Contains(_mailSizeDictionary[exchangeParams.MessageSize]))
                    {
                        cb_MailSize.SelectedIndex = i;
                    }
                    i++;
                }
            }

            var sqlParams = SqlGeneratorParameters.DeserializeSqlParamsFromFile();

            if (sqlParams == null)
            {
                return;
            }
            tb_dbName.Text        = sqlParams.DbName;
            tb_SQLAmountRows.Text = sqlParams.RowsToInsert.ToString();
        }