/// <summary> /// Creates a new manager state for the specified slice. /// </summary> /// <param name="slice">The slice configuration.</param> /// <param name="nodes">The list of PlanetLab nodes.</param> public PlManagerState(PlConfigSlice slice, ICollection<PlNode> nodes) { // Validate the arguments. if (null == slice) throw new ArgumentNullException("slice"); if (null == nodes) throw new ArgumentNullException("nodes"); // Set the parameters. this.slice = slice; this.nodes = nodes; }
// Public methods. /// <summary> /// Starts the execution of the PlanetLab commands on the specified list of PlanetLab nodes. /// </summary> /// <param name="crawler">The crawler.</param> /// <param name="slice">The slice configuration.</param> /// <param name="nodes">The PlanetLab nodes.</param> /// <returns>The manager state.</returns> public PlManagerState Start(PlConfigSlice slice, ICollection<PlNode> nodes) { // Create a new manager state. PlManagerState state = new PlManagerState(slice, nodes); lock (state.Sync) { // Update the manager status. state.Status = PlManagerState.ExecutionStatus.Starting; state.StartTime = DateTime.Now; // Call the starting event handler. if (null != this.Starting) this.Starting(this, new PlManagerEventArgs(state)); // Update the manager status. state.Status = PlManagerState.ExecutionStatus.Started; // Call the started event handler. if (null != this.Started) this.Started(this, new PlManagerEventArgs(state)); } // Check the slice configuration. if (slice.UpdateNodesBeforeRun) { // Update the nodes information. this.OnUpdateNodes(state); } else { // Execute the commands. this.OnRunNodes(state); } // Return the manager state. return state; }
// Public methods. /// <summary> /// Deletes the configuration registry key corresponding to the given slice. /// </summary> /// <param name="config">The slice configuration.</param> /// <param name="rootKey">The root registry key.</param> public static void Delete(PlConfigSlice config, RegistryKey rootKey) { // Check the arguments. if (null == config) throw new ArgumentNullException("config"); // Delete the registry key. rootKey.DeleteSubKeyTree(config.slice.Id.Value.ToString(), false); }
/// <summary> /// An event handler called when the list of slices is updated. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnSlicesUpdated(object sender, EventArgs e) { // Lock the slices list. this.listLocalSlices.Lock(); try { // For each slice. foreach (PlSlice slice in this.listLocalSlices) { // If the slice has a valid identifier. if (slice.Id.HasValue) { // Create a new slice configuration. PlConfigSlice configSlice = new PlConfigSlice(slice, this.keySlices); // Add the configuration to the dictionary. this.configSlices.Add(slice.Id.Value, configSlice); } } } finally { // Unlock the slices list. this.listLocalSlices.Unlock(); } }
/// <summary> /// An event handler called when a slice is added. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnSlicesAdded(object sender, PlObjectEventArgs<PlSlice> e) { // If the slice has a valid identifier. if (e.Object.Id.HasValue) { // Create a new slice configuration. PlConfigSlice configSlice = new PlConfigSlice(e.Object, this.keySlices); // Add the configuration to the dictionary. this.configSlices.Add(e.Object.Id.Value, configSlice); } }
// Public methods. /// <summary> /// Initializes the control with a crawler object. /// </summary> /// <param name="crawler">The crawler object.</param> /// <param name="slice">The slice.</param> /// <param name="controls">The controls collection.</param> /// <param name="treeNode">The tree node corresponding to this control.</param> public void Initialize(Crawler crawler, PlSlice slice, Control.ControlCollection controls, TreeNode treeNode) { // Save the parameters. this.crawler = crawler; // Get the status handler. this.status = this.crawler.Status.GetHandler(this); // Set the slice. this.slice = slice; this.slice.Changed += this.OnSliceChanged; // Set the controls. this.controls = controls; // Set the tree node. this.treeNodeSlice = treeNode; // Set the slice configuration. this.config = this.crawler.PlanetLab.GetSliceConfiguration(this.slice); // Set the title. this.panelSlice.Title = "PlanetLab Slice ({0})".FormatWith(this.slice.Name); // Enable the control. this.Enabled = true; // Update the information of the PlanetLab slice. this.OnUpdateSlice(); // Create the run option. this.OnCreateRun(); // Create the log option. this.OnCreateLog(); }
// Public methods. /// <summary> /// Initializes the control with a crawler object. /// </summary> /// <param name="crawler">The crawler object.</param> /// <param name="slice">The slice.</param> /// <param name="config">The slice configuration.</param> /// <param name="treeNode">The tree node.</param> public void Initialize(Crawler crawler, PlSlice slice, PlConfigSlice config, TreeNode treeNode) { // Save the parameters. this.crawler = crawler; // Get the status handler. this.status = this.crawler.Status.GetHandler(this); // Set the slice. this.slice = slice; this.slice.Changed += this.OnSliceChanged; // Set the slice configuration. this.config = config; // Set the commands event handlers. this.config.Commands.CommandAdded += this.OnCommandAdded; this.config.Commands.CommandRemoved += this.OnCommandRemoved; // Create the manager. this.manager = new PlManager(this.crawler); // Add the PlanetLab manager event handlers. this.manager.Starting += this.OnRunStarting; this.manager.Started += this.OnRunStarted; this.manager.Pausing += this.OnRunPausing; this.manager.Paused += this.OnRunPaused; this.manager.Resuming += this.OnRunResuming; this.manager.Resumed += this.OnRunResumed; this.manager.Stopping += this.OnRunStopping; this.manager.Stopped += this.OnRunStopped; this.manager.NodesUpdateStarted += this.OnNodesUpdateStarted; this.manager.NodesUpdateCanceled += this.OnNodesUpdateCanceled; this.manager.NodesUpdateFinishedSuccess += this.OnNodesUpdateFinishedSuccess; this.manager.NodesUpdateFinishedFail += this.OnNodesUpdateFinishedFail; this.manager.NodeEnabled += this.OnNodeEnabled; this.manager.NodeDisabled += this.OnNodeDisabled; this.manager.NodeSkipped += this.OnNodeSkipped; this.manager.NodeStarted += this.OnNodeStarted; this.manager.NodeCanceled += this.OnNodeCanceled; this.manager.NodeFinishedSuccess += this.OnNodeFinishedSuccess; this.manager.NodeFinishedFail += this.OnNodeFinishedFail; this.manager.CommandStarted += this.OnCommandStarted; this.manager.CommandCanceled += this.OnCommandCanceled; this.manager.CommandFinishedSuccess += this.OnCommandFinishedSuccess; this.manager.CommandFinishedFail += this.OnCommandFinishedFail; this.manager.SubcommandSuccess += this.OnSubcommandSuccess; this.manager.SubcommandFail += this.OnSubcommandFail; // Create the manager history. this.managerHistory = new PlManagerHistory(slice); // Set the tree node. this.treeNode = treeNode; // Set the title. this.panelRun.Title = "Run on PlanetLab Slice ({0})".FormatWith(this.slice.Name); // Enable the control. this.Enabled = true; // Initialize the tools control. this.controlMethods.Initialize(this.crawler.Toolbox, this.config.ToolMethods, ControlSliceRun.toolTriggers); // Load the configuration. this.OnLoadConfiguration(this, EventArgs.Empty); // Update the information of the PlanetLab slice. this.OnUpdateSlice(); // Update the information of the PlanetLab commands. this.OnUpdateCommands(); // Update the information of the PlanetLab history. this.OnUpdateHistory(); }
// Public methods. /// <summary> /// Initialized the control with the specified crawler. /// </summary> /// <param name="crawler">The crawler.</param> /// <param name="config">The slice configuration.</param> /// <param name="node">The PlanetLab node.</param> public void Initialize(Crawler crawler, PlConfigSlice config, PlNode node) { // Set the crawler. this.crawler = crawler; // Set the slice configuration. this.config = config; // Set the node. this.node = node; // Set the title. this.panelConsole.Title = "Secure Shell Connection to {0}".FormatWith(node.Hostname); // Set the slice configuration event handlers. this.config.Changed += this.OnConfigurationChanged; this.config.Disposed += this.OnConfigurationChanged; // Set the node event handlers. this.node.Changed += this.OnConfigurationChanged; // Set the node hostname. this.labelHostname.Text = this.node.Hostname; // Get the crawler status. this.status = this.crawler.Status.GetHandler(this); this.status.Send(ApplicationStatus.StatusType.Normal, "Disconnected.", Resources.Server_16); // Enable the control. this.Enabled = true; }