Exemple #1
0
    def test_start_traffic_xml_conversion(self):
        # Open rw-fpath-d yang model
        yang = rw_peas.PeasPlugin('yangmodel_plugin-c', 'YangModelPlugin-1.0')
        yang_model = yang.get_interface('Model')

        #yang_module = yang.get_interface('Module')
        #yang_node = yang.get_interface('Node')
        #yang_key = yang.get_interface('Key')

        model = yang_model.alloc()
        module = yang_model.load_module(model, "rw-fpath-d")

        #populate the start
        self.start.name = "test-name"
        self.start.traffic = RwFpathDYang.StartTraffic_Traffic()
        self.start.traffic.port_name = "riftport"

        # recreate a start using to_xml and from_xml methods
        xml_str = self.start.to_xml(model)
        recreated_start = RwFpathDYang.StartTraffic()
        recreated_start.from_xml(model, xml_str)
        print "Start           : ", self.start
        print "Recreated Start : ", recreated_start

        # check the newly created start is identical
        self.assertEqual(self.start.name, recreated_start.name)
        self.assertEqual(len(self.start.name), len(recreated_start.name))
        self.assertEqual(self.start.traffic.port_name,
                         recreated_start.traffic.port_name)
        self.assertEqual(len(self.start.traffic.port_name),
                         len(recreated_start.traffic.port_name))
Exemple #2
0
 def test_fastpath_packet_trace_protobuf_conversion(self):
     self.fastpath_packet_trace = RwFpathDYang.YangNotif_RwFpathD_FastpathPacketTrace(
     )
     self.fastpath_packet_trace.packet_info = bin(10203)
     pbuf = self.fastpath_packet_trace.to_pbuf()
     recreated_fastpath_packet_trace = RwFpathDYang.YangNotif_RwFpathD_FastpathPacketTrace(
     )
     recreated_fastpath_packet_trace.from_pbuf(pbuf)
     print "FpathPacketTrace           : ", self.fastpath_packet_trace
     print "Recreated FpathPacketTrace : ", recreated_fastpath_packet_trace
     self.assertEqual(self.fastpath_packet_trace.packet_info,
                      recreated_fastpath_packet_trace.packet_info)
Exemple #3
0
 def test_colony_lbprofile_max_protobuf_conversion(self):
     self.colony.name = "riftcolony"
     nc = self.colony.network_context.add()
     nc.name = "trafgen"
     lbprof = []
     for i in range(33):
         lbprof.append(nc.lb_profile.add())
         lbprof[i].name = "DiameterLB" + str(i)
     pbuf = self.colony.to_pbuf()
     recreated_colony = RwFpathDYang.ConfigColony()
     recreated_colony.from_pbuf(pbuf)
     print "Colony           : ", self.colony
     print "Recreated Colony : ", recreated_colony
     # check the newly created start is identical
     self.assertEqual(self.colony.name, recreated_colony.name)
     self.assertEqual(nc.name, recreated_colony.network_context[0].name)
     print len(recreated_colony.network_context)
     self.assertEqual(len(recreated_colony.network_context), 1)
     print len(recreated_colony.network_context[0].lb_profile)
     self.assertEqual(len(recreated_colony.network_context[0].lb_profile),
                      32)
     for i in range(len(recreated_colony.network_context[0].lb_profile)):
         self.assertEqual(
             lbprof[i].name,
             recreated_colony.network_context[0].lb_profile[i].name)
Exemple #4
0
 def test_gi_get_pbcmd_from_xpath(self):
     xpath = "D,/rw-base:colony[rw-base:name='trafgen']"
     schema = RwFpathDYang.get_schema()
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony().retrieve_descriptor())
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther().retrieve_descriptor())
     #container
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:lacp"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther_Lacp().retrieve_descriptor())
     #leaf, should give error
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:open"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertFalse(pbcmd);
Exemple #5
0
    def test_start_traffic_protobuf_conversion(self):
        self.start.name = "test-name"
        self.start.traffic = RwFpathDYang.StartTraffic_Traffic()
        self.start.traffic.port_name = "riftport"

        # recreate a start using to_pbuf and from_pbuf methods
        pbuf = self.start.to_pbuf()
        recreated_start = RwFpathDYang.StartTraffic()
        recreated_start.from_pbuf(pbuf)
        print "Start           : ", self.start
        print "Recreated Start : ", recreated_start

        # check the newly created start is identical
        self.assertEqual(self.start.name, recreated_start.name)
        self.assertEqual(len(self.start.name), len(recreated_start.name))
        self.assertEqual(self.start.traffic.port_name,
                         recreated_start.traffic.port_name)
        self.assertEqual(len(self.start.traffic.port_name),
                         len(recreated_start.traffic.port_name))
