private void DeconfigureSecondaryManagement(PIF master, int hi) { System.Diagnostics.Trace.Assert(!bostonOrGreater); NewFirstSlaves[master] = NetworkingHelper.CopyIPConfig(master, FirstSlaves[master]); NetworkingActionHelpers.BringDown(this, master, hi); Secondaries.Add(master); }
internal void SetPool(Pool pool) { Connection = pool.Connection; bondSizeLimit = Helpers.BondSizeLimit(Connection); PopulateDataGridView(NetworkingHelper.GetAllPhysicalPIFs(pool)); ShowHideControls(); }
private void OnEndpointFound(System.ServiceModel.Discovery.EndpointDiscoveryMetadata obj) { try { var channelFactory = new DuplexChannelFactory <IDebugService>(this, NetworkingHelper.CreateTcpBinding()); var debugService = channelFactory.CreateChannel(obj.Address); var info = debugService.Initialize(); if (_connections.Add(info)) { _clients[debugService] = new ClientContext(debugService, info); var communicationObject = (debugService as ICommunicationObject); communicationObject.Faulted += OnEndpointLost; communicationObject.Closed += OnEndpointLost; } else { debugService.Close(); (debugService as ICommunicationObject).Close(); } } catch (Exception e) { Console.WriteLine(e.Message); //Try restore connection _dynamicServiceResolver.Probe(_probeTimeout); } }
public static NetworkError RegisterClient(TCPServerInfos client, string password) { if (NetworkingHelper.GetInstance().Server.Room == null) { return(NetworkError.NoRoomStarted); } if (NetworkingHelper.GetInstance().Server.Room.Password != "") { if (NetworkingHelper.GetInstance().Server.Room.Password != password) { return(NetworkError.BadPassword); } } if (client == null) { return(NetworkError.NullClientSent); } if (_clients == null) { _clients = new List <TCPServerInfos>(); } _clients.RemoveAll(x => x.ServerIP == client.ServerIP); _clients.Add(client); return(NetworkError.None); }
internal void SetHost(Host host) { Connection = host.Connection; bondSizeLimit = Helpers.BondSizeLimit(Connection); PopulateDataGridView(NetworkingHelper.GetAllPhysicalPIFs(host)); ShowHideControls(); }
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); }
/// <param name="name_label">The name for the new network.</param> /// <param name="PIFs_on_master">The PIFs on the master representing the physical NICs that are to be bonded together.</param> /// <param name="autoplug">Whether the new network is marked AutoPlug.</param> /// <param name="mtu">The MTU for the Bond, ignored for pre cowley</param> /// <param name="bondMode">The bond mode, ignored for pre-Boston</param> public CreateBondAction(IXenConnection connection, string name_label, List <PIF> PIFs_on_master, bool autoplug, long mtu, bond_mode bondMode, Bond.hashing_algoritm hashingAlgoritm) : base(connection, string.Format(Messages.ACTION_CREATE_BOND_TITLE, name_label), string.Format(Messages.ACTION_CREATE_BOND_DESCRIPTION, name_label)) { this.name_label = name_label; this.autoplug = autoplug; this.mtu = mtu; this.bondMode = bondMode; this.hashingAlgoritm = hashingAlgoritm; Pool = Helpers.GetPoolOfOne(Connection); if (Pool == null) { throw new Failure(Failure.INTERNAL_ERROR, "Pool has gone away"); } Master = Connection.Resolve(Pool.master); if (Master == null) { throw new Failure(Failure.INTERNAL_ERROR, "Pool master has gone away"); } bostonOrGreater = Helpers.BostonOrGreater(connection); tampaOrGreater = Helpers.TampaOrGreater(connection); foreach (Host host in Connection.Cache.Hosts) { AppliesTo.Add(host.opaque_ref); } #region RBAC Dependencies ApiMethodsToRoleCheck.Add("host.management_reconfigure"); ApiMethodsToRoleCheck.Add("network.create"); ApiMethodsToRoleCheck.Add("network.destroy"); ApiMethodsToRoleCheck.Add("network.remove_from_other_config"); ApiMethodsToRoleCheck.Add("pif.reconfigure_ip"); ApiMethodsToRoleCheck.Add("pif.plug"); ApiMethodsToRoleCheck.Add("bond.create"); ApiMethodsToRoleCheck.Add("bond.destroy"); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList); #endregion PIFs = NetworkingHelper.PIFsOnAllHosts(PIFs_on_master); // these locks will be cleared in clean() foreach (List <PIF> pifs in PIFs.Values) { foreach (PIF pif in pifs) { pif.Locked = true; } } }
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); }
internal DialogResult ShowCreationWarning() { List <PIF> pifs = BondedPIFs; bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); if (will_disturb_primary && will_disturb_secondary) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.BOND_CREATE_WILL_DISTURB_BOTH, Messages.BOND_CREATE)).ShowDialog(this); return(DialogResult.Cancel); } if (will_disturb_primary) { Pool pool = Helpers.GetPool(Connection); if (pool != null && pool.ha_enabled) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_CREATE_HA_ENABLED, pool.Name), Messages.BOND_CREATE)).ShowDialog(this); return(DialogResult.Cancel); } return(new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_PRIMARY, Messages.BOND_CREATE), "BondConfigError", new ThreeButtonDialog.TBDButton(Messages.BOND_CREATE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel).ShowDialog(this)); } if (will_disturb_secondary) { return(new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_SECONDARY, Messages.BOND_CREATE), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel).ShowDialog(this)); } return(DialogResult.OK); }
// ----------------------------- // Main Loop // ----------------------------- // Runs at the start of the application void Start() { // Setting object reference to the instance of object networking = new NetworkingHelper(); writeTextHelper = new WriteTextHelper(); // Sends starting message to server to check whether the http functions are working StartCoroutine(UploadHTTP("Connected!")); // Starts clock for updating current brick coordinate text mesh in virtual environment at a slow 2fps to reduce computation InvokeRepeating("UpdateText", 0.5f, 0.5f); // initially assign to empty string posX = ""; posY = ""; posZ = ""; rotX = ""; rotY = ""; rotZ = ""; // Initializes gesture recognition for single taps tapRecognizer = new GestureRecognizer(); tapRecognizer.SetRecognizableGestures(GestureSettings.Tap); tapRecognizer.TappedEvent += TapRecognizer_TappedEvent; tapRecognizer.StartCapturingGestures(); odd_tap = true;// Used for identifying odd and even taps, which either creates a new brick or dropps a brick // Voice Recognition for resetting brick KeywordRecognizer resetRecognizer = new KeywordRecognizer(new[] { "Reset" }); resetRecognizer.OnPhraseRecognized += ResetRecognizer_OnPhraseRecognized; resetRecognizer.Start(); // assign the file path the data will be written into //path = "Asset/Resources/test.txt"; // relative path path = "C:/Users/Danny/Documents/RobotSandbox/test.txt"; // absolute path: so the path could be referred to after the compilation // Clear the content of text file before loading data into it File.WriteAllText(path, String.Empty); }
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 override Packet OnPacketReceive(Packet receivedPacket) { ClientSendChatMessageEventPacket p = (receivedPacket as ClientSendChatMessageEventPacket); string wordToFind = NetworkingHelper.GetInstance().Server.Room.Word; if (p.Message.RefactorText() == wordToFind.RefactorText()) { //Show to everyone that he found the word p.Message = $"{p.Time.ToShortTimeString()} : {p.Sender} a trouvé le mot"; ScoreManager.GetInstance().PlayerFoundWord(p.Sender, p.Time); } EventsManager.OnChatMessageReceive?.Invoke(new Objects.EventArgs.OnChatMessageReceiveEventArgs( p.Sender, p.Message, p.Time) ); ClientsManager.SendPacketToEveryClients(receivedPacket); return(new ServerResponsePacket(NetworkError.None)); }
public override Packet OnPacketReceive(Packet receivedPacket) { return new ServerSendRoomPacket(NetworkingHelper.GetInstance().Server.Room); }
/// <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; } }
public JoinRoomView() { network = NetworkingHelper.GetInstance(); InitializeComponent(); }
internal bool CanCreateBond() { List <PIF> pifs = BondedPIFs; bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); bool will_disturb_clustering = NetworkingHelper.ContainsClusteringPif(pifs); // It is not allowed to bond primary and secondary interfaces together. if (will_disturb_primary && will_disturb_secondary) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.BOND_CREATE_WILL_DISTURB_BOTH, Messages.BOND_CREATE))) { dlg.ShowDialog(this); } return(false); } // Only primary management interface. // In this case, clustering interface warning is hidden if it happens to be the management interface. if (will_disturb_primary) { Pool pool = Helpers.GetPool(Connection); if (pool != null && pool.ha_enabled) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_CREATE_HA_ENABLED, pool.Name()), Messages.BOND_CREATE))) { dlg.ShowDialog(this); } return(false); } DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_PRIMARY, Messages.BOND_CREATE), "BondConfigError", new ThreeButtonDialog.TBDButton(Messages.BOND_CREATE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(this); } return(dialogResult == DialogResult.OK); } // Only secondary interface. // If there is clustering interface, shows clustering warning. Otherwise, shows secondary interface warning. if (will_disturb_secondary) { DialogResult dialogResult; if (will_disturb_clustering) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_CLUSTERING, Messages.BOND_CREATE), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(this); } } else { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_SECONDARY, Messages.BOND_CREATE), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(this); } } return(dialogResult == DialogResult.OK); } return(true); }
protected sealed override void ExecuteCore(SelectedItemCollection selection) { //It only supports one item selected for now Trace.Assert(selection.Count == 1); XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject; List <PIF> pifs = network.Connection.ResolveAll(network.PIFs); if (pifs.Count == 0) { // Should never happen as long as the caller is enabling the button correctly, but // it's possible in a tiny window across disconnecting. log.Error("Network has no PIFs"); return; } // We just want one, so that we can name it. PIF pif = pifs[0]; string new_name; string msg; if (network != null && !Helpers.BostonOrGreater(network.Connection) && network.Connection.ResolveAll(network.VIFs).Count > 0) { // We have a live pre-Boston network. Tell the user that we're going to rename it. new_name = Helpers.MakeUniqueName(Messages.RENAMED_BOND, GetAllNetworkNames(network.Connection)); msg = string.Format(Messages.DELETE_BOND_WITH_VIFS_MESSAGE, pif.Name, new_name); } else { // It's not in use -- delete the network as well as the bonds and PIFs. new_name = null; msg = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name); } bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); if (will_disturb_primary) { Pool pool = Helpers.GetPool(network.Connection); if (pool != null && pool.ha_enabled) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name), Messages.DELETE_BOND)).ShowDialog(Parent); return; } string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg); if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND), "NetworkingConfigWarning", new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) { return; } } else if (will_disturb_secondary) { if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) { return; } } else { if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true), ThreeButtonDialog.ButtonCancel).ShowDialog(Program.MainWindow)) { return; } } // The UI shouldn't offer deleting a bond in this case, but let's make sure we've // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436). Bond bond = pif.BondMasterOf; if (bond != null) { new Actions.DestroyBondAction(bond, new_name).RunAsync(); } }
private string GetManagementBondName() { Bond bond = NetworkingHelper.GetMasterManagementBond(Connection); return(bond == null ? Messages.UNKNOWN : bond.Name()); }
protected sealed override void ExecuteCore(SelectedItemCollection selection) { //It only supports one item selected for now Trace.Assert(selection.Count == 1); XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject; List <PIF> pifs = network.Connection.ResolveAll(network.PIFs); if (pifs.Count == 0) { // Should never happen as long as the caller is enabling the button correctly, but // it's possible in a tiny window across disconnecting. log.Error("Network has no PIFs"); return; } // We just want one, so that we can name it. PIF pif = pifs[0]; string msg = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name()); bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); if (will_disturb_primary) { Pool pool = Helpers.GetPool(network.Connection); if (pool != null && pool.ha_enabled) { using (var dlg = new ErrorDialog(string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name(), pool.Name())) { WindowTitle = Messages.DELETE_BOND }) { dlg.ShowDialog(Parent); } return; } string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg); DialogResult result; using (var dlg = new WarningDialog(message, new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel) { HelpName = "NetworkingConfigWarning", WindowTitle = Messages.DELETE_BOND }) { result = dlg.ShowDialog(Parent); } if (DialogResult.OK != result) { return; } } else if (will_disturb_secondary) { DialogResult dialogResult; using (var dlg = new WarningDialog(string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (DialogResult.OK != dialogResult) { return; } } else { DialogResult dialogResult; using (var dlg = new WarningDialog(msg, new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, selected: true), ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (DialogResult.OK != dialogResult) { return; } } // The UI shouldn't offer deleting a bond in this case, but let's make sure we've // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436). Bond bond = pif.BondMasterOf(); if (bond != null) { new Actions.DestroyBondAction(bond).RunAsync(); } }