Ejemplo n.º 1
0
    ifc_delete.interface_configuration.append(ifc)
    ifc_delete.yfilter = YFilter.delete
    reply = service.set(provider, ifc_delete)

if __name__ == "__main__":

    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    parser.add_argument("device",
                        help="NETCONF device (ssh://user:password@host:port)")
    args = parser.parse_args()
    device = urlparse(args.device)

    # log debug messages if verbose argument specified
    if args.verbose:
        import logging
        enable_logging(logging.DEBUG)

    # create gNMI service provider
    repo = Repository("/home/ygorelik/ydk-gen/scripts/samples/repository/192.168.122.107")
    provider = gNMIServiceProvider(repo=repo,
                                   address=device.hostname,
                                   port=device.port,
                                   username=device.username,
                                   password=device.password)
    run_test(provider)

# End of script
Ejemplo n.º 2
0
        # Read single leaf
        ifcs = openconfig_interfaces.Interfaces()
        lo10 = openconfig_interfaces.Interfaces.Interface()
        lo10.name = 'Loopback10'
        lo10.config.description = YFilter.read
        ifcs.interface.append(lo10)
        ifcs.ignore_validation = True

        read_descr = self.crud.read(self.provider, lo10)
        expected = '''<interface>
  <name>Loopback10</name>
  <config>
    <description>Test</description>
  </config>
</interface>
'''
        self.assertEqual( entity_to_string(read_descr, self.schema), expected)

        # Delete configuration
        ifc = openconfig_interfaces.Interfaces.Interface()
        ifc.name = 'Loopback10'
        bgp = openconfig_bgp.Bgp()
        res = self.crud.delete(self.provider, [ifc, bgp])

if __name__ == '__main__':
    import sys
    enable_logging(logging.ERROR)
    suite = unittest.TestLoader().loadTestsFromTestCase(SanityGnmiCrud)
    ret = not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful()
    sys.exit(ret)
Ejemplo n.º 3
0
                        help="print debugging messages",
                        action="store_true")
    parser.add_argument("device",
                        help="gNMI device (ssh://user:password@host:port)")
    parser.add_argument(
        "repo",
        help=
        "yang model repository location - full path to repository directory")

    args = parser.parse_args()
    device = urlparse(args.device)
    repo_path = args.repo

    # log debug messages if verbose argument specified
    if args.verbose:
        enable_logging(logging.INFO)

    # create gNMI session
    repo = Repository(repo_path)
    provider = gNMIServiceProvider(repo,
                                   address=device.hostname,
                                   port=device.port,
                                   username=device.username,
                                   password=device.password)
    # create CRUD service
    crud = CRUDService()

    # create system time object
    system_time = xr_shellutil_oper.SystemTime()

    # read system time from device
Ejemplo n.º 4
0

if __name__ == "__main__":
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v",
                        "--verbose",
                        help="print debugging messages",
                        action="store_true")
    parser.add_argument("device",
                        help="NETCONF device (ssh://user:password@host:port)")
    args = parser.parse_args()
    device = urlparse(args.device)

    # log debug messages if verbose argument specified
    if args.verbose:
        import logging
        enable_logging(logging.DEBUG)

    # create gNMI service provider
    repo = Repository(
        "/home/ygorelik/ydk-gen/scripts/samples/repository/192.168.122.107")
    provider = gNMIServiceProvider(repo=repo,
                                   address=device.hostname,
                                   port=device.port,
                                   username=device.username,
                                   password=device.password)
    run_test(provider)

# End of script
Ejemplo n.º 5
0
    """Execute main program."""
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="print debugging messages",
                        action="store_true")
    parser.add_argument("device",
                        help="gNMI device (ssh://user:password@host:port)")
    parser.add_argument("repo",
                        help="yang model repository location - full path to repository directory")

    args = parser.parse_args()
    device = urlparse(args.device)
    repo_path = args.repo

    # log debug messages if verbose argument specified
    if args.verbose:
        enable_logging(logging.INFO)

    # create gNMI session
    repo = Repository(repo_path)
    provider = gNMIServiceProvider(repo,
                                   address=device.hostname,
                                   port=device.port,
                                   username=device.username,
                                   password=device.password)
    # create CRUD service
    crud = CRUDService()

    # create system time object
    system_time = xr_shellutil_oper.SystemTime()

    # read system time from device
Ejemplo n.º 6
0
 
        # Read single leaf
        ifcs = openconfig_interfaces.Interfaces()
        lo10 = openconfig_interfaces.Interfaces.Interface()
        lo10.name = 'Loopback10'
        lo10.config.description = YFilter.read
        ifcs.interface.append(lo10)
        read_descr = self.crud.read(self.provider, lo10)
        #print_entity(read_descr, self.schema)
        expected = '''<interface>
  <name>Loopback10</name>
  <config>
    <description>Test</description>
  </config>
</interface>
'''
        self.assertEqual( entity_to_string(read_descr, self.schema), expected)
         
        # Delete configuration
        ifc = openconfig_interfaces.Interfaces.Interface()
        ifc.name = 'Loopback10'
        bgp = openconfig_bgp.Bgp()
        res = self.crud.delete(self.provider, [ifc, bgp])

if __name__ == '__main__':
    import sys
    enable_logging(logging.ERROR)
    suite = unittest.TestLoader().loadTestsFromTestCase(SanityGnmiCrud)
    ret = not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful()
    sys.exit(ret)