Exemple #6
0
    def test_fastpath_packet_trace_xml_conversion(self):
        yang = rw_peas.PeasPlugin('yangmodel_plugin-c', 'YangModelPlugin-1.0')
        yang_model = yang.get_interface('Model')
        model = yang_model.alloc()
        module = yang_model.load_module(model, "rw-fpath-d")

        self.fastpath_packet_trace = RwFpathDYang.YangNotif_RwFpathD_FastpathPacketTrace(
        )
        self.fastpath_packet_trace.packet_info = bin(10203)

        # recreate a start using to_xml and from_xml methods
        xml_str = self.fastpath_packet_trace.to_xml(model)
        recreated_fastpath_packet_trace = RwFpathDYang.YangNotif_RwFpathD_FastpathPacketTrace(
        )
        recreated_fastpath_packet_trace.from_xml(model, xml_str)
        print "FpathPacketTrace           : ", self.fastpath_packet_trace
        print "Recreated FpathPacketTrace : ", recreated_fastpath_packet_trace
        self.assertEqual(self.fastpath_packet_trace.packet_info,
                         recreated_fastpath_packet_trace.packet_info)
Exemple #7
0
 def test_gi_keyspec_string_method(self):
     #create a keyspec that points to a leaf node
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-base:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertFalse(keyspec)
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-fpath:mtu"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     v_create_string =  keyspec.create_string(schema)
     v_create_string_no_schema =  keyspec.create_string()
     print("create_string           = %s" % (v_create_string,))
     print("create_string_no_schema = %s" % (v_create_string_no_schema,))
     self.assertEqual(v_create_string, xpath)
Exemple #8
0
 def test_gi_keyspec_string_method(self):
     #create a keyspec that points to a leaf node
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-base:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertFalse(keyspec)
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-fpath:mtu"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     v_create_string =  keyspec.create_string(schema)
     v_create_string_no_schema =  keyspec.create_string()
     print("create_string           = %s" % (v_create_string,))
     print("create_string_no_schema = %s" % (v_create_string_no_schema,))
     self.assertEqual(v_create_string, xpath)
Exemple #9
0
    def test_str_max_inline_max_protobuf_conversion(self):
        self.start.name = "123456789 123456789 123456789 123456789 123456789 123456789 123456789"
        # recreate a start using to_pbuf and from_pbuf methods
        pbuf = self.start.to_pbuf()
        recreated_start = RwFpathDYang.StartTraffic()
        recreated_start.from_pbuf(pbuf)
        print "Start           : ", self.start
        print "Recreated Start : ", recreated_start

        # check the newly created start is identical
        self.assertEqual(self.start.name, recreated_start.name)
        self.assertEqual(len(self.start.name), len(recreated_start.name))

        start = None
        recreated_start = None
        fastpath_packet_trace = None
        recreated_fastpath_packet_trace = None
Exemple #10
0
 def test_gi_get_pbcmd_from_xpath(self):
     xpath = "D,/rw-base:colony[rw-base:name='trafgen']"
     schema = RwFpathDYang.get_schema()
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony().retrieve_descriptor())
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther().retrieve_descriptor())
     #container
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:lacp"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther_Lacp().retrieve_descriptor())
     #leaf, should give error
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:open"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertFalse(pbcmd);
Exemple #11
0
 def test_gi_schema_context_methods(self):
     #create a keyspec that points to a leaf node
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']/rw-fpath:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     gi_desc = RwFpathDYang.ConfigColony_BundleEther.schema()
     self.assertTrue(gi_desc);
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertTrue(lname)
     print("Leaf " + lname)
     self.assertEqual(lname, "mtu")
     #Error case not a leaf keyspec
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname);
     #Error wrong schema
     gi_desc = RwFpathDYang.ConfigColony.schema()
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname)
Exemple #12
0
 def test_gi_schema_context_methods(self):
     #create a keyspec that points to a leaf node
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']/rw-fpath:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     gi_desc = RwFpathDYang.ConfigColony_BundleEther.schema()
     self.assertTrue(gi_desc);
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertTrue(lname)
     print("Leaf " + lname)
     self.assertEqual(lname, "mtu")
     #Error case not a leaf keyspec
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname);
     #Error wrong schema
     gi_desc = RwFpathDYang.ConfigColony.schema()
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname)
Exemple #13
0
 def setUp(self):
     self.colony = RwFpathDYang.ConfigColony()
     self.colony1 = RwAppmgrDYang.ConfigColony()
Exemple #14
0
 def setUp(self):
     self.start = RwFpathDYang.StartTraffic()
Exemple #15
0
 def setUp(self):
     self.colony = RwFpathDYang.ConfigColony()