<commit_before>module KnifeProfitbricksFog
  module UpdateServer

    private
    def update_server
      @server_is_new = false
      log "Update Server #{server_name}"
      
      ram = server_config['ram_in_gb'] * 1024
      cores = server_config['cores']

      log "Check LVS state #{server_name}"
      if self.class::LVS_ATTRIBUTES.all? {|attr| server.send(attr).to_s == 'true' }
        log "LVS is available"
      else
        log "Update LVS settings"
        
        server.options = self.class::LVS_CONFIG
        server.update
        server.wait_for { ready? }

        log "LVS config updated"
      end
      
      if server.ram != ram || server.cores != cores
        server.options = { :cores => cores, :ram => ram }
        server.update
        server.wait_for { ready? }
      end
      
      update_volumes
    end

    def update_volumes
      server_config['volumes'].each do |hd_name, size_in_gb|
        name = "#{server_name}_#{hd_name}"
        log "Update Volume '#{name}' size: #{size_in_gb} GB"
        volume = compute.volumes.all.find do |v|
          v.data_center_id == dc.id && v.name == name
        end
       
        if volume.size > size_in_gb
          error "The size of the Volume can only be increased and not decreased! Volume: #{name} - old size #{volume.size} GB - new size #{size_in_gb} GB" 
        elsif volume.size != size_in_gb
          volume.options = { :size => size_in_gb }
          volume.update
          volume.wait_for { ready? }
          volume.reload
        end<commit_msg> * LVS config fixed<commit_after>module KnifeProfitbricksFog
  module UpdateServer

    private
    def update_server
      @server_is_new = false
      log "Update Server #{server_name}"
      
      ram = server_config['ram_in_gb'] * 1024
      cores = server_config['cores']

      log "Check LVS state #{server_name}"
      if self.class::LVS_ATTRIBUTES.all? {|attr| server.send(attr).to_s == 'true' }
        log "LVS is available"
      else
        log "Update LVS settings"
        
        server.options = {:options => self.class::LVS_CONFIG}
        server.update
        server.wait_for do 
          state == 'AVAILABLE' && machine_state == 'RUNNING' ||
            state == 'INACTIVE' && machine_state == 'SHUTOFF'
        end

        log "LVS config updated"
      end
      
      if server.ram != ram || server.cores != cores
        server.options = { :cores => cores, :ram => ram }
        server.update
        server.wait_for do 
          state == 'AVAILABLE' && machine_state == 'RUNNING' ||
            state == 'INACTIVE' && machine_state == 'SHUTOFF'
        end
      end
      
      update_volumes
    end

    def update_volumes
      server_config['volumes'].each do |hd_name, size_in_gb|
        name = "#{server_name}_#{hd_name}"
        log "Update Volume '#{name}' size: #{size_in_gb} GB"
        volume = compute.volumes.all.find do |v|
          v.data_center_id == dc.id && v.name == name
        end
       
        if volume.size > size_in_gb
          error "The size of the Volume can only be increased and not decreased! Volume: #{name} - old size #{volume.size} GB - new size #{size_in_gb} GB" 
        elsif volume.size != size_in_gb
          volume.options = { :size => size_in_gb }
          volume.update
          volume.wait_for { ready? }
          volume.reload
        end
{'fraction_non_alphanumeric': 0.10794780545670225, 'fraction_numerical': 0.002372479240806643, 'mean_word_length': 2.036003600360036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '3389776', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1024, 'n_words': 269}