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
#brocade_version, #cisco_show_version, #command_output, #ruby_host_os, #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_string, #winrm?
Methods included from Helpers::Windows
#detect_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_platform, #redhatish_version
Constructor Details
#initialize(platform) ⇒ UUID
Returns a new instance of UUID.
11 12 13 14 |
# File 'lib/train/platforms/detect/uuid.rb', line 11 def initialize(platform) @platform = platform @backend = @platform.backend end |
Instance Method Details
#find_or_create_uuid ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/train/platforms/detect/uuid.rb', line 16 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 if @platform[:uuid_command] result = @backend.run_command(@platform[:uuid_command]) return uuid_from_string(result.stdout.chomp) if result.exit_status.zero? && !result.stdout.empty? end raise 'Could not find platform uuid! Please set a uuid_command for your platform.' end end |