/// <summary> /// Constructor. /// </summary> /// <param name="stepNumber">The step number or zero for quiet steps.</param> /// <param name="stepLabel">The setup step label.</param> /// <param name="stepState">The current status for the step.</param> /// <param name="internalStep">Specifies the internal setup controller step.</param> /// <param name="runTime">Optionally specifies the runtime for completed steps or <see cref="TimeSpan.Zero"/> when the step hasn't completed execution.</param> public SetupStepStatus(int stepNumber, string stepLabel, SetupStepState stepState, ISetupControllerStep internalStep, TimeSpan runTime = default) { Covenant.Requires <ArgumentException>(stepNumber >= 0, nameof(stepNumber)); Covenant.Requires <ArgumentException>(internalStep != null, nameof(internalStep)); Covenant.Requires <ArgumentException>(runTime >= TimeSpan.Zero, nameof(runTime)); this.isClone = false; this.Number = stepNumber; this.Label = string.IsNullOrEmpty(stepLabel) ? "<unlabeled step>" : stepLabel; this.State = stepState; this.IsQuiet = stepNumber == 0; this.Runtime = runTime > TimeSpan.Zero ? runTime : TimeSpan.Zero; this.InternalStep = internalStep; }
/// <summary> /// Constructor. /// </summary> /// <param name="nodeOrHost">The source node or vm host.</param> /// <param name="metadata">The node metadata or <c>null</c>.</param> public SetupNodeStatus(LinuxSshProxy nodeOrHost, object metadata) { Covenant.Requires <ArgumentNullException>(nodeOrHost != null, nameof(nodeOrHost)); Covenant.Requires <ArgumentNullException>(metadata != null, nameof(metadata)); this.isClone = false; this.Name = nodeOrHost.Name; this.Metadata = metadata; this.Status = nodeOrHost.Status; if (!nodeOrHost.IsInvolved) { this.stepState = SetupStepState.NotInvolved; } else { if (nodeOrHost.IsConfiguring) { this.stepState = SetupStepState.Running; } else if (nodeOrHost.IsReady) { this.stepState = SetupStepState.Done; } else if (nodeOrHost.IsFaulted) { this.stepState = SetupStepState.Failed; } else { this.stepState = SetupStepState.Pending; } } // $hack(jefflill): // // This isn't super clean: we need to identify the role played // by the node/host here. If [metadata] isn't NULL, we'll obtain // the role from that. [metadata] will typically be NULL for // virtual machine hosts so we'll use [NodeSshProxy.NodeRole] // in those cases. // // A cleaner fix would be to ensure that [NodeSshProxy.NodeRole] // is always set correctly. var metadataType = metadata.GetType(); if (metadataType == typeof(NodeDefinition)) { this.Role = ((NodeDefinition)metadata).Role; } else if (metadataType.Implements <IXenClient>()) { this.Role = NodeRole.XenServer; } else { var nodeSshProxy = nodeOrHost as INodeSshProxy; if (nodeSshProxy != null) { this.Role = nodeSshProxy.Role ?? string.Empty; } else { throw new NotImplementedException(); } } }