From 4b503b08dbdfb77b74dd38704051edf7d0a91dfb Mon Sep 17 00:00:00 2001 From: Clint Branham Date: Sat, 21 Mar 2026 09:07:39 -0500 Subject: [PATCH] fix: backup job creation requires vmid or -All, fix Enabled default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Integration test: add -All to New-PveBackupJob call — PVE API requires either vmid or all when creating a backup job - Fix New-PveBackupJob Enabled logic: jobs are enabled by default unless user explicitly passes -Enabled:$false (was broken because SwitchParameter default=true doesn't set IsPresent) - Fix XML doc cref warning in NetworkService after RequireSdn removal Co-Authored-By: Claude Opus 4.6 (1M context) --- src/PSProxmoxVE.Core/Services/NetworkService.cs | 2 +- src/PSProxmoxVE/Cmdlets/Backup/NewPveBackupJobCmdlet.cs | 8 ++++---- tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PSProxmoxVE.Core/Services/NetworkService.cs b/src/PSProxmoxVE.Core/Services/NetworkService.cs index 18d61e1..667c1ff 100644 --- a/src/PSProxmoxVE.Core/Services/NetworkService.cs +++ b/src/PSProxmoxVE.Core/Services/NetworkService.cs @@ -11,7 +11,7 @@ namespace PSProxmoxVE.Core.Services { /// /// Service for Proxmox VE node network and SDN (Software-Defined Networking) API operations. - /// SDN methods require PVE 8.0 or later and will throw otherwise. + /// SDN methods require PVE 8.0 or later. Version checks are performed at the cmdlet layer. /// public class NetworkService { diff --git a/src/PSProxmoxVE/Cmdlets/Backup/NewPveBackupJobCmdlet.cs b/src/PSProxmoxVE/Cmdlets/Backup/NewPveBackupJobCmdlet.cs index 2a9ffe2..57a14fe 100644 --- a/src/PSProxmoxVE/Cmdlets/Backup/NewPveBackupJobCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/Backup/NewPveBackupJobCmdlet.cs @@ -73,10 +73,10 @@ namespace PSProxmoxVE.Cmdlets.Backup public string? MailNotification { get; set; } /// - /// Whether the backup job is enabled. Default is true. + /// Whether the backup job is enabled. Enabled by default unless -Enabled:$false is specified. /// - [Parameter(Mandatory = false, HelpMessage = "Whether the backup job is enabled.")] - public SwitchParameter Enabled { get; set; } = true; + [Parameter(Mandatory = false, HelpMessage = "Whether the backup job is enabled. Default is enabled.")] + public SwitchParameter Enabled { get; set; } /// /// A comment or description for the backup job. @@ -102,7 +102,7 @@ namespace PSProxmoxVE.Cmdlets.Backup { ["schedule"] = Schedule, ["storage"] = Storage, - ["enabled"] = Enabled.IsPresent ? "1" : "0" + ["enabled"] = MyInvocation.BoundParameters.ContainsKey("Enabled") && !Enabled.IsPresent ? "0" : "1" }; if (!string.IsNullOrEmpty(Mode)) config["mode"] = Mode!; diff --git a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 index 08aa5ae..34b5103 100644 --- a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 @@ -1443,7 +1443,7 @@ Describe 'Integration Tests' -Tag 'Integration' { Context 'Backup Jobs' { It 'Should create a backup job' { Skip-IfNoTarget - { New-PveBackupJob -Schedule 'sat 03:00' -Storage $script:Storage -Mode snapshot -Comment 'pester-test-backup' -ErrorAction Stop } | Should -Not -Throw + { New-PveBackupJob -Schedule 'sat 03:00' -Storage $script:Storage -Mode snapshot -All -Comment 'pester-test-backup' -ErrorAction Stop } | Should -Not -Throw } It 'Should list backup jobs and find the test job' {