<commit_before>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'common'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'login'))
require 'oneview-sdk'

Puppet::Type.type(:ethernet_network).provide(:ruby) do

  # Helper methods - TO BE REDEFINED

  def initialize(*args)
    super(*args)
    @client = OneviewSDK::Client.new(login)
    puts "Running #{resource}"
    Puppet.notice("Connected to OneView appliance at #{@client.url}")
  end

  # Provider methods

  def exists?
    ethernet_network = get_ethernet_network(resource['attributes']['name'])
    ethernet_network_exists = false ; ethernet_network_exists = true if ethernet_network.first

    if ethernet_network_exists
      new_attributes = attributes_parse(resource['attributes'])
      puts new_attributes
      current = ethernet_network.first.data
      current.delete('modified')
      current.delete('connectionTemplateUri')
      current['vlanId'] = String(current['vlanId'])
      puts current
      update = current.merge(new_attributes)
      update.delete('modified')
      update.delete('connectionTemplateUri') if update['connectionTemplateUri'] == nil
      puts update
      if update != current
        Puppet.warning("THIS IS DIFFERENT")
        Puppet.warning(update.to_a-current.to_a)
        ethernet_network.first.update(update)
      end
    end

    # if ethernet_network_exists
    #   new_attributes = attributes_parse(resource['attributes'])
    #   current = ethernet_network.first.data<commit_msg>minor changes, added hash containing the different values to be updated (if they exist)<commit_after>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'common'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'login'))
require 'oneview-sdk'

Puppet::Type.type(:ethernet_network).provide(:ruby) do

  # Helper methods - TO BE REDEFINED

  def initialize(*args)
    super(*args)
    @client = OneviewSDK::Client.new(login)
    puts "Running #{resource}"
    Puppet.notice("Connected to OneView appliance at #{@client.url}")
  end

  # Provider methods

  def exists?
    ethernet_network = get_ethernet_network(resource['attributes']['name'])
    ethernet_network_exists = false ; ethernet_network_exists = true if ethernet_network.first

    if ethernet_network_exists
      new_attributes = attributes_parse(resource['attributes'])
      puts new_attributes
      current = ethernet_network.first.data
      current.delete('modified')
      current.delete('connectionTemplateUri')
      current['vlanId'] = String(current['vlanId'])
      puts current
      update = current.merge(new_attributes)
      update.delete('modified')
      update.delete('connectionTemplateUri') if update['connectionTemplateUri'] == nil
      puts update
      if update != current
        Puppet.warning("THIS IS DIFFERENT")
        Puppet.warning(update.to_a-current.to_a)
        update = Hash[update.to_a-current.to_a]
        puts update
        puts ethernet_network.first.update(update)
      end
    end

    # if ethernet_network_exists
    #   new_attributes = attributes_parse(resource['attributes'])
    #   current = ethernet_network.first.data
{'fraction_non_alphanumeric': 0.11438420557818865, 'fraction_numerical': 0.0, 'mean_word_length': 3.964230171073095, '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': '2130329', 'n_tokens_mistral': 955, 'n_tokens_neox': 922, 'n_words': 179}