<commit_before>require 'pathname'

provider_path = Pathname.new(__FILE__).parent.parent
Puppet.debug provider_path
require File.join(provider_path, 'ciscoucs')

Puppet::Type.type(:ciscoucs_serviceprofile_association).provide(:default, :parent => Puppet::Provider::Ciscoucs) do
  @doc = "Manage association of service profile on Cisco UCS device."

  include PuppetX::Puppetlabs::Transport
  @doc = "Associate server profile on Cisco UCS device."
  def create
    name=resource[:name]
    serverchesisid = resource[:serverchesisid]
    serverslot = resource[:serverslot]      
    profile_dn = resource[:profile_dn]    
    server_dn = resource[:server_dn]

    @profile_associate_input_xml =
    '<configConfMos cookie="'+cookie+'" inHierarchical="false">
        <inConfigs>
            <pair key="'+profile_dn+'">
                <lsServer dn="'+profile_dn+'">
                    <lsBinding pnDn="'+server_dn+'" rn="pn">
                    </lsBinding>
                </lsServer>
            </pair>
        </inConfigs>
    </configConfMos>';

    @profile_associate_output_xml = RestClient.post url, @profile_associate_input_xml, :content_type => 'text/xml';
    
    puts @profile_associate_output_xml;

  end

  def destroy

    name=resource[:name]      
    profile_dn = resource[:profile_dn]

    @profile_disassociate_input_xml =
    '<configConfMos cookie="'+cookie+'" inHierarchical="false">
         <inConfigs>
            <pair key="'+profile_dn+'">
                <lsBinding dn="'+profile_dn+'" status="deleted" >
                 </lsBinding>
            </pair>
          </inConfigs>
        </configConfMos>';

    @profile_disassociate_output_xml = RestClient.post url, @profile_disassociate_input_xml, :content_type => 'text/xml';

    puts @profile_disassociate_output_xml;
  end

  #check If exist
  def exists?
    ens = resource[:ensure]
    result = false;
    if (ens.to_s =="present")
      result = false;
    elsif (ens.to_s =="absent")
      result = true;
    end
    return result;
  end

end<commit_msg>Incorporated new xml changes JAXP<commit_after>require 'pathname'

provider_path = Pathname.new(__FILE__).parent.parent
Puppet.debug provider_path
require File.join(provider_path, 'ciscoucs')

Puppet::Type.type(:ciscoucs_serviceprofile_association).provide(:default, :parent => Puppet::Provider::Ciscoucs) do
  @doc = "Manage association of service profile on Cisco UCS device."

  include PuppetX::Puppetlabs::Transport
  @doc = "Associate server profile on Cisco UCS device."
  def create
    
    #@serverchesisid = resource[:serverchesisid]
    @pndn = resource[:pndn]
    #@serverslot = resource[:serverslot]      
    @serviceprofilename = resource[:serviceprofilename]   

      
    formatter = PuppetX::Util::Ciscoucs::Xml_formatter.new("associateServiceProfile")
    parameters = PuppetX::Util::Ciscoucs::NestedHash.new

    puts "---------befor xml"
    parameters['/configConfMos'][:cookie] = cookie
    parameters['/configConfMos'][:inHierarchical] = 'false'
    parameters['/configConfMos/inConfigs/pair'][:key] = @serviceprofilename
    parameters['/configConfMos/inConfigs/pair/lsBinding'][:dn] = @serviceprofilename
    parameters['/configConfMos/inConfigs/pair/lsBinding'][:pnDn] = @pndn
    parameters['/configConfMos/inConfigs/pair/lsBinding'][:restrictMigration] = 'no'
      
    profile_associate_input_xml = formatter.command_xml(parameters)
      
    profile_associate_output_xml = post profile_associate_input_xml;
    
    assoresponse = REXML::Document.new(profile_associate_output_xml)
    root = assoresponse.root
    puts assoresponse
      


  end

  def destroy

    
  end

  #check If exist
  def exists?

  end

end
{'fraction_non_alphanumeric': 0.11962110960757781, 'fraction_numerical': 0.0, 'mean_word_length': 3.5128205128205128, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 17}, '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': '2404482', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1185, 'n_words': 209}