Merge pull request #37 from GoodOlClint/copilot/sub-pr-36

This commit is contained in:
GoodOlClint
2026-03-25 19:50:20 -05:00
committed by GitHub
5 changed files with 24 additions and 8 deletions
@@ -65,11 +65,12 @@ namespace PSProxmoxVE.Cmdlets.Cluster
var upid = service.AddConfigNode(session, Node, NewNodeIp, linkDict, NodeId, Votes,
Force.IsPresent ? true : (bool?)null, ApiVersion);
var task = new PveTask { Upid = upid, Status = "running" };
var nodeName = GetNodeFromUpid(upid, session.Hostname);
var task = new PveTask { Upid = upid, Status = "running", Node = nodeName };
if (Wait.IsPresent && !string.IsNullOrEmpty(upid))
{
var nodeName = upid.Split(':').Length > 1 ? upid.Split(':')[1] : session.Hostname;
var taskService = new TaskService();
task = taskService.WaitForTask(session, nodeName, upid);
}
@@ -81,7 +81,8 @@ namespace PSProxmoxVE.Cmdlets.Cluster
var upid = service.JoinCluster(session, Hostname, Fingerprint, plainPassword,
linkDict, NodeId, Votes, Force.IsPresent ? true : (bool?)null);
var task = new PveTask { Upid = upid, Status = "running" };
var node = GetNodeFromUpid(upid, session.Hostname);
var task = new PveTask { Upid = upid, Status = "running", Node = node };
if (Wait.IsPresent && !string.IsNullOrEmpty(upid))
{
@@ -53,12 +53,12 @@ namespace PSProxmoxVE.Cmdlets.Cluster
WriteVerbose($"Creating cluster '{ClusterName}'...");
var upid = service.CreateCluster(session, ClusterName, linkDict, NodeId, Votes);
var task = new PveTask { Upid = upid, Status = "running" };
var node = GetNodeFromUpid(upid, session.Hostname);
var task = new PveTask { Upid = upid, Status = "running", Node = node };
if (Wait.IsPresent && !string.IsNullOrEmpty(upid))
{
// Extract node name from UPID (format: UPID:node:...)
var node = upid.Split(':').Length > 1 ? upid.Split(':')[1] : session.Hostname;
var taskService = new TaskService();
task = taskService.WaitForTask(session, node, upid);
}
@@ -20,8 +20,7 @@ namespace PSProxmoxVE.Cmdlets.HA
public string Rule { get; set; } = string.Empty;
/// <summary>Rule type (required by PVE API on update).</summary>
[Parameter(Mandatory = true, Position = 1, HelpMessage = "HA rule type: node-affinity or resource-affinity.")]
[ValidateSet("node-affinity", "resource-affinity")]
[Parameter(Mandatory = true, Position = 1, HelpMessage = "HA rule type (as defined in PVE, e.g. node-affinity, resource-affinity, location, colocation).")]
public string Type { get; set; } = string.Empty;
/// <summary>Rule state.</summary>
+15
View File
@@ -160,6 +160,21 @@ namespace PSProxmoxVE.Cmdlets
TimeSpan.FromSeconds(timeoutSeconds));
}
/// <summary>
/// Extracts the node name from a UPID string (format: UPID:node:...).
/// Falls back to <paramref name="fallback"/> if the UPID is empty or cannot be parsed.
/// </summary>
protected static string GetNodeFromUpid(string? upid, string fallback)
{
if (upid != null && upid.Length > 0)
{
var parts = upid.Split(':');
if (parts.Length > 1 && !string.IsNullOrWhiteSpace(parts[1]))
return parts[1];
}
return fallback;
}
/// <summary>
/// Parses an array of Corosync link strings (e.g. "link0=10.0.0.1") into a dictionary.
/// Emits a warning for entries that do not match the expected "key=value" format.