<commit_before>require 'fog/azure/compute'
require 'fog/azure/models/compute/images'
require 'fog/azure/models/compute/server'
require 'fog/azure/models/compute/servers'

class Fog::Compute::Azure::Server
  def stop
    raise Atmosphere::UnsupportedException, 'Azure des not support stop action'
  end

  def suspend
    shutdown
  end

  def pause
    raise Atmosphere::UnsupportedException, 'Azure des not support pause action'
  end

  def id
    identity
  end

  def flavor
    { 'id' => flavor_id }
  end

  def image_id
    attributes[:image]
  end

  def created
    vm = Atmosphere::VirtualMachine.find_by(id_at_site: id)
    vm ? vm.created_at : (Atmosphere.childhood_age - 1).seconds.ago
  end

  def task_state
    nil
  end

  def flavor_id
    attributes[:vm_size]
  end
end

class Fog::Compute::Azure::Servers
  alias_method :create_orig, :create

  def destroy(id_at_site)
    # get requires both identity and cloud service name params
    # in our case id == cloud service name
    server = all.detect { |s| s.name == id_at_site }
    server ? server.destroy : false
  end

  def create(params)
    cs_id = params.delete :cs_id
    Atmosphere::Cloud::AzureVmCreator.perform_async(cs_id, params)
    params[:vm_name]
  end
end

class Fog::Compute::Azure::Images
  alias_method :all_orig, :all

  def all(_filters = nil)
    all_orig.select { |tmpl| tmpl.category == 'User' }
  end
end

class Fog::Compute::Azure::Image<commit_msg>fixed async creation of vm in Azure<commit_after>require 'fog/azure/compute'
require 'fog/azure/models/compute/images'
require 'fog/azure/models/compute/server'
require 'fog/azure/models/compute/servers'

class Fog::Compute::Azure::Server
  def stop
    raise Atmosphere::UnsupportedException, 'Azure des not support stop action'
  end

  def suspend
    shutdown
  end

  def pause
    raise Atmosphere::UnsupportedException, 'Azure des not support pause action'
  end

  def id
    identity
  end

  def flavor
    { 'id' => flavor_id }
  end

  def image_id
    attributes[:image]
  end

  def created
    vm = Atmosphere::VirtualMachine.find_by(id_at_site: id)
    vm ? vm.created_at : (Atmosphere.childhood_age - 1).seconds.ago
  end

  def task_state
    nil
  end

  def flavor_id
    attributes[:vm_size]
  end
end

class Fog::Compute::Azure::Servers
  alias_method :create_orig, :create

  def destroy(id_at_site)
    # get requires both identity and cloud service name params
    # in our case id == cloud service name
    server = all.detect { |s| s.name == id_at_site }
    server ? server.destroy : false
  end

  def create(params)
    cs_id = params.delete :cs_id
    Atmosphere::Cloud::AzureVmCreator.perform_async(cs_id, params)
    params[:vm_name].define_singleton_method(:id) do
      params[:vm_name]
    end
    params[:vm_name]
  end
end

class Fog::Compute::Azure::Images
  alias_method :all_orig, :all

  def all(_filters = nil)
    all_orig.select { |tmpl| tmpl.category == 'User' }
  end
end

class Fog::Compute::Azure::Image
{'fraction_non_alphanumeric': 0.09673115410273515, 'fraction_numerical': 0.00066711140760507, 'mean_word_length': 3.6138461538461537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '909425', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1007, 'n_words': 261}