Beispiel #1
0
    def CASE6( self, main ):
        """
        Configure Network Subnet Port
        """
        import os

        try:
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
        except ImportError:
            main.log.exception( "Something wrong with import file or code error." )
            main.log.info( "Import Error, please check!" )
            main.cleanup()
            main.exit()

        main.log.info( "Configure Network Subnet Port Start" )
        main.case( "Configure Network Subnet Port" )
        main.caseExplanation = "Configure Network Subnet Port " +\
                                "Verify post is OK"

        ctrlip = os.getenv( main.params['CTRL']['ip1'] )
        httpport = main.params['HTTP']['port']
        path = main.params['HTTP']['path']

        main.step( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        subnet = SubnetData()
        subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
        subnet.tenant_id = network.tenant_id
        subnet.network_id = network.id
        subnet.start = "10.0.0.1"
        subnet.end = "10.0.0.254"
        subnet.cidr = "10.0.0.0/24"
        port1 = VirtualPortData()
        port1.id = "00000000-0000-0000-0000-000000000001"
        port1.subnet_id = subnet.id
        port1.tenant_id = network.tenant_id
        port1.network_id = network.id
        port1.macAddress = "00:00:00:00:00:01"
        port1.ip_address = "10.0.0.1"
        port2 = VirtualPortData()
        port2.id = "00000000-0000-0000-0000-000000000002"
        port2.subnet_id = subnet.id
        port2.tenant_id = network.tenant_id
        port2.network_id = network.id
        port2.macAddress = "00:00:00:00:00:02"
        port2.ip_address = "10.0.0.2"

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        port1postdata = port1.DictoJson()
        port2postdata = port2.DictoJson()

        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
                                                 'POST', None, networkpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
                                                 'POST', None, subnetpostdata )
        utilities.assert_equals(
                expect='202',
                actual=Poststatus,
                onpass="******",
                onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Port1 Data via HTTP" )
        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
                                                 'POST', None, port1postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Port2 Data via HTTP" )
        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
                                                 'POST', None, port2postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
    def CASE6( self, main ):
        """
        Configure Network Subnet Port
        """
        import os

        try:
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
        except ImportError:
            main.log.exception( "Something wrong with import file or code error." )
            main.log.info( "Import Error, please check!" )
            main.cleanAndExit()

        main.log.info( "Configure Network Subnet Port Start" )
        main.case( "Configure Network Subnet Port" )
        main.caseExplanation = "Configure Network Subnet Port " +\
                                "Verify post is OK"

        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
        httpport = main.params[ 'HTTP' ][ 'port' ]
        path = main.params[ 'HTTP' ][ 'path' ]

        main.step( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        subnet = SubnetData()
        subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
        subnet.tenant_id = network.tenant_id
        subnet.network_id = network.id
        subnet.start = "10.0.0.1"
        subnet.end = "10.0.0.254"
        subnet.cidr = "10.0.0.0/24"
        port1 = VirtualPortData()
        port1.id = "00000000-0000-0000-0000-000000000001"
        port1.subnet_id = subnet.id
        port1.tenant_id = network.tenant_id
        port1.network_id = network.id
        port1.macAddress = "00:00:00:00:00:01"
        port1.ip_address = "10.0.0.1"
        port2 = VirtualPortData()
        port2.id = "00000000-0000-0000-0000-000000000002"
        port2.subnet_id = subnet.id
        port2.tenant_id = network.tenant_id
        port2.network_id = network.id
        port2.macAddress = "00:00:00:00:00:02"
        port2.ip_address = "10.0.0.2"

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        port1postdata = port1.DictoJson()
        port2postdata = port2.DictoJson()

        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( 'networks/', ctrlip, httpport, path,
                                                                 'POST', None, networkpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( 'subnets/', ctrlip, httpport, path,
                                                                 'POST', None, subnetpostdata )
        utilities.assert_equals(
                expect='202',
                actual=Poststatus,
                onpass="******",
                onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Port1 Data via HTTP" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( 'ports/', ctrlip, httpport, path,
                                                                 'POST', None, port1postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Post Port2 Data via HTTP" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( 'ports/', ctrlip, httpport, path,
                                                                 'POST', None, port2postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )