Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
            }
        }