<commit_before>require 'vagrant/action/builder'
require 'log4r'

module VagrantPlugins
  module ProviderLibvirt
    module Action
      # Include the built-in modules so we can use them as top-level things.
      include Vagrant::Action::Builtin
      @logger = Log4r::Logger.new('vagrant_libvirt::action')

      # remove image from libvirt storage pool
      def self.remove_libvirt_image
        Vagrant::Action::Builder.new.tap do |b|
          b.use RemoveLibvirtImage
        end
      end

      # This action is called to bring the box up from nothing.
      def self.action_up
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use Call, IsCreated do |env, b2|
            # Create VM if not yet created.
            if !env[:result]
              b2.use SetNameOfDomain
              if !env[:machine].config.vm.box
                b2.use CreateDomain
                b2.use CreateNetworks
                b2.use CreateNetworkInterfaces
                b2.use SetBootOrder
                b2.use StartDomain
              else
                b2.use HandleStoragePool
                b2.use HandleBox
                b2.use HandleBoxImage
                b2.use CreateDomainVolume
                b2.use CreateDomain

                b2.use Provision
                b2.use PrepareNFSValidIds
                b2.use SyncedFolderCleanup
                b2.use SyncedFolders
                b2.use PrepareNFSSettings
                b2.use ShareFolders
                b2.use CreateNetworks
                b2.use CreateNetworkInterfaces
                b2.use SetBootOrder

                b2.use StartDomain
                b2.use WaitTillUp

                b2.use ForwardPorts
                b2.use SetHostname
                # b2.use SyncFolders
              end
            else
              b2.use action_start
            end
          end
        end
      end

      # Assuming VM is created, just start it. This action is not called
      # directly by any subcommand. VM can be suspended, already running or in
      # poweroff state.
      def self.action_start
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use Call, IsRunning do |env, b2|
            # If the VM is running, then our work here is done, exit
            next if env[:result]

            b2.use Call, IsSuspended do |env2, b3|
              # if vm is suspended resume it then exit
              if env2[:result]
                b3.use ResumeDomain
                next
              end

              if !env[:machine].config.vm.box
                # With no box, we just care about network creation and starting it
                b3.use CreateNetworks
                b3.use SetBootOrder
                b3.use StartDomain
              else
                # VM is not running or suspended.

                b3.use Provision

                # Ensure networks are created and active
                b3.use CreateNetworks
                b3.use SetBootOrder
<commit_msg>Always call provisioners logic for booted machines<commit_after>require 'vagrant/action/builder'
require 'log4r'

module VagrantPlugins
  module ProviderLibvirt
    module Action
      # Include the built-in modules so we can use them as top-level things.
      include Vagrant::Action::Builtin
      @logger = Log4r::Logger.new('vagrant_libvirt::action')

      # remove image from libvirt storage pool
      def self.remove_libvirt_image
        Vagrant::Action::Builder.new.tap do |b|
          b.use RemoveLibvirtImage
        end
      end

      # This action is called to bring the box up from nothing.
      def self.action_up
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use Call, IsCreated do |env, b2|
            # Create VM if not yet created.
            if !env[:result]
              b2.use SetNameOfDomain
              if !env[:machine].config.vm.box
                b2.use CreateDomain
                b2.use CreateNetworks
                b2.use CreateNetworkInterfaces
                b2.use SetBootOrder
                b2.use StartDomain
              else
                b2.use HandleStoragePool
                b2.use HandleBox
                b2.use HandleBoxImage
                b2.use CreateDomainVolume
                b2.use CreateDomain

                b2.use Provision
                b2.use PrepareNFSValidIds
                b2.use SyncedFolderCleanup
                b2.use SyncedFolders
                b2.use PrepareNFSSettings
                b2.use ShareFolders
                b2.use CreateNetworks
                b2.use CreateNetworkInterfaces
                b2.use SetBootOrder

                b2.use StartDomain
                b2.use WaitTillUp

                b2.use ForwardPorts
                b2.use SetHostname
                # b2.use SyncFolders
              end
            else
              b2.use action_start
            end
          end
        end
      end

      # Assuming VM is created, just start it. This action is not called
      # directly by any subcommand. VM can be suspended, already running or in
      # poweroff state.
      def self.action_start
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use Call, IsRunning do |env, b2|
            # If the VM is running, run the necessary provisioners
            if env[:result]
              b2.use action_provision
              next
            end

            b2.use Call, IsSuspended do |env2, b3|
              # if vm is suspended resume it then exit
              if env2[:result]
                b3.use ResumeDomain
                next
              end

              if !env[:machine].config.vm.box
                # With no box, we just care about network creation and starting it
                b3.use CreateNetworks
                b3.use SetBootOrder
                b3.use StartDomain
              else
                # VM is not running or suspended.

                b3.use Provision

                # Ensure networks are created and active
                b3.use CreateNetworks
                b3.use SetBootOrder

{'fraction_non_alphanumeric': 0.04929917834702755, 'fraction_numerical': 0.013371999355566296, 'mean_word_length': 1.3338345864661654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6117739', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1588, 'n_words': 500}