Esempio n. 1
0
 public ApplyLicenseAction(Network.IXenConnection connection, Host host, string filepath, bool activateFreeLicense)
     : base(connection, string.Format(Messages.APPLYLICENSE_TITLE, host.Name), Messages.APPLYLICENSE_PREP)
 {
     this.Host = host;
     this.Filepath = filepath;
     this.ActivateFreeLicense = activateFreeLicense;
 }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="pool">May be null.</param>
        /// <param name="host">Never null. In the case of a pool, "host" is set to the master.</param>
        public NewNetworkWizard(Network.IXenConnection connection, Pool pool, Host host)
            : base(connection)
        {
            InitializeComponent();

            pageNetworkType = new NetWTypeSelect();
            pageName = new NetWName();
            pageNetworkDetails = new NetWDetails();
            pageBondDetails = new NetWBondDetails();
            pageChinDetails = new NetWChinDetails();

            System.Diagnostics.Trace.Assert(host != null);
            Pool = pool;
            Host = host;

            if (Pool != null)
                pageBondDetails.SetPool(Pool);
            else
                pageBondDetails.SetHost(Host);

            pageNetworkDetails.Host = host;
            pageChinDetails.Host = host;
            pageChinDetails.Pool = pool;

            AddPage(pageNetworkType);
            AddPage(new XenTabPage { Text = "" });
        }
Esempio n. 3
0
 private Network GetNetwork()
 {
     Network network = new Network();
     network.name_label = System.Guid.NewGuid().ToString();
     network.name_description = "test descript";
     return network;
 }
Esempio n. 4
0
 public CreateChinAction(IXenConnection connection, XenAPI.Network newNetwork, XenAPI.Network theInterface)
     : base(connection,
         string.Format(Messages.NETWORK_ACTION_CREATING_NETWORK_TITLE, newNetwork.Name, Helpers.GetName(connection)))
 {
     this.newNetwork = newNetwork;
     this.theInterface = theInterface;
 }
 public VMCrossPoolMigrateAction(VM vm, Host destinationHost, XenAPI.Network transferNetwork, VmMapping mapping)
     : base(vm.Connection, GetTitle(vm, destinationHost))
 {
     Session = vm.Connection.Session;
     Description = Messages.ACTION_PREPARING;
     VM = vm;
     Host = destinationHost;
     Pool = Helpers.GetPool(vm.Connection);
     this.mapping = mapping;
     this.transferNetwork = transferNetwork;
 }
Esempio n. 6
0
        public void SetXenObjects(IXenObject orig, IXenObject clone)
        {
            network = clone as XenAPI.Network;
            if (network == null)
                return;

            // use the pif of the master to populate the controls. We use it later in the create_VLAN_from_PIF call in Network Action
            host = Helpers.GetMaster(network.Connection);
            
            Repopulate();
            EnableDisable();
        }
Esempio n. 7
0
        /// <summary>
        /// Create an external (VLAN) network.
        /// </summary>
        /// <param name="network">A new Network instance describing the changes to be made on the server side.</param>
        /// <param name="pif">The PIF representing the physical NIC from which we're basing our new VLAN.</param>
        /// <param name="vlan">The new VLAN tag.</param>
        public NetworkAction(IXenConnection connection, XenAPI.Network network, PIF pif, long vlan)
            : base(connection, string.Format(Messages.NETWORK_ACTION_CREATING_NETWORK_TITLE, network.Name,
            Helpers.GetName(connection)))
        {
            actionType = network_actions.create;
            this.networkClone = network;
            this.pif = pif;
            this.vlan = vlan;
            this.external = true;
            this.PIFs = null;

            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("network.create");
            ApiMethodsToRoleCheck.Add("pool.create_VLAN_from_PIF");
            #endregion

            init();
        }
Esempio n. 8
0
            public NetworkRow(XenAPI.Network network, IXenObject xmo)
            {
                Network = network;
                Xmo     = xmo;

                Cells.AddRange(ImageCell,
                               NameCell,
                               DescriptionCell,
                               NicCell,
                               VlanCell,
                               AutoCell,
                               LinkStatusCell,
                               MacCell,
                               MtuCell);

                Network.PropertyChanged += Server_PropertyChanged;

                Program.Invoke(Program.MainWindow, UpdateDetails);
            }
Esempio n. 9
0
 /// <summary>
 /// Nothrow guarantee.
 /// </summary>
 /// <param name="network"></param>
 /// <param name="new_bonds"></param>
 private void UnlockAll(XenAPI.Network network, List <NewBond> new_bonds)
 {
     if (network != null)
     {
         network.Locked = false;
         foreach (NewBond newbond in new_bonds)
         {
             newbond.master.Locked = false;
             newbond.bond.Locked   = false;
         }
     }
     foreach (Host host in PIFs.Keys)
     {
         foreach (PIF pif in PIFs[host])
         {
             pif.Locked = false;
         }
     }
 }
Esempio n. 10
0
 private bool ShowNetwork(XenAPI.Network network)
 {
     if (network.IsGuestInstallerNetwork)
     {
         return(false);
     }
     if (network.IsInUseBondSlave)
     {
         return(false);
     }
     if ((this.selected_host != null) && !HalsignHelpers.hostCanSeeNetwork(selected_host, network))
     {
         return(false);
     }
     if ((this.selected_host == null) && !HalsignHelpers.allHostsCanSeeNetwork(network))
     {
         return(false);
     }
     return(true);
 }
Esempio n. 11
0
        /// <summary>
        /// Create or destroy a private network.
        /// </summary>
        public NetworkAction(IXenConnection connection, XenAPI.Network network, bool create)
            : base(connection,
                   string.Format(create ? Messages.NETWORK_ACTION_CREATING_NETWORK_TITLE : Messages.NETWORK_ACTION_REMOVING_NETWORK_TITLE,
                                 network.Name(), Helpers.GetName(connection)))
        {
            this.networkClone = network;
            this.external     = false;

            if (create)
            {
                #region RBAC Dependencies

                ApiMethodsToRoleCheck.Add("network.create");

                #endregion
                actionType = network_actions.create;
                PIFs       = null;
            }
            else
            {
                PIFs = Connection.ResolveAll(network.PIFs);
                #region RBAC Dependencies
                ApiMethodsToRoleCheck.Add("network.destroy");
                if (PIFs.Find(p => p.IsTunnelAccessPIF()) != null)
                {
                    ApiMethodsToRoleCheck.Add("tunnel.destroy");
                }
                if (PIFs.Find(p => !p.IsTunnelAccessPIF() && p.physical) != null)
                {
                    ApiMethodsToRoleCheck.Add("pif.forget");  // actually, we should have at most one of tunnel.destroy and pif.forget
                }
                if (PIFs.Find(p => !p.IsTunnelAccessPIF() && !p.physical) != null)
                {
                    ApiMethodsToRoleCheck.Add("vlan.destroy");  // same here, shouldn't be both virtual and physcial really
                }
                #endregion
                actionType = network_actions.destroy;
            }

            init();
        }
Esempio n. 12
0
        string CreateNetwork(int lo, int hi)
        {
            log.DebugFormat("Creating network {0}...", name_label);

            XenAPI.Network network = new XenAPI.Network();
            network.name_label = name_label;
            network.AutoPlug   = autoplug;
            network.MTU        = mtu;
            if (network.other_config == null)
            {
                network.other_config = new Dictionary <string, string>();
            }
            network.other_config[XenAPI.Network.CREATE_IN_PROGRESS] = "true";

            RelatedTask = XenAPI.Network.async_create(Session, network);
            PollToCompletion(lo, hi);

            log.DebugFormat("Created network {0} as {1}.", name_label, Result);

            return(Result);
        }
Esempio n. 13
0
        protected override bool AllowSriovNetwork(XenAPI.Network network, string sysId)
        {
            if (sysId == null)
            {
                return(false);
            }

            VM vm = Connection.Resolve(new XenRef <VM>(sysId));

            if (vm == null)
            {
                return(false);
            }

            if (vm.power_state != vm_power_state.Halted)
            {
                return(false);
            }

            return(vm.HasSriovRecommendation());
        }
Esempio n. 14
0
        public UnplugPlugNetworkAction(XenAPI.Network network, bool suppressHistory)
            : base(network.Connection, Messages.ACTION_PIF_UNPLUG_PLUG_TITLE, Messages.ACTION_PIF_UNPLUG_PLUG_DESC, suppressHistory)
        {
            PIFs = Connection.ResolveAll <PIF>(network.PIFs);
            PIFs.RemoveAll(delegate(PIF p) { return(!p.currently_attached); });
            VIFs = Connection.ResolveAll <VIF>(network.VIFs);
            VIFs.RemoveAll(delegate(VIF v)
            {
                if (!v.currently_attached)
                {
                    return(true);
                }
                VM vm = v.Connection.Resolve(v.VM);
                if (vm == null || vm.power_state != vm_power_state.Running)      // we only replug running VMs
                {
                    return(true);
                }
                return(false);
            });

            network.Locked = true;
            foreach (PIF p in PIFs)
            {
                p.Locked = true;
            }
            foreach (VIF v in VIFs)
            {
                v.Locked = true;
            }

            #region RBAC
            ApiMethodsToRoleCheck.Add("pif.async_unplug");
            ApiMethodsToRoleCheck.Add("pif.async_plug");
            ApiMethodsToRoleCheck.Add("vif.async_plug");
            ApiMethodsToRoleCheck.Add("vif.async_unplug");
            #endregion
            Pool = Helpers.GetPool(Connection);

            this.network = network;
        }
