Method: Chef::Util::DSC::LocalConfigurationManager::Parser.parse

Defined in:
lib/chef/util/dsc/lcm_output_parser.rb

.parse(lcm_output, test_dsc_configuration) ⇒ Object

Parses the output from LCM and returns a list of Chef::Util::DSC::ResourceInfo objects that describe how the resources affected the system

Example for WhatIfParser:

parse "What if: [Machine]: LCM: [Start Set      ]\nWhat if: [Machine]: LCM: [Start Resource ] [[File]FileToNotBeThere]\nWhat if: [Machine]: LCM: [Start Set      ] [[File]FileToNotBeThere]\nWhat if:                                   [C:\\ShouldNotExist.txt] removed\nWhat if: [Machine]: LCM: [End Set        ] [[File]FileToNotBeThere] in 0.1 seconds\nWhat if: [Machine]: LCM: [End Resource   ] [[File]FileToNotBeThere]\nWhat if: [Machine]: LCM: [End Set        ]\n"

would return

[
  Chef::Util::DSC::ResourceInfo.new(
    '[[File]FileToNotBeThere]',
    true,
    [
      '[[File]FileToNotBeThere]',
      '[C:\Shouldnotexist.txt]',
      '[[File]FileToNotBeThere] in 0.1 seconds'
    ]
  )
]

Example for TestDSCParser:

parse "InDesiredState            : False\nResourcesInDesiredState   :\nResourcesNotInDesiredState: {[Environment]texteditor}\nReturnValue               : 0\nPSComputerName            : .\n"

would return

[
  Chef::Util::DSC::ResourceInfo.new(
    '{[Environment]texteditor}',
    true,
    [
    ]
  )
]


77
78
79
80
# File 'lib/chef/util/dsc/lcm_output_parser.rb', line 77

def self.parse(lcm_output, test_dsc_configuration)
  lcm_output = String(lcm_output).split("\n")
  test_dsc_configuration ? test_dsc_parser(lcm_output) : what_if_parser(lcm_output)
end