def test_sanity_crud_read_interface(self):
        address = ysanity.Native.Interface.Loopback.Ipv4.Address()
        address.ip = "2.2.2.2"
        address.netmask = "255.255.255.255"

        loopback = ysanity.Native.Interface.Loopback()
        loopback.name = 2222
        loopback.ipv4.address.append(address)

        native = ysanity.Native()
        native.interface.loopback.append(loopback)

        crud = CRUDService()
        result = crud.create(self.ncc, native)
        self.assertEqual(result, True)

        native_read = ysanity.Native()
        interfaces = crud.read(self.ncc, native_read)

        codec_service = CodecService()
        codec_provider = CodecServiceProvider()
        codec_provider.encoding = EncodingFormat.XML

        xml_encode = codec_service.encode(codec_provider, interfaces)
        print('\n===== Printing entity: {}'.format(interfaces))
        print(xml_encode)

        # Delete configuration
        result = crud.delete(self.ncc, native)
        self.assertEqual(result, True)
Exemple #2
0
    def test_oc_nis_decode(self):
        codec_provider = CodecServiceProvider(type='xml')
        codec = CodecService()

        nis_top = oc_nis.NetworkInstances()
        entity = codec.decode(codec_provider, nis_xml, nis_top);
        self.assertIsNotNone(entity)
Exemple #3
0
def prepare_config(datafile):
    data = ''
    # read xml file passes
    with open(datafile) as fh:
        data = fh.read()

    #associate this with codec service to get an ydk object
    codec = CodecService()
    return codec.decode(CodecServiceProvider(type='xml'), data)
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = \
'<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <enum-value>local</enum-value>\n</built-in-t>\n'

        self._enum_payload_2 = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <ytypes>\n    <built-in-t>\n      <enum-value>local</enum-value>\n    </built-in-t>\n  </ytypes>\n</runner>\n'

        self._runner_payload = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n\
Exemple #5
0
 def test_encode_decode(self):
     intf = interface_configurations.InterfaceConfigurations()
     iss = intf.InterfaceConfiguration()
     iss.active = 'act'
     iss.interface_name = 'Loopback0'
     iss.vrf = 'red'
     intf.interface_configuration.append(iss)
     codec = CodecService()
     codec_p = CodecServiceProvider(type='json')
     json = codec.encode(codec_p, intf)
     print(json)
     obj = codec.decode(codec_p, json)
     print(obj)
Exemple #6
0
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = '''<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
'''

        self._enum_payload_2 = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>
