<commit_before># creates all virtual machines with libvirt


node.lvirt.vms.each do |name,info|
  # copy image
  vm_cfg = node.lvirt.vmdefault.deep_merge(info)
  if !vm_cfg.disk.key?('name')
    vm_cfg.update({ :disk => { :name => name + '.img' } })
  end
  disk = vm_cfg.disk.folder + '/' + vm_cfg.disk.name
  execute "cp #{ vm_cfg.disk.template } #{ disk }" do
    not_if "[ -f #{ disk } ]"
  end
  # TODO: resize to require size
  # TODO: mount guest image and set host name
  domain_file = "#{Chef::Config[:file_cache_path]}/libvirt-domain-for-#{ name }.xml"
  # create domain spec
  template domain_file do
    source "libvirt-domain.xml.erb"
    variables ({ :name => name, :info => vm_cfg })
  end

  # call virsh
  execute "virsh #{ vm_cfg.produce_as } #{ domain_file }" do
    not_if "virsh domid --domain #{ name }"
  end

  if vm_cfg.produce_as == :define
    execute "virsh autostart #{ name }"
  end

  execute "virsh start #{ name }" do
    not_if "virsh domstate --domain #{ name } | grep -c running"
  end
end<commit_msg>fix autostart for non persistent domains<commit_after># creates all virtual machines with libvirt


node.lvirt.vms.each do |name,info|
  # copy image
  vm_cfg = node.lvirt.vmdefault.deep_merge(info)
  if !vm_cfg.disk.key?('name')
    vm_cfg.update({ :disk => { :name => name + '.img' } })
  end
  disk = vm_cfg.disk.folder + '/' + vm_cfg.disk.name
  execute "cp #{ vm_cfg.disk.template } #{ disk }" do
    not_if "[ -f #{ disk } ]"
  end
  # TODO: resize to require size
  # TODO: mount guest image and set host name
  domain_file = "#{Chef::Config[:file_cache_path]}/libvirt-domain-for-#{ name }.xml"
  # create domain spec
  template domain_file do
    source "libvirt-domain.xml.erb"
    variables ({ :name => name, :info => vm_cfg })
  end

  # call virsh
  execute "virsh #{ vm_cfg.produce_as } #{ domain_file }" do
    not_if "virsh domid --domain #{ name }"
  end

  execute "virsh autostart #{ name }" do
    only_if "virsh dominfo n5 | grep Persistent: | grep -c yes"
  end

  execute "virsh start #{ name }" do
    not_if "virsh domstate --domain #{ name } | grep -c running"
  end
end
{'fraction_non_alphanumeric': 0.14165103189493433, 'fraction_numerical': 0.00046904315196998124, 'mean_word_length': 3.166015625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3612329', 'n_tokens_mistral': 774, 'n_tokens_neox': 759, 'n_words': 213}