Beispiel #1
0
        // This method runs DDT tool with specific parameters on remote server using WMI
        public static void Runddtremotely(ServerConnectionCredentials serverCreds, DDTParameters ddtParameters, CancellationToken token)
        {
            string remotePath = "\\\\" + serverCreds.IP + "\\" + HelperMethods.separateVolumeAndFolder(ddtParameters.Filepath, HelperMethods.FilepathParts.volume)
                        + "$\\" + HelperMethods.separateVolumeAndFolder(ddtParameters.Filepath, HelperMethods.FilepathParts.folder);

            WMIKillDDT(serverCreds);

            CopyDDTtoRemoteMachine(serverCreds);

            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;
                }

                cleanFilepathRemotely(serverCreds, remotePath);

                WMIRunDDT(serverCreds, ddtParameters);

                Thread.Sleep(ddtParameters.Interval * 60000);
            }
        }
        // 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

            for (int x = 0; x < selectedServers.Count; x++)
            {
                for (int y = 0; y < serversList.Count; y++)
                {
                    if (selectedServers[x].SubItems[1].Text == serversList[y].ServerCredentials.IP)
                    {
                        int index = y;

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

                        serversList[y].DdtStatus = Server.DDTStatus.Running;
                        serversList[y].CTS = new CancellationTokenSource();
                        serversList[y].DdtParameters = ddtparameters;
                     
                        serversList[y].Task = new Task(() => serversList[index].Runddt());
                        serversList[y].Task.Start();

                    }
                }
            }
        }
Beispiel #3
0
        private void btn_startDDT_Click(object sender, EventArgs e)
        {
            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
            };

            ddtParameters.SerizalizeDDTParamsToFile();

            // Start DDT for selected servers with specific parameters
            DDTWrapper.StartDDT(lv_AgentsList,
                            ServerWrapper.serversList,
                            ddtParameters);

            // Update ListView
            ServerWrapper.UpdateListView(lv_AgentsList, lbl_ChangeRateValue, lbl_totalAgentsRunningValue);

        }
Beispiel #4
0
        // This methdo starts DDT on remote machine using WMI
        public 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" };
            ConnectionOptions options = new ConnectionOptions();

            options.Username = serverCreds.Username;
            options.Password = serverCreds.Password;

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

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

            int 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;
                    }
                }
            }
        }