<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2012-2019 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Ohai.plugin(:Openstack) do
  require_relative "../mixin/ec2_metadata"
  require_relative "../mixin/http_helper"
  require "etc" unless defined?(Etc)
  include Ohai::Mixin::Ec2Metadata
  include Ohai::Mixin::HttpHelper

  provides "openstack"
  depends "virtualization"

  # use virtualization data
  def openstack_virtualization?
    if get_attribute(:virtualization, :systems, :openstack)
      logger.trace("Plugin Openstack: has_openstack_virtualization? == true")
      true
    end
  end

  # check for the ohai hint and log trace messaging
  def openstack_hint?
    if hint?("openstack")
      logger.trace("Plugin Openstack: openstack hint present")
      true
    else
      logger.trace("Plugin Openstack: openstack hint not present")
      false
    end
  end

  # dreamhost systems *had* the dhc-user on them < 2016. We should probably remove all this logic
  # https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
  def openstack_provider
    # dream host doesn't support windows so bail early if we're on windows
    return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/

    if Etc::Passwd.map{|a| a.name}.include?("dhc-user")
      "dreamhost"
    else
      "openstack"
    end
  end

  collect_data do
    # fetch data if we look like openstack
    if openstack_hint? || openstack_virtualization?
      openstack Mash.new<commit_msg>use &: to use single method<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2012-2019 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Ohai.plugin(:Openstack) do
  require_relative "../mixin/ec2_metadata"
  require_relative "../mixin/http_helper"
  require "etc" unless defined?(Etc)
  include Ohai::Mixin::Ec2Metadata
  include Ohai::Mixin::HttpHelper

  provides "openstack"
  depends "virtualization"

  # use virtualization data
  def openstack_virtualization?
    if get_attribute(:virtualization, :systems, :openstack)
      logger.trace("Plugin Openstack: has_openstack_virtualization? == true")
      true
    end
  end

  # check for the ohai hint and log trace messaging
  def openstack_hint?
    if hint?("openstack")
      logger.trace("Plugin Openstack: openstack hint present")
      true
    else
      logger.trace("Plugin Openstack: openstack hint not present")
      false
    end
  end

  # dreamhost systems *had* the dhc-user on them < 2016. We should probably remove all this logic
  # https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
  def openstack_provider
    # dream host doesn't support windows so bail early if we're on windows
    return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/

    if Etc::Passwd.map(&:name).include?("dhc-user")
      "dreamhost"
    else
      "openstack"
    end
  end

  collect_data do
    # fetch data if we look like openstack
    if openstack_hint? || openstack_virtualization?
      openstack Mash.new
{'fraction_non_alphanumeric': 0.0976470588235294, 'fraction_numerical': 0.014588235294117647, 'mean_word_length': 3.7979683972911964, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2948957', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1251, 'n_words': 436}