Skip to content

Conversation

@arudell
Copy link
Member

@arudell arudell commented Dec 31, 2025

Description

This pull request refactors how SDN fabric details are handled across several modules by introducing a single SdnFabricInfrastructure class and using it as a strongly-typed parameter instead of a generic object. It also updates certificate creation and rotation functions to distribute generated certificates to all relevant SDN fabric nodes automatically. Additionally, the code simplifies and clarifies admin and role checks, and improves code organization by centralizing the class definition.

Type and Parameter Refactoring:

  • Introduced a centralized SdnFabricInfrastructure class in SdnDiagnostics.psm1 and removed its duplicate definition from SdnDiag.NetworkController.psm1. All relevant function parameters now use this class instead of [System.Object] for SDN fabric details. [1] [2] F9758a62L91R91, F9758a62L313R313, F6bf2815L475R475, [3] [4] [5] [6] [7] [8]

Certificate Distribution Enhancements:

  • Updated certificate creation functions (New-SdnNetworkControllerNodeCertificate, New-SdnMuxCertificate, New-SdnServerCertificate) to automatically distribute generated certificates to all nodes in the SDN fabric using the new SdnFabricInfrastructure parameter. [1] [2] [3]

Improved Role and Admin Checks:

  • Replaced feature-based checks with explicit role checks (Confirm-IsNetworkController, Confirm-IsLoadBalancerMux, Confirm-IsAdmin) for clarity and reliability when verifying the correct execution context. [1] [2]

Code Organization and Module Imports:

  • Added using module ..\SdnDiagnostics.psm1 to all SDN role modules to ensure the shared class and logic are available everywhere. [1] [2] [3] [4]

Minor Documentation and Logic Improvements:

  • Updated parameter documentation to clarify that FabricDetails refers to the environment info from Get-SdnInfrastructureInfo. [1] [2] [3]
  • Cleaned up and clarified try/catch and logging logic in certificate rotation functions. [1] [2] [3] [4] [5]

These changes make the codebase more maintainable, type-safe, and ensure consistent handling of SDN fabric details and certificate distribution across all SDN roles.

Change type

  • Bug fix (non-breaking change)
  • Code style update (formatting, local variables)
  • New Feature (non-breaking change that adds new functionality without impacting existing)
  • Breaking change (fix or feature that may cause functionality impact)
  • Other

Checklist:

  • My code follows the style and contribution guidelines of this project.
  • I have tested and validated my code changes.

@arudell arudell requested a review from a team as a code owner December 31, 2025 15:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors SDN fabric infrastructure handling by introducing a centralized SdnFabricInfrastructure class and using it as a strongly-typed parameter across certificate management functions. The changes improve code maintainability, type safety, and consistency while automating certificate distribution across SDN fabric nodes.

Changes:

  • Centralized the SdnFabricInfrastructure class definition in the main module and updated all role modules to reference it via using module statements
  • Replaced generic [System.Object] parameter types with strongly-typed [SdnFabricInfrastructure] across certificate creation and rotation functions
  • Enhanced certificate functions to conditionally distribute generated certificates to all fabric nodes when FabricDetails is provided

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/SdnDiagnostics.psm1 Added centralized SdnFabricInfrastructure class definition and updated parameter type in certificate rotation scriptblock
src/modules/SdnDiag.NetworkController.psm1 Removed duplicate class definition, added using statement, updated parameter types, improved role validation, and added conditional certificate distribution
src/modules/SdnDiag.LoadBalancerMux.psm1 Added using statement, updated parameter types, replaced feature checks with Confirm-IsLoadBalancerMux, and added conditional certificate distribution
src/modules/SdnDiag.Server.psm1 Added using statement, updated parameter types and documentation, and added conditional certificate distribution
src/modules/SdnDiag.Common.psm1 Added using statement and updated parameter types for certificate distribution functions


$certObject = [PSCustomObject]@{
# distribute the certificate to the Network Controller(s) in the fabric to be installed in trusted root store
if ($FabricDetails){
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before opening brace. The conditional statement should be formatted as if ($FabricDetails) { to match the code style used in the other modules (SdnDiag.Server.psm1 line 2732 and SdnDiag.NetworkController.psm1 line 2549). This ensures consistent code formatting across the codebase.

Suggested change
if ($FabricDetails){
if ($FabricDetails) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using New-SdnMuxCertificate, it fails if FabricDetails not provided

2 participants