'''

        self._runner_payload = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <two-list>
    <ldata>
      <number>21</number>
      <name>runner:twolist:ldata[21]:name</name>
      <subl1>
        <number>211</number>
        <name>runner:twolist:ldata[21]:subl1[211]:name</name>
      </subl1>
      <subl1>
        <number>212</number>
        <name>runner:twolist:ldata[21]:subl1[212]:name</name>
      </subl1>
    </ldata>
    <ldata>
      <number>22</number>
      <name>runner:twolist:ldata[22]:name</name>
      <subl1>
        <number>221</number>
        <name>runner:twolist:ldata[22]:subl1[221]:name</name>
      </subl1>
      <subl1>
        <number>222</number>
        <name>runner:twolist:ldata[22]:subl1[222]:name</name>
      </subl1>
    </ldata>
  </two-list>
</runner>
'''
        self._oc_pattern_payload = '''<oc-A xmlns="http://cisco.com/ns/yang/oc-pattern">
Exemple #7
0
 def setUpClass(self):
     self.codec_provider = CodecServiceProvider()
     self.codec = CodecService()
     self.repo = Repository(get_local_repo_dir())
     self.provider = gNMIServiceProvider( self.repo, "127.0.0.1", "admin", "admin", port=50051)
     self.schema = self.provider.get_session().get_root_schema()
     self.crud = CRUDService()
Exemple #8
0
def _get_decoded_entity():
    from ydk.providers import CodecServiceProvider
    from ydk.services import CodecService

    payload = '''
    <system xmlns="urn:ietf:params:xml:ns:yang:ietf-system">
        <contact>[email protected]</contact>
        <hostname>1.2.3.4</hostname>
        <clock>
          <timezone-name>Argentina</timezone-name>
        </clock>
        <ntp>
          <server>
            <name>xyz</name>
            <udp>
              <address>1.2.3.4</address>
              <port>22</port>
            </udp>
            <association-type>peer</association-type>
          </server>
        </ntp>
        <dns-resolver>
          <search>abc.com</search>
          <search>fff.com</search>
          <server>
            <name>abc</name>
            <udp-and-tcp>
              <address>1.2.3.4</address>
              <port>830</port>
            </udp-and-tcp>
          </server>
        </dns-resolver>
        <authentication>
          <user>
            <name>guest</name>
            <password>guest</password>
          </user>
          <user>
            <name>admin</name>
            <password>admin</password>
          </user>
        </authentication>
      </system>
    '''
    codec = CodecService()
    provider = CodecServiceProvider(type='xml')
    return codec.decode(provider, payload)
 def setUpClass(cls):
     cls.ncc = NetconfServiceProvider(cls.hostname, cls.username,
                                      cls.password, cls.port, cls.protocol,
                                      cls.on_demand, cls.common_cache,
                                      cls.timeout)
     cls.executor = ExecutorService()
     cls.codec = CodecService()
     cls.codec_provider = CodecServiceProvider(type=EncodingFormat.XML)
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type=EncodingFormat.XML)

        self._enum_payload_1 = """<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
"""

        self._enum_payload_2 = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>"""

        self._runner_payload = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
    def setUpClass(self):
        from ydk.providers import CodecServiceProvider
        from ydk.services import CodecService
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = """<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
"""

        self._enum_payload_2 = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>"""

        self._runner_payload = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
Exemple #12
0
def run_multiple_routing_bgp(netconf_service, session):
    crud = CRUDService()
    codec = CodecService()
    codec_provider = CodecServiceProvider()

    crud.delete(session, bgp())
    crud.delete(session, RoutingPolicy())

    multi_cfg = _get_bgp_routing_multiple_object()
    multi_payload_expected = codec.encode(codec_provider, multi_cfg)

    result = netconf_service.edit_config(session, Datastore.candidate, multi_cfg)
    assert 'ok' in result

    multi_filter = {'bgp':bgp(), 'routing-policy':RoutingPolicy()}
    multi_entity_read = netconf_service.get_config(session, Datastore.candidate, multi_filter)

    multi_payload_actual = codec.encode(codec_provider, multi_entity_read)

    assert multi_payload_expected == multi_payload_actual
Exemple #13
0
def run_multiple_routing_bgp(netconf_service, session):
    crud = CRUDService()
    codec = CodecService()
    codec_provider = CodecServiceProvider()

    crud.delete(session, bgp())
    crud.delete(session, RoutingPolicy())

    multi_cfg = _get_bgp_routing_multiple_object()
    multi_payload_expected = codec.encode(codec_provider, multi_cfg)

    result = netconf_service.edit_config(session, Datastore.candidate, multi_cfg)
    assert 'ok' in result

    multi_filter = {'bgp':bgp(), 'routing-policy':RoutingPolicy()}
    multi_entity_read = netconf_service.get_config(session, Datastore.candidate, multi_filter)

    multi_payload_actual = codec.encode(codec_provider, multi_entity_read)

    assert multi_payload_expected == multi_payload_actual
    def test_crud_read_collection(self):
        crud = CRUDService()

        # Build configuration of multiple objects
        create_list = Config()

        native = ysanity.Native()
        native.hostname = 'NativeHost'
        native.version = '0.1.0'
        create_list.append(native)

        bgp = openconfig.Bgp()
        bgp.global_.config.as_ = 65001
        bgp.global_.config.router_id = "1.2.3.4"
        create_list.append(bgp)

        create_list = Config([native, bgp])

        # Configure device
        result = crud.create(self.ncc, create_list)
        self.assertEqual(result, True)

        # Read configuration
        read_filter = Filter([ysanity.Native(),
                              openconfig.Bgp()])
        read_config = crud.read(self.ncc, read_filter)
        self.assertEqual(isinstance(read_config, Config), True)
        self.assertEqual(len(read_config), 2)

        # Print configuration
        codec_service = CodecService()
        codec_provider = CodecServiceProvider()
        codec_provider.encoding = EncodingFormat.XML
        for entity in read_config:
            xml = codec_service.encode(codec_provider, entity)
            print('\n===== Printing entity: {}'.format(entity))
            print(xml)

        # Delete configuration
        result = crud.delete(self.ncc, create_list)
        self.assertEqual(result, True)
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = \
'<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <enum-value>local</enum-value>\n</built-in-t>\n'

        self._enum_payload_2 = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <ytypes>\n    <built-in-t>\n      <enum-value>local</enum-value>\n    </built-in-t>\n  </ytypes>\n</runner>\n'

        self._runner_payload = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n\
Exemple #16
0
    def test_ylist_runner_no_key_list(self):
        runner = ysanity.Runner()
        t1 = ysanity.Runner().NoKeyList()
        t1.test = 't1'
        t2 = ysanity.Runner().NoKeyList()
        t2.test = 't2'
        t3 = ysanity.Runner().NoKeyList()
        t3.test = 't3'
        runner.no_key_list.extend([t1, t2, t3])

        count = ''
        for elem in runner.no_key_list:
            count += elem.test
        self.assertEqual(count, 't1t2t3')

        from ydk.providers import CodecServiceProvider
        from ydk.services  import CodecService
        provider = CodecServiceProvider(type='xml')
        codec = CodecService()

        payload = codec.encode(provider, runner)
        expected = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <no-key-list>
    <test>t1</test>
  </no-key-list>
  <no-key-list>
    <test>t2</test>
  </no-key-list>
  <no-key-list>
    <test>t3</test>
  </no-key-list>
</runner>
'''
        self.assertEqual(payload, expected)

        runner_decode = codec.decode(provider, payload)
        self.assertEqual(runner_decode, runner)
