Exemplo n.º 1
0
        private IEnumerable <SummaryDetails> GetVMMappingSummary()
        {
            //Use decorators to build a summary
            MappingSummary summary = new VMMappingSummary();

            foreach (KeyValuePair <string, VmMapping> pair in m_vmMappings)
            {
                if (HasTemplatesOnly)
                {
                    summary = new TemplateTitleSummary(summary, pair.Value);
                }
                else
                {
                    summary = new VmTitleSummary(summary, pair.Value);
                }

                summary = new DestinationPoolSummary(summary, pair.Value, TargetConnection);
                summary = new TargetServerSummary(summary, pair.Value, TargetConnection);
                summary = new TransferNetworkSummary(summary, m_pageTransferNetwork.NetworkUuid.Value);
                summary = new StorageSummary(summary, pair.Value, xenConnection);
                summary = new NetworkSummary(summary, pair.Value, xenConnection);
                summary = new SummarySplitter(summary);
            }
            return(summary.Details);
        }
        public List <NetworkSummary> GetNetworks()
        {
            var list = new List <NetworkSummary>();

            // Default profile
            list.Add(new NetworkSummary()
            {
                Name = "Other network"
            });

            // Freenode
            list.Add(new NetworkSummary()
            {
                Name    = "FreeNode",
                Servers = new List <string>()
                {
                    "chat.freenode.net"
                }
            });

            foreach (var networkGroup in trackers.Where(t => t.Servers.Count > 0).GroupBy(t => t.Servers.First().Network.ToLowerInvariant()))
            {
                var summary = new NetworkSummary()
                {
                    Name     = networkGroup.First().Servers.First().Network,
                    Profiles = networkGroup.Select(p => p.LongName).ToList(),
                    Servers  = networkGroup.SelectMany(p => p.Servers).SelectMany(s => s.Servers).Select(s => s.ToLowerInvariant().Trim()).Distinct().ToList()
                };
                list.Add(summary);
            }

            return(list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// check if the speed is being checked, and if so check that its above the set minimum
        /// if the speed is NOT being checked, TRUE is returned
        /// </summary>
        /// <returns></returns>
        private Boolean isLinkSpeedOK(NetworkSummary vNS)
        {
            // if not checking link speed, then this is okay:
            if (!Properties.Settings.Default.LinkSpeedCheck)
            {
                return(true);
            }
            // check link speed:
            if (vNS.LinkSpeed < Properties.Settings.Default.LinkSpeedMin)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private String getNetworkName()
        {
            String networkName = null;
            VirtualMachineRuntimeInfo vmRuntimeInfo
                = (VirtualMachineRuntimeInfo)cb.getServiceUtil().GetDynamicProperty(
                      _virtualMachine, "runtime");
            ManagedObjectReference envBrowser
                = (ManagedObjectReference)cb.getServiceUtil().GetDynamicProperty(
                      _virtualMachine, "environmentBrowser");
            ManagedObjectReference hmor = vmRuntimeInfo.host;

            if (hmor != null)
            {
                ConfigTarget configTarget
                    = cb.getConnection()._service.QueryConfigTarget(envBrowser, null);
                if (configTarget.network != null)
                {
                    for (int i = 0; i < configTarget.network.Length; i++)
                    {
                        VirtualMachineNetworkInfo netInfo    = configTarget.network[i];
                        NetworkSummary            netSummary = netInfo.network;
                        if (netSummary.accessible)
                        {
                            if (netSummary.name.Equals(
                                    cb.get_option("value")))
                            {
                                networkName = netSummary.name;
                                break;
                            }
                        }
                    }
                    if (networkName == null)
                    {
                        Console.WriteLine("Specify the Correct Network Name");
                        return(null);
                    }
                }
                Console.WriteLine("network Name " + networkName);
                return(networkName);
            }
            else
            {
                Console.WriteLine("No Host is responsible to run this VM");
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set the selected network
        /// </summary>
        private void setNetwork()
        {
            Properties.Settings.Default.NetworkToCheck = cbNetwork.SelectedItem.ToString();
            Properties.Settings.Default.Save();

            btnSetNetwork.Text    = "Working...";
            btnSetNetwork.Enabled = false;
            cbNetwork.Enabled     = false;

            ComboboxItemCustom selectedItem = (ComboboxItemCustom)cbNetwork.SelectedItem;

            CheckNS = new NetworkSummary(Guid.Parse(selectedItem.Name));

            doMainTimerTick(true);

            cbNetwork.Enabled  = true;
            btnSetNetwork.Text = "Set Network Info";
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set initial values
        /// Used on startup and reset settings
        /// </summary>
        private void Initialise()
        {
            ProblemFound = false;

            CheckNS   = new NetworkSummary(Properties.Settings.Default.NetworkToCheck);
            CurrentNS = new NetworkSummary(Properties.Settings.Default.NetworkToCheck);

            SetFormValues();
            UpdateCurrentNetworkInfo();

            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged      += NetworkChange_NetworkAddressChanged;

            this.FormClosing                     += FrmMain_FormClosing;
            this.Resize                          += FrmMain_Resize;
            this.notifyIcon1.MouseClick          += NotifyIcon1_MouseClick;
            this.numLinkSpeedMin.KeyUp           += NumLinkSpeedMin_KeyUp;
            this.numCheckSecs.KeyUp              += NumCheckSecs_KeyUp;
            this.notifyIcon1.BalloonTipClicked   += NotifyIcon_BalloonTipClicked;
            this.soundPlayer1.FileChangeDetected += SoundPlayer1_FileChangeDetected;
            this.soundPlayer1.Volume              = 95;

            if (Properties.Settings.Default.StartMinimized)
            {
                this.WindowState = FormWindowState.Minimized;
                this.Hide();
                ShowInTaskbar = false;
            }

            if (IsUpdateAvailable())
            {
                lblUpdateAvailable.Visible = true;
            }

            doMainTimerTick(true); // do first pass to set the screen

            tmrMain.Interval = Properties.Settings.Default.CheckSeconds * 1000;
            tmrMain.Start();
        }
Exemplo n.º 7
0
        public VirtualMachineConfigSpec createVmConfigSpec(String vmName,

                                                           String datastoreName,

                                                           int diskSizeMB,

                                                           ManagedObjectReference computeResMor,

                                                           ManagedObjectReference hostMor)

        {
            ConfigTarget configTarget = getConfigTargetForHost(computeResMor, hostMor);

            VirtualDevice[] defaultDevices = getDefaultDevices(computeResMor, hostMor);

            VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();



            String networkName = null;

            if (configTarget.network != null)

            {
                for (int i = 0; i < configTarget.network.Length; i++)

                {
                    VirtualMachineNetworkInfo netInfo = configTarget.network[i];

                    NetworkSummary netSummary = netInfo.network;

                    if (netSummary.accessible)

                    {
                        networkName = netSummary.name;

                        break;
                    }
                }
            }

            ManagedObjectReference datastoreRef = null;

            if (datastoreName != null)

            {
                Boolean flag = false;

                for (int i = 0; i < configTarget.datastore.Length; i++)

                {
                    VirtualMachineDatastoreInfo vdsInfo = configTarget.datastore[i];

                    DatastoreSummary dsSummary = vdsInfo.datastore;

                    if (dsSummary.name.Equals(datastoreName))

                    {
                        flag = true;

                        if (dsSummary.accessible)

                        {
                            datastoreName = dsSummary.name;

                            datastoreRef = dsSummary.datastore;
                        }

                        else

                        {
                            throw new Exception("Specified Datastore is not accessible");
                        }

                        break;
                    }
                }

                if (!flag)

                {
                    throw new Exception("Specified Datastore is not Found");
                }
            }

            else

            {
                Boolean flag = false;

                for (int i = 0; i < configTarget.datastore.Length; i++)

                {
                    VirtualMachineDatastoreInfo vdsInfo = configTarget.datastore[i];

                    DatastoreSummary dsSummary = vdsInfo.datastore;

                    if (dsSummary.accessible)

                    {
                        datastoreName = dsSummary.name;

                        datastoreRef = dsSummary.datastore;

                        flag = true;

                        break;
                    }
                }

                if (!flag)

                {
                    throw new Exception("No Datastore found on host");
                }
            }

            String datastoreVolume = getVolumeName(datastoreName);

            VirtualMachineFileInfo vmfi = new VirtualMachineFileInfo();

            vmfi.vmPathName = datastoreVolume;

            configSpec.files = vmfi;

            // Add a scsi controller

            int diskCtlrKey = 1;

            VirtualDeviceConfigSpec scsiCtrlSpec = new VirtualDeviceConfigSpec();

            scsiCtrlSpec.operation = VirtualDeviceConfigSpecOperation.add;

            scsiCtrlSpec.operationSpecified = true;

            VirtualLsiLogicController scsiCtrl = new VirtualLsiLogicController();

            scsiCtrl.busNumber = 0;

            scsiCtrlSpec.device = scsiCtrl;

            scsiCtrl.key = diskCtlrKey;

            scsiCtrl.sharedBus = VirtualSCSISharing.noSharing;

            String ctlrType = scsiCtrl.GetType().Name;



            // Find the IDE controller

            VirtualDevice ideCtlr = null;

            for (int di = 0; di < defaultDevices.Length; di++)

            {
                if (defaultDevices[di].GetType().Name.Equals("VirtualIDEController"))

                {
                    ideCtlr = defaultDevices[di];

                    break;
                }
            }



            // Add a floppy

            VirtualDeviceConfigSpec floppySpec = new VirtualDeviceConfigSpec();

            floppySpec.operation = VirtualDeviceConfigSpecOperation.add;

            floppySpec.operationSpecified = true;

            VirtualFloppy floppy = new VirtualFloppy();

            VirtualFloppyDeviceBackingInfo flpBacking = new VirtualFloppyDeviceBackingInfo();

            flpBacking.deviceName = "/dev/fd0";

            floppy.backing = flpBacking;

            floppy.key = 3;

            floppySpec.device = floppy;



            // Add a cdrom based on a physical device

            VirtualDeviceConfigSpec cdSpec = null;



            if (ideCtlr != null)

            {
                cdSpec = new VirtualDeviceConfigSpec();

                cdSpec.operation = VirtualDeviceConfigSpecOperation.add;

                cdSpec.operationSpecified = true;

                VirtualCdrom cdrom = new VirtualCdrom();

                VirtualCdromIsoBackingInfo cdDeviceBacking = new VirtualCdromIsoBackingInfo();

                cdDeviceBacking.datastore = datastoreRef;

                cdDeviceBacking.fileName = datastoreVolume + "testcd.iso";

                cdrom.backing = cdDeviceBacking;

                cdrom.key = 20;

                cdrom.controllerKey = ideCtlr.key;

                cdrom.controllerKeySpecified = true;

                cdrom.unitNumberSpecified = true;

                cdrom.unitNumber = 0;

                cdSpec.device = cdrom;
            }



            // Create a new disk - file based - for the vm

            VirtualDeviceConfigSpec diskSpec = null;

            diskSpec = createVirtualDisk(datastoreName, diskCtlrKey, datastoreRef, diskSizeMB);



            // Add a NIC. the network Name must be set as the device name to create the NIC.

            VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec();

            if (networkName != null)

            {
                nicSpec.operation = VirtualDeviceConfigSpecOperation.add;

                nicSpec.operationSpecified = true;

                VirtualEthernetCard nic = new VirtualPCNet32();

                VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();

                nicBacking.deviceName = networkName;

                nic.addressType = "generated";

                nic.backing = nicBacking;

                nic.key = 4;

                nicSpec.device = nic;
            }



            var deviceConfigSpec = new List <VirtualDeviceConfigSpec>();

            deviceConfigSpec.Add(scsiCtrlSpec);

            deviceConfigSpec.Add(floppySpec);

            deviceConfigSpec.Add(diskSpec);

            deviceConfigSpec.Add(nicSpec);



            if (ideCtlr != null)

            {
                deviceConfigSpec.Add(cdSpec);
            }



            configSpec.deviceChange = deviceConfigSpec.ToArray();

            return(configSpec);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Main timer function for checking and processing network checks
        /// </summary>
        private void doMainTimerTick(Boolean vManualRefresh)
        {
            // dont do anything if the app is disabled, and not a manual refresh
            if (!Properties.Settings.Default.Enabled && !vManualRefresh)
            {
                return;
            }

            updateLastChecked();

            // if no network is selected, dont bother processing
            if (string.IsNullOrEmpty(Properties.Settings.Default.NetworkToCheck))
            {
                return;
            }

            // if the network change event is fired it sets this flag, update the network list here
            if (NetworkChanged)
            {
                NetworkChanged = false;
                FillNetworkList(Properties.Settings.Default.NetworkToCheck, NetworkConnectivityLevels.All);
            }

            try
            {
                CurrentNS = new NetworkSummary(Properties.Settings.Default.NetworkToCheck);
            }
            catch (Exception)
            {
                return;
            }

            // display current data
            UpdateCurrentNetworkInfo();

            // if a problem is found
            if (!CheckNS.Equals(CurrentNS) || !isLinkSpeedOK(CurrentNS))
            {
                ProblemFound = true;
                tmrMain.Stop();

                if (Properties.Settings.Default.PlaySound)
                {
                    soundPlayer1.StopSound();
                    soundPlayer1.PlaySound();
                }
                if (Properties.Settings.Default.ShowBalloon)
                {
                    ShowBalloon("Network Settings have Changed",
                                "Network " + Properties.Settings.Default.NetworkToCheck + " has Changed",
                                false, Properties.Settings.Default.CheckSeconds);
                }
                if (Properties.Settings.Default.ShowPopup)
                {
                    MessageBox.Show("Network " + Properties.Settings.Default.NetworkToCheck + " has Changed", "Detect Network Changes", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                notifyIcon1.Icon      = new System.Drawing.Icon(Application.StartupPath + @"\Icon_Problem.ico");
                lblState.Text         = "r"; // Webdings X / cross
                lblState.ForeColor    = Color.OrangeRed;
                btnSetNetwork.Enabled = true;
                btnSetNetwork.Text    = "Update Network Info";

                tmrMain.Start();
            }
            else
            {
                lblState.Text      = "a"; // Webdings tick
                lblState.ForeColor = Color.ForestGreen;

                // entries match = no problem (anymore)
                if (ProblemFound == true)
                {
                    ProblemFound     = false;
                    notifyIcon1.Icon = new System.Drawing.Icon(Application.StartupPath + @"\Icon.ico");
                }

                btnSetNetwork.Text = "Set Network Info";
            }
        }