Ejemplo n.º 1
0
 def setUpClass(self):
     self.ydk_client = NativeNetconfServiceProvider(address='127.0.0.1',
                                                    username='******',
                                                    password='******',
                                                    protocol='ssh',
                                                    port=12022)
     self.netconf_service = NetconfService()
Ejemplo n.º 2
0
 def setUpClass(self):
     self.ydk_client = NativeNetconfServiceProvider(address='127.0.0.1',
                                                    username='******',
                                                    password='******',
                                                    protocol='ssh',
                                                    port=12022)
     self.netconf_service = NetconfService()
 def setUpClass(self):
     if SanityMeta.PROVIDER_TYPE == "native":
         self.ncc = NativeNetconfServiceProvider(address='127.0.0.1',
                                                 username='******',
                                                 password='******',
                                                 protocol='ssh',
                                                 port=12022)
     else:
         self.ncc = NetconfServiceProvider(address='127.0.0.1',
                                           username='******',
                                           password='******',
                                           protocol='ssh',
                                           port=12022)
    def setUpClass(self):
        from ydk.providers import NetconfServiceProvider
        from ydk.services import NetconfService

        if SanityNetconf.PROVIDER_TYPE == "native":
            self.ncc = NativeNetconfServiceProvider(address='127.0.0.1',
                                                    username='******',
                                                    password='******',
                                                    protocol='ssh',
                                                    port=12022)
        else:
            self.ncc = NetconfServiceProvider(address='127.0.0.1',
                                              username='******',
                                              password='******',
                                              protocol='ssh',
                                              port=12022)
        self.netconf_service = NetconfService()
Ejemplo n.º 5
0
 def setUpClass(self):
     if SanityYang.PROVIDER_TYPE == "native":
         self.ncc = NativeNetconfServiceProvider(address='127.0.0.1',
                                                 username='******',
                                                 password='******',
                                                 protocol='ssh',
                                                 port=12022)
     else:
         self.ncc = NetconfServiceProvider(address='127.0.0.1',
                                           username='******',
                                           password='******',
                                           protocol='ssh',
                                           port=12022)
     self.crud = CRUDService()
     # config device with entity a
     a = self.getInitEntity()
     self.crud.delete(self.ncc, a)
     self.crud.create(self.ncc, a)
Ejemplo n.º 6
0
class SanityTest(unittest.TestCase):
    PROVIDER_TYPE = "non-native"

    @classmethod
    def setUpClass(self):
        self.ydk_client = NativeNetconfServiceProvider(address='127.0.0.1',
                                                       username='******',
                                                       password='******',
                                                       protocol='ssh',
                                                       port=12022)
        self.netconf_service = NetconfService()

    @classmethod
    def tearDownClass(self):
        self.ydk_client.close()
        pass

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_payload(self):
        result = self.ydk_client.execute('''
            <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
            <edit-config>
            <target><candidate/></target>
            <config>
                <runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"><ytypes><built-in-t><number8>12</number8></built-in-t></ytypes></runner>
            </config>
            </edit-config>
            </rpc>''', '')
        self.assertIn('ok', result)

    def test_server_error(self):
        try:
            result = self.ydk_client.execute('''
                <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
                <edit-config>
                <target><candidate/></target>
                <config>
                    <runner xmlns="http://invalid.com"></runner>
                </config>
                </edit-config>
                </rpc>''', '')
            self.assertIn('ok', result)
        except Exception as e:
            self.assertIsInstance(e, YPYServiceProviderError)
            msg = str(e)
            self.assertEqual(msg, 'Server rejected request.\n\terror-type: protocol\n\terror-tag: unknown-namespace\n\t'
                             'error-severity: error\n\terror-path: /rpc/edit-config/config\n\tbad-element: runner\n'
                             '\tbad-namespace: http://invalid.com')

    def test_compare_clients(self):
        ncc = NetconfServiceProvider(address='127.0.0.1',
                                     username='******',
                                     password='******',
                                     protocol='ssh',
                                     port=12022)
        import time
        start_time = time.time()
        native_result = self.netconf_service.get(self.ydk_client, None)
        native_end_time = time.time()
        ncc_result = self.netconf_service.get(ncc, None)
        ncc_end_time = time.time()
        print 'Native client time taken: ' + str(native_end_time - start_time) + ' seconds'
        print 'NCClient time taken: ' + str(ncc_end_time - native_end_time) + ' seconds'
        self.assertEqual(True, is_equal(native_result, ncc_result))
Ejemplo n.º 7
0
class SanityTest(unittest.TestCase):
    PROVIDER_TYPE = "non-native"

    @classmethod
    def setUpClass(self):
        self.ydk_client = NativeNetconfServiceProvider(address='127.0.0.1',
                                                       username='******',
                                                       password='******',
                                                       protocol='ssh',
                                                       port=12022)
        self.netconf_service = NetconfService()

    @classmethod
    def tearDownClass(self):
        self.ydk_client.close()
        pass

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_payload(self):
        result = self.ydk_client.execute(
            '''
            <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
            <edit-config>
            <target><candidate/></target>
            <config>
                <runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"><ytypes><built-in-t><number8>12</number8></built-in-t></ytypes></runner>
            </config>
            </edit-config>
            </rpc>''', '')
        self.assertIn('ok', result)

    def test_server_error(self):
        try:
            result = self.ydk_client.execute(
                '''
                <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
                <edit-config>
                <target><candidate/></target>
                <config>
                    <runner xmlns="http://invalid.com"></runner>
                </config>
                </edit-config>
                </rpc>''', '')
            self.assertIn('ok', result)
        except Exception as e:
            self.assertIsInstance(e, YPYServiceProviderError)
            msg = str(e)
            self.assertEqual(
                msg,
                'Server rejected request.\n\terror-type: protocol\n\terror-tag: unknown-namespace\n\t'
                'error-severity: error\n\terror-path: /rpc/edit-config/config\n\tbad-element: runner\n'
                '\tbad-namespace: http://invalid.com')

    def test_compare_clients(self):
        ncc = NetconfServiceProvider(address='127.0.0.1',
                                     username='******',
                                     password='******',
                                     protocol='ssh',
                                     port=12022)
        import time
        start_time = time.time()
        native_result = self.netconf_service.get(self.ydk_client, None)
        native_end_time = time.time()
        ncc_result = self.netconf_service.get(ncc, None)
        ncc_end_time = time.time()
        print('Native client time taken: %s seconds' %
              (native_end_time - start_time))
        print('NCClient time taken: %s seconds' %
              (ncc_end_time - native_end_time))
        self.assertEqual(True, is_equal(native_result, ncc_result))