Exemple #17
0
    def test_sanity_crud_read_interface(self):
        enable_logging(logging.ERROR)

        address = ysanity.Native.Interface.Loopback.Ipv4.Address();
        address.ip = "2.2.2.2"
        address.netmask = "255.255.255.255"

        loopback = ysanity.Native.Interface.Loopback()
        loopback.name = 2222
        loopback.ipv4.address.append(address)

        native = ysanity.Native()
        native.interface.loopback.append(loopback)

        crud = CRUDService()
        result = crud.create(self.ncc, native)

        native_read = ysanity.Native()
        interfaces = crud.read(self.ncc, native_read)

        codec_service = CodecService()
        codec_provider = CodecServiceProvider()
        codec_provider.encoding = EncodingFormat.XML
        xml_encode = codec_service.encode(codec_provider, interfaces)
    def setUpClass(cls):
        tmp_dir = tempfile.mkdtemp()
        repo = Repository(tmp_dir)

        cls.ncc_empty_repo = NetconfServiceProvider(repo, cls.hostname,
                                                    cls.username, cls.password,
                                                    cls.port, cls.protocol,
                                                    cls.on_demand)
        cls.ncc = NetconfServiceProvider(cls.hostname, cls.username,
                                         cls.password, cls.port, cls.protocol,
                                         cls.on_demand, cls.common_cache)
        cls.crud = CRUDService()

        cls.codec_provider = CodecServiceProvider()
        cls.codec = CodecService()
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = '''<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
'''

        self._enum_payload_2 = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>
