Beispiel #1
0
        protected override void Run()
        {
            // Create the new network
            XenRef <XenAPI.Network> networkRef = XenAPI.Network.create(Session, newNetwork);

            PIF pifOnMaster = null;

            foreach (PIF thePif in selectedPifs)
            {
                Host host = thePif.Connection.Resolve <XenAPI.Host>(thePif.host);
                if (host == null)
                {
                    continue;
                }

                if (host.IsMaster())
                {
                    pifOnMaster = thePif;
                    break;
                }
            }

            Connection.ExpectDisruption = true;

            // Enable SR-IOV network on Pool Master
            RelatedTask = Network_sriov.async_create(Session, pifOnMaster.opaque_ref, networkRef);
            PollToCompletion(0, 100);

            // Enable SR-IOV network on Pool Slaves
            selectedPifs.Remove(pifOnMaster);
            foreach (PIF thePif in selectedPifs)
            {
                Network_sriov.create(Session, thePif.opaque_ref, networkRef);
            }
        }
Beispiel #2
0
        protected override void Run()
        {
            PIF pifOnMaster = null;

            if (selectedPifs.Count == 0)
            {
                return;
            }

            foreach (PIF thePif in selectedPifs)
            {
                Host host = thePif.Connection.Resolve <XenAPI.Host>(thePif.host);
                if (host == null)
                {
                    continue;
                }

                if (host.IsMaster())
                {
                    pifOnMaster = thePif;
                    break;
                }
            }
            Connection.ExpectDisruption = true;

            //Enable SR-IOV network on Pool requires enabling master first.
            if (pifOnMaster != null)
            {
                selectedPifs.Remove(pifOnMaster);
                selectedPifs.Insert(0, pifOnMaster);
            }

            int inc = 100 / selectedPifs.Count;
            int lo  = 0;

            // Create the new network
            XenRef <XenAPI.Network> networkRef = XenAPI.Network.create(Session, newNetwork);

            try
            {
                foreach (PIF thePif in selectedPifs)
                {
                    RelatedTask = Network_sriov.async_create(Session, thePif.opaque_ref, networkRef);
                    PollToCompletion(lo, lo + inc);
                    lo += inc;
                }
            }
            catch (Exception)
            {
                if (lo == 0)
                {
                    DestroyNetwork(networkRef);
                }
                throw;
            }
        }
Beispiel #3
0
        private void destroyPIFs()
        {
            foreach (PIF pif in PIFs)
            {
                if (pif.IsTunnelAccessPIF())
                {
                    // A tunnel access PIF is destroyed by destroying its tunnel.
                    // (Actually each network will have either all tunnel access PIFs (if
                    // it is a CHIN) or all regular PIFs (if it isn't), but we don't use
                    // that: we do it PIF-by-PIF).
                    foreach (Tunnel tunnel in Connection.ResolveAll(pif.tunnel_access_PIF_of))  // actually there will only ever be one
                    {
                        Tunnel.destroy(Session, tunnel.opaque_ref);
                    }
                }
                else
                {
                    if (!pif.physical)
                    {
                        if (pif.VLAN != -1)
                        {
                            VLAN.destroy(Session, pif.VLAN_master_of);
                        }

                        if (pif.IsSriovLogicalPIF())
                        {
                            Network_sriov.destroy(Session, pif.sriov_logical_PIF_of[0]);
                        }
                    }
                    else
                    {
                        // do we ever destroy physical pifs anyway? not sure this is something we need but here for completeness
                        PIF.forget(Session, pif.opaque_ref);
                    }
                }
            }
            PIFs = null;
        }
