Uploaded image for project: 'Migration Toolkit for Virtualization'
  1. Migration Toolkit for Virtualization
  2. MTV-3907

Consolidate FC WWN formatting into shared fcutil package

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • Not Selected

      Description

      Refactored Fibre Channel World Wide Name (WWN) parsing and formatting logic into a new shared fcutil package, eliminating code duplication across storage backend implementations.

      New Package: fcutil

      Created cmd/vsphere-xcopy-volume-populator/internal/fcutil with:
      - ParseFCAdapter: Parse ESX FC adapter IDs (fc.WWNN:WWPN format)
      - ExtractAndFormatWWPN: Extract and format WWPN with colons
      - ExtractWWPN: Extract WWPN without formatting
      - FormatWWNWithColons: Format WWN with colon separators
      - NormalizeWWN: Remove formatting for comparison
      - CompareWWNs: Compare WWNs ignoring formatting differences
      - Comprehensive unit tests with 43 test cases

      Updated Storage Backends

      • Pure FlashArray: fcUIDToWWPN now delegates to fcutil
      • FlashSystem: extractWWPNsFromFCFormat now uses fcutil
      • Primera/3PAR: sanitizeWWN now uses fcutil

      Benefits

      • Single source of truth for FC WWN handling
      • Comprehensive test coverage (all edge cases)
      • Consistent error handling across backends
      • Easier maintenance and bug fixes
      • Clear, documented API

      Files Changed

      • cmd/vsphere-xcopy-volume-populator/internal/fcutil/fcutil.go (new)
      • cmd/vsphere-xcopy-volume-populator/internal/fcutil/fcutil_test.go (new)
      • cmd/vsphere-xcopy-volume-populator/internal/flashsystem/flashsystem.go
      • cmd/vsphere-xcopy-volume-populator/internal/primera3par/par3client.go
      • cmd/vsphere-xcopy-volume-populator/internal/pure/flashArray.go
      • cmd/vsphere-xcopy-volume-populator/internal/pure/flashArray_test.go

      Testing

      All existing tests pass. New fcutil package has comprehensive test coverage including:
      - Valid/invalid FC adapter ID formats
      - Case conversion and normalization
      - Hex validation
      - Edge cases (odd lengths, empty strings, multiple colons, etc.)

      Branch

      refactor-fc-wwn-utilities

              rgolan1@redhat.com Roy Golan
              rgolan1@redhat.com Roy Golan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: