<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using &amp;quot;Empty&amp;quot; type for configuration in Tools</title>
    <link>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154759#M1622</link>
    <description>&lt;P&gt;Thanks! It worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Sep 2020 16:04:54 GMT</pubDate>
    <dc:creator>MahdiR</dc:creator>
    <dc:date>2020-09-21T16:04:54Z</dc:date>
    <item>
      <title>Using "Empty" type for configuration</title>
      <link>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154589#M1620</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to change admin status of an interface on a XE device (ASR920).&lt;/P&gt;&lt;P&gt;However running the code below does not seem to have any affect! It runs with no errors, but the interface status doesn't change.&lt;/P&gt;&lt;P&gt;Also if setting shutdown to Empty() brings the interface down, how can I bring it back up again?&lt;/P&gt;&lt;PRE&gt;import logging
import ydk.models.cisco_ios_xe.Cisco_IOS_XE_native as xe_native
from ydk.services.netconf_service import NetconfService, Datastore
from ydk.providers.netconf_provider import NetconfServiceProvider
from ydk.types import Empty


def enable_logging(level):
    log = logging.getLogger('ydk')
    log.setLevel(level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)


def shutdown(native):
    gigabitethernet = native.interface.GigabitEthernet()
    gigabitethernet.name = "0/0/7"
    gigabitethernet.shutdown = Empty()
    native.interface.gigabitethernet.append(gigabitethernet)


if __name__ == "__main__":
    enable_logging(logging.DEBUG)

    service = NetconfService()
    provider = NetconfServiceProvider(address="address",
                                      username="username",
                                      password="password")

    native = xe_native.Native()

    shutdown(native)

    service.edit_config(provider=provider, target=Datastore.running, config=native)&lt;/PRE&gt;&lt;P&gt;Attachment: DEBUG output from the logger&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 11:30:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154589#M1620</guid>
      <dc:creator>MahdiR</dc:creator>
      <dc:date>2020-09-21T11:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using "Empty" type for configuration</title>
      <link>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154751#M1621</link>
      <description>&lt;P&gt;In YANG model:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;leaf&lt;/SPAN&gt;&lt;SPAN&gt; shutdown {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;description&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;"Shutdown the selected interface"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;empty&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;That means, if the leaf is set to &lt;EM&gt;Empty&lt;/EM&gt; value (present), then interface is shut down; if the leaf is not present, then interface is up. This is basically repeats the CLI logic. Hence, if you want to bring interface up, you need delete leaf 'shutdown'.&lt;/P&gt;&lt;PRE&gt;import logging
import ydk.models.cisco_ios_xe.Cisco_IOS_XE_native as xe_native
from ydk.services.netconf_service import NetconfService, Datastore
from ydk.providers.netconf_provider import NetconfServiceProvider
from ydk.types import Empty


def enable_logging(level):
    log = logging.getLogger('ydk')
    log.setLevel(level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)


def down_up(provider, shutdown_value):
    gigabitethernet = native.interface.GigabitEthernet()
    gigabitethernet.name = "0/0/7"
    gigabitethernet.shutdown = shutdown_value
    native = xe_native.Native()&lt;BR /&gt;    native.interface.gigabitethernet.append(gigabitethernet)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;   service = NetconfService() &lt;BR /&gt;    service.edit_config(provider=provider, target=Datastore.running, config=native)


if __name__ == "__main__":
    enable_logging(logging.DEBUG)

    provider = NetconfServiceProvider(address="address",
                                      username="username",
                                      password="password")
    # Shutdown interface
    down_up(provider, Empty())
&lt;BR /&gt;    # Bring up interface &lt;BR /&gt;    down_up(provider, YFilter.delete)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 15:55:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154751#M1621</guid>
      <dc:creator>yangorelik</dc:creator>
      <dc:date>2020-09-21T15:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using "Empty" type for configuration</title>
      <link>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154759#M1622</link>
      <description>&lt;P&gt;Thanks! It worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 16:04:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/using-quot-empty-quot-type-for-configuration/m-p/4154759#M1622</guid>
      <dc:creator>MahdiR</dc:creator>
      <dc:date>2020-09-21T16:04:54Z</dc:date>
    </item>
  </channel>
</rss>

