static void Main(string[] args) { //info for the remote host we want to connect to Host host = new Host("172.16.10.115", 29171); host.Name = "TCC9"; Console.WriteLine("Connecting to Xen Host: " + host.Ip + ":" + host.Port + "..."); XenConnect master = new XenConnect(host, testServerId, testip); VirtualMachineList vms = master.getHostVirtualMachineList(); Console.WriteLine("Retrieved host details\n\t" + master.getHost().ToString()); Console.WriteLine("Retrieving Virtual Machine List..."); foreach (VM vm in vms.Values) { Console.WriteLine("\t" + vm.ToString()); } Console.WriteLine("Test Complete..."); //Test_ListIso(host); //Test_CreateVmExisting(host); //Test_GetVNCPort(host, "4cb12bd0-b1c6-a6bb-d1c4-46246585d351"); //Test_FileTransfer(host, "C:\\Users\\DODTech\\Desktop\\sample.txt", "\\home\\guest_images\\"); //Test_CloneVM(host, "4cb12bd0-b1c6-a6bb-d1c4-46246585d351", "CopyBuntu"); //Test_GetProcessList(host, "Buntu5-1"); //Test_SendProcessListScan(host, "Buntu5-1"); //Test_ListVMStatistics(host, "4cb12bd0-b1c6-a6bb-d1c4-46246585d351"); //Test_ListVmApplications(host); //Test_StartVmApplication(host); //Test_ListMalware(host); //TestMalwareDirectory(host, "\\\\172.16.10.180\\public\\malware"); //Test_SendMalwareTo(host, "172.16.10.89", 3645); //Test_getVHDStorageList(host); Test_CreateVmExisting2(host); //Console.ReadLine(); }
protected void LinkButton_Connect_Click(object sender, EventArgs e) { Label_IPAddress.Text = Textbox_IPAddress.Text; //populate information Textbox_Host.Text = "VM Hypervisor"; Textbox_CPU.Text = "Cores"; Textbox_MHZ.Text = "GHZ"; Textbox_Memory.Text = "GB"; Panel_slow.Visible = true; Label_IPAddress.Text = ""; Label_VMList.Text = ""; //unique identifier or name for the server that is sending the request string testServerId = "Senior Project Xen Master Test"; //ip address of the sending server string testip = "172.16.10.76"; //info for the remote host we want to connect to //Host host = new Host("172.16.10.115", 29171); Host host = new Host(Textbox_IPAddress.Text, 29171); host.Name = "TCC9"; //Console.WriteLine(">>>>D'Mita Levy User Story 1: Senior Project<<<"); //Console.Write("Please Enter the Xen Host Ip: "); testip = Textbox_IPAddress.Text; Label_IPAddress.Text = ("Connecting to Xen Host: " + host.Ip + ":" + host.Port + "...<br>"); XenConnect master = new XenConnect(host, testServerId, testip); VirtualMachineList vms = master.getHostVirtualMachineList(); Label_IPAddress.Text = (Label_IPAddress.Text + "Retrieved host details " + master.getHost().ToString()) + "<br>"; Label_IPAddress.Text = (Label_IPAddress.Text + "Retrieving Virtual Machine List...<br>"); DataTable dt = new DataTable(); dt.Columns.Add("VMName", Type.GetType("System.String")); dt.Columns.Add("State", Type.GetType("System.String")); dt.Columns.Add("Vcpus", Type.GetType("System.String")); dt.Columns.Add("Max memory", Type.GetType("System.String")); using (SqlConnection con = new SqlConnection("CTAMConnectionString")) { using (SqlCommand cmd = new SqlCommand("VMStatus_AddStatus", con)) { foreach (VM vm in vms.Values) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@HostID", vm.Id); cmd.Parameters.AddWithValue("@HostName", vm.); cmd.Parameters.AddWithValue("@VMUUID", vm.UUID); cmd.Parameters.AddWithValue("@VMName", vm.Name); cmd.Parameters.AddWithValue("@OperatingSystem", vm.Os); cmd.Parameters.AddWithValue("@CPUTime", "123456"); cmd.Parameters.AddWithValue("@VMState", vm.State); cmd.Parameters.AddWithValue("@Memory", "TEst"); cmd.Parameters.AddWithValue("@MaxMemory", vm.MaxMem); cmd.Parameters.AddWithValue("@VirtualCPUS", vm.VCpus); cmd.Parameters.AddWithValue("@StatusCode", vm.Id); cmd.Parameters.AddWithValue("@Comments", vm.Id); con.Open(); cmd.ExecuteNonQuery(); } } } foreach (VM vm in vms.Values) { //Console.WriteLine("\t" + vm.ToString()); dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["VMName"] = vm.Name; dt.Rows[dt.Rows.Count - 1]["State"] = vm.PowerState; dt.Rows[dt.Rows.Count - 1]["Vcpus"] = vm.VCpus; dt.Rows[dt.Rows.Count - 1]["Max memory"] = vm.MaxMem; Label_VMList.Text = Label_VMList.Text + vm.ToString() + "<br>"; } GridView1.DataSource = dt; GridView1.DataBind(); //Console.WriteLine("Complete..."); }