public MessageAlert(XenAPI.Message m) { Message = m; uuid = m.uuid; _timestamp = m.timestamp; try { _priority = (int)m.priority; } catch (OverflowException) { _priority = DEFAULT_PRIORITY; } Connection = m.Connection; XenObject = Helpers.XenObjectFromMessage(m); // TODO: This would be better if there was some way of getting the actual host that the XenObject belongs to // Currently if the applies to object is not a host or pool and belongs to a slave it is filtered under the master. Host h = XenObject as Host; if (h == null) h = Helpers.GetMaster(m.Connection); if (h != null) HostUuid = h.uuid; }
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 DestroyPoolAction(XenAPI.Pool pool) : base(pool.Connection, string.Format(Messages.DESTROYING_POOL, pool.Name)) { System.Diagnostics.Trace.Assert(pool != null); Pool = pool; this.Description = Messages.WAITING; }
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; }
public IscsiChoicesDialog(IXenConnection connection, XenAPI.SR.SRInfo srInfo) : base(connection) { InitializeComponent(); this.labelSRinfo.Text = String.Format(Messages.ISCSI_DIALOG_SR_DETAILS, Util.DiskSizeString(srInfo.Size), srInfo.UUID); }
public HostPowerOnAction(XenAPI.Host host) : base(host.Connection, Messages.HOST_POWER_ON) { Host = host; AddCommonAPIMethodsToRoleCheck(); ApiMethodsToRoleCheck.Add("pool.send_wlb_configuration"); ApiMethodsToRoleCheck.Add("host.power_on"); }
public NetworkListViewItem(IXenConnection connection, XenAPI.Network network, int index) { Vif = new VIF(); Vif.Connection = connection; Vif.device = index.ToString(); Vif.network = new XenRef<XenAPI.Network>(network.opaque_ref); CreateCells(); }
public ChangeServerPasswordDialog(XenAPI.Pool pool) { InitializeComponent(); this.pool = pool; pool.PropertyChanged += new PropertyChangedEventHandler(Server_PropertyChanged); UpdateText(); checkConfirmEnablement(); }
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; }
public ChangeServerPasswordDialog(XenAPI.Host host) { InitializeComponent(); this.host = host; host.PropertyChanged += new PropertyChangedEventHandler(Server_PropertyChanged); UpdateText(); checkConfirmEnablement(); }
public MoveVirtualDiskAction(IXenConnection connection, XenAPI.VDI vdi, SR sr) : base(connection, string.Format(Messages.ACTION_MOVING_VDI_TITLE, Helpers.GetName(vdi), Helpers.GetName(sr))) { this.vdi = vdi; SR = sr; vdi.Locked = true; sr.Locked = true; ApiMethodsToRoleCheck.Add("vdi.destroy"); ApiMethodsToRoleCheck.Add("vdi.copy"); if (vdi.type == vdi_type.suspend) ApiMethodsToRoleCheck.Add("vm.set_suspend_VDI"); ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList); ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList); }
public VbdSaveAndPlugAction(VM vm, XenAPI.VBD vbd, string vdiName, XenAPI.Session session, bool supress, Action showMustRebootBoxCD, Action showVBDWarningBox) : base(vm.Connection, string.Format(Messages.ATTACHING_VIRTUAL_DISK, vdiName, vm.Name), "", supress) { _ShowVBDWarningBox = showVBDWarningBox; _ShowMustRebootBoxCD = showMustRebootBoxCD; VM = vm; this.vbd = vbd; // Preserve existing session if provided. if (session != null) this.Session = session; ApiMethodsToRoleCheck.Add("vbd.async_plug"); ApiMethodsToRoleCheck.Add("vbd.set_userdevice"); }
/// <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(); }
public static Image GetImage16For(XenAPI.Message.MessageType type) { return GetImage16For(GetIconFor(type)); }
public static Icons GetIconFor(XenAPI.Message.MessageType type) { switch (type) { case XenAPI.Message.MessageType.VM_STARTED: return Icons.VmStart; case XenAPI.Message.MessageType.VM_SHUTDOWN: return Icons.VmShutdown; case XenAPI.Message.MessageType.VM_REBOOTED: return Icons.VmReboot; case XenAPI.Message.MessageType.VM_SUSPENDED: return Icons.VmSuspend; case XenAPI.Message.MessageType.VM_RESUMED: return Icons.VmResumed; case XenAPI.Message.MessageType.VM_CLONED: return Icons.VmCloned; default: return Icons.MessageUnknown; } }
public static Icons GetIconFor(XenAPI.Network network) { return Icons.Network; }
public VMCannotSeeNetwork(Check check, VM vm, XenAPI.Network network) : base(check, vm) { Network = network; }
private void CheckMessage(XenAPI.Message m, CollectionChangeAction a) { if (!m.ShowOnGraphs || m.cls != cls.VM) return; Host h = XenObject as Host; if (h != null) { List<VM> resVMs = h.Connection.ResolveAll<VM>(h.resident_VMs); foreach (VM v in resVMs) { if (v.uuid == m.obj_uuid) { if (a == CollectionChangeAction.Add) DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m)); else DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m)); break; } } } else if (XenObject is VM) { if (m.obj_uuid != Helpers.GetUuid(XenObject)) return; if (a == CollectionChangeAction.Add) DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m)); else DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m)); } }
private string FindOtherPurpose(XenAPI.Network network) { if (InUseMap[network] != null) { List<NetworkingPropertiesPage> pages = InUseMap[network]; foreach (NetworkingPropertiesPage page in pages) { if (page != this) return page.Purpose; } } return null; }
public static void RemoveAlert(XenAPI.Message m) { Alert a = FindAlert(m); if (a != null) RemoveAlert(a); }
/// <summary> /// Parses a XenAPI.Message into an Alert object. /// </summary> /// <param name="msg"></param> /// <returns></returns> public static Alert ParseMessage(XenAPI.Message msg) { if (msg.IsPerfmonAlarm) { return new AlarmMessageAlert(msg); } // For all other kinds of alert return new MessageAlert(msg); }
/// <summary> /// Find the MessageAlert corresponding to the given Message, or null if none exists. /// </summary> /// <param name="m"></param> public static Alert FindAlert(XenAPI.Message m) { return FindAlert(a => a is MessageAlert && ((MessageAlert)a).Message.opaque_ref == m.opaque_ref && m.Connection == a.Connection); }
public VMCrossPoolMigrateAction(VM vm, Host destinationHost, XenAPI.Network transferNetwork, VmMapping mapping) : this(vm, destinationHost, transferNetwork, mapping, false) { }
public DestroyBondCommand(IMainWindow mainWindow, XenAPI.Network network) : base(mainWindow, 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(); }
/// <summary> /// A general HttpPut method, with delegates for progress and cancelling /// </summary> /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param> /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param> /// <param name="timeout">Timeout value in ms</param> /// <param name="task">The task used to track this http get</param> /// <param name="session">Session used to make api calls (may be replaced if logged out, hence ref)</param> /// <param name="path">Path to file to put</param> /// <returns>The result of the task passed in</returns> public static String Put(XenAPI.HTTP.UpdateProgressDelegate progressDelegate, HTTP.FuncBool cancellingDelegate, int timeout, IXenConnection connection, XenRef<Task> task, ref Session session, string path, string hostname, Delegate f, params object[] p) { log.DebugFormat("HTTP PUTTING file from {0} to {1}", path, hostname); HTTP.FuncBool cancellingDelegate2 = (HTTP.FuncBool)delegate() { return (XenAdminConfigManager.Provider.ForcedExiting || cancellingDelegate != null && cancellingDelegate()); }; try { List<object> args = new List<object>(); args.Add(progressDelegate); args.Add(cancellingDelegate2); args.Add(timeout); args.Add(hostname); args.Add(XenAdminConfigManager.Provider.GetProxyFromSettings(connection)); args.Add(path); args.Add(task.opaque_ref); // task_id args.AddRange(p); f.DynamicInvoke(args.ToArray()); } catch (Exception e) { log.DebugFormat("Caught exception doing HTTP PUT from {0} to {1}", path, hostname); log.Debug(e, e); PollTaskForResult(connection, ref session, cancellingDelegate2, task, true); if (e is CancelledException || e.InnerException is CancelledException) throw new XenAdmin.CancelledException(); else throw; } return PollTaskForResult(connection, ref session, cancellingDelegate2, task); }
/// <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(); }
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; }
internal void RefreshNetworkComboBox(Dictionary<XenAPI.Network, List<NetworkingPropertiesPage>> InUseMap, XenAPI.Network ManagementNetwork) { 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 (type == Type.PRIMARY || type == Type.PRIMARY_WITH_HA) networks.RemoveAll( network=>network.IsVLAN); NetworkComboBox.Items.AddRange(networks.ToArray()); SquelchNetworkComboBoxChange = true; try { NetworkComboBox.SelectedItem = selected; } finally { SquelchNetworkComboBoxChange = false; } if (!TriggeringChange) { RefreshButtons(); } }
/// <summary> /// A general HttpPut method, with delegates for progress and cancelling /// </summary> /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param> /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param> /// <param name="timeout">Whether to apply a timeout</param> /// <param name="task">The task used to track this http get</param> /// <param name="session">Session used to make api calls (may be replaced if logged out, hence ref)</param> /// <param name="path">Path to file to put</param> /// <returns>The result of the task passed in</returns> public static String Put(XenAPI.HTTP.UpdateProgressDelegate progressDelegate, HTTP.FuncBool cancellingDelegate, bool timeout, IXenConnection connection, XenRef<Task> task, ref Session session, string path, string hostname, Delegate f, params object[] p) { return Put(progressDelegate, cancellingDelegate, XenAdminConfigManager.Provider.GetProxyTimeout(timeout), connection, task, ref session, path, hostname, f, p); }