Beispiel #4
0
            private void Update()
            {
                _cellName.Value      = Pif.Name();
                _cellMac.Value       = Pif.MAC;
                _cellConnected.Value = Pif.Carrier() ? Messages.CONNECTED : Messages.DISCONNECTED;
                _cellSpeed.Value     = Pif.Carrier() ? Pif.Speed() : Messages.HYPHEN;
                _cellDuplex.Value    = Pif.Carrier() ? Pif.Duplex() : Messages.HYPHEN;

                var pifMetrics = Pif.PIFMetrics();

                _cellVendor.Value  = pifMetrics == null ? Messages.HYPHEN : pifMetrics.vendor_name;
                _cellDevice.Value  = pifMetrics == null ? Messages.HYPHEN : pifMetrics.device_name;
                _cellBusPath.Value = pifMetrics == null ? Messages.HYPHEN : pifMetrics.pci_bus_path;

                _cellFcoe.Value = Pif.FCoECapable().ToYesNoStringI18n();

                if (!Pif.SriovCapable())
                {
                    _cellSriov.Value = Messages.NO;
                }
                else if (!Pif.IsSriovPhysicalPIF())
                {
                    _cellSriov.Value = Messages.SRIOV_NETWORK_SHOULD_BE_CREATED;
                }
                else
                {
                    var networkSriov = Pif.Connection.Resolve(Pif.sriov_physical_PIF_of[0]);

                    if (networkSriov == null || networkSriov.requires_reboot)
                    {
                        _cellSriov.Value = Messages.HOST_NEEDS_REBOOT_ENABLE_SRIOV;
                        return;
                    }

                    PIF sriovLogicalPif = Pif.Connection.Resolve(networkSriov.logical_PIF);

                    if (sriovLogicalPif == null || !sriovLogicalPif.currently_attached)
                    {
                        _cellSriov.Value = Messages.SRIOV_LOGICAL_PIF_UNPLUGGED;
                        return;
                    }

                    var sriovSupported = "";
                    var action         = new DelegatedAsyncAction(Pif.Connection, "", "", "", delegate(Session session)
                    {
                        try
                        {
                            var remainingCapacity = Network_sriov.get_remaining_capacity(session, Pif.sriov_physical_PIF_of[0].opaque_ref);
                            sriovSupported        = string.Format(Messages.REMAINING_VFS, remainingCapacity);
                        }
                        catch
                        {
                            sriovSupported = Messages.YES;
                        }
                    },
                                                                  true);

                    action.Completed += delegate
                    {
                        Program.Invoke(Program.MainWindow, () => _cellSriov.Value = sriovSupported);
                    };
                    action.RunAsync();
                }
            }
Beispiel #5
0
            private void updateCell(int index)
            {
                switch (index)
                {
                case 0:
                    Cells[0].Value = pif.Name();
                    break;

                case 1:
                    Cells[1].Value = pif.MAC;
                    break;

                case 2:
                    Cells[2].Value = pif.Carrier() ? Messages.CONNECTED : Messages.DISCONNECTED;
                    break;

                case 3:
                    Cells[3].Value = pif.Carrier() ? pif.Speed() : Messages.HYPHEN;
                    break;

                case 4:
                    Cells[4].Value = pif.Carrier() ? pif.Duplex() : Messages.HYPHEN;
                    break;

                case 5:
                    Cells[5].Value = vendor;
                    break;

                case 6:
                    Cells[6].Value = device;
                    break;

                case 7:
                    Cells[7].Value = busPath;
                    break;

                case 8:
                    Cells[8].Value = pif.FCoECapable().ToYesNoStringI18n();
                    break;

                case 9:
                    string sriovSupported = "";
                    if (!pif.SriovCapable() || !pif.IsSriovPhysicalPIF())
                    {
                        sriovSupported = !pif.SriovCapable() ? Messages.NO : Messages.SRIOV_DISABLED;
                        Cells[9].Value = sriovSupported;
                    }
                    else
                    {
                        DelegatedAsyncAction action = new DelegatedAsyncAction(pif.Connection,
                                                                               "", "", "",
                                                                               delegate(Session session)
                        {
                            try
                            {
                                var remainingCapacity = Network_sriov.get_remaining_capacity(session, pif.sriov_physical_PIF_of[0].opaque_ref);
                                sriovSupported        = string.Format(Messages.REAMININF_VFS, remainingCapacity);
                            }
                            catch
                            {
                                sriovSupported = Messages.YES;
                            }
                        },
                                                                               true);

                        action.Completed += delegate
                        {
                            Program.Invoke(Program.MainWindow, delegate { Cells[9].Value = sriovSupported; });
                        };
                        action.RunAsync();
                    }

                    break;
                }
            }