'''

        self._runner_payload = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <two-list>
    <ldata>
      <number>21</number>
      <name>runner:twolist:ldata[21]:name</name>
      <subl1>
        <number>211</number>
        <name>runner:twolist:ldata[21]:subl1[211]:name</name>
      </subl1>
      <subl1>
        <number>212</number>
        <name>runner:twolist:ldata[21]:subl1[212]:name</name>
      </subl1>
    </ldata>
    <ldata>
      <number>22</number>
      <name>runner:twolist:ldata[22]:name</name>
      <subl1>
        <number>221</number>
        <name>runner:twolist:ldata[22]:subl1[221]:name</name>
      </subl1>
      <subl1>
        <number>222</number>
        <name>runner:twolist:ldata[22]:subl1[222]:name</name>
      </subl1>
    </ldata>
  </two-list>
</runner>
'''
        self._oc_pattern_payload = '''<oc-A xmlns="http://cisco.com/ns/yang/oc-pattern">
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type=EncodingFormat.XML)

        self._enum_payload_1 = """<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
"""

        self._enum_payload_2 = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>"""

        self._runner_payload = """<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
Exemple #21
0
def serialize_model(model):
    provider = CodecServiceProvider(type="xml")
    codec = CodecService()
    return codec.encode(provider, model)
Exemple #22
0
    )
    comm_set.community_set_name = 'testing'
    comm_set.community_member.append("oooo")
    comm_set.community_member.append("a")
    routing_policy.defined_sets.bgp_defined_sets.community_sets.community_set.append(
        comm_set)

    routing_payload = codec_service.encode(provider, routing_policy)
    print routing_payload
    routing_entity = codec_service.decode(provider, routing_payload)
    print 'Encoded payload:\n', routing_payload, \
            '\nRe-encode the decoded payload:\n', codec_service.encode(provider, routing_entity)
    assert routing_payload == codec_service.encode(provider, routing_entity)


def init_logging():
    import logging
    log = logging.getLogger('ydk')
    log.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    log.addHandler(ch)


if __name__ == "__main__":
    init_logging()
    provider = CodecServiceProvider(type='xml')
    codec_service = CodecService()
    bgp_run(codec_service, provider)
    run_routing(codec_service, provider)
    exit()
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    bgp = xr_ipv4_bgp_cfg.Bgp()  # create object
    config_bgp(bgp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, bgp))

    provider.close()
    exit()
# End of script
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    isis = xr_clns_isis_cfg.Isis()  # create object
    config_isis(isis)  # add object configuration

    # encode and print object
    print(codec.encode(provider, isis))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    clock = xr_infra_infra_clock_linux_cfg.Clock()  # create object
    config_clock(clock)  # add object configuration

    # encode and print object
    print(codec.encode(provider, clock))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    cdp = xr_cdp_cfg.Cdp()  # create object
    config_cdp(cdp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, cdp))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ospf = xr_ipv4_ospf_cfg.Ospf()  # create object
    config_ospf(ospf)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ospf))

    exit()
# End of script
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ospfv3 = xr_ipv6_ospfv3_cfg.Ospfv3()  # create object
    config_ospfv3(ospfv3)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ospfv3))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    syslog = xr_infra_syslog_cfg.Syslog()  # create object
    config_syslog(syslog)  # add object configuration

    # encode and print object
    print(codec.encode(provider, syslog))

    exit()
# End of script
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    isis = xr_clns_isis_cfg.Isis()  # create object
    config_isis(isis)  # add object configuration

    # encode and print object
    print(codec.encode(provider, isis))

    provider.close()
    exit()
# End of script
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    global_interface_configuration = xr_ifmgr_cfg.GlobalInterfaceConfiguration()  # create object
    config_global_interface_configuration(global_interface_configuration)  # add object configuration

    # encode and print object
    print(codec.encode(provider, global_interface_configuration))

    provider.close()
    exit()
# End of script
class SanityYang(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = \
'<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <enum-value>local</enum-value>\n</built-in-t>\n'

        self._enum_payload_2 = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n  <ytypes>\n    <built-in-t>\n      <enum-value>local</enum-value>\n    </built-in-t>\n  </ytypes>\n</runner>\n'

        self._runner_payload = \
'<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">\n\
  <two-list>\n\
    <ldata>\n\
      <number>21</number>\n\
      <name>runner:twolist:ldata[21]:name</name>\n\
      <subl1>\n\
        <number>211</number>\n\
        <name>runner:twolist:ldata[21]:subl1[211]:name</name>\n\
      </subl1>\n\
      <subl1>\n\
        <number>212</number>\n\
        <name>runner:twolist:ldata[21]:subl1[212]:name</name>\n\
      </subl1>\n\
    </ldata>\n\
    <ldata>\n\
      <number>22</number>\n\
      <name>runner:twolist:ldata[22]:name</name>\n\
      <subl1>\n\
        <number>221</number>\n\
        <name>runner:twolist:ldata[22]:subl1[221]:name</name>\n\
      </subl1>\n\
      <subl1>\n\
        <number>222</number>\n\
        <name>runner:twolist:ldata[22]:subl1[222]:name</name>\n\
      </subl1>\n\
    </ldata>\n\
  </two-list>\n\
</runner>\n'

    @classmethod
    def tearDownClass(self):
        pass

    def setUp(self):
        print '\nIn method', self._testMethodName + ':'

    def tearDown(self):
        pass

    def _get_runner_entity(self):
        r_1 = ysanity.Runner()
        e_1, e_2 = ysanity.Runner.TwoList.Ldata(), ysanity.Runner.TwoList.Ldata()
        e_11, e_12 = ysanity.Runner.TwoList.Ldata.Subl1(), ysanity.Runner.TwoList.Ldata.Subl1()
        e_1.number = 21
        e_1.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:name'
        e_11.number = 211
        e_11.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:subl1[' + str(e_11.number) + ']:name'
        e_12.number = 212
        e_12.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:subl1[' + str(e_12.number) + ']:name'
        e_1.subl1.extend([e_11, e_12])
        e_21, e_22 = ysanity.Runner.TwoList.Ldata.Subl1(), ysanity.Runner.TwoList.Ldata.Subl1()
        e_2.number = 22
        e_2.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:name'
        e_21.number = 221
        e_21.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:subl1[' + str(e_21.number) + ']:name'
        e_22.number = 222
        e_22.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:subl1[' + str(e_22.number) + ']:name'
        e_2.subl1.extend([e_21, e_22])
        r_1.two_list.ldata.extend([e_1, e_2])
        return r_1

    def test_encode_1(self):
        r_1 = self._get_runner_entity()
        payload = self.codec.encode(self.provider, r_1)
        self.assertEqual(self._runner_payload, payload)

    def test_encode_2(self):
        from ydk.models.ydktest.ydktest_sanity import YdkEnumTestEnum
        r_1 = ysanity.Runner.Ytypes.BuiltInT()
        r_1.enum_value = YdkEnumTestEnum.LOCAL

        payload = self.codec.encode(self.provider, r_1)
        self.assertEqual(self._enum_payload_1, payload)

    def test_decode_1(self):
        entity = self.codec.decode(self.provider, self._enum_payload_2)
        self.assertEqual(self._enum_payload_2, self.codec.encode(self.provider, entity))

    def test_encode_decode(self):
        r_1 = self._get_runner_entity()
        payload = self.codec.encode(self.provider, r_1)
        entity = self.codec.decode(self.provider, payload)
        self.assertEqual(is_equal(r_1, entity), True)
        self.assertEqual(payload, self.codec.encode(self.provider, entity))
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    interface_configurations = xr_ifmgr_cfg.InterfaceConfigurations()  # create object
    config_interface_configurations(interface_configurations)  # add object configuration

    # encode and print object
    print(codec.encode(provider, interface_configurations))

    exit()
# End of script
Exemple #34
0
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    bgp = xr_ipv4_bgp_cfg.Bgp()  # create object
    config_bgp(bgp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, bgp))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    telemetry_system = oc_telemetry.TelemetrySystem()  # create object
    config_telemetry_system(telemetry_system)  # add object configuration

    # encode and print object
    print(codec.encode(provider, telemetry_system))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    routing_policy = oc_routing_policy.RoutingPolicy()  # create object
    config_routing_policy(routing_policy)  # add object configuration

    # encode and print object
    print(codec.encode(provider, routing_policy))

    exit()
# End of script
class SanityTest(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.csp = CodecServiceProvider(type=EncodingFormat.XML)
        self.es = ExecutorService()
        self.cs = CodecService()

    def setUp(self):
        # start a brand new session for every single test case
        # so test_close_session_rpc will not interfere with other test cases
        # self.ncc = NetconfServiceProvider('127.0.0.1', 'admin', 'admin', 12022)
        self.ncc = NetconfServiceProvider(
            self.hostname,
            self.username,
            self.password,
            self.port,
            self.protocol,
            self.on_demand,
            self.common_cache,
            self.timeout)
        from ydk.services import CRUDService
        crud = CRUDService()
        runner = ysanity.Runner()
        crud.delete(self.ncc, runner)

    def tearDown(self):
        # close session by close session rpc
        try:
            rpc = ietf_netconf.CloseSession()
            self.es.execute_rpc(self.ncc, rpc)
        except YError:
            pass
        del self.ncc

    @unittest.skip('Issues in confd')
    def test_close_session_rpc(self):
        rpc = ietf_netconf.CloseSession()

        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    def test_commit_rpc(self):
        rpc = ietf_netconf.Commit()
        rpc.input.confirmed = Empty()
        rpc.input.confirm_timeout = 5

        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    def test_copy_config_rpc(self):
        rpc = ietf_netconf.CopyConfig()
        rpc.input.target.candidate = Empty()
        rpc.input.source.running = Empty()

        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    @unittest.skip('Issues in netsim')
    def test_delete_config_rpc(self):
        rpc = ietf_netconf.DeleteConfig()
        rpc.input.target.url = "http://test"

        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    def test_discard_changes_rpc(self):
        rpc = ietf_netconf.DiscardChanges()
        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    # test edit config, get config, and get rpcs
    def test_edit_config_rpc(self):
        runner = ysanity.Runner()
        runner.ydktest_sanity_one.number = 1
        runner.ydktest_sanity_one.name = 'runner:one:name'

        runner_xml = self.cs.encode(self.csp, runner)
        filter_xml = self.cs.encode(self.csp, ysanity.Runner())

        # Edit Config
        edit_rpc = ietf_netconf.EditConfig()
        edit_rpc.input.target.candidate = Empty()
        edit_rpc.input.config = runner_xml
        reply = self.es.execute_rpc(self.ncc, edit_rpc)
        self.assertIsNone(reply)

        # Get Config
        get_config_rpc = ietf_netconf.GetConfig()
        get_config_rpc.input.source.candidate = Empty()
        get_config_rpc.input.filter = filter_xml
        reply = self.es.execute_rpc(self.ncc, get_config_rpc, runner)
        self.assertIsNotNone(reply)
        self.assertEqual(reply, runner)

        # Commit
        commit_rpc = ietf_netconf.Commit()
        reply = self.es.execute_rpc(self.ncc, commit_rpc)
        self.assertIsNone(reply)

        # Get
        get_rpc = ietf_netconf.Get()
        get_rpc.input.filter = filter_xml
        reply = self.es.execute_rpc(self.ncc, get_rpc, runner)
        self.assertIsNotNone(reply)
        self.assertEqual(reply, runner)

    @unittest.skip('YServiceProviderError')
    def test_kill_session(self):
        rpc = ietf_netconf.KillSession()
        rpc.input.session_id = 3
        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    # test lock, unlock rpc
    def test_lock_rpc(self):
        lock_rpc = ietf_netconf.Lock()
        lock_rpc.input.target.candidate = Empty()
        reply = self.es.execute_rpc(self.ncc, lock_rpc)
        self.assertIsNone(reply)

        unlock_rpc = ietf_netconf.Unlock()
        unlock_rpc.input.target.candidate = Empty()
        reply = self.es.execute_rpc(self.ncc, unlock_rpc)
        self.assertIsNone(reply)

    def test_unlock_rpc_fail(self):
        lock_rpc = ietf_netconf.Lock()
        lock_rpc.input.target.candidate = Empty()
        reply = self.es.execute_rpc(self.ncc, lock_rpc)
        self.assertIsNone(reply)

        unlock_rpc = ietf_netconf.Unlock()
        unlock_rpc.input.target.running = Empty()
        try:
            reply = self.es.execute_rpc(self.ncc, unlock_rpc)
        except Exception as e:
            self.assertIsInstance(e, YError)

    def test_validate_rpc_1(self):
        rpc = ietf_netconf.Validate()
        rpc.input.source.candidate = Empty()
        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    def test_validate_rpc_2(self):
        runner = ysanity.Runner()
        runner.ydktest_sanity_one.number = 1
        runner.ydktest_sanity_one.name = 'runner:one:name'

        runner_xml = self.cs.encode(self.csp, runner)

        rpc = ietf_netconf.Validate()
        rpc.input.source.config = runner_xml
        reply = self.es.execute_rpc(self.ncc, rpc)
        self.assertIsNone(reply)

    def test_non_rpc_fail(self):
        runner = ysanity.Runner()
        try:
            self.es.execute_rpc(self.ncc, runner)
        except Exception as e:
            self.assertIsInstance(e, YError)
            # self.assertEqual(e.code, YErrorCode.INVALID_RPC)

    def test_execute_get_schema(self):
        get_rpc = ietf_netconf.Get()
        get_rpc.input.filter = '<bgp xmlns="http://openconfig.net/yang/bgp"/>'
        self.es.execute_rpc(self.ncc, get_rpc, openconfig_bgp.Bgp())
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    telemetry_model_driven = xr_telemetry_model_driven_cfg.TelemetryModelDriven()  # create object
    config_telemetry_model_driven(telemetry_model_driven)  # add object configuration

    # encode and print object
    print(codec.encode(provider, telemetry_model_driven))

    exit()
# End of script
 def setUpClass(self):
     self.csp = CodecServiceProvider(type=EncodingFormat.XML)
     self.es = ExecutorService()
     self.cs = CodecService()
class SanityYang(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.codec = CodecService()
        self.provider = CodecServiceProvider(type='xml')

        self._enum_payload_1 = '''<built-in-t xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <enum-value>local</enum-value>
