Module: TrainPlugins::Juniper::Platform
- Included in:
- Connection
- Defined in:
- lib/train-juniper/platform.rb
Overview
Note:
This module is mixed into the Connection class to provide platform detection
Platform detection mixin for Juniper network devices
Constant Summary collapse
- PLATFORM_NAME =
Platform name constant for consistency
'juniper'
Instance Method Summary collapse
-
#platform ⇒ Train::Platform
Platform detection for Juniper network devices.
Instance Method Details
#platform ⇒ Train::Platform
Note:
Uses force_platform! to bypass Train’s automatic detection
Platform detection for Juniper network devices
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/train-juniper/platform.rb', line 23 def platform # Return cached platform if already computed return @platform if defined?(@platform) # Register the juniper platform in Train's platform registry # JunOS devices are FreeBSD-based, so inherit from bsd family for InSpec resource compatibility # This allows InSpec resources like 'command' to work with Juniper devices Train::Platforms.name(PLATFORM_NAME).title('Juniper JunOS').in_family('bsd') # Try to detect actual JunOS version and architecture from device device_version = detect_junos_version || TrainPlugins::Juniper::VERSION device_arch = detect_junos_architecture || 'unknown' logger&.debug("Detected device architecture: #{device_arch}") # Bypass Train's platform detection and declare our known platform # Include architecture in the platform details to ensure it's properly set platform_details = { release: device_version, arch: device_arch } platform_obj = force_platform!(PLATFORM_NAME, platform_details) logger&.debug("Set platform data: #{platform_obj.platform}") # Log platform detection results if logging helpers available log_platform_detection(PLATFORM_NAME, device_version) if respond_to?(:log_platform_detection) # Cache the platform object to prevent repeated calls @platform = platform_obj end |