当前位置: 首页>>代码示例>>Python>>正文


Python services.CodecService类代码示例

本文整理汇总了Python中ydk.services.CodecService的典型用法代码示例。如果您正苦于以下问题:Python CodecService类的具体用法?Python CodecService怎么用?Python CodecService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CodecService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_oc_nis_decode

    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)
开发者ID:CiscoDevNet,项目名称:ydk-gen,代码行数:7,代码来源:test_oc_nis.py

示例2: _get_decoded_entity

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)
开发者ID:111pontes,项目名称:ydk-gen,代码行数:47,代码来源:ietf_system.py

示例3: run_multiple_routing_bgp

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
开发者ID:mirceaulinic,项目名称:ydk-py,代码行数:20,代码来源:bgp_netconf.py

示例4: setUpClass

    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\
开发者ID:ReignInChaos,项目名称:ydk-gen,代码行数:12,代码来源:test_sanity_codec.py

示例5: setUpClass

    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">
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:48,代码来源:test_sanity_codec.py

示例6: setUpClass

    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">
开发者ID:111pontes,项目名称:ydk-gen,代码行数:18,代码来源:test_sanity_service_errors.py

示例7: ArgumentParser

    """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
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-man-ems-cfg-25-ydk.py

示例8: ArgumentParser

    """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
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-ip-rsvp-cfg-22-ydk.py

示例9: ArgumentParser

    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
开发者ID:abhikeshav,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-infra-infra-locale-cfg-26-ydk.py

示例10: ArgumentParser

    """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
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-ip-domain-cfg-25-ydk.py

示例11: ArgumentParser

    """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
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xe-native-interface-32-ydk.py

示例12: SanityYang

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):
#.........这里部分代码省略.........
开发者ID:manradhaCisco,项目名称:ydk-gen,代码行数:101,代码来源:test_sanity_codec.py

示例13: ArgumentParser

    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
开发者ID:abhikeshav,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-ifmgr-cfg-20-ydk.py

示例14: ArgumentParser

    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
开发者ID:abhikeshav,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-ipv4-bgp-cfg-44-ydk.py

示例15: ArgumentParser

    """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
开发者ID:111pontes,项目名称:ydk-py-samples,代码行数:30,代码来源:cd-encode-xr-ip-ntp-cfg-25-ydk.py


注:本文中的ydk.services.CodecService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。