bosh_agent/lib/bosh_agent/state.rb
# Reads the current agent state from the state file and saves it internally.
# Empty file is fine but malformed file raises an exception.
Reads the current agent state from the state file and saves it internally.
Empty file is fine but malformed file raises an exception.
Reads the current agent state from the state file and saves it internally . Empty file is fine but malformed file raises an exception .
def read
      @lock.synchronize do
        if File.exists?(@state_file)
          state = Psych.load_file(@state_file) || default_state
          unless state.kind_of?(Hash)
            raise_format_error(state)
          end
          @data = state
        else
          @data = default_state
        end
      end
      self
    rescue SystemCallError => e
      raise StateError, "Cannot read agent state file `#{@state_file}': #{e}"
    rescue Psych::SyntaxError
      raise StateError, "Malformed agent state: #{e}"
    end
def read @lock . synchronize do if File . exists? ( @state_file ) state = Psych . load_file ( @state_file ) || default_state unless state . kind_of? ( Hash ) raise_format_error ( state ) end @data = state else @data = default_state end end self rescue SystemCallError => e raise StateError , "Cannot read agent state file `#{@state_file}': #{e}" rescue Psych :: SyntaxError raise StateError , "Malformed agent state: #{e}" end
Reads the current agent state from the state file and saves it internally.
Reads the current agent state from the state file and saves it internally .