</built-in-t>
'''

        self._enum_payload_2 = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <enum-value>local</enum-value>
    </built-in-t>
  </ytypes>
</runner>
'''

        self._runner_payload = '''<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <two-list>
    <ldata>
      <number>21</number>
      <name>runner:twolist:ldata[21]:name</name>
      <subl1>
        <number>211</number>
        <name>runner:twolist:ldata[21]:subl1[211]:name</name>
      </subl1>
      <subl1>
        <number>212</number>
        <name>runner:twolist:ldata[21]:subl1[212]:name</name>
      </subl1>
    </ldata>
    <ldata>
      <number>22</number>
      <name>runner:twolist:ldata[22]:name</name>
      <subl1>
        <number>221</number>
        <name>runner:twolist:ldata[22]:subl1[221]:name</name>
      </subl1>
      <subl1>
        <number>222</number>
        <name>runner:twolist:ldata[22]:subl1[222]:name</name>
      </subl1>
    </ldata>
  </two-list>
</runner>
'''
        self._oc_pattern_payload = '''<oc-A xmlns="http://cisco.com/ns/yang/oc-pattern">
  <a>Hello</a>
</oc-A>
'''

    @classmethod
    def tearDownClass(self):
        pass

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def _get_runner_entity(self):
        r_1 = ysanity.Runner()
        e_1, e_2 = ysanity.Runner.TwoList.Ldata(), ysanity.Runner.TwoList.Ldata()
        e_11, e_12 = ysanity.Runner.TwoList.Ldata.Subl1(), ysanity.Runner.TwoList.Ldata.Subl1()
        e_1.number = 21
        e_1.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:name'
        e_11.number = 211
        e_11.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:subl1[' + str(e_11.number) + ']:name'
        e_12.number = 212
        e_12.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:subl1[' + str(e_12.number) + ']:name'
        e_1.subl1.extend([e_11, e_12])
        e_21, e_22 = ysanity.Runner.TwoList.Ldata.Subl1(), ysanity.Runner.TwoList.Ldata.Subl1()
        e_2.number = 22
        e_2.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:name'
        e_21.number = 221
        e_21.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:subl1[' + str(e_21.number) + ']:name'
        e_22.number = 222
        e_22.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:subl1[' + str(e_22.number) + ']:name'
        e_2.subl1.extend([e_21, e_22])
        r_1.two_list.ldata.extend([e_1, e_2])
        return r_1

    def test_encode_1(self):
        r_1 = self._get_runner_entity()
        payload = self.codec.encode(self.provider, r_1)
        self.assertEqual(self._runner_payload, payload)

    def test_encode_2(self):
        from ydk.models.ydktest_sanity import YdkEnumTestEnum
        r_1 = ysanity.Runner.Ytypes.BuiltInT()
        r_1.enum_value = YdkEnumTestEnum.LOCAL

        payload = self.codec.encode(self.provider, r_1)
        self.assertEqual(self._enum_payload_1, payload)

    def test_encode_invalid_1(self):
        try:
            self.codec.encode(self.provider, None)
        except YPYServiceError as err:
            self.assertEqual(
                err.message, "'encoder' and 'entity' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_encode_invalid_2(self):
        try:
            self.codec.encode(None, self._get_runner_entity())
        except YPYServiceError as e:
            err = e
            self.assertEqual(
                err.message, "'encoder' and 'entity' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_encode_invalid_3(self):
        try:
            self.codec.encode(None, None)
        except YPYServiceError as e:
            err = e
            self.assertEqual(
                err.message, "'encoder' and 'entity' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_decode_1(self):
        entity = self.codec.decode(self.provider, self._enum_payload_2)
        self.assertEqual(
            self._enum_payload_2, self.codec.encode(self.provider, entity))

    def test_decode_invalid_1(self):
        try:
            self.codec.decode(None, self._enum_payload_2)
        except YPYServiceError as e:
            err = e
            self.assertEqual(
                err.message, "'decoder' and 'payload' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_decode_invalid_2(self):
        try:
            self.codec.decode(self.provider, None)
        except YPYServiceError as e:
            err = e
            self.assertEqual(
                err.message, "'decoder' and 'payload' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_decode_invalid_3(self):
        try:
            self.codec.decode(None, None)
        except YPYServiceError as e:
            err = e
            self.assertEqual(
                err.message, "'decoder' and 'payload' cannot be None")
        else:
            raise Exception('YPYServiceError not raised')

    def test_encode_decode(self):
        r_1 = self._get_runner_entity()
        payload = self.codec.encode(self.provider, r_1)
        entity = self.codec.decode(self.provider, payload)
        self.assertEqual(is_equal(r_1, entity), True)
        self.assertEqual(payload, self.codec.encode(self.provider, entity))

    def test_encode_decode_dict(self):
        r_1 = self._get_runner_entity()
        r_entity = {'ydktest-sanity':r_1}
        payload = self.codec.encode(self.provider, r_entity)
        entity = self.codec.decode(self.provider, payload)
        for module in entity:
            self.assertEqual(is_equal(r_entity[module], entity[module]), True)
        self.assertEqual(payload, self.codec.encode(self.provider, entity))

    def test_decode_oc_pattern(self):
        obj_A = oc_pattern.OcA()
        obj_A.a = 'Hello'
        entity = self.codec.decode(self.provider, self._oc_pattern_payload)

        self.assertEqual(is_equal(obj_A, entity), True)
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ip_domain = xr_ip_domain_cfg.IpDomain()  # create object
    config_ip_domain(ip_domain)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ip_domain))

    exit()
# End of script
if __name__ == "__main__":
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    network_instances = oc_network_instance.NetworkInstances()
    config_mpls(network_instances)  # add object configuration

    # encode and print object
    print(codec.encode(provider, network_instances))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    native = xe_native.Native()  # create object
    config_native(native)  # add object configuration

    # encode and print object
    print(codec.encode(provider, native))

    exit()
# End of script
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    router_static = xr_ip_static_cfg.RouterStatic()  # create object
    config_router_static(router_static)  # add object configuration

    # encode and print object
    print(codec.encode(provider, router_static))

    provider.close()
    exit()
# End of script
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    syslog_service = xr_infra_syslog_cfg.SyslogService()  # create object
    config_syslog_service(syslog_service)  # add object configuration

    # encode and print object
    print(codec.encode(provider, syslog_service))

    provider.close()
    exit()
# End of script
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ip_domain = xr_ip_domain_cfg.IpDomain()  # create object
    config_ip_domain(ip_domain)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ip_domain))

    provider.close()
    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    rsvp = xr_ip_rsvp_cfg.Rsvp()  # create object
    config_rsvp(rsvp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, rsvp))

    exit()
# End of script
Exemple #48
0
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    telemetry_model_driven = xr_telemetry_model_driven_cfg.TelemetryModelDriven(
    )  # create object
    config_telemetry_model_driven(
        telemetry_model_driven)  # add object configuration

    # encode and print object
    print(codec.encode(provider, telemetry_model_driven))

    exit()
# End of script
Exemple #49
0
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.DEBUG)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    locale = xr_infra_infra_locale_cfg.Locale()  # create object
    config_locale(locale)  # add object configuration

    # encode and print object
    print(codec.encode(provider, locale))

    provider.close()
    exit()
# End of script
Exemple #50
0
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    arpgmp = xr_ipv4_arp_cfg.Arpgmp()  # create object
    config_arpgmp(arpgmp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, arpgmp))

    exit()
# End of script
Exemple #51
0
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    telemetry_system = oc_telemetry.TelemetrySystem()  # create object
    config_telemetry_system(telemetry_system)  # add object configuration

    # encode and print object
    print(codec.encode(provider, telemetry_system))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ntp = xr_ip_ntp_cfg.Ntp()  # create object
    config_ntp(ntp)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ntp))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    grpc = xr_man_ems_cfg.Grpc()  # create object
    config_grpc(grpc)  # add object configuration

    # encode and print object
    print(codec.encode(provider, grpc))

    exit()
