/// <summary> /// /// </summary> /// <param name="connection"></param> /// <param name="pool">May be null, in which case we're acting on a single host basis.</param> /// <param name="host">If pool is set, then host should be the pool master.</param> /// <param name="newPIFs">New PIF instances that are to be created on the server.</param> /// <param name="downPIFs"></param> /// <param name="newManagement">May be null, in which case the management network will not be disturbed. /// Note that it is still possible for the management interface to receive a new IP address even if this /// parameter is null, because it may be in newPIFs. You only need to use this parameter if the management /// interface is switching onto a different PIF.</param> /// <param name="downManagement">May be null iff newManagement is null.</param> public ChangeNetworkingAction(IXenConnection connection, Pool pool, Host host, List<PIF> newPIFs, List<PIF> downPIFs, PIF newManagement, PIF downManagement, bool managementIPChanged) : base(connection, Messages.ACTION_CHANGE_NETWORKING_TITLE) { Pool = pool; Host = host; this.newPIFs = newPIFs; this.downPIFs = downPIFs; this.newManagement = newManagement; this.downManagement = downManagement; this.managementIPChanged = managementIPChanged; if (pool != null) { // If we're going to compute address ranges, then we need a sorted list of hosts (to keep the addresses stable). Hosts = Connection.Cache.Hosts; Array.Sort(Hosts); foreach (Host h in Hosts) { AppliesTo.Add(h.opaque_ref); } } #region RBAC Dependencies ApiMethodsToRoleCheck.Add("vm.set_memory_limits"); ApiMethodsToRoleCheck.Add("host.management_reconfigure"); ApiMethodsToRoleCheck.Add("pif.reconfigure_ip"); ApiMethodsToRoleCheck.Add("pif.plug"); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList); #endregion }
//private static void BringDown(AsyncAction action, PIF master, bool this_host, int hi) //{ // ForSomeHosts(action, master, this_host, false, hi, BringDown); //} /// <summary> /// Depurpose (set disallow_unplug=false) and remove the IP address from the given PIF. /// </summary> internal static void BringDown(AsyncAction action, PIF pif, int hi) { int mid = (action.PercentComplete + hi) / 2; Depurpose(action, pif, mid); ClearIP(action, pif, hi); }
private static void Download_PIF(Session session, List <ObjectChange> changes) { Dictionary <XenRef <PIF>, PIF> records = PIF.get_all_records(session); foreach (KeyValuePair <XenRef <PIF>, PIF> entry in records) { changes.Add(new ObjectChange(typeof(PIF), entry.Key.opaque_ref, entry.Value)); } }
/// <summary> /// Copy the IP details from src to a clone of dest, and return the clone. /// </summary> public static PIF CopyIPConfig(PIF src, PIF dest) { PIF result = (PIF)dest.Clone(); result.ManagementPurpose = src.ManagementPurpose; result.ip_configuration_mode = src.ip_configuration_mode; result.IP = src.IP; result.netmask = src.netmask; result.gateway = src.gateway; result.DNS = src.DNS; return result; }
public NetworkingProperties(Host host,PIF selectedPIF):this() { Host = host; Pool = null; connection = host.Connection; ObjectName = Helpers.GetName(host); BlurbLabel.Text = string.Format(Messages.NETWORKING_PROPERTIES_BLURB_HOST, ObjectName); Configure(selectedPIF); }
private string PIFName(PIF pif) { bool bond; if (pif.VLAN >= 0) { return(string.Format(Messages.VLAN_NETWORK_NAME, pif.NICIdentifier(out bond), pif.VLAN)); } else { return(string.Format(Messages.NETWORK_NAME, pif.NICIdentifier(out bond))); } }
public NetworkingProperties(Pool pool,PIF selectedPIF):this() { Pool = pool; connection = pool.Connection; ObjectName = Helpers.GetName(Pool); Host =connection.Resolve(pool.master); if (Host == null) throw new Failure(Failure.INTERNAL_ERROR, "Could not resolve master"); BlurbLabel.Text = string.Format(Messages.NETWORKING_PROPERTIES_BLURB_POOL, ObjectName); Configure(selectedPIF); }
private void ProcessRecordMaster(string bond) { RunApiCall(() => { string objRef = XenAPI.Bond.get_master(session, bond); XenAPI.PIF obj = null; if (objRef != "OpaqueRef:NULL") { obj = XenAPI.PIF.get_record(session, objRef); obj.opaque_ref = objRef; } WriteObject(obj, true); }); }
/// <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(); }
internal static void ReconfigureIP(AsyncAction action, PIF new_pif, PIF existing_pif, string ip, int hi) { log.DebugFormat("Reconfiguring IP on {0} {1} ...", existing_pif.Name, existing_pif.uuid); action.RelatedTask = PIF.async_reconfigure_ip(action.Session, existing_pif.opaque_ref, new_pif.ip_configuration_mode, ip, new_pif.netmask, new_pif.gateway, new_pif.DNS); action.PollToCompletion(action.PercentComplete, hi); log.DebugFormat("Reconfiguring IP on {0} {1} done.", existing_pif.Name, existing_pif.uuid); }
/// <summary> /// Configure an IP address, management purpose, and set the disallow_unplug flag on the given existing_pif. /// </summary> /// <param name="new_pif">The source of the new IP details</param> /// <param name="existing_pif">The PIF to configure</param> internal static void BringUp(AsyncAction action, PIF new_pif, string new_ip, PIF existing_pif, int hi) { bool primary = string.IsNullOrEmpty(new_pif.ManagementPurpose); int lo = action.PercentComplete; int inc = (hi - lo) / (primary ? 2 : 3); log.DebugFormat("Bringing PIF {0} {1} up as {2}/{3}, {4}, {5}...", existing_pif.Name, existing_pif.uuid, new_ip, new_pif.netmask, new_pif.gateway, new_pif.DNS); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_UP, existing_pif.Name); PIF p = (PIF)existing_pif.Clone(); p.disallow_unplug = !primary; p.ManagementPurpose = new_pif.ManagementPurpose; p.SaveChanges(action.Session); action.PercentComplete = lo + inc; ReconfigureIP(action, new_pif, existing_pif, new_ip, action.PercentComplete + inc); if (!primary) Plug(action, existing_pif, hi); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_UP_DONE, existing_pif.Name); log.DebugFormat("Brought PIF {0} {1} up.", existing_pif.Name, existing_pif.uuid); }
public void UpdateDetails() { Enabled = !Network.IsSlave; DeregisterPifEvents(); Pif = Helpers.FindPIF(Network, Xmo as Host); RegisterPifEvents(); ImageCell.Value = Properties.Resources._000_Network_h32bit_16; NameCell.Value = NetworkName(); DescriptionCell.Value = Network.Description; NicCell.Value = Helpers.GetName(Pif); VlanCell.Value = Helpers.VlanString(Pif); AutoCell.Value = Network.AutoPlug ? Messages.YES : Messages.NO; LinkStatusCell.Value = Xmo is Pool ? Network.LinkStatusString : Pif == null ? Messages.NONE : Pif.LinkStatusString; MacCell.Value = Pif != null && Pif.IsPhysical ? Pif.MAC : Messages.SPACED_HYPHEN; MtuCell.Value = Network.CanUseJumboFrames ? Network.MTU.ToString() : Messages.SPACED_HYPHEN; }
private void InitNetTopology() { this.panel1.Controls.Clear(); XenAPI.PIF[] pifs = host.Connection.Cache.PIFs; XenAPI.Network[] networks = host.Connection.Cache.Networks; XenAPI.SR[] srs = host.Connection.Cache.SRs; XenAPI.PBD[] pbds = host.Connection.Cache.PBDs; XenAPI.VIF[] vifs = host.Connection.Cache.VIFs; //XenAPI.VM[] vms = host.Connection.ResolveAll(host.resident_VMs); XenAPI.VM[] vms = host.Connection.Cache.VMs; int tmpi = 0; foreach (IXenObject o in host.Connection.Cache.XenSearchableObjects) { tmpi++; } //List<VM> vms = host.Connection.ResolveAll(host.resident_VMs); XenAPI.Bond[] bonds = host.Connection.Cache.Bonds; //组装bonds的pif HashSet <string> bondSets = new HashSet <string>(); for (int bondi = 0; bondi < bonds.Length; bondi++) { foreach (var pifop in bonds[bondi].slaves) { bondSets.Add(pifop); } } //组装network 与 pif 关系 Hashtable networkpif = new Hashtable(); Hashtable bridgedevice = new Hashtable(); foreach (var netob in networks) { if (netob.PIFs.Count > 0) { foreach (var pifob in pifs) { if (pifob.opaque_ref.Equals(netob.PIFs[0].opaque_ref)) { networkpif.Add(netob, pifob); } } } else { networkpif.Add(netob, null); } } IDictionaryEnumerator enumerator = networkpif.GetEnumerator(); while (enumerator.MoveNext()) { XenAPI.Network network = (XenAPI.Network)enumerator.Key; XenAPI.PIF pif = (XenAPI.PIF)enumerator.Value; //if (!network.bridge.StartsWith("xenapi") &&!bondSets.Contains(pif.opaque_ref) && pif.VLAN==-1) if (network.bridge.StartsWith("xenapi")) { continue; } if (network.PIFs.Count == 0) { bridgedevice.Add(network.bridge, ""); } else if (!bondSets.Contains(pif.opaque_ref) && pif.VLAN == -1) { //bridgeSets.Add(network.bridge); bridgedevice.Add(network.bridge, pif.device); } } int totaly = 0; ArrayList switchesArray = new ArrayList(); int i = 0; foreach (DictionaryEntry bd in bridgedevice) { totaly += 20; this.panel1.Controls.Add(newLable(40, totaly, 430, 30, "lable" + i, Messages.NETWORKTOPOLOGY_VSWITCH + ":" + bd.Key)); totaly += 30; this.panel1.Controls.Add(newLineShape(40, totaly, 730, totaly, "xenbrline", "", DashStyle.Dot, 2)); //遍历network 匹配当前相同虚拟交换机 int nowy = 0; totaly += 10; for (int l1 = 0; l1 < networks.Length; l1++) { int vmsize = 0; if (networks[l1].bridge.Equals("xenapi")) { continue; } else { if (!bd.Key.Equals(networks[l1].bridge)) { if (networkpif[networks[l1]] != null && ((XenAPI.PIF)networkpif[networks[l1]]).device.Equals(bd.Value)) { } else { continue; } } HashSet <string> vmSets = new HashSet <string>(); //筛选vm for (int vift = 0; vift < vifs.Length; vift++) { if (vifs[vift].network.opaque_ref.Equals(networks[l1].opaque_ref)) { vmSets.Add(vifs[vift].VM.opaque_ref); } } ArrayList vmlist = new ArrayList(); //for (int vmt = 0; vmt < vms.Length; vmt++) foreach (var vmob in vms) { //if (vmSets.Contains(vms[vmt].opaque_ref) && vms[vmt].TemplateType == XenAPI.VM.VmTemplateType.NoTemplate ) if (vmSets.Contains(vmob.opaque_ref) && vmob.TemplateType == XenAPI.VM.VmTemplateType.NoTemplate && host.Equals(vmob.Home())) { vmlist.Add(vmob); } } //groupBox1 System.Windows.Forms.GroupBox groupBox1 = new System.Windows.Forms.GroupBox(); //totaly += 10; //nowy +=20; groupBox1.SuspendLayout(); groupBox1.Size = new Size(250, 70 + (vmlist.Count * 20 + 12)); groupBox1.Controls.Add(newLable(10, 20, 150, 20, "lable21" + i, networks[l1].name_label.Replace("Pool-wide network associated with", "Network"))); groupBox1.Controls.Add(newLable(10, 40, 150, 20, "lable22" + i, vmlist.Count + Messages.NETWORKTOPOLOGY_VMS)); groupBox1.Controls.Add(newPictureBox(220, 20, 20, 20, "groupBox1PictureBox", global::XenAdmin.Properties.Resources._000_ManagementInterface_h32bit_16));//networkinterfacecard this.panel1.Controls.Add(newOvalShape(297, totaly + 27, 6, 6, "groupBox1Ovalshape", Color.Lime)); this.panel1.Controls.Add(newLineShape(280, totaly + 30, 297, totaly + 30, "", "", DashStyle.Solid, 1)); groupBox1.Controls.Add(newLineShape(0, 50, 250, 50, "lineShape2", "", DashStyle.Dot, 2)); //遍历虚拟机 int groupboxY = 80; vmsize = vmlist.Count; for (int j = 0; j < vmsize; j++) { groupBox1.Controls.Add(newLable(10, groupboxY + (j * 20), 200, 20, "lable24" + i, ((VM)vmlist[j]).name_label)); if (((VM)vmlist[j]).power_state == vm_power_state.Running) { groupBox1.Controls.Add(newPictureBox(220, groupboxY + (j * 20), 20, 20, "pictureBoxvm" + j, global::XenAdmin.Properties.Resources._000_StartVM_h32bit_16)); this.panel1.Controls.Add(newOvalShape(297, totaly + groupboxY + (j * 20) + 7, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newLineShape(280, totaly + groupboxY + (j * 20) + 10, 297, totaly + groupboxY + (j * 20) + 10, "", "", DashStyle.Solid, 1)); } else { groupBox1.Controls.Add(newPictureBox(220, groupboxY + (j * 20), 20, 20, "pictureBoxvm" + j, global::XenAdmin.Properties.Resources._000_StoppedVM_h32bit_16)); } } this.panel1.Controls.Add(groupBox1); groupBox1.Name = "groupBox1"; groupBox1.TabStop = false; groupBox1.Location = new Point(40, totaly); //groupBox1.Text = networks[l1].name_label.StartsWith("Pool-wide network associated with ")?"":""; groupBox1.Text = Messages.NETWORKTOPOLOGY_VMS_GROUP; groupBox1.ResumeLayout(false); } totaly += 70 + (vmsize * 20 + 10); nowy += 70 + (vmsize * 20 + 10); } //遍历硬件 if (!bd.Value.Equals("")) { for (int pift = 0; pift < pifs.Length; pift++) { if (pifs[pift].device.Equals(bd.Value) && pifs[pift].currently_attached && pifs[pift].VLAN == -1) { ArrayList nicArray = new ArrayList(); if (pifs[pift].management) { System.Windows.Forms.GroupBox groupBox2 = new System.Windows.Forms.GroupBox(); groupBox2.SuspendLayout(); groupBox2.Size = new Size(250, 70); groupBox2.Controls.Add(newLable(10, 20, 200, 20, "nic", pifs[pift].ManagementInterfaceNameOrUnknown)); groupBox2.Controls.Add(newLable(10, 40, 200, 20, "ip", Messages.NETWORKPANEL_IP + ":" + pifs[pift].IP)); groupBox2.Controls.Add(newPictureBox(220, 20, 20, 20, "pictureBox1", global::XenAdmin.Properties.Resources._000_ManagementInterface_h32bit_16)); this.panel1.Controls.Add(newOvalShape(297, totaly + 27, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newLineShape(280, totaly + 30, 297, totaly + 30, "", "", DashStyle.Solid, 1)); this.panel1.Controls.Add(groupBox2); groupBox2.Name = "groupBox2" + i; groupBox2.TabStop = false; groupBox2.Location = new Point(40, totaly); groupBox2.Text = Messages.NETWORKTOPOLOGY_MANAGEMENTINTERFACE; groupBox2.ResumeLayout(false); totaly += 70; nowy += 70; } //网卡线路 System.Windows.Forms.GroupBox groupBox3 = new System.Windows.Forms.GroupBox(); groupBox3.SuspendLayout(); groupBox3.Size = new Size(300, 70); groupBox3.AutoSize = true; if (((string)bd.Value).StartsWith("bond")) { foreach (var bondob in bonds) { if (bondob.master.opaque_ref.Equals(pifs[pift].opaque_ref)) { int slavei = 0; foreach (var slaveob in bondob.slaves) { foreach (var pifob in pifs) { if (slaveob.opaque_ref.Equals(pifob.opaque_ref)) { groupBox3.Controls.Add(newPictureBox(35, 40 * (1 + slavei) - 20, 20, 20, "pictureBoxnic", global::XenAdmin.Properties.Resources.networkinterfacecard)); groupBox3.Controls.Add(newLable(60, 40 * (1 + slavei) - 20, 220, 20, "nic", pifob.Name + " " + pifob.Speed + ";duplex:" + pifob.Duplex)); groupBox3.Controls.Add(newLable(60, 40 * (1 + slavei), 240, 20, "ipaddress", Messages.NETWORKPANEL_IP + ":" + pifob.IP + ";" + Messages.NETWORKTOPOLOGY_GATEWAY + ":" + pifob.gateway)); if (pifob.Carrier) { groupBox3.Controls.Add(newOvalShape(20, 27 + 40 * (slavei), 6, 6, "shapeContainer1", Color.Lime)); groupBox3.Controls.Add(newOvalShape(290, 27 + 40 * (slavei), 6, 6, "shapeContainer1", Color.Lime)); string[] ss = new string[2]; ss[0] = totaly - nowy + 30 + 40 * (slavei) + ""; nicArray.Add(ss); } else { groupBox3.Controls.Add(newOvalShape(20, 27 + 40 * (slavei), 6, 6, "shapeContainer1", Color.Red)); } if (slavei == 0) { this.panel1.Controls.Add(newOvalShape(312, totaly - nowy + 27, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newLineShape(318, totaly - nowy + 30, 355, totaly - nowy + 30 + 40 * (slavei), "", "", DashStyle.Solid, 1)); } else { if (slavei > 1 && nowy < (30 * (slavei + 1))) { totaly += 40; nowy += 40; } groupBox3.Controls.Add(newLineShape(10, 14, 10, 14 + 40 * (slavei), "Lline1" + slavei, "", DashStyle.Solid, 1)); groupBox3.Controls.Add(newLineShape(10, 14 + 40 * (slavei), 17, 14 + 40 * (slavei), "Lline2" + slavei, "", DashStyle.Solid, 1)); } slavei++; } } } } } } else { groupBox3.Controls.Add(newPictureBox(35, 20, 20, 20, "pictureBoxnic", global::XenAdmin.Properties.Resources.networkinterfacecard)); groupBox3.Controls.Add(newLable(60, 20, 220, 20, "nic", pifs[pift].Name + " " + pifs[pift].Speed + ";duplex:" + pifs[pift].Duplex)); groupBox3.Controls.Add(newLable(60, 40, 240, 20, "ipaddress", "ip:" + pifs[pift].IP + /*"netmask:" + pifs[pift].netmask +*/ ";gateway:" + pifs[pift].gateway)); this.panel1.Controls.Add(newOvalShape(312, totaly - nowy + 27, 6, 6, "shapeContainer1", Color.Lime)); if (pifs[pift].Carrier) { groupBox3.Controls.Add(newOvalShape(20, 27, 6, 6, "shapeContainer1", Color.Lime)); groupBox3.Controls.Add(newOvalShape(290, 27, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newLineShape(318, totaly - nowy + 30, 355, totaly - nowy + 30, "", "", DashStyle.Solid, 1)); string[] ss = new string[1]; ss[0] = totaly - nowy + 30 + ""; nicArray.Add(ss); } else { groupBox3.Controls.Add(newOvalShape(20, 27, 6, 6, "shapeContainer1", Color.Red)); this.panel1.Controls.Add(newLineShape(318, totaly - nowy + 30, 355, totaly - nowy + 30, "", "", DashStyle.Solid, 1)); } } /* * this.panel1.Controls.Add(groupBox3); * groupBox3.Name = "groupBox3" + i; * groupBox3.TabStop = false; * groupBox3.Location = new Point(335, totaly - nowy); * groupBox3.Text = "物理适配器"; * groupBox3.ResumeLayout(false); */ if (nicArray.Count > 0) { //路由或交换机 System.Windows.Forms.GroupBox groupBox4 = new System.Windows.Forms.GroupBox(); groupBox4.SuspendLayout(); groupBox4.Size = new Size(150, 70); groupBox4.Controls.Add(newPictureBox(25, 20, 105, 28, "pictureBoxnic", global::XenAdmin.Properties.Resources.switches)); groupBox4.Controls.Add(newOvalShape(10, 27, 6, 6, "shapeContainer1", Color.Lime)); //groupBox4.Controls.Add(newOvalShape(140, 27, 6, 6, "shapeContainer1", Color.Lime)); foreach (var nicob in nicArray) { this.panel1.Controls.Add(newLineShape(631, System.Int32.Parse(((string[])nicob)[0]), 665, totaly - nowy + 30, "", "", DashStyle.Solid, 1)); } this.panel1.Controls.Add(groupBox4); groupBox4.Name = "groupBox4" + i; groupBox4.TabStop = false; groupBox4.Location = new Point(655, totaly - nowy); groupBox4.Text = Messages.NETWORKTOPOLOGY_SWITCH_ROUTER; groupBox4.ResumeLayout(false); string[] ss = new string[4]; ss[0] = pifs[pift].IP; ss[1] = pifs[pift].netmask; ss[2] = 805 + ""; ss[3] = totaly - nowy + 27 + ""; switchesArray.Add(ss); } this.panel1.Controls.Add(groupBox3); groupBox3.Name = "groupBox3" + i; groupBox3.TabStop = false; groupBox3.Location = new Point(335, totaly - nowy); groupBox3.Text = Messages.NETWORKTOPOLOGY_PHYSICAL_ADAPTER; groupBox3.ResumeLayout(false); break; } } } else { //无物理网卡 System.Windows.Forms.GroupBox groupBox3 = new System.Windows.Forms.GroupBox(); groupBox3.SuspendLayout(); groupBox3.Size = new Size(300, 70); groupBox3.Controls.Add(newLable(60, 20, 200, 20, "nic", Messages.NETWORKTOPOLOGY_NO_PHYSICAL_NIC)); groupBox3.Controls.Add(newOvalShape(20, 27, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newOvalShape(312, totaly - nowy + 27, 6, 6, "shapeContainer1", Color.Lime)); this.panel1.Controls.Add(newLineShape(318, totaly - nowy + 30, 355, totaly - nowy + 30, "", "", DashStyle.Solid, 1)); this.panel1.Controls.Add(groupBox3); groupBox3.Name = "groupBox3" + i; groupBox3.TabStop = false; groupBox3.Location = new Point(335, totaly - nowy); groupBox3.Text = Messages.NETWORKTOPOLOGY_PHYSICAL_ADAPTER; groupBox3.ResumeLayout(false); } //vswicth this.panel1.Controls.Add(newRectangleShape(300, totaly - nowy + 10, 15, nowy - 10, "rectangleShape1", 2)); this.panel1.Controls.Add(newLable(0, totaly + 10, 0, 10, "labelend", "")); i++; } //存储 System.Windows.Forms.GroupBox groupBox5 = new System.Windows.Forms.GroupBox(); groupBox5.SuspendLayout(); groupBox5.AutoSize = true; groupBox5.AutoScrollOffset = new Point(250, 70); groupBox5.Size = new Size(150, 70); int srui = 0; for (int sri = 0; sri < srs.Length; sri++) { if (srs[sri].shared && !srs[sri].name_label.Equals("vGateServer Tools")) { for (int pbdi = 0; pbdi < pbds.Length; pbdi++) { if (pbds[pbdi].SR.opaque_ref.Equals(srs[sri].opaque_ref)) { if (pbds[pbdi].currently_attached) { groupBox5.Controls.Add(newPictureBox(25, 40 * (1 + srui) - 20, 16, 16, "pictureBoxnic", global::XenAdmin.Properties.Resources._000_Storage_h32bit_16)); groupBox5.Controls.Add(newOvalShape(10, 27 + (40 * srui), 6, 6, "shapeContainer1", Color.Lime)); break; } else { groupBox5.Controls.Add(newPictureBox(25, 40 * (1 + srui) - 20, 16, 16, "pictureBoxnic", global::XenAdmin.Properties.Resources._000_StorageBroken_h32bit_16)); groupBox5.Controls.Add(newOvalShape(10, 27 + (40 * srui), 6, 6, "shapeContainer1", Color.Red)); break; } } } groupBox5.Controls.Add(newLable(40, 40 * (1 + srui) - 20, 200, 20, "sr", srs[sri].name_label)); groupBox5.Controls.Add(newLable(40, 40 * (1 + srui), 200, 20, "srdescription", srs[sri].name_description)); /* * for(int swi = 0; swi < switchesArray.Count; swi++) * { * string[] ss = (string[])switchesArray[swi]; * this.panel1.Controls.Add(newLineShape(System.Int32.Parse(ss[2]), System.Int32.Parse(ss[3]), 865, 50 + 27 + (40 *srui), "", "", DashStyle.Solid, 1)); * }*/ srui++; } } //this.panel1.Controls.Add(newLineShape(800, totaly - nowy + 30, 840, totaly - nowy + 30, "", "", DashStyle.Solid, 1)); this.panel1.Controls.Add(groupBox5); groupBox5.Name = "groupBox5"; groupBox5.TabStop = false; groupBox5.Location = new Point(855, 70); groupBox5.Text = Messages.CONFIGURATION_HARDWARE_STORAGE; groupBox5.ResumeLayout(false); this.panel1.Controls.Add(newLable(1115, 0, 20, 20, "labelrend", "")); }
/// <summary> /// Configure an IP address, management purpose, and set the disallow_unplug flag on the given pif, then plug it. /// </summary> internal static void BringUp(AsyncAction action, PIF new_pif, PIF existing_pif, int hi) { BringUp(action, new_pif, new_pif.IP, existing_pif, hi); }
private void ReconfigureSecondaryManagement(PIF src, PIF dest, int hi) { System.Diagnostics.Trace.Assert(!bostonOrGreater); int mid = (PercentComplete + hi) / 2; PIF new_dest = NetworkingHelper.CopyIPConfig(src, dest); NetworkingActionHelpers.BringDown(this, src, mid); NetworkingActionHelpers.BringUp(this, new_dest, dest, hi); }
/// <summary> /// Switch the host's management interface from its current setting over to the given PIF. /// </summary> private static void ReconfigureManagement_(AsyncAction action, PIF pif, int hi) { log.DebugFormat("Switching to PIF {0} {1} for management...", pif.Name, pif.uuid); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_MANAGEMENT_RECONFIGURING, pif.Name); int mid = (hi + action.PercentComplete) / 2; PIF p = (PIF)pif.Clone(); p.disallow_unplug = false; p.ManagementPurpose = null; p.SaveChanges(action.Session); action.PercentComplete = mid; action.RelatedTask = XenAPI.Host.async_management_reconfigure(action.Session, pif.opaque_ref); action.PollToCompletion(mid, hi); log.DebugFormat("Switched to PIF {0} {1} for management.", pif.Name, pif.uuid); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_MANAGEMENT_RECONFIGURED, pif.Name); }
private XenAPI.Network FindCHINMainNetwork(PIF networksPIF) { // Assumes that the pif is the access pif of only one CHIN. If there's more than one, you get the first. if (networksPIF.tunnel_access_PIF_of.Count < 1) return null; Tunnel t = networksPIF.Connection.Resolve<Tunnel>(networksPIF.tunnel_access_PIF_of[0]); PIF transportPIF = networksPIF.Connection.Resolve<PIF>(t.transport_PIF); if (transportPIF == null) return null; //unexepected return networksPIF.Connection.Resolve<XenAPI.Network>(transportPIF.network); }
/// <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(); }
internal NewBond(Bond bond, PIF master, List<PIF> slaves) { this.bond = bond; this.master = master; this.slaves = slaves; }
/// <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); }
private string PIFName(PIF pif) { bool bond; return(string.Format(Messages.NETWORK_NAME, pif.NICIdentifier(out bond))); }
private List<int> GetVLANList(PIF nic) { List<int> vlans = new List<int>(); foreach (PIF pif in nic.Connection.Cache.PIFs) { if (pif.device == nic.device) { vlans.Add((int)pif.VLAN); } } return vlans; }
internal static void Plug(AsyncAction action, PIF pif, int hi) { if (!PIF.get_currently_attached(action.Session, pif.opaque_ref)) { log.DebugFormat("Plugging {0} {1} ...", pif.Name, pif.uuid); action.RelatedTask = PIF.async_plug(action.Session, pif.opaque_ref); action.PollToCompletion(action.PercentComplete, hi); log.DebugFormat("Plugging {0} {1} done.", pif.Name, pif.uuid); } }
/// <summary> /// If the "from" PIF is a secondary management interface, /// move the management interface name to the "to" PIF instead. /// </summary> internal static void MoveManagementInterfaceName(AsyncAction action, PIF from, PIF to) { string managementPurpose = from.ManagementPurpose; if (string.IsNullOrEmpty(managementPurpose)) return; log.DebugFormat("Moving management interface name from {0} to {1}...", from.uuid, to.uuid); PIF to_clone = (PIF)to.Clone(); to_clone.ManagementPurpose = from.ManagementPurpose; to_clone.SaveChanges(action.Session); PIF from_clone = (PIF)from.Clone(); from_clone.ManagementPurpose = null; from_clone.SaveChanges(action.Session); log.DebugFormat("Moving management interface name from {0} to {1} done.", from.uuid, to.uuid); }
internal static void ForSomeHosts(AsyncAction action, PIF pif, bool this_host, bool lock_pif, int hi, PIFMethod pif_method) { System.Diagnostics.Trace.Assert(pif != null); XenAPI.Network network = action.Connection.Resolve(pif.network); if (network == null) { log.Warn("Network has gone away"); return; } List<PIF> to_reconfigure = action.Connection.ResolveAll(network.PIFs).FindAll( (Predicate<PIF>)delegate(PIF p) { return this_host == (p.host.opaque_ref == pif.host.opaque_ref); }); if (to_reconfigure.Count == 0) return; int lo = action.PercentComplete; int inc = (hi - lo) / to_reconfigure.Count; foreach (PIF p in to_reconfigure) { if (lock_pif) p.Locked = true; try { lo += inc; pif_method(action, p, lo); } finally { if (lock_pif) p.Locked = false; } } }
private void Unplug(PIF p) { if (!p.currently_attached) { // We will try and unplug the PIF even if it seems to be already unplugged (CA-75969) log.DebugFormat("Unplugging PIF '{0}': this PIF is not currently attached. Will try to unplug anyway", p.uuid); } PIF.unplug(Session, p.opaque_ref); }
internal static void ReconfigureManagement(AsyncAction action, PIF down_pif, PIF up_pif, bool this_host, bool lock_pif, int hi, bool bring_down_down_pif) { System.Diagnostics.Trace.Assert(down_pif.host.opaque_ref == up_pif.host.opaque_ref); // To change the management interface on a host, you need to: // 1. Clear the disallow_unplug flag from the current management PIF (we clear ManagementPurpose at the same time); // 2. Use Host.management_reconfigure to switch to the new PIF; // 3. Clear the IP address from the old management PIF. int lo = action.PercentComplete; int inc = (hi - lo) / 3; lo += inc; if (bring_down_down_pif) ForSomeHosts(action, down_pif, this_host, lock_pif, lo, Depurpose); lo += inc; ForSomeHosts(action, up_pif, this_host, lock_pif, lo, ReconfigureManagement_); if (bring_down_down_pif) ForSomeHosts(action, down_pif, this_host, lock_pif, hi, ClearIP); }
private string PIFDescription(PIF pif) { Bond bond = pif.BondSlaveOf; return bond == null ? "" : string.Format(Messages.ALREADY_IN_BOND, bond.Name); }
internal static void ReconfigurePrimaryManagement(AsyncAction action, PIF src, PIF dest, int hi) { PIF new_dest = NetworkingHelper.CopyIPConfig(src, dest); // We bring up the slave interfaces on the slave hosts, without plugging them. // Then the slave interface on the master host. // Then we reconfigure the management interface on the slaves. // Then the master. int lo = action.PercentComplete; int inc = (hi - lo) / 4; lo += inc; BringUp(action, new_dest, false, lo); lo += inc; BringUp(action, new_dest, true, lo); lo += inc; ReconfigureManagement(action, src, new_dest, false, false, lo, true); ReconfigureManagement(action, src, new_dest, true, false, hi, true); }
public static Icons GetIconFor(PIF pif) { return pif.IsPrimaryManagementInterface() ? Icons.PifPrimary : Icons.PifSecondary; }
internal static void ReconfigureSinglePrimaryManagement(AsyncAction action, PIF src, PIF dest, int hi) { PIF new_dest = NetworkingHelper.CopyIPConfig(src, dest); // We put an IP address on the destination interface, then we reconfigure the management interface onto it. int mid = (hi + action.PercentComplete) / 2; BringUp(action, new_dest, new_dest.IP, dest, mid); ReconfigureManagement(action, src, new_dest, true, false, hi, true); }
// Can the network's NIC and VLAN be edited? private bool Editable(PIF pif) { return (pif == null || (!pif.IsPhysical && !pif.IsTunnelAccessPIF)); }
//internal static void DeconfigureSecondaryManagement(AsyncAction action, PIF pif, int hi) //{ // int mid = (action.PercentComplete + hi) / 2; // BringDown(action, pif, false, mid); // BringDown(action, pif, true, hi); //} //internal static void ReconfigureSecondaryManagement(AsyncAction action, PIF pif, int hi) //{ // // We reconfigure the interfaces on the slaves, then the master. // int mid = (action.PercentComplete + hi) / 2; // BringUp(action, pif, false, mid); // BringUp(action, pif, true, hi); //} private static void BringUp(AsyncAction action, PIF new_pif, bool this_host, int hi) { ForSomeHosts(action, new_pif, this_host, false, hi, delegate(AsyncAction a, PIF p, int h) { BringUp(a, new_pif, new_pif.IP, p, h); }); }
private NetworkComboBoxItem CreateNewItem(PIF pif) { var network = PopulateConnection.Resolve(pif.network); return new NetworkComboBoxItem { IncludePoolNameInComboBox = IncludePoolNameInComboBox, IsManagement = pif.management, Network = network, NetworkIsConnected = pif.LinkStatus == PIF.LinkState.Connected, HasIPAddress = pif.IsManagementInterface(false) }; }
/// <summary> /// Remove the IP address from the given PIF. /// </summary> private static void ClearIP(AsyncAction action, PIF pif, int hi) { log.DebugFormat("Removing IP address from {0} {1}...", pif.Name, pif.uuid); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_DOWN, pif.Name); action.RelatedTask = PIF.async_reconfigure_ip(action.Session, pif.opaque_ref, ip_configuration_mode.None, "", "", "", ""); action.PollToCompletion(action.PercentComplete, hi); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_DOWN_DONE, pif.Name); log.DebugFormat("Removed IP address from {0} {1}.", pif.Name, pif.uuid); }
/// <summary> /// Clear the disallow_unplug and ManagementPurpose on the given NIC. /// </summary> private static void Depurpose(AsyncAction action, PIF pif, int hi) { log.DebugFormat("Depurposing PIF {0} {1}...", pif.Name, pif.uuid); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_DEPURPOSING, pif.Name); PIF p = (PIF)pif.Clone(); p.disallow_unplug = false; p.ManagementPurpose = null; p.SaveChanges(action.Session); action.PercentComplete = hi; log.DebugFormat("Depurposed PIF {0} {1}.", pif.Name, pif.uuid); action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_DEPURPOSED, pif.Name); }
protected override void ProcessRecord() { XenAPI.Session session = XenObject as XenAPI.Session; if (session != null) { WriteObject(new XenRef <XenAPI.Session>(session)); return; } XenAPI.Auth auth = XenObject as XenAPI.Auth; if (auth != null) { WriteObject(new XenRef <XenAPI.Auth>(auth)); return; } XenAPI.Subject subject = XenObject as XenAPI.Subject; if (subject != null) { WriteObject(new XenRef <XenAPI.Subject>(subject)); return; } XenAPI.Role role = XenObject as XenAPI.Role; if (role != null) { WriteObject(new XenRef <XenAPI.Role>(role)); return; } XenAPI.Task task = XenObject as XenAPI.Task; if (task != null) { WriteObject(new XenRef <XenAPI.Task>(task)); return; } XenAPI.Event evt = XenObject as XenAPI.Event; if (evt != null) { WriteObject(new XenRef <XenAPI.Event>(evt)); return; } XenAPI.Pool pool = XenObject as XenAPI.Pool; if (pool != null) { WriteObject(new XenRef <XenAPI.Pool>(pool)); return; } XenAPI.Pool_patch pool_patch = XenObject as XenAPI.Pool_patch; if (pool_patch != null) { WriteObject(new XenRef <XenAPI.Pool_patch>(pool_patch)); return; } XenAPI.Pool_update pool_update = XenObject as XenAPI.Pool_update; if (pool_update != null) { WriteObject(new XenRef <XenAPI.Pool_update>(pool_update)); return; } XenAPI.VM vm = XenObject as XenAPI.VM; if (vm != null) { WriteObject(new XenRef <XenAPI.VM>(vm)); return; } XenAPI.VM_metrics vm_metrics = XenObject as XenAPI.VM_metrics; if (vm_metrics != null) { WriteObject(new XenRef <XenAPI.VM_metrics>(vm_metrics)); return; } XenAPI.VM_guest_metrics vm_guest_metrics = XenObject as XenAPI.VM_guest_metrics; if (vm_guest_metrics != null) { WriteObject(new XenRef <XenAPI.VM_guest_metrics>(vm_guest_metrics)); return; } XenAPI.VMPP vmpp = XenObject as XenAPI.VMPP; if (vmpp != null) { WriteObject(new XenRef <XenAPI.VMPP>(vmpp)); return; } XenAPI.VMSS vmss = XenObject as XenAPI.VMSS; if (vmss != null) { WriteObject(new XenRef <XenAPI.VMSS>(vmss)); return; } XenAPI.VM_appliance vm_appliance = XenObject as XenAPI.VM_appliance; if (vm_appliance != null) { WriteObject(new XenRef <XenAPI.VM_appliance>(vm_appliance)); return; } XenAPI.DR_task dr_task = XenObject as XenAPI.DR_task; if (dr_task != null) { WriteObject(new XenRef <XenAPI.DR_task>(dr_task)); return; } XenAPI.Host host = XenObject as XenAPI.Host; if (host != null) { WriteObject(new XenRef <XenAPI.Host>(host)); return; } XenAPI.Host_crashdump host_crashdump = XenObject as XenAPI.Host_crashdump; if (host_crashdump != null) { WriteObject(new XenRef <XenAPI.Host_crashdump>(host_crashdump)); return; } XenAPI.Host_patch host_patch = XenObject as XenAPI.Host_patch; if (host_patch != null) { WriteObject(new XenRef <XenAPI.Host_patch>(host_patch)); return; } XenAPI.Host_metrics host_metrics = XenObject as XenAPI.Host_metrics; if (host_metrics != null) { WriteObject(new XenRef <XenAPI.Host_metrics>(host_metrics)); return; } XenAPI.Host_cpu host_cpu = XenObject as XenAPI.Host_cpu; if (host_cpu != null) { WriteObject(new XenRef <XenAPI.Host_cpu>(host_cpu)); return; } XenAPI.Network network = XenObject as XenAPI.Network; if (network != null) { WriteObject(new XenRef <XenAPI.Network>(network)); return; } XenAPI.VIF vif = XenObject as XenAPI.VIF; if (vif != null) { WriteObject(new XenRef <XenAPI.VIF>(vif)); return; } XenAPI.VIF_metrics vif_metrics = XenObject as XenAPI.VIF_metrics; if (vif_metrics != null) { WriteObject(new XenRef <XenAPI.VIF_metrics>(vif_metrics)); return; } XenAPI.PIF pif = XenObject as XenAPI.PIF; if (pif != null) { WriteObject(new XenRef <XenAPI.PIF>(pif)); return; } XenAPI.PIF_metrics pif_metrics = XenObject as XenAPI.PIF_metrics; if (pif_metrics != null) { WriteObject(new XenRef <XenAPI.PIF_metrics>(pif_metrics)); return; } XenAPI.Bond bond = XenObject as XenAPI.Bond; if (bond != null) { WriteObject(new XenRef <XenAPI.Bond>(bond)); return; } XenAPI.VLAN vlan = XenObject as XenAPI.VLAN; if (vlan != null) { WriteObject(new XenRef <XenAPI.VLAN>(vlan)); return; } XenAPI.SM sm = XenObject as XenAPI.SM; if (sm != null) { WriteObject(new XenRef <XenAPI.SM>(sm)); return; } XenAPI.SR sr = XenObject as XenAPI.SR; if (sr != null) { WriteObject(new XenRef <XenAPI.SR>(sr)); return; } XenAPI.LVHD lvhd = XenObject as XenAPI.LVHD; if (lvhd != null) { WriteObject(new XenRef <XenAPI.LVHD>(lvhd)); return; } XenAPI.VDI vdi = XenObject as XenAPI.VDI; if (vdi != null) { WriteObject(new XenRef <XenAPI.VDI>(vdi)); return; } XenAPI.VBD vbd = XenObject as XenAPI.VBD; if (vbd != null) { WriteObject(new XenRef <XenAPI.VBD>(vbd)); return; } XenAPI.VBD_metrics vbd_metrics = XenObject as XenAPI.VBD_metrics; if (vbd_metrics != null) { WriteObject(new XenRef <XenAPI.VBD_metrics>(vbd_metrics)); return; } XenAPI.PBD pbd = XenObject as XenAPI.PBD; if (pbd != null) { WriteObject(new XenRef <XenAPI.PBD>(pbd)); return; } XenAPI.Crashdump crashdump = XenObject as XenAPI.Crashdump; if (crashdump != null) { WriteObject(new XenRef <XenAPI.Crashdump>(crashdump)); return; } XenAPI.VTPM vtpm = XenObject as XenAPI.VTPM; if (vtpm != null) { WriteObject(new XenRef <XenAPI.VTPM>(vtpm)); return; } XenAPI.Console console = XenObject as XenAPI.Console; if (console != null) { WriteObject(new XenRef <XenAPI.Console>(console)); return; } XenAPI.User user = XenObject as XenAPI.User; if (user != null) { WriteObject(new XenRef <XenAPI.User>(user)); return; } XenAPI.Data_source data_source = XenObject as XenAPI.Data_source; if (data_source != null) { WriteObject(new XenRef <XenAPI.Data_source>(data_source)); return; } XenAPI.Blob blob = XenObject as XenAPI.Blob; if (blob != null) { WriteObject(new XenRef <XenAPI.Blob>(blob)); return; } XenAPI.Message message = XenObject as XenAPI.Message; if (message != null) { WriteObject(new XenRef <XenAPI.Message>(message)); return; } XenAPI.Secret secret = XenObject as XenAPI.Secret; if (secret != null) { WriteObject(new XenRef <XenAPI.Secret>(secret)); return; } XenAPI.Tunnel tunnel = XenObject as XenAPI.Tunnel; if (tunnel != null) { WriteObject(new XenRef <XenAPI.Tunnel>(tunnel)); return; } XenAPI.PCI pci = XenObject as XenAPI.PCI; if (pci != null) { WriteObject(new XenRef <XenAPI.PCI>(pci)); return; } XenAPI.PGPU pgpu = XenObject as XenAPI.PGPU; if (pgpu != null) { WriteObject(new XenRef <XenAPI.PGPU>(pgpu)); return; } XenAPI.GPU_group gpu_group = XenObject as XenAPI.GPU_group; if (gpu_group != null) { WriteObject(new XenRef <XenAPI.GPU_group>(gpu_group)); return; } XenAPI.VGPU vgpu = XenObject as XenAPI.VGPU; if (vgpu != null) { WriteObject(new XenRef <XenAPI.VGPU>(vgpu)); return; } XenAPI.VGPU_type vgpu_type = XenObject as XenAPI.VGPU_type; if (vgpu_type != null) { WriteObject(new XenRef <XenAPI.VGPU_type>(vgpu_type)); return; } XenAPI.PVS_site pvs_site = XenObject as XenAPI.PVS_site; if (pvs_site != null) { WriteObject(new XenRef <XenAPI.PVS_site>(pvs_site)); return; } XenAPI.PVS_server pvs_server = XenObject as XenAPI.PVS_server; if (pvs_server != null) { WriteObject(new XenRef <XenAPI.PVS_server>(pvs_server)); return; } XenAPI.PVS_proxy pvs_proxy = XenObject as XenAPI.PVS_proxy; if (pvs_proxy != null) { WriteObject(new XenRef <XenAPI.PVS_proxy>(pvs_proxy)); return; } XenAPI.PVS_cache_storage pvs_cache_storage = XenObject as XenAPI.PVS_cache_storage; if (pvs_cache_storage != null) { WriteObject(new XenRef <XenAPI.PVS_cache_storage>(pvs_cache_storage)); return; } XenAPI.Feature feature = XenObject as XenAPI.Feature; if (feature != null) { WriteObject(new XenRef <XenAPI.Feature>(feature)); return; } XenAPI.SDN_controller sdn_controller = XenObject as XenAPI.SDN_controller; if (sdn_controller != null) { WriteObject(new XenRef <XenAPI.SDN_controller>(sdn_controller)); return; } XenAPI.Vdi_nbd_server_info vdi_nbd_server_info = XenObject as XenAPI.Vdi_nbd_server_info; if (vdi_nbd_server_info != null) { WriteObject(new XenRef <XenAPI.Vdi_nbd_server_info>(vdi_nbd_server_info)); return; } XenAPI.PUSB pusb = XenObject as XenAPI.PUSB; if (pusb != null) { WriteObject(new XenRef <XenAPI.PUSB>(pusb)); return; } XenAPI.USB_group usb_group = XenObject as XenAPI.USB_group; if (usb_group != null) { WriteObject(new XenRef <XenAPI.USB_group>(usb_group)); return; } XenAPI.VUSB vusb = XenObject as XenAPI.VUSB; if (vusb != null) { WriteObject(new XenRef <XenAPI.VUSB>(vusb)); return; } }