Esempio n. 15
0
        private void CreateNonBonded()
        {
            XenAPI.Network network = PopulateNewNetworkObj();

            PIF nic;

            if (pageNetworkDetails.CreateVlanOnSriovNetwork)
            {
                if (pageNetworkDetails.SelectedHostNic == null || !pageNetworkDetails.SelectedHostNic.IsSriovPhysicalPIF())
                {
                    return;
                }

                var sriovPhysicalPif = xenConnection.Resolve(pageNetworkDetails.SelectedHostNic.sriov_physical_PIF_of[0]);
                if (sriovPhysicalPif == null)
                {
                    return;
                }

                nic = xenConnection.Resolve(sriovPhysicalPif.logical_PIF);
                if (nic == null)
                {
                    return;
                }
            }
            else
            {
                nic = pageNetworkDetails.SelectedHostNic;
            }


            long vlan = pageNetworkDetails.VLAN;

            NetworkAction action = pageNetworkType.SelectedNetworkType == NetworkTypes.External
                                       ? new NetworkAction(xenConnection, network, nic, vlan)
                                       : new NetworkAction(xenConnection, network, true);

            action.RunAsync();
        }
Esempio n. 16
0
        private bool ShowNetwork(XenAPI.Network network)
        {
            if (network.IsGuestInstallerNetwork)
            {
                return(false);
            }
            if (network.IsInUseBondSlave)
            {
                return(false);
            }

            Host temp_host = null;

            if (this._xenModelObject is VM)
            {
                VM _xenVM = this._xenModelObject as VM;
                temp_host = HalsignHelpers.VMHome(_xenVM);
            }
            else if (this._xenModelObject is Host)
            {
                temp_host = _xenModelObject as Host;
            }
            else
            {
                temp_host = Helpers.GetMaster(this._xenModelObject.Connection);
            }

            if ((temp_host != null) && !HalsignHelpers.hostCanSeeNetwork(temp_host, network))
            {
                return(false);
            }
            if ((temp_host == null) && !HalsignHelpers.allHostsCanSeeNetwork(network))
            {
                return(false);
            }
            return(true);
        }
        private bool ShowNetwork(Host targetHost, XenAPI.Network network)
        {
            if (!network.Show(Properties.Settings.Default.ShowHiddenVMs))
            {
                return(false);
            }

            if (network.IsSlave)
            {
                return(false);
            }

            if (targetHost != null && !targetHost.CanSeeNetwork(network))
            {
                return(false);
            }

            if (targetHost == null && !network.AllHostsCanSeeNetwork)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 18
0
        /// <summary>
        /// Function tells you when you can / cannot show the network based on the following rules
        /// 1) Don't show the guest installer network or networks with HideFromXenCenter==true.
        /// 2) If you selected an affinity, only show networks that host can see
        /// 3) If you haven't selected an affinity, only show networks all hosts can see
        /// </summary>
        private bool ShowNetwork(XenAPI.Network network)
        {
            if (!network.Show(Properties.Settings.Default.ShowHiddenVMs))
            {
                return(false);
            }

            if (network.IsSlave)
            {
                return(false);
            }

            if (m_selectedAffinity != null && !m_selectedAffinity.CanSeeNetwork(network))
            {
                return(false);
            }

            if (m_selectedAffinity == null && !network.AllHostsCanSeeNetwork)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 19
0
        private void NetworkComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;

            XenAPI.Network network =
                (XenAPI.Network)(e.Index == -1 ? NetworkComboBox.SelectedItem : NetworkComboBox.Items[e.Index]);

            if (network == null)
            {
                return;
            }

            string purpose = FindOtherPurpose(network);
            string label   =
                purpose == null || purpose == Purpose?
                network.ToString() :
                    string.Format(Messages.NETWORK_IN_USE_BY, network.ToString(), purpose);

            Brush text_brush = (e.State & DrawItemState.Selected) > 0 ? SystemBrushes.HighlightText : SystemBrushes.ControlText;

            e.DrawBackground();
            g.DrawString(label, Program.DefaultFont, text_brush, new PointF(e.Bounds.X + 1, e.Bounds.Y + 1));
            e.DrawFocusRectangle();
        }
Esempio n. 20
0
            public NetworkRow(XenAPI.Network network, IXenObject xmo)
            {
                Network = network;
                Xmo     = xmo;

                Cells.AddRange(ImageCell,
                               NameCell,
                               DescriptionCell,
                               NicCell,
                               VlanCell,
                               AutoCell,
                               LinkStatusCell,
                               MacCell);

                // add MTU to grid view on Network tab for pools and hosts, for Cowley or greater only (CA-45643)
                if (Helpers.CowleyOrGreater(Xmo.Connection))
                {
                    Cells.Add(this.MtuCell);
                }

                Network.PropertyChanged += Server_PropertyChanged;

                Program.Invoke(Program.MainWindow, UpdateDetails);
            }
Esempio n. 21
0
        internal void RefreshNetworkComboBox(Dictionary <XenAPI.Network, List <NetworkingPropertiesPage> > InUseMap, XenAPI.Network ManagementNetwork, bool AllowManagementOnVLAN)
        {
            this.InUseMap          = InUseMap;
            this.ManagementNetwork = ManagementNetwork;

            XenAPI.Network selected = (XenAPI.Network)NetworkComboBox.SelectedItem;

            List <XenAPI.Network> networks = new List <XenAPI.Network>(InUseMap.Keys);

            networks.Sort();
            NetworkComboBox.Items.Clear();

            if (!AllowManagementOnVLAN && (type == Type.PRIMARY || type == Type.PRIMARY_WITH_HA))
            {
                networks.RemoveAll(network => network.IsVLAN());
            }

            networks.RemoveAll(network => network.IsSriov());

            NetworkComboBox.Items.AddRange(networks.ToArray());

            SquelchNetworkComboBoxChange = true;
            try
            {
                NetworkComboBox.SelectedItem = selected;
            }
            finally
            {
                SquelchNetworkComboBoxChange = false;
            }

            if (!TriggeringChange)
            {
                RefreshButtons();
            }
        }
Esempio n. 22
0
        protected override void Run()
        {
            SafeToExit = false;
            bool isTemplate;

            try
            {
                string vmRef;

                if (m_filename.EndsWith("ova.xml"))                //importing version 1 from of VM
                {
                    m_filename = m_filename.Replace("ova.xml", "");
                    vmRef      = GetVmRef(applyVersionOneFiles());
                }
                else                //importing current format of VM
                {
                    vmRef = GetVmRef(applyFile());
                }

                if (Cancelling)
                {
                    throw new CancelledException();
                }

                // Now lets try and set the affinity and start the VM

                if (string.IsNullOrEmpty(vmRef))
                {
                    return;
                }

                while (!Cancelling && (VM = Connection.Resolve(new XenRef <VM>(vmRef))) == null)
                {
                    Thread.Sleep(100);
                }

                if (Cancelling)
                {
                    throw new CancelledException();
                }

                isTemplate = VM.get_is_a_template(Session, vmRef);
                if (isTemplate && Helpers.FalconOrGreater(Connection) && VM.get_is_default_template(Session, vmRef))
                {
                    var otherConfig = VM.get_other_config(Session, vmRef);
                    if (!otherConfig.ContainsKey(IMPORT_TASK) || otherConfig[IMPORT_TASK] != RelatedTask.opaque_ref)
                    {
                        throw new Exception(Messages.IMPORT_TEMPLATE_ALREADY_EXISTS);
                    }
                }

                Description = isTemplate ? Messages.IMPORT_TEMPLATE_UPDATING_TEMPLATE : Messages.IMPORTVM_UPDATING_VM;
                VM.set_name_label(Session, vmRef, DefaultVMName(VM.get_name_label(Session, vmRef)));

                if (!isTemplate && m_affinity != null)
                {
                    VM.set_affinity(Session, vmRef, m_affinity.opaque_ref);
                }

                // Wait here for the wizard to finish
                Description = isTemplate ? Messages.IMPORT_TEMPLATE_WAITING_FOR_WIZARD : Messages.IMPORTVM_WAITING_FOR_WIZARD;
                lock (monitor)
                {
                    while (!(m_wizardDone || Cancelling))
                    {
                        Monitor.Wait(monitor);
                    }
                }

                if (Cancelling)
                {
                    throw new CancelledException();
                }

                if (m_proxyVIFs != null)
                {
                    Description = isTemplate ? Messages.IMPORT_TEMPLATE_UPDATING_NETWORKS : Messages.IMPORTVM_UPDATING_NETWORKS;

                    // For ElyOrGreater hosts, we can move the VIFs to another network,
                    // but for older hosts we need to destroy all vifs and recreate them

                    List <XenRef <VIF> >  vifs     = VM.get_VIFs(Session, vmRef);
                    List <XenAPI.Network> networks = new List <XenAPI.Network>();

                    bool canMoveVifs = Helpers.ElyOrGreater(Connection);

                    foreach (XenRef <VIF> vif in vifs)
                    {
                        // Save the network as we may have to delete it later
                        XenAPI.Network network = Connection.Resolve(VIF.get_network(Session, vif));
                        if (network != null)
                        {
                            networks.Add(network);
                        }

                        if (canMoveVifs)
                        {
                            var vifObj = Connection.Resolve(vif);
                            if (vifObj == null)
                            {
                                continue;
                            }
                            // try to find a matching VIF in the m_proxyVIFs list, based on the device field
                            var matchingProxyVif = m_proxyVIFs.FirstOrDefault(proxyVIF => proxyVIF.device == vifObj.device);
                            if (matchingProxyVif != null)
                            {
                                // move the VIF to the desired network
                                VIF.move(Session, vif, matchingProxyVif.network);
                                // remove matchingProxyVif from the list, so we don't create the VIF again later
                                m_proxyVIFs.Remove(matchingProxyVif);
                                continue;
                            }
                        }
                        // destroy the VIF, if we haven't managed to move it
                        VIF.destroy(Session, vif);
                    }

                    // recreate VIFs if needed (m_proxyVIFs can be empty, if we moved all the VIFs in the previous step)
                    foreach (Proxy_VIF proxyVIF in m_proxyVIFs)
                    {
                        VIF vif = new VIF(proxyVIF)
                        {
                            VM = new XenRef <VM>(vmRef)
                        };
                        VIF.create(Session, vif);
                    }

                    // now delete any Networks associated with this task if they have no VIFs

                    foreach (XenAPI.Network network in networks)
                    {
                        if (!network.other_config.ContainsKey(IMPORT_TASK))
                        {
                            continue;
                        }

                        if (network.other_config[IMPORT_TASK] != RelatedTask.opaque_ref)
                        {
                            continue;
                        }

                        try
                        {
                            if (XenAPI.Network.get_VIFs(Session, network.opaque_ref).Count > 0)
                            {
                                continue;
                            }

                            if (XenAPI.Network.get_PIFs(Session, network.opaque_ref).Count > 0)
                            {
                                continue;
                            }

                            XenAPI.Network.destroy(Session, network.opaque_ref);
                        }
                        catch (Exception e)
                        {
                            log.ErrorFormat("Exception while deleting network {0}. Squashing.", network.Name());
                            log.Error(e, e);
                        }
                    }
                }

                if (!VM.get_is_a_template(Session, vmRef))
                {
                    if (m_startAutomatically)
                    {
                        Description = Messages.IMPORTVM_STARTING;
                        VM.start(Session, vmRef, false, false);
                    }
                }
            }
            catch (CancelledException)
            {
                Description = Messages.CANCELLED_BY_USER;
                throw;
            }

            Description = isTemplate ? Messages.IMPORT_TEMPLATE_IMPORTCOMPLETE : Messages.IMPORTVM_IMPORTCOMPLETE;
        }
Esempio n. 23
0
            public NetworkRow(XenAPI.Network network, IXenObject xmo)
            {
                Network = network;
                Xmo = xmo;

                Cells.AddRange(ImageCell,
                               NameCell,
                               DescriptionCell,
                               NicCell,
                               VlanCell,
                               AutoCell,
                               LinkStatusCell,
                               MacCell);

                // add MTU to grid view on Network tab for pools and hosts, for Cowley or greater only (CA-45643)
                if (Helpers.CowleyOrGreater(Xmo.Connection))
                    Cells.Add(this.MtuCell);
                
                Network.PropertyChanged += Server_PropertyChanged;

                Program.Invoke(Program.MainWindow, UpdateDetails);
            }
Esempio n. 24
0
        public static Icons GetIconFor(IXenObject o)
        {
            VM vm = o as VM;

            if (vm != null)
            {
                return(GetIconFor(vm));
            }

            VM_appliance appl = o as VM_appliance;

            if (appl != null)
            {
                return(GetIconFor(appl));
            }

            SR sr = o as SR;

            if (sr != null)
            {
                return(GetIconFor(sr));
            }

            Host host = o as Host;

            if (host != null)
            {
                return(GetIconFor(host));
            }

            Pool pool = o as Pool;

            if (pool != null)
            {
                return(GetIconFor(pool));
            }

            XenAPI.Network network = o as XenAPI.Network;
            if (network != null)
            {
                return(GetIconFor(network));
            }

            VDI vdi = o as VDI;

            if (vdi != null)
            {
                return(GetIconFor(vdi));
            }

            VBD vbd = o as VBD;

            if (vbd != null)
            {
                return(GetIconFor(vbd));
            }

            Folder folder = o as Folder;

            if (folder != null)
            {
                return(GetIconFor(folder));
            }

            PIF pif = o as PIF;

            if (pif != null)
            {
                return(GetIconFor(pif));
            }

            StorageLinkServer storageLinkServer = o as StorageLinkServer;

            if (storageLinkServer != null)
            {
                return(GetIconFor(storageLinkServer));
            }

            StorageLinkSystem storageLinkSystem = o as StorageLinkSystem;

            if (storageLinkSystem != null)
            {
                return(GetIconFor(storageLinkSystem));
            }

            StorageLinkPool storageLinkPool = o as StorageLinkPool;

            if (storageLinkPool != null)
            {
                return(GetIconFor(storageLinkPool));
            }

            StorageLinkVolume storageLinkVolume = o as StorageLinkVolume;

            if (storageLinkVolume != null)
            {
                return(GetIconFor(storageLinkVolume));
            }

            StorageLinkRepository storageLinkRepository = o as StorageLinkRepository;

            if (storageLinkRepository != null)
            {
                return(GetIconFor(storageLinkRepository));
            }

            System.Diagnostics.Trace.Assert(false,
                                            "You asked for an icon for a type I don't recognise!");

            return(Icons.XenCenter);
        }
Esempio n. 25
0
        public UnplugPlugNetworkAction(XenAPI.Network network, bool suppressHistory)
            : base(network.Connection, Messages.ACTION_PIF_UNPLUG_PLUG_TITLE, Messages.ACTION_PIF_UNPLUG_PLUG_DESC, suppressHistory)
        {
            PIFs = Connection.ResolveAll<PIF>(network.PIFs);
            PIFs.RemoveAll(delegate(PIF p) { return !p.currently_attached; });
            VIFs = Connection.ResolveAll<VIF>(network.VIFs);
            VIFs.RemoveAll(delegate(VIF v)
                {
                    if (!v.currently_attached)
                        return true;
                    VM vm = v.Connection.Resolve(v.VM);
                    if (vm == null || vm.power_state != vm_power_state.Running)  // we only replug running VMs
                        return true;
                    return false;
                });

            network.Locked = true;
            foreach (PIF p in PIFs)
                p.Locked = true;
            foreach (VIF v in VIFs)
                v.Locked = true;

            #region RBAC
            ApiMethodsToRoleCheck.Add("pif.async_unplug");
            ApiMethodsToRoleCheck.Add("pif.async_plug");
            ApiMethodsToRoleCheck.Add("vif.async_plug");
            ApiMethodsToRoleCheck.Add("vif.async_unplug");
            #endregion
            Pool = Helpers.GetPool(Connection);

            this.network = network;
        }
Esempio n. 26
0
        /// <summary>
        /// scan each ip address (from the guest agent) for an open port
        /// </summary>
        /// <param name="port"></param>
        public String PollPort(int port, bool vnc)
        {
            try
            {
                if (Source == null)
                {
                    return(null);
                }

                VM vm = Source;

                XenRef <VM_guest_metrics> guestMetricsRef = vm.guest_metrics;
                if (guestMetricsRef == null || Helper.IsNullOrEmptyOpaqueRef(guestMetricsRef.opaque_ref))
                {
                    return(null);
                }

                VM_guest_metrics metrics = vm.Connection.Resolve(guestMetricsRef);
                if (metrics == null)
                {
                    return(null);
                }
                Dictionary <string, string> networks = metrics.networks;

                if (networks == null)
                {
                    return(null);
                }

                List <string> ipAddresses   = new List <string>();
                List <string> ipv6Addresses = new List <string>();

                foreach (VIF vif in vm.Connection.ResolveAll(vm.VIFs))
                {
                    XenAPI.Network network = vif.Connection.Resolve(vif.network);
                    XenAPI.Host    host    = vm.Connection.Resolve(vm.resident_on);
                    XenAPI.PIF     pif     = Helpers.FindPIF(network, host);
                    if (pif != null && pif.LinkStatus == PIF.LinkState.Connected)
                    {
                        foreach (var networkInfo in networks.Where(n => n.Key.StartsWith(String.Format("{0}/ip", vif.device))))
                        {
                            if (networkInfo.Key.EndsWith("ip")) // IPv4 address
                            {
                                ipAddresses.Add(networkInfo.Value);
                            }
                            else
                            {
                                if (networkInfo.Key.Contains("ipv6")) // IPv6 address, enclose in square brackets
                                {
                                    ipv6Addresses.Add(String.Format("[{0}]", networkInfo.Value));
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }

                ipAddresses.AddRange(ipv6Addresses); // make sure IPv4 addresses are scanned first (CA-102755)

                foreach (String ipAddress in ipAddresses)
                {
                    try
                    {
                        Log.DebugFormat("Poll port {0}:{1}", ipAddress, port);
                        Stream s = connectGuest(ipAddress, port, vm.Connection);
                        if (vnc)
                        {
                            Log.DebugFormat("Connected. Set Pending Vnc connection {0}:{1}", ipAddress, port);
                            SetPendingVNCConnection(s);
                        }
                        else
                        {
                            s.Close();
                        }
                        return(ipAddress);
                    }
                    catch (Exception exn)
                    {
                        Log.Debug(exn);
                    }
                }
            }
            catch (WebException)
            {
                // xapi has gone away.
            }
            catch (IOException)
            {
                // xapi has gone away.
            }
            catch (Failure exn)
            {
                if (exn.ErrorDescription[0] == Failure.HANDLE_INVALID)
                {
                    // HANDLE_INVALID is fine -- the guest metrics are not there yet.
                }
                else if (exn.ErrorDescription[0] == Failure.SESSION_INVALID)
                {
                    // SESSION_INVALID is fine -- these will expire from time to time.
                    // We need to invalidate the session though.
                    lock (activeSessionLock)
                    {
                        activeSession = null;
                    }
                }
                else
                {
                    Log.Warn("Exception while polling VM for port " + port + ".", exn);
                }
            }
            catch (Exception e)
            {
                Log.Warn("Exception while polling VM for port " + port + ".", e);
            }
            return(null);
        }
Esempio n. 27
0
 public VMCannotSeeNetwork(Check check,  VM vm, XenAPI.Network network)
     : base(check,  vm)
 {
     Network = network;
 }
Esempio n. 28
0
        private Problem GetProblem(IXenConnection connection, XenRef <VM> vmRef, string[] exception)
        {
            try
            {
                System.Diagnostics.Trace.Assert(exception.Length > 0);

                var vm = connection.Resolve <VM>(vmRef);

                if (vm == null)
                {
                    throw new NullReferenceException(exception[0]);
                }

                switch (exception[0])
                {
                case Failure.VM_REQUIRES_SR:
                    XenRef <SR> srRef = new XenRef <SR>(exception[2]);
                    SR          sr    = connection.Resolve <SR>(srRef);

                    if (sr == null)
                    {
                        throw new NullReferenceException(Failure.VM_REQUIRES_SR);
                    }

                    if (sr.content_type == SR.Content_Type_ISO)
                    {
                        return(new LocalCD(this, vm));
                    }
                    else if (!sr.shared)
                    {
                        // Only show the problem if it is really local storage
                        // As the pbd-plug checks will pick up broken storage.
                        return(new LocalStorage(this, vm));
                    }

                    return(null);

                case Failure.VM_MISSING_PV_DRIVERS:
                    return(new NoPVDrivers(this, vm));

                case Failure.VM_LACKS_FEATURE:
                    return(new CannotMigrateVM(this, vm, GetMoreSpecificReasonForCannotMigrateVm(vm, CannotMigrateVM.CannotMigrateVMReason.CannotMigrateVm)));

                case Failure.VM_LACKS_FEATURE_SUSPEND:
                    return(new CannotMigrateVM(this, vm, GetMoreSpecificReasonForCannotMigrateVm(vm, CannotMigrateVM.CannotMigrateVMReason.LacksFeatureSuspend)));

                case Failure.VM_HAS_PCI_ATTACHED:
                    return(new CannotMigrateVM(this, vm, GetMoreSpecificReasonForCannotMigrateVm(vm, CannotMigrateVM.CannotMigrateVMReason.HasPCIAttached)));

                case "VM_OLD_PV_DRIVERS":
                    return(new PVDriversOutOfDate(this, vm));

                case Failure.NO_HOSTS_AVAILABLE:
                    //CA-63531: Boston server will come here in case of single host pool or standalone host
                    return(new NoHosts(this, vm));

                case Failure.HOST_NOT_ENOUGH_FREE_MEMORY:
                    Pool pool = Helpers.GetPool(vm.Connection);

                    if (pool == null || pool.Connection.Cache.HostCount == 1)
                    {
                        //CA-63531: Cowley server will come here in case of single host pool or standalone host
                        return(new NoHosts(this, vm));
                    }

                    Host host = vm.Connection.Resolve(vm.resident_on);
                    return(new NotEnoughMem(this, host));

                case Failure.VM_REQUIRES_NETWORK:
                    XenRef <XenAPI.Network> netRef  = new XenRef <XenAPI.Network>(exception[2]);
                    XenAPI.Network          network = connection.Resolve(netRef);

                    if (network == null)
                    {
                        throw new NullReferenceException(Failure.VM_REQUIRES_NETWORK);
                    }

                    return(new VMCannotSeeNetwork(this, vm, network));

                case Failure.VM_REQUIRES_GPU:
                    return(new CannotMigrateVM(this, vm, CannotMigrateVM.CannotMigrateVMReason.CannotMigrateVmNoGpu));

                case Failure.VM_HAS_VGPU:
                    return(new VmHasVgpu(this, vm));

                case Failure.OTHER_OPERATION_IN_PROGRESS:
                    return(new CannotMigrateVM(this, vm, CannotMigrateVM.CannotMigrateVMReason.OperationInProgress));

                default:
                    throw new NullReferenceException(exception[0]);
                }
            }
            catch (Exception e)
            {
                log.Debug("Exception parsing exception", e);

                throw new Failure(new List <String>(exception));
            }
        }
Esempio n. 29
0
        private void UpdateEnablement()
        {
            bool locked = _xenObject.Locked;

            if (SelectedNetwork != null)
            {
                XenAPI.Network TheNetwork = SelectedNetwork;

                AddNetworkButton.Enabled  = !locked;
                EditNetworkButton.Enabled = !locked && !TheNetwork.Locked && !TheNetwork.IsSlave && !TheNetwork.CreateInProgress;

                if (HasPhysicalNonBondNIC(TheNetwork))
                {
                    RemoveNetworkButton.Enabled = false;
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_PIF);
                }
                else
                {
                    RemoveNetworkButton.Enabled = !locked && !TheNetwork.Locked && !TheNetwork.IsSlave && !TheNetwork.CreateInProgress;
                    RemoveButtonContainer.SetToolTip("");
                }
            }
            else if (SelectedVif != null)
            {
                VIF vif = SelectedVif;
                AddNetworkButton.Enabled = !locked;
                // In this case read vif.currently_attached as is-it-plugged
                RemoveNetworkButton.Enabled  = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                EditNetworkButton.Enabled    = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                buttonActivateToggle.Enabled = !locked && (
                    vif.currently_attached && vif.allowed_operations.Contains(vif_operations.unplug) ||
                    !vif.currently_attached && vif.allowed_operations.Contains(vif_operations.plug));

                buttonActivateToggle.Text = vif.currently_attached ? Messages.VM_NETWORK_TAB_DEACTIVATE_BUTTON_LABEL : Messages.VM_NETWORK_TAB_ACTIVATE_BUTTON_LABEL;

                VM vm = (VM)XenObject;
                if (vm.power_state == vm_power_state.Suspended)
                {
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_SUSPENDED);
                    EditButtonContainer.SetToolTip(Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                    toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                        ? Messages.TOOLTIP_DEACTIVATE_VIF_SUSPENDED : Messages.TOOLTIP_ACTIVATE_VIF_SUSPENDED);
                }
                else
                {
                    if (vm.power_state == vm_power_state.Running && vm.GetVirtualisationStatus != XenAPI.VM.VirtualisationStatus.OPTIMIZED)
                    {
                        RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_TOOLS);
                        EditButtonContainer.SetToolTip(Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                        toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                            ? Messages.TOOLTIP_DEACTIVATE_VIF_TOOLS : Messages.TOOLTIP_ACTIVATE_VIF_TOOLS);
                    }
                    else
                    {
                        RemoveButtonContainer.RemoveAll();
                        EditButtonContainer.RemoveAll();
                        toolTipContainerActivateToggle.RemoveAll();
                    }
                }
            }
            else
            {
                AddNetworkButton.Enabled     = !locked;
                RemoveNetworkButton.Enabled  = false;
                EditNetworkButton.Enabled    = false;
                buttonActivateToggle.Enabled = false;
            }
        }
 public void TestSetup()
 {
     networks = DatabaseManager.ConnectionFor(dbName).Cache.Networks.Length;
     newNetwork = GetNetwork();
 }
Esempio n. 31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bond"></param>
        public DestroyBondAction(Bond bond)
            : base(bond.Connection, string.Format(Messages.ACTION_DESTROY_BOND_TITLE, bond.Name),
                   string.Format(Messages.ACTION_DESTROY_BOND_DESCRIPTION, bond.Name))
        {
            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("host.management_reconfigure");
            ApiMethodsToRoleCheck.Add("network.destroy");
            ApiMethodsToRoleCheck.Add("vif.plug");
            ApiMethodsToRoleCheck.Add("vif.unplug");
            ApiMethodsToRoleCheck.Add("pif.reconfigure_ip");
            ApiMethodsToRoleCheck.Add("pif.plug");
            ApiMethodsToRoleCheck.Add("bond.destroy");
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList);
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList);
            #endregion

            Name = bond.Name;

            Pool = Helpers.GetPoolOfOne(Connection);

            foreach (Host host in Connection.Cache.Hosts)
            {
                Bond b = NetworkingHelper.FindBond(host, bond);
                if (b != null)
                {
                    Bonds.Add(b);

                    b.Locked = true;

                    PIF master = Connection.Resolve(b.master);
                    if (master != null)
                    {
                        Masters.Add(master);
                        master.Locked = true;

                        List<PIF> slaves = Connection.ResolveAll(b.slaves);
                        NetworkingHelper.Sort(slaves);
                        foreach (PIF pif in slaves)
                        {
                            Slaves.Add(pif);
                            pif.Locked = true;
                        }

                        FirstSlaves[master] = Connection.Resolve(b.primary_slave);

                        if (!FirstSlaves.ContainsKey(master) && slaves.Count != 0)
                            FirstSlaves[master] = slaves[0];
                    }

                    AppliesTo.Add(host.opaque_ref);
                }
            }

            PIF master_master = Connection.Resolve(bond.master);
            if (master_master != null)
            {
                Network = Connection.Resolve(master_master.network);
                Network.Locked = true;
            }
        }
Esempio n. 32
0
        /// <summary>
        /// Will throw an exception if the network has gone away.
        /// </summary>
        /// <param name="page"></param>
        /// <param name="oldPIF"></param>
        /// <param name="newPIFs"></param>
        /// <param name="newNamePIFs"></param>
        private void CollateChanges(NetworkingPropertiesPage page, PIF oldPIF, List <PifTuple> newPIFs, List <PifTuple> newNamePIFs)
        {
            bool changed     = false;
            bool changedName = false;

            if (oldPIF == null)
            {
                // This tab is newly created.

                XenAPI.Network network = (XenAPI.Network)page.NetworkComboBox.SelectedItem;
                oldPIF = FindPIFForThisHost(network.PIFs);
                if (oldPIF == null)
                {
                    throw new Failure(Failure.INTERNAL_ERROR, "Network has gone away");
                }
                changed = true;
            }
            else
            {
                // This tab was populated when this dialog was launched.

                XenAPI.Network network = connection.Resolve(oldPIF.network);

                if ((XenAPI.Network)page.NetworkComboBox.SelectedItem != network)
                {
                    // The user has changed the network, so find the one we're using now.
                    XenAPI.Network new_network = (XenAPI.Network)page.NetworkComboBox.SelectedItem;
                    oldPIF = FindPIFForThisHost(new_network.PIFs);
                    if (oldPIF == null)
                    {
                        throw new Failure(Failure.INTERNAL_ERROR, "Network has gone away");
                    }
                    changed = true;
                }
            }

            PIF newPIF = (PIF)oldPIF.Clone();

            newPIF.PropertyChanged += (sender, e) => { changed = true; };

            PIF newNamePIF = (PIF)oldPIF.Clone();

            newNamePIF.PropertyChanged += (sender, e) => { changedName = true; };

            if (page.DHCPIPRadioButton.Checked)
            {
                newPIF.ip_configuration_mode = ip_configuration_mode.DHCP;
            }
            else
            {
                newPIF.ip_configuration_mode = ip_configuration_mode.Static;
                newPIF.netmask = page.SubnetTextBox.Text;
                newPIF.gateway = page.GatewayTextBox.Text;
                newPIF.IP      = page.IPAddressTextBox.Text;

                List <string> dns = new List <string>();
                if (page.PreferredDNSTextBox.Text.Length > 0)
                {
                    dns.Add(page.PreferredDNSTextBox.Text);
                }
                if (page.AlternateDNS1TextBox.Text.Length > 0)
                {
                    dns.Add(page.AlternateDNS1TextBox.Text);
                }
                if (page.AlternateDNS2TextBox.Text.Length > 0)
                {
                    dns.Add(page.AlternateDNS2TextBox.Text);
                }
                var newDns = string.Join(",", dns.ToArray());

                newPIF.DNS = newDns;
            }

            newPIF.management = page.type != NetworkingPropertiesPage.Type.SECONDARY;

            if (page.type == NetworkingPropertiesPage.Type.SECONDARY)
            {
                if (changed)
                {
                    newPIF.SetManagementPurpose(page.PurposeTextBox.Text);
                }
                else
                {
                    newNamePIF.SetManagementPurpose(page.PurposeTextBox.Text);
                }
            }

            newPIFs.Add(new PifTuple(newPIF, changed));
            newNamePIFs.Add(new PifTuple(newNamePIF, changedName));
        }
Esempio n. 33
0
        public void RefreshButtons()
        {
            XenAPI.Network network = (XenAPI.Network)NetworkComboBox.SelectedItem;
            string         purpose = network == null ? null : FindOtherPurpose(network);

            InUseWarning =
                purpose == null || purpose == Purpose ?
                null :
                type == Type.SECONDARY && network == ManagementNetwork?
                string.Format(Messages.NETWORKING_PROPERTIES_IN_USE_WARNING_MANAGEMENT, network.ToString()) :
                    string.Format(Messages.NETWORKING_PROPERTIES_IN_USE_WARNING, network.ToString(), purpose);

            PurposeLabel.Visible         =
                PurposeTextBox.Visible   =
                    DeleteButton.Visible =
                        (type == Type.SECONDARY);

            panelHAEnabledWarning.Visible =
                (type == Type.PRIMARY_WITH_HA);

            SetDNSControlsVisible(type != Type.SECONDARY);

            panelInUseWarning.Visible =
                InUseWarning != null;
            InUseWarningText.Text = InUseWarning;

            IpAddressSettingsLabel.Text = type == Type.SECONDARY
                                              ? Messages.NETWORKING_PROPERTIES_IP_SETTINGS
                                              : Messages.NETWORKING_PROPERTIES_IP_AND_DNS_SETTINGS;
            IPAddressLabel.Text = Pool ? Messages.IP_ADDRESS_RANGE_LABEL : Messages.IP_ADDRESS_LABEL;

            tableLayoutPanelStaticSettings.Enabled = FixedIPRadioButton.Checked;

            RangeEndLabel.Visible = Pool;

            Valid =
                InUseWarning == null &&
                NetworkComboBox.SelectedIndex != -1 &&
                (DHCPIPRadioButton.Checked ||
                 ((StringUtility.IsIPAddress(IPAddressTextBox.Text)) &&
                  StringUtility.IsValidNetmask(SubnetTextBox.Text) && IsOptionalIPAddress(GatewayTextBox.Text))) &&
                (type == Type.SECONDARY || ((IsOptionalIPAddress(PreferredDNSTextBox.Text) &&
                                             IsOptionalIPAddress(AlternateDNS1TextBox.Text) &&
                                             IsOptionalIPAddress(AlternateDNS2TextBox.Text))));

            // Grey out everything if HA is enabled: CA-24714
            if (type == Type.PRIMARY_WITH_HA)
            {
                foreach (Control c in Controls)
                {
                    c.Enabled = false;
                }
                haEnabledWarningIcon.Enabled =
                    haEnabledRubric.Enabled  =
                        true;
            }

            var pif             = Tag as PIF;
            var existingCluster = network != null?network.Connection.Cache.Clusters.FirstOrDefault() : null;

            if (pif != null && existingCluster != null)
            {
                Host host = network.Connection.Resolve(pif.host);

                ClusteringEnabled = network.Connection.Cache.Cluster_hosts.Any(cluster =>
                                                                               cluster.host.opaque_ref == pif.host.opaque_ref && cluster.enabled);

                if (ClusteringEnabled)
                {
                    if (host != null && host.enabled)
                    {
                        DisableControls(string.Format(Messages.CANNOT_CHANGE_IP_CLUSTERING_ENABLED, network.Name()));
                    }
                    else
                    {
                        DeleteButton.Enabled    = false;
                        tableLayoutInfo.Visible = true;
                        labelWarning.Text       = string.Format(Messages.CANNOT_REMOVE_IP_WHEN_CLUSTERING_ON_NETWORK, network.Name());
                    }
                }
            }
        }
Esempio n. 34
0
        /// <summary>
        /// Update a network.
        /// </summary>
        /// <param name="network">The modified network that we're going to save to the server.</param>
        /// <param name="changePIFs">True if we're going to create or destroy PIFs (i.e. change a private network to a
        /// VLAN, or vice versa.</param>
        /// <param name="external">Whether the new network is external i.e. a VLAN.</param>
        /// <param name="pif">The PIF representing the physical NIC from which we're basing our new VLAN.
        /// Null iff changePIFs is false or external is false.</param>
        /// <param name="vlan">The new VLAN tag.  Ignored iff changePIFs is false or external is false.</param>
        /// <param name="suppressHistory"></param>
        public NetworkAction(IXenConnection connection, XenAPI.Network network,
            bool changePIFs, bool external, PIF pif, long vlan, bool suppressHistory)
            : base(connection, string.Format(Messages.NETWORK_ACTION_UPDATING_NETWORK_TITLE,
            network.Name, Helpers.GetName(connection)), suppressHistory)
        {
            actionType = network_actions.update;
            this.networkClone = network;
            this.changePIFs = changePIFs;
            this.external = external;
            this.pif = pif;
            this.vlan = vlan;
            PIFs = changePIFs ? Connection.ResolveAll(network.PIFs) : null;

            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("network.set_name_label");
            ApiMethodsToRoleCheck.Add("network.set_other_config");
            ApiMethodsToRoleCheck.Add("network.add_to_other_config");
            ApiMethodsToRoleCheck.Add("network.remove_from_other_config");
            ApiMethodsToRoleCheck.Add("network.set_tags");
            ApiMethodsToRoleCheck.Add("network.add_tags");
            ApiMethodsToRoleCheck.Add("network.remove_tags");
            if (changePIFs)
            {
                ApiMethodsToRoleCheck.Add("pif.destroy");
                if (external)
                    ApiMethodsToRoleCheck.Add("pool.create_VLAN_from_PIF");
            }

            #endregion

            init();
        }
Esempio n. 35
0
 private void init()
 {
     SetAppliesTo(Connection);
     if (networkClone.opaque_ref != null)
     {
         // we are updating an existing object, and so should lock it
         networkServerObject = Connection.Resolve<XenAPI.Network>(new XenRef<XenAPI.Network>(networkClone.opaque_ref));
         networkServerObject.Locked = true;
     }
     if (PIFs == null) return;
     foreach (PIF pif in PIFs)
         pif.Locked = true;
 }
Esempio n. 36
0
        /// <summary>
        /// Create or destroy a private network.
        /// </summary>
        public NetworkAction(IXenConnection connection, XenAPI.Network network, bool create)
            : base(connection,
                   string.Format(create ? Messages.NETWORK_ACTION_CREATING_NETWORK_TITLE : Messages.NETWORK_ACTION_REMOVING_NETWORK_TITLE,
                                 network.Name, Helpers.GetName(connection)))
        {
            this.networkClone = network;
            this.external = false;

            if (create)
            {
                #region RBAC Dependencies

                ApiMethodsToRoleCheck.Add("network.create");

                #endregion
                actionType = network_actions.create;
                PIFs = null;
            }
            else
            {
                PIFs = Connection.ResolveAll(network.PIFs);
                #region RBAC Dependencies
                ApiMethodsToRoleCheck.Add("network.destroy");
                if (PIFs.Find(p => p.IsTunnelAccessPIF) != null)
                    ApiMethodsToRoleCheck.Add("tunnel.destroy");
                if (PIFs.Find(p => !p.IsTunnelAccessPIF && p.physical) != null)
                    ApiMethodsToRoleCheck.Add("pif.forget");  // actually, we should have at most one of tunnel.destroy and pif.forget
                if (PIFs.Find(p => !p.IsTunnelAccessPIF && !p.physical) != null)
                    ApiMethodsToRoleCheck.Add("vlan.destroy");  // same here, shouldn't be both virtual and physcial really
                #endregion
                actionType = network_actions.destroy;
            }

            init();
        }
Esempio n. 37
0
        private void SetMTUControlEnablement()
        {
            if (!network.CanUseJumboFrames)
            {
                labelCannotConfigureMTU.Visible = false;
                labelMTU.Visible = numericUpDownMTU.Visible = false;
                return;
            }

            if (SelectedIsInternal)
            {
                // internal
                // MTU doesn't really do much here
                labelCannotConfigureMTU.Visible = false;
                numericUpDownMTU.Enabled        = false;
                return;
            }

            PIF networksPIF = GetSelectedPIF();  // returns null for new VLAN

            if (networksPIF == null || !networksPIF.IsManagementInterface(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
            {
                // non management external (could be bond)

                if (runningVMsWithoutTools)
                {
                    // The MTU controls have been designed to be more relaxed than the rest of the page, we will only block if we can't unplug the vifs
                    // due to lack of tools (which then lets us unplug the PIFs)
                    labelCannotConfigureMTU.Text    = Messages.CANNOT_CONFIGURE_JUMBO_VM_NO_TOOLS;
                    labelCannotConfigureMTU.Visible = true;
                    numericUpDownMTU.Enabled        = false;
                }
                else if (networksPIF != null && networksPIF.IsTunnelAccessPIF)
                {
                    // This branch is currently not in use as setting the MTU is disabled on CHINs.
                    // Left in in case future support is added

                    // with no other more danger warnings we should tell the user it's recommended that they set the MTU on the underlying networks to match
                    XenAPI.Network mainNetwork = FindCHINMainNetwork(networksPIF);
                    labelCannotConfigureMTU.Text = string.Format(Messages.SET_MTU_ON_CHINS_UNDER_NETWORK, mainNetwork.Name);
                    // incase some odd value has been set on the CLI
                    numericUpDownMTU.Maximum        = Math.Max(network.MTU, XenAPI.Network.MTU_MAX);
                    numericUpDownMTU.Minimum        = Math.Min(network.MTU, XenAPI.Network.MTU_MIN);
                    numericUpDownMTU.Enabled        = true;
                    labelCannotConfigureMTU.Visible = true;
                }
                else
                {
                    labelCannotConfigureMTU.Visible = false;
                    // in case some odd value has been set on the CLI
                    numericUpDownMTU.Maximum = Math.Max(network.MTU, XenAPI.Network.MTU_MAX);
                    numericUpDownMTU.Minimum = Math.Min(network.MTU, XenAPI.Network.MTU_MIN);
                    numericUpDownMTU.Enabled = true;
                }
            }
            else
            {
                // physical or virtual external management (could be bond)
                numericUpDownMTU.Enabled        = false;
                labelCannotConfigureMTU.Text    = string.Format(Messages.CANNOT_CONFIGURE_JUMBO_DISTURB_MANAGEMENT, networksPIF.ManagementInterfaceNameOrUnknown);
                labelCannotConfigureMTU.Visible = true;
            }
        }
Esempio n. 38
0
        private void UpdateEnablement()
        {
            bool locked = _xenObject.Locked;

            if (SelectedNetwork != null)
            {
                XenAPI.Network TheNetwork = SelectedNetwork;

                AddNetworkButton.Enabled = !locked;

                EditNetworkButton.Enabled = !locked && !TheNetwork.Locked && !TheNetwork.IsSlave() && !TheNetwork.CreateInProgress() &&
                                            !TheNetwork.IsGuestInstallerNetwork();
                // CA-218956 - Expose HIMN when showing hidden objects
                // HIMN should not be editable

                if (HasPhysicalNonBondNIC(TheNetwork))
                {
                    RemoveNetworkButton.Enabled = false;
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_PIF);
                }
                else
                {
                    RemoveNetworkButton.Enabled = EditNetworkButton.Enabled;
                    // CA-218956 - Expose HIMN when showing hidden objects
                    // HIMN should not be removable

                    RemoveButtonContainer.SetToolTip("");
                }
            }
            else if (SelectedVif != null)
            {
                VIF vif = SelectedVif;
                AddNetworkButton.Enabled = !locked;
                // In this case read vif.currently_attached as is-it-plugged
                RemoveNetworkButton.Enabled  = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                EditNetworkButton.Enabled    = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                buttonActivateToggle.Enabled = !locked && (
                    vif.currently_attached && vif.allowed_operations.Contains(vif_operations.unplug) ||
                    !vif.currently_attached && vif.allowed_operations.Contains(vif_operations.plug));

                buttonActivateToggle.Text = vif.currently_attached ? Messages.VM_NETWORK_TAB_DEACTIVATE_BUTTON_LABEL : Messages.VM_NETWORK_TAB_ACTIVATE_BUTTON_LABEL;

                VM vm = (VM)XenObject;
                if (vm.power_state == vm_power_state.Suspended)
                {
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_SUSPENDED);
                    EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                    toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                        ? Messages.TOOLTIP_DEACTIVATE_VIF_SUSPENDED : Messages.TOOLTIP_ACTIVATE_VIF_SUSPENDED);
                }
                else
                {
                    if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus().HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        RemoveButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_REMOVE_NETWORK_IO_DRIVERS : Messages.TOOLTIP_REMOVE_NETWORK_TOOLS);
                        EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                        toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                            ? Messages.TOOLTIP_DEACTIVATE_VIF_TOOLS : Messages.TOOLTIP_ACTIVATE_VIF_TOOLS);
                    }
                    else
                    {
                        RemoveButtonContainer.RemoveAll();
                        EditButtonContainer.RemoveAll();
                        toolTipContainerActivateToggle.RemoveAll();
                    }
                }
            }
            else
            {
                AddNetworkButton.Enabled     = !locked;
                RemoveNetworkButton.Enabled  = false;
                EditNetworkButton.Enabled    = false;
                buttonActivateToggle.Enabled = false;
            }
        }
Esempio n. 39
0
 private XenAPI.Network PopulateNewNetworkObj()
 {
     XenAPI.Network result = new XenAPI.Network();
     result.name_label = pageName.NetworkName;
     result.name_description = pageName.NetworkDescription;
     result.AutoPlug = (pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN ? pageChinDetails.isAutomaticAddNicToVM : pageNetworkDetails.isAutomaticAddNicToVM);
     if (pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN)
         result.MTU = pageChinDetails.MTU;
     else if (pageNetworkDetails.MTU.HasValue) //Custom MTU may not be allowed if we are making a virtual network or something
         result.MTU = pageNetworkDetails.MTU.Value;
     return result;
 }
Esempio n. 40
0
        protected override void Run()
        {
            // the network lock and the connection.expectDisruption will be cleared in clean()

            new_bonds = new List<NewBond>();
            network = null;
            Connection.ExpectDisruption = true;
            int inc = 100 / (Connection.Cache.HostCount * 3 + 1);
            string network_ref = CreateNetwork(0, inc);

            try
            {
                network = Connection.WaitForCache(new XenRef<XenAPI.Network>(network_ref));
                network.Locked = true;
                XenAPI.Network.remove_from_other_config(Session, network_ref, XenAPI.Network.CREATE_IN_PROGRESS);

                int lo = inc;
                foreach (Host host in GetHostsMasterLast())
                {
                    List<PIF> pifs = PIFs[host].FindAll(x => x.physical).ToList();

                    List<XenRef<PIF>> pif_refs = new List<XenRef<PIF>>();
                    foreach (PIF pif in pifs)
                    {
                        pif_refs.Add(new XenRef<PIF>(pif.opaque_ref));
                    }

                    log.DebugFormat("Creating bond on {0} with {1} PIFs...", Helpers.GetName(host), pifs.Count);

                    Dictionary<string, string> bondProperties = new Dictionary<string, string>();
                    if (bondMode == bond_mode.lacp)
                        bondProperties.Add("hashing_algorithm", Bond.HashingAlgoritmToString(hashingAlgoritm));

                    RelatedTask = tampaOrGreater ?
                        Bond.async_create(Session, network_ref, pif_refs, "", bondMode, bondProperties) :
                        bostonOrGreater ?
                            Bond.async_create(Session, network_ref, pif_refs, "", bondMode) : 
                            Bond.async_create(Session, network_ref, pif_refs, "");

                    PollToCompletion(lo, lo + inc);
                    lo += inc;
                    log.DebugFormat("Creating bond on {0} done: bond is {1}.", Helpers.GetName(host), Result);

                    Bond new_bond = Connection.WaitForCache(new XenRef<Bond>(Result));
                    if (new_bond == null)
                        throw new Failure(Failure.INTERNAL_ERROR, "Bond didn't appear in our cache!");

                    PIF new_master = Connection.Resolve(new_bond.master);
                    if (new_master == null)
                        throw new Failure(Failure.INTERNAL_ERROR, "Bond master didn't appear in our cache!");

                    new_bonds.Add(new NewBond(new_bond, new_master, pifs));

                    new_bond.Locked = true;
                    new_master.Locked = true;
                }

                foreach (NewBond new_bond in new_bonds)
                {
                    lo += inc;
                    ReconfigureManagementInterfaces(new_bond.slaves, new_bond.master, lo);
                }

                foreach (NewBond new_bond in new_bonds)
                {
                    lo += inc;
                    if (!bostonOrGreater)
                        NetworkingActionHelpers.Plug(this, new_bond.master, lo);
                }
            }
            catch (Exception)
            {
                foreach (NewBond new_bond in new_bonds)
                {
                    RevertManagementInterfaces(new_bond);
                    DestroyBond(new_bond.bond);
                }

                DestroyNetwork(network_ref);
                throw;
            }

            Description = string.Format(Messages.ACTION_CREATE_BOND_DONE, name_label);
        }
Esempio n. 41
0
        protected override void Run()
        {
            switch (actionType)
            {
                case network_actions.destroy:
                    Description = Messages.NETWORK_ACTION_REMOVING_NETWORK;
                    destroyPIFs();
                    XenAPI.Network.destroy(Session, networkClone.opaque_ref);
                    networkClone = null;
                    Description = Messages.NETWORK_ACTION_NETWORK_REMOVED;
                    break;

                case network_actions.update:
                    Description = Messages.NETWORK_ACTION_UPDATING_NETWORK;

                    if (changePIFs)
                    {
                        if (external)
                        {
                            //Before we do a destroy check the vlan tag is not in use on this network
                            foreach (PIF p in Connection.Cache.PIFs)
                            {
                                if (p.VLAN == vlan && p.device == pif.device)
                                    throw new Exception(FriendlyErrorNames.PIF_VLAN_EXISTS);
                            }
                        }
                        destroyPIFs();
                        if (external)
                            CreateVLAN(networkClone.opaque_ref);
                    }

                    Description = Messages.NETWORK_ACTION_NETWORK_UPDATED;
                    break;

                case network_actions.create:
                    Description = Messages.NETWORK_ACTION_CREATING_NETWORK;

                    XenRef<XenAPI.Network> networkRef = XenAPI.Network.create(Session, networkClone);
                    if (external)
                        CreateVLAN(networkRef.opaque_ref);

                    Description = Messages.NETWORK_ACTION_NETWORK_CREATED;
                    break;
            }
        }
Esempio n. 42
0
 public NetworkComboBoxItem(XenAPI.Network network)
 {
     Network = network;
 }
Esempio n. 43
0
            public NetworkRow(XenAPI.Network network, IXenObject xmo)
            {
                Network = network;
                Xmo = xmo;

                Cells.AddRange(ImageCell,
                               NameCell,
                               DescriptionCell,
                               NicCell,
                               VlanCell,
                               AutoCell,
                               LinkStatusCell,
                               MacCell,
                               MtuCell);

                Network.PropertyChanged += Server_PropertyChanged;

                Program.Invoke(Program.MainWindow, UpdateDetails);
            }
        public override bool FailureFoundFor(IXenObject itemToFilterOn)
        {
            Pool        targetPool;
            List <Host> targets = CollateHosts(itemToFilterOn, out targetPool);

            foreach (VM vm in preSelectedVMs)
            {
                log.InfoFormat("Asserting can migrate VM {0} to {1}...", vm.Name(), itemToFilterOn);
                bool vmIsMigratable = false;
                foreach (Host host in targets)
                {
                    if (canceled)
                    {
                        return(false);
                    }

                    // obtain the cache data for a vm
                    IDictionary <string, string> vmCache;
                    lock (cacheLock)
                    {
                        if (!cache.ContainsKey(vm.opaque_ref))
                        {
                            cache.Add(vm.opaque_ref, new Dictionary <string, string>());
                        }
                        vmCache = cache[vm.opaque_ref];
                    }

                    try
                    {
                        //CA-220218: for intra-pool motion of halted VMs we do a move, so no need to assert we can migrate
                        Pool vmPool = Helpers.GetPoolOfOne(vm.Connection);
                        if (_wizardMode == WizardMode.Move && vmPool != null && targetPool != null && vmPool.opaque_ref == targetPool.opaque_ref)
                        {
                            // vm is migratable, no need to itearate through all the pool members
                            vmIsMigratable = true;
                            break;
                        }

                        //Skip the resident host as there's a filter for it and
                        //if not then you could exclude intrapool migration
                        //CA-205799: do not offer the host the VM is currently on
                        Host homeHost = vm.Home();
                        if (homeHost != null && homeHost.opaque_ref == host.opaque_ref)
                        {
                            continue;
                        }

                        if (vmCache.ContainsKey(host.opaque_ref))
                        {
                            disableReason = vmCache[host.opaque_ref];
                            if (string.IsNullOrEmpty(disableReason))
                            {
                                // vm is migratable to at least one host in the pool, no need to itearate through all the pool members
                                vmIsMigratable = true;
                                break;
                            }
                            continue;
                        }

                        //if pool_migrate can be done, then we will allow it in the wizard, even if storage migration is not allowed (i.e. users can use the wizard to live-migrate a VM inside the pool)
                        if (_wizardMode == WizardMode.Migrate && vmPool != null && targetPool != null && vmPool.opaque_ref == targetPool.opaque_ref)
                        {
                            var reason = VMOperationHostCommand.GetVmCannotBootOnHostReason(vm, host, vm.Connection.Session, vm_operations.pool_migrate);
                            if (string.IsNullOrEmpty(reason))
                            {
                                lock (cacheLock)
                                {
                                    vmCache.Add(host.opaque_ref, reason);
                                }
                                // vm is migratable to at least one host in the pool, no need to itearate through all the pool members
                                vmIsMigratable = true;
                                break;
                            }
                        }

                        //check if the destination host is older than the source host
                        var destinationVersion = Helpers.HostPlatformVersion(host);
                        var sourceVersion      = Helpers.HostPlatformVersion(vm.Home() ?? Helpers.GetMaster(vmPool));
                        if (Helpers.productVersionCompare(destinationVersion, sourceVersion) < 0)
                        {
                            throw new Failure(Messages.OLDER_THAN_CURRENT_SERVER);
                        }

                        PIF            managementPif     = host.Connection.Cache.PIFs.First(p => p.management);
                        XenAPI.Network managementNetwork = host.Connection.Cache.Resolve(managementPif.network);

                        Session session = host.Connection.DuplicateSession();
                        Dictionary <string, string> receiveMapping = Host.migrate_receive(session, host.opaque_ref, managementNetwork.opaque_ref, new Dictionary <string, string>());

                        var targetSrs     = host.Connection.Cache.SRs.Where(sr => sr.SupportsStorageMigration()).ToList();
                        var targetNetwork = GetANetwork(host);

                        VM.assert_can_migrate(vm.Connection.Session,
                                              vm.opaque_ref,
                                              receiveMapping,
                                              true,
                                              GetVdiMap(vm, targetSrs),
                                              vm.Connection == host.Connection ? new Dictionary <XenRef <VIF>, XenRef <XenAPI.Network> >() : GetVifMap(vm, targetNetwork),
                                              new Dictionary <string, string>());
                        lock (cacheLock)
                        {
                            vmCache.Add(host.opaque_ref, string.Empty);
                        }
                        // vm is migratable to at least one host in the pool, no need to itearate through all the pool members
                        vmIsMigratable = true;
                        break;
                    }
                    catch (Failure failure)
                    {
                        if (failure.ErrorDescription.Count > 0 && failure.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED)
                        {
                            disableReason = failure.Message.Split('\n')[0].TrimEnd('\r'); // we want the first line only
                        }
                        else
                        {
                            disableReason = failure.Message;
                        }

                        lock (cacheLock)
                        {
                            vmCache.Add(host.opaque_ref, disableReason.Clone().ToString());
                        }

                        log.ErrorFormat("VM: {0}, Host: {1} - Reason: {2};", vm.Name(), host.Name(), failure.Message);

                        vmIsMigratable = false;
                    }
                }

                // if at least one VM is not migratable to the target pool, then there is no point checking the remaining VMs
                if (!vmIsMigratable)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 45
0
        public void BuildList()
        {
            Program.AssertOnEventThread();
            if (!this.Visible)
            {
                return;
            }

            if (InBuildList)
            {
                return;
            }

            InBuildList = true;

            try
            {
                if (XenObject == null || XenObject.Locked)
                {
                    return;
                }

                if (!XenObject.Connection.CacheIsPopulated)
                {
                    return;
                }

                if (XenObject is VM)
                {
                    DeregisterEventsOnGridRows();
                    VIF selectedVIF = SelectedVif;
                    VM  vm          = XenObject as VM;

                    NetworksGridView.SuspendLayout();
                    NetworksGridView.Rows.Clear();

                    List <VIF> vifs = vm.Connection.ResolveAll(vm.VIFs);
                    vifs.Sort();

                    // CA-8981 - Listen for guest metric changes which is necessary for IP Address updates
                    VM_guest_metrics vmGuestMetrics = vm.Connection.Resolve(vm.guest_metrics);
                    if (vmGuestMetrics != null)
                    {
                        vmGuestMetrics.PropertyChanged += Server_PropertyChanged;
                    }

                    var vifRowsToAdd = new List <VifRow>();
                    foreach (var vif in vifs)
                    {
                        var network = vif.Connection.Resolve(vif.network);
                        if (network != null &&
                            // CA-218956 - Expose HIMN when showing hidden objects
                            (network.IsGuestInstallerNetwork() && !XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
                        {
                            continue;   // Don't show the guest installer network in the network tab (CA-73056)
                        }
                        vifRowsToAdd.Add(new VifRow(vif));
                    }
                    NetworksGridView.Rows.AddRange(vifRowsToAdd.ToArray());

                    bool selected = true;

                    if (selectedVIF != null)
                    {
                        foreach (VifRow row in NetworksGridView.Rows)
                        {
                            // Cannot compare opaque_ref as VIFs get destroyed / recreated on each edit.
                            if (row.Vif.device == selectedVIF.device)
                            {
                                row.Selected = true;
                                break;
                            }
                        }
                    }

                    if (!selected && NetworksGridView.Rows.Count > 0)
                    {
                        NetworksGridView.Rows[0].Selected = true;
                    }
                }
                else if (XenObject is Host || XenObject is Pool)
                {
                    DeregisterEventsOnGridRows();
                    XenAPI.Network selectedNetwork = SelectedNetwork;

                    NetworksGridView.SuspendLayout();
                    NetworksGridView.Rows.Clear();

                    XenAPI.Network[] networks = XenObject.Connection.Cache.Networks;
                    Array.Sort <XenAPI.Network>(networks);

                    List <NetworkRow> networkRowsToAdd = new List <NetworkRow>();
                    for (int i = 0; i < networks.Length; i++)
                    {
                        if (!networks[i].Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
                        {
                            continue;
                        }
                        networkRowsToAdd.Add(new NetworkRow(networks[i], XenObject));
                    }
                    NetworksGridView.Rows.AddRange(networkRowsToAdd.ToArray());
                    // The following update causes this to be a lot slower with many networks. Alot! CA-43944
                    //foreach(NetworkRow r in NetworksGridView.Rows)
                    //r.UpdateDefaultCellStyle();  // Has to be done again after adding to the grid view, even though it's already called in the constructor

                    if (selectedNetwork != null)
                    {
                        foreach (NetworkRow row in NetworksGridView.Rows)
                        {
                            if (row.Network.opaque_ref == selectedNetwork.opaque_ref && selectedNetwork.Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
                            {
                                row.Selected = true;
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (NetworksGridView.SortedColumn != null)
                {
                    NetworksGridView.Sort(
                        NetworksGridView.SortedColumn,
                        NetworksGridView.SortOrder == SortOrder.Ascending
                            ? ListSortDirection.Ascending : ListSortDirection.Descending);
                }
                NetworksGridView.ResumeLayout();
                InBuildList = false;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="bond"></param>
        public DestroyBondAction(Bond bond)
            : base(bond.Connection, string.Format(Messages.ACTION_DESTROY_BOND_TITLE, bond.Name),
                   string.Format(Messages.ACTION_DESTROY_BOND_DESCRIPTION, bond.Name))
        {
            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("host.management_reconfigure");
            ApiMethodsToRoleCheck.Add("network.destroy");
            ApiMethodsToRoleCheck.Add("vif.plug");
            ApiMethodsToRoleCheck.Add("vif.unplug");
            ApiMethodsToRoleCheck.Add("pif.reconfigure_ip");
            ApiMethodsToRoleCheck.Add("pif.plug");
            ApiMethodsToRoleCheck.Add("bond.destroy");
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList);
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList);
            #endregion

            Name = bond.Name;

            Pool = Helpers.GetPoolOfOne(Connection);

            foreach (Host host in Connection.Cache.Hosts)
            {
                Bond b = NetworkingHelper.FindBond(host, bond);
                if (b != null)
                {
                    Bonds.Add(b);

                    b.Locked = true;

                    PIF master = Connection.Resolve(b.master);
                    if (master != null)
                    {
                        Masters.Add(master);
                        master.Locked = true;

                        List <PIF> slaves = Connection.ResolveAll(b.slaves);
                        NetworkingHelper.Sort(slaves);
                        foreach (PIF pif in slaves)
                        {
                            Slaves.Add(pif);
                            pif.Locked = true;
                        }

                        FirstSlaves[master] = Connection.Resolve(b.primary_slave);

                        if (!FirstSlaves.ContainsKey(master) && slaves.Count != 0)
                        {
                            FirstSlaves[master] = slaves[0];
                        }
                    }

                    AppliesTo.Add(host.opaque_ref);
                }
            }

            PIF master_master = Connection.Resolve(bond.master);
            if (master_master != null)
            {
                Network        = Connection.Resolve(master_master.network);
                Network.Locked = true;
            }
        }
Esempio n. 47
0
 private void CreateCHIN()
 {
     XenAPI.Network network      = PopulateNewNetworkObj();
     XenAPI.Network theInterface = pageChinDetails.SelectedInterface;
     (new CreateChinAction(xenConnection, network, theInterface)).RunAsync();
 }
Esempio n. 48
0
 public CreateChinAction(IXenConnection connection, XenAPI.Network newNetwork, XenAPI.Network theInterface)
     : base(connection,
            string.Format(Messages.NETWORK_ACTION_CREATING_NETWORK_TITLE, newNetwork.Name, Helpers.GetName(connection)))
 {
     this.newNetwork   = newNetwork;
     this.theInterface = theInterface;
 }
Esempio n. 49
0
 public static Icons GetIconFor(XenAPI.Network network)
 {
     return(Icons.Network);
 }
Esempio n. 50
0
        string CreateNetwork(int lo, int hi)
        {
            log.DebugFormat("Creating network {0}...", name_label);

            XenAPI.Network network = new XenAPI.Network();
            network.name_label = name_label;
            network.AutoPlug = autoplug;
            if (Helpers.CowleyOrGreater(Connection))
                network.MTU = mtu;
            if (network.other_config == null)
                network.other_config = new Dictionary<string, string>();
            network.other_config[XenAPI.Network.CREATE_IN_PROGRESS] = "true";

            RelatedTask = XenAPI.Network.async_create(Session, network);
            PollToCompletion(lo, hi);

            log.DebugFormat("Created network {0} as {1}.", name_label, Result);

            return Result;
        }