# End of script
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    bgp = oc_bgp.Bgp()  # create object
    config_bgp(bgp)  # add object configuration

    # encode and print object
    # print(codec.encode(provider, bgp))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    syslog_service = xr_infra_syslog_cfg.SyslogService()  # create object
    config_syslog_service(syslog_service)  # add object configuration

    # encode and print object
    print(codec.encode(provider, syslog_service))

    exit()
# End of script
Exemple #56
0
                        help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                       "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ipv4_acl_and_prefix_list = xr_ipv4_acl_cfg.Ipv4AclAndPrefixList(
    )  # create object
    config_ipv4_acl_and_prefix_list(
        ipv4_acl_and_prefix_list)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ipv4_acl_and_prefix_list))

    exit()
# End of script
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    args = parser.parse_args()

    # log debug messages if verbose argument specified
    if args.verbose:
        logger = logging.getLogger("ydk")
        logger.setLevel(logging.INFO)
        handler = logging.StreamHandler()
        formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    # create codec provider
    provider = CodecServiceProvider(type="xml")

    # create codec service
    codec = CodecService()

    ipv4_acl_and_prefix_list = xr_ipv4_acl_cfg.Ipv4AclAndPrefixList()  # create object
    config_ipv4_acl_and_prefix_list(ipv4_acl_and_prefix_list)  # add object configuration

    # encode and print object
    print(codec.encode(provider, ipv4_acl_and_prefix_list))

    exit()
# End of script