Skip to content

Commit

Permalink
Merge pull request #478 from Juniper/476-test-failure-testgetsetsyste…
Browse files Browse the repository at this point in the history
…magentmanagerconfiguration

Introduce `compatibility.HasDeviceOsImageDownloadTimeout`
  • Loading branch information
chrismarget-j authored Dec 27, 2024
2 parents 280ed3f + d0ef7e5 commit 7024096
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions apstra/api_system_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
const apiUrlSystemAgentManagerConfig = "/api/system-agent/manager-config"

type SystemAgentManagerConfig struct {
DeviceOsImageDownloadTimeout *int `json:"device_os_image_download_timeout,omitempty"` // introduced in and required by 5.1.0 (1-2700)
SkipRevertToPristineOnUninstall bool `json:"skip_revert_to_pristine_on_uninstall"`
SkipPristineValidation bool `json:"skip_pristine_validation"`
SkipInterfaceShutdownOnUpgrade bool `json:"skip_interface_shutdown_on_upgrade"`
Expand Down
4 changes: 4 additions & 0 deletions apstra/api_system_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package apstra
import (
"context"
"log"
"math/rand/v2"
"testing"

"github.com/Juniper/apstra-go-sdk/apstra/compatibility"
Expand All @@ -35,6 +36,9 @@ func TestGetSetSystemAgentManagerConfiguration(t *testing.T) {
SkipPristineValidation: !mgrCfg.SkipPristineValidation,
SkipInterfaceShutdownOnUpgrade: !mgrCfg.SkipInterfaceShutdownOnUpgrade,
}
if compatibility.HasDeviceOsImageDownloadTimeout.Check(client.client.apiVersion) {
testCfg.DeviceOsImageDownloadTimeout = toPtr(rand.IntN(2700) + 1)
}

// set new config
log.Printf("testing SetSystemAgentManagerConfig() against %s %s (%s)", client.clientType, clientName, client.client.ApiVersion())
Expand Down
3 changes: 3 additions & 0 deletions apstra/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,9 @@ func (o *Client) GetSystemAgentManagerConfig(ctx context.Context) (*SystemAgentM
// SetSystemAgentManagerConfig uses a *SystemAgentManagerConfig object to configure the Advanced Settings
// found on the Managed Devices page of the Web UI.
func (o *Client) SetSystemAgentManagerConfig(ctx context.Context, cfg *SystemAgentManagerConfig) error {
if compatibility.HasDeviceOsImageDownloadTimeout.Check(o.apiVersion) != (cfg.DeviceOsImageDownloadTimeout != nil) {
return fmt.Errorf("DeviceOsImageDownloadTimeout is required with apstra %s, and must not be used with other versions", compatibility.HasDeviceOsImageDownloadTimeout)
}
if !compatibility.SystemManagerHasSkipInterfaceShutdownOnUpgrade.Check(o.apiVersion) && cfg.SkipInterfaceShutdownOnUpgrade {
return fmt.Errorf("SkipInterfaceShutdownOnUpgrade may only be used with apstra %s", compatibility.SystemManagerHasSkipInterfaceShutdownOnUpgrade)
}
Expand Down
1 change: 1 addition & 0 deletions apstra/compatibility/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
apstra422 = "4.2.2"
apstra500 = "5.0.0"
apstra501 = "5.0.1"
apstra510 = "5.1.0"
)

var (
Expand Down
7 changes: 5 additions & 2 deletions apstra/compatibility/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ var (
BpHasVirtualNetworkPolicyNode = Constraint{
constraints: version.MustConstraints(version.NewConstraint("<=" + apstra420)),
}
EmptyVnBindingsOk = Constraint{
constraints: version.MustConstraints(version.NewConstraint(">=" + apstra500)),
}
FabricSettingsApiOk = Constraint{
constraints: version.MustConstraints(version.NewConstraint(">=" + apstra421)),
}
EmptyVnBindingsOk = Constraint{
constraints: version.MustConstraints(version.NewConstraint(">=" + apstra500)),
HasDeviceOsImageDownloadTimeout = Constraint{
constraints: version.MustConstraints(version.NewConstraint(">=" + apstra510)),
}
IbaDashboardSupported = Constraint{
constraints: version.MustConstraints(version.NewConstraint(">=" + apstra500)),
Expand Down

0 comments on commit 7024096

Please sign in to comment.