/// <summary> /// Establishes an SSH connection to the assocated XenServer. /// </summary> /// <returns>The connected <see cref="LinuxSshProxy"/>.</returns> public LinuxSshProxy Connect() { var proxy = new LinuxSshProxy(Name, IPAddress.Parse(Address), SshCredentials.FromUserPassword(username, password)); proxy.Connect(); return(proxy); }
/// <inheritdoc/> public override string GetDataDisk(LinuxSshProxy node) { Covenant.Requires <ArgumentNullException>(node != null, nameof(node)); var unpartitonedDisks = node.ListUnpartitionedDisks(); if (unpartitonedDisks.Count() == 0) { return("PRIMARY"); } Covenant.Assert(unpartitonedDisks.Count() == 1, "VMs are assumed to have no more than one attached data disk."); return(unpartitonedDisks.Single()); }
/// <inheritdoc/> public abstract string GetDataDisk(LinuxSshProxy node);
/// <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(); } } }