<commit_before>require 'fog/vcloud_director/parsers/compute/vm_parser_helper'

module Fog
  module Parsers
    module Compute
      module VcloudDirector
        class Vm < VcloudDirectorParser
          include VmParserHelper

          def reset
            @in_operating_system = false
            @in_children = false
            @resource_type = nil
            @response = { :vm => { :ip_address => '' } }
            @links = []
          end

          def start_element(name, attributes)
            super
            if name == 'Vm'
              vm_attrs = extract_attributes(attributes)
              @response[:vm].merge!(vm_attrs.reject {|key,value| ![:href, :name, :status, :type, :deployed].include?(key)})
              @response[:vm][:id] = @response[:vm][:href].split('/').last
              @response[:vm][:status] = human_status(@response[:vm][:status])
            else
              parse_start_element name, attributes, @response[:vm]
            end
          end

          def end_element(name)
            parse_end_element name, @response[:vm]
          end

          def human_status(status)
            case status
            when '0', 0
              'creating'
            when '8', 8
              'off'
            when '4', 4
              'on'
            else
              'unknown'
            end
          end
        end
      end
    end
  end
end<commit_msg>Adding 'deployed' status to model so that one can decide whether to undeploy.<commit_after>require 'fog/vcloud_director/parsers/compute/vm_parser_helper'

module Fog
  module Parsers
    module Compute
      module VcloudDirector
        class Vm < VcloudDirectorParser
          include VmParserHelper

          def reset
            @in_operating_system = false
            @in_children = false
            @resource_type = nil
            @response = { :vm => { :ip_address => '' } }
            @links = []
          end

          def start_element(name, attributes)
            super
            if name == 'Vm'
              vm_attrs = extract_attributes(attributes)
              @response[:vm].merge!(vm_attrs.reject {|key,value| ![:href, :name, :status, :type, :deployed].include?(key)})
              @response[:vm][:id] = @response[:vm][:href].split('/').last
              @response[:vm][:status] = human_status(@response[:vm][:status])
              @response[:vm][:deployed] = @response[:vm][:deployed] == 'true'
            else
              parse_start_element name, attributes, @response[:vm]
            end
          end

          def end_element(name)
            parse_end_element name, @response[:vm]
          end

          def human_status(status)
            case status
            when '0', 0
              'creating'
            when '8', 8
              'off'
            when '4', 4
              'on'
            else
              'unknown'
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10569105691056911, 'fraction_numerical': 0.0040650406504065045, 'mean_word_length': 1.5347639484978541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3424909', 'n_tokens_mistral': 816, 'n_tokens_neox': 791, 'n_words': 186}