<commit_before>from ncclient import manager
import ncclient
import xml.etree.ElementTree as ET

host = "192.168.1.1"
username="root"
password="<PASSWORD>"

#due to ofconfig design problem, it need fill port feature 
#but we won't use it currently.

config_xml="""
  <config>
    <capable-switch xmlns="urn:onf:of111:config:yang">
      <id>capable-switch-1</id>
      <resources>
       <port>
         <resource-id>65538</resource-id>     
           <features>
             <current>
               <rate>10Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>      
             </current>
             <advertised>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </advertised>    
             <supported>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </supported> 
             <advertised-peer>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </advertised-peer>        
           </features>
           <ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
             <ofdpa10:phy-port>6633</ofdpa10:phy-port>
             <ofdpa10:vid>4093</ofdpa10:vid>
             <ofdpa10:vni>10</ofdpa10:vni>
           </ofdpa10:vtap>
       </port> 
      </resources>
      <logical-switches>
          <switch>
            <id>fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b</id>
            <datapath-id>00:00:70:72:cf:b5:ea:88</datapath-id>
            <resources>
              <port>65538</port>
            </resources>
          </switch>
      </logical-switches>
    </capable-switch>

  </config>
  """
  
with manager.connect_ssh(host=host, port=830, username=username, password=password, hostkey_verify=False ) as m:
    print m.edit_config(target='running', 
                      config=config_xml, 
                      default_operation='merge', 
                      error_option='stop-on-error')

    print m.get_config(source='running').data_xml<commit_msg>correct content<commit_after>from ncclient import manager
import ncclient
import xml.etree.ElementTree as ET

host = "192.168.1.1"
username="netconfuser"
password="<PASSWORD>"

#due to ofconfig design problem, it need fill port feature 
#but we won't use it currently.

config_vni_xml="""
  <config>
      <of11-config:capable-switch xmlns:of11-config="urn:onf:of111:config:yang">
        <ofdpa10:vni xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
          <ofdpa10:id>10</ofdpa10:id>
        </ofdpa10:vni>
      </of11-config:capable-switch>
  </config>
  """

config_xml="""
  <config>
    <capable-switch xmlns="urn:onf:of111:config:yang">
      <id>capable-switch-1</id>
      <resources>
       <port>
         <resource-id>10005</resource-id>     
           <features>
             <current>
               <rate>10Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>      
             </current>
             <advertised>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </advertised>    
             <supported>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </supported> 
             <advertised-peer>
               <rate>10Gb</rate>
               <rate>100Gb</rate>
               <medium>fiber</medium>
               <pause>symmetric</pause>
             </advertised-peer>        
           </features>
           <ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
             <ofdpa10:phy-port>1</ofdpa10:phy-port>
             <ofdpa10:vid>4093</ofdpa10:vid>
             <ofdpa10:vni>10</ofdpa10:vni>
           </ofdpa10:vtap>
       </port> 
      </resources>
      <logical-switches>
          <switch>
            <id>fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b</id>
            <datapath-id>fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b</datapath-id>
            <resources>
              <port>10005</port>
            </resources>
          </switch>
      </logical-switches>
    </capable-switch>
  </config>
  """
  
with manager.connect_ssh(host=host, port=830, username=username, password=password, hostkey_verify=False ) as m:
    print m.edit_config(target='running', 
                      config=config_vni_xml, 
                      default_operation='merge', 
                      error_option='stop-on-error')
                      
    print m.edit_config(target='running', 
                      config=config_xml, 
                      default_operation='merge', 
                      error_option='stop-on-error')

    print m.get_config(source='running').data_xml
{'fraction_non_alphanumeric': 0.13371976813911654, 'fraction_numerical': 0.04757145712572457, 'mean_word_length': 1.7254901960784315, 'pattern_counts': {'":': 0, '<': 157, '<?xml version=': 0, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 2, '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': '4042492', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1623, 'n_words': 209}