Class: Train::Platforms::Detect::UUID
- Inherits:
-
Object
- Object
- Train::Platforms::Detect::UUID
- Includes:
- Helpers::OSCommon
- Defined in:
- lib/train/platforms/detect/uuid.rb
Instance Method Summary collapse
- #find_or_create_uuid ⇒ Object
-
#initialize(platform) ⇒ UUID
constructor
A new instance of UUID.
Methods included from Helpers::OSCommon
#backend_name, #brocade_version, #cisco_show_version, #command_output, #json_cmd, #ruby_host_os, #set_from_uname, #unix_file_contents, #unix_file_exist?, #unix_uname_m, #unix_uname_r, #unix_uname_s, #unix_uuid, #unix_uuid_from_chef, #unix_uuid_from_machine_file, #uuid_from_command, #uuid_from_containerized_system, #uuid_from_string, #winrm?
Methods included from Helpers::Windows
#check_cmd, #check_powershell, #detect_windows, #local_windows?, #read_wmic, #read_wmic_cpu, #windows_uuid, #windows_uuid_from_chef, #windows_uuid_from_machine_file, #windows_uuid_from_registry, #windows_uuid_from_wmic
Methods included from Helpers::Linux
#linux_os_release, #lsb_config, #lsb_release, #parse_os_release_info, #read_linux_lsb, #redhatish, #redhatish_platform, #redhatish_version
Constructor Details
#initialize(platform) ⇒ UUID
Returns a new instance of UUID.
9 10 11 12 |
# File 'lib/train/platforms/detect/uuid.rb', line 9 def initialize(platform) @platform = platform @backend = @platform.backend end |
Instance Method Details
#find_or_create_uuid ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/train/platforms/detect/uuid.rb', line 14 def find_or_create_uuid # for api transports uuid is defined on the connection if defined?(@backend.unique_identifier) uuid_from_string(@backend.unique_identifier) elsif @platform.unix? unix_uuid elsif @platform.windows? windows_uuid else # Checking "unknown" :uuid_command which is set for mock transport. if @platform[:uuid_command] && !@platform[:uuid_command] == "unknown" result = @backend.run_command(@platform[:uuid_command]) return uuid_from_string(result.stdout.chomp) if result.exit_status == 0 && !result.stdout.empty? end raise Train::PlatformUuidDetectionFailed.new("Could not find platform uuid! Please set a uuid_command for your platform.") end end |