Example #1
0
    def CASE4(self, main):

        """
        Test Delete Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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("ONOS Network Delete test Start")
        main.case("Virtual Network NBI Test - Network")
        main.caseExplanation = "Test Network Delete NBI " + "Verify Stored Data is NULL after Delete"

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

        main.log.info("Generate Post Data")
        network = NetworkData()
        network.id = "030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc"
        network.tenant_id = "26cd996094344a0598b0a1af1d525cdc"
        postdata = network.DictoJson()

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

        main.step("Delete Data via HTTP")
        Deletestatus, result = main.ONOSrest.send(ctrlip, port, network.id, path + "networks/", "DELETE", None, None)
        utilities.assert_equals(
            expect="200",
            actual=Deletestatus,
            onpass="******",
            onfail="Delete Failed " + str(Deletestatus) + str(result),
        )

        main.step("Get Data is NULL")
        Getstatus, result = main.ONOSrest.send(ctrlip, port, network.id, path + "networks/", "GET", None, None)
        utilities.assert_equals(
            expect="Network is not found",
            actual=result,
            onpass="******",
            onfail="Get Failed " + str(Getstatus) + str(result),
        )

        if result != "Network is not found":
            main.log.error("Delete Network failed")
Example #2
0
    def CASE12(self, main):

        """
        Test Post Error Json Create Subnet
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
        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("ONOS Post Error Json Create Subnet test Start")
        main.case("Virtual Network NBI Test - Subnet")
        main.caseExplanation = "Test Subnet Post With Error json " + "The wrong Json can't post network successfully"

        ctrlip = os.getenv(main.params["CTRL"]["ip1"])
        port = 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"
        # The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
        subnet.enable_dhcp = "tttttttttttttt"
        # The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
        subnet.shared = "ffffffffffffff"
        subnet.tenant_id = network.tenant_id
        subnet.network_id = network.id

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()

        main.step("Post Network Data via HTTP(Post Subnet need post network)")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", 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")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", path + "subnets/", "POST", None, subnetpostdata)
        utilities.assert_equals(
            expect="500",
            actual=Poststatus,
            onpass="******",
            onfail="Wrong Json can post successfully ",
        )
    def CASE4( self, main ):
        """
        Test Delete Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Network Delete test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Delete NBI " +\
                                "Verify Stored Data is NULL after Delete"

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

        main.log.info( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        postdata = network.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
                                             'POST', None, postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Failed " + str( Poststatus ) + str( result ) )

        main.step( "Delete Data via HTTP" )
        Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Deletestatus,
                onpass="******",
                onfail="Delete Failed " + str( Deletestatus ) + str( result ) )

        main.step( "Get Data is NULL" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='Network is not found',
                actual=result,
                onpass="******",
                onfail="Get Failed " + str( Getstatus ) + str( result ) )

        if result != 'Network is not found':
            main.log.error( "Delete Network failed" )
Example #4
0
    def CASE4( self, main ):
        """
        Test Delete Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Network Delete test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Delete NBI " +\
                                "Verify Stored Data is NULL after Delete"

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

        main.log.info( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        postdata = network.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
                                             'POST', None, postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Failed " + str( Poststatus ) + str( result ) )

        main.step( "Delete Data via HTTP" )
        Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Deletestatus,
                onpass="******",
                onfail="Delete Failed " + str( Deletestatus ) + str( result ) )

        main.step( "Get Data is NULL" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='Network is not found',
                actual=result,
                onpass="******",
                onfail="Get Failed " + str( Getstatus ) + str( result ) )

        if result != 'Network is not found':
            main.log.error( "Delete Network failed" )
Example #5
0
    def CASE12( self, main ):
        """
        Test Post Error Json Create Subnet
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
        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( "ONOS Post Error Json Create Subnet test Start" )
        main.case( "Virtual Network NBI Test - Subnet" )
        main.caseExplanation = "Test Subnet Post With Error json " +\
                                "The wrong Json can't post network successfully"

        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
        port = 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"
        # The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
        subnet.enable_dhcp = 'tttttttttttttt'
        # The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
        subnet.shared = 'ffffffffffffff'
        subnet.tenant_id = network.tenant_id
        subnet.network_id = network.id

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()

        main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', 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" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/',
                                                                 'POST', None, subnetpostdata )
        utilities.assert_equals(
                expect='500',
                actual=Poststatus,
                onpass="******",
                onfail="Wrong Json can post successfully " )
Example #6
0
    def CASE11( self, main ):
        """
        Test Post Error Json Create Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Post Error Json Create Network test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Post With Error json The wrong Json can't post network successfully"

        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
        port = 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'
        # The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
        network.admin_state_up = 'tttttttttt'
        # The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
        network.routerExternal = 'ffffffffffff'
        # The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
        network.shared = 'ffffffffffffff'
        postdata = network.DictoJson()

        main.step( "Post Data via HTTP" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
                                                                 'POST', None, postdata )

        utilities.assert_equals(
                expect='500',
                actual=Poststatus,
                onpass="******",
                onfail="Wrong Json can post successfully " )
Example #7
0
    def CASE11(self, main):

        """
        Test Post Error Json Create Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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("ONOS Post Error Json Create Network test Start")
        main.case("Virtual Network NBI Test - Network")
        main.caseExplanation = "Test Network Post With Error json " + "The wrong Json can't post network successfully"

        ctrlip = os.getenv(main.params["CTRL"]["ip1"])
        port = 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"
        # The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
        network.admin_state_up = "tttttttttt"
        # The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
        network.routerExternal = "ffffffffffff"
        # The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
        network.shared = "ffffffffffffff"
        postdata = network.DictoJson()

        main.step("Post Data via HTTP")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", path + "networks/", "POST", None, postdata)

        utilities.assert_equals(
            expect="500",
            actual=Poststatus,
            onpass="******",
            onfail="Wrong Json can post successfully ",
        )
    def CASE11( self, main ):
        """
        Test Post Error Json Create Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Post Error Json Create Network test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Post With Error json The wrong Json can't post network successfully"

        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
        port = 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'
        # The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
        network.admin_state_up = 'tttttttttt'
        # The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
        network.routerExternal = 'ffffffffffff'
        # The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
        network.shared = 'ffffffffffffff'
        postdata = network.DictoJson()

        main.step( "Post Data via HTTP" )
        Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
                                                                 'POST', None, postdata )

        utilities.assert_equals(
                expect='500',
                actual=Poststatus,
                onpass="******",
                onfail="Wrong Json can post successfully " )
    def CASE10( self, main ):
        """
        Test Delete Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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( "ONOS Port Delete test Start" )
        main.case( "Virtual Network NBI Test - Port" )
        main.caseExplanation = "Test Port Delete NBI " +\
                                "Verify port delete success"

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

        main.log.info( "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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = ctrl.REST.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 = ctrl.REST.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 Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
                                             'POST', None, portpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Delete Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                             'Delete', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Get Port Data is NULL" )
        Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='VirtualPort is not found',
                actual=result,
                onpass="******",
                onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )

        if result != 'VirtualPort is not found':
            main.log.error( "Delete Port failed" )

        main.step( "Clean Data via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )
Example #10
0
    def CASE9( self, main ):
        """
        Test Update Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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( "ONOS Port Update test Start" )
        main.case( "Virtual Network NBI Test - Port" )
        main.caseExplanation = "Test Port Update NBI " +\
                                "Verify Stored Data is same with New Post Data"

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

        main.log.info( "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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id
        port.name = "onos"

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()

        # create update data
        port.name = "onos-new"
        newportpostdata = port.DictoJson()
        # end
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = ctrl.REST.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 = ctrl.REST.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 Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
                                             'POST', None, portpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Update Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                             'PUT', None, newportpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Get Port Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )

        main.step( "Compare Update Port Data" )
        IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
        TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
        NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
        Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )

        Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Network id compare:" + str( NetoworkIDcmpresult ) +
                       ",Name compare:" + str( Nameresult ) )

        main.step( "Clean Data via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update port compare failed" )
    def CASE6( self, main ):
        """
        Test Post Subnet
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
        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( "ONOS Subnet Update test Start" )
        main.case( "Virtual Network NBI Test - Subnet" )
        main.caseExplanation = "Test Subnet Update NBI " +\
                                "Verify Stored Data is same with Update Data"

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

        main.log.info( "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 = "192.168.2.1"
        subnet.end = "192.168.2.255"
        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()

        # Change allocation_poolsdata scope
        subnet.start = "192.168.102.1"
        subnet.end = "192.168.102.255"
        # end change
        newsubnetpostdata = subnet.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', 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" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
                                             'POST', None, subnetpostdata )
        utilities.assert_equals(
                expect='202',
                actual=Poststatus,
                onpass="******",
                onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Update Subnet Data via HTTP" )
        Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
                                            'PUT', None, newsubnetpostdata )
        utilities.assert_equals(
                expect='203',
                actual=Putstatus,
                onpass="******",
                onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )

        main.step( "Get Subnet Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )

        IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
        TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
        Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )

        main.step( "Compare Subnet Data" )
        Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Pool compare:" + str( Poolcmpresult ) )

        main.step( "Delete Subnet via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update Subnet compare failed" )
    def CASE9( self, main ):
        """
        Test Update Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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( "ONOS Port Update test Start" )
        main.case( "Virtual Network NBI Test - Port" )
        main.caseExplanation = "Test Port Update NBI " +\
                                "Verify Stored Data is same with New Post Data"

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

        main.log.info( "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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id
        port.name = "onos"

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()

        # create update data
        port.name = "onos-new"
        newportpostdata = port.DictoJson()
        # end
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = ctrl.REST.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 = ctrl.REST.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 Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
                                             'POST', None, portpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Update Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                             'PUT', None, newportpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Get Port Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )

        main.step( "Compare Update Port Data" )
        IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
        TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
        NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
        Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )

        Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Network id compare:" + str( NetoworkIDcmpresult ) +
                       ",Name compare:" + str( Nameresult ) )

        main.step( "Clean Data via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update port compare failed" )
    def CASE3( self, main ):
        """
        Test Update Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Network Update test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Update NBI Verify Update Data same with Stored Data"

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

        main.log.info( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        network.shared = False
        postdata = network.DictoJson()

        network.shared = True
        postdatanew = network.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
                                             'POST', None, postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Failed " + str( Poststatus ) + str( result ) )

        main.step( "Update Data via HTTP" )
        Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'PUT', None, postdatanew )
        utilities.assert_equals(
                expect='200',
                actual=Updatestatus,
                onpass="******",
                onfail="Update Failed " + str( Updatestatus ) + str( result ) )

        main.step( "Get Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Failed " + str( Getstatus ) + str( result ) )

        main.step( "Compare Update data." )
        IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
        TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
        Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )

        Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Name compare:" + str( Shareresult ) )

        deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )

        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update Network compare failed" )
Example #14
0
    def CASE3(self, main):

        """
        Test Update Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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("ONOS Network Update test Start")
        main.case("Virtual Network NBI Test - Network")
        main.caseExplanation = "Test Network Update NBI " + "Verify Update Data same with Stored Data"

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

        main.log.info("Generate Post Data")
        network = NetworkData()
        network.id = "030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc"
        network.tenant_id = "26cd996094344a0598b0a1af1d525cdc"
        network.shared = False
        postdata = network.DictoJson()

        network.shared = True
        postdatanew = network.DictoJson()

        main.step("Post Data via HTTP")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", path + "networks", "POST", None, postdata)
        utilities.assert_equals(
            expect="200",
            actual=Poststatus,
            onpass="******",
            onfail="Post Failed " + str(Poststatus) + str(result),
        )

        main.step("Update Data via HTTP")
        Updatestatus, result = main.ONOSrest.send(
            ctrlip, port, network.id, path + "networks/", "PUT", None, postdatanew
        )
        utilities.assert_equals(
            expect="200",
            actual=Updatestatus,
            onpass="******",
            onfail="Update Failed " + str(Updatestatus) + str(result),
        )

        main.step("Get Data via HTTP")
        Getstatus, result = main.ONOSrest.send(ctrlip, port, network.id, path + "networks/", "GET", None, None)
        utilities.assert_equals(
            expect="200", actual=Getstatus, onpass="******", onfail="Get Failed " + str(Getstatus) + str(result)
        )

        main.step("Compare Update data.")
        IDcmpresult = network.JsonCompare(postdatanew, result, "network", "id")
        TanantIDcmpresult = network.JsonCompare(postdatanew, result, "network", "tenant_id")
        Shareresult = network.JsonCompare(postdatanew, result, "network", "shared")

        Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
        utilities.assert_equals(
            expect=True,
            actual=Cmpresult,
            onpass="******",
            onfail="Compare Failed:ID compare:"
            + str(IDcmpresult)
            + ",Tenant id compare:"
            + str(TanantIDcmpresult)
            + ",Name compare:"
            + str(Shareresult),
        )

        deletestatus, result = main.ONOSrest.send(ctrlip, port, network.id, path + "networks/", "DELETE", None, None)

        utilities.assert_equals(
            expect="200", actual=deletestatus, onpass="******", onfail="Delete Network Failed"
        )

        if Cmpresult != True:
            main.log.error("Update Network compare failed")
Example #15
0
    def CASE6(self, main):

        """
        Test Post Subnet
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
        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("ONOS Subnet Update test Start")
        main.case("Virtual Network NBI Test - Subnet")
        main.caseExplanation = "Test Subnet Update NBI " + "Verify Stored Data is same with Update Data"

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

        main.log.info("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 = "192.168.2.1"
        subnet.end = "192.168.2.255"
        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()

        # Change allocation_poolsdata scope
        subnet.start = "192.168.102.1"
        subnet.end = "192.168.102.255"
        # end change
        newsubnetpostdata = subnet.DictoJson()

        main.step("Post Network Data via HTTP(Post Subnet need post network)")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", 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")
        Poststatus, result = main.ONOSrest.send(ctrlip, port, "", path + "subnets/", "POST", None, subnetpostdata)
        utilities.assert_equals(
            expect="202",
            actual=Poststatus,
            onpass="******",
            onfail="Post Subnet Failed " + str(Poststatus) + "," + str(result),
        )

        main.step("Update Subnet Data via HTTP")
        Putstatus, result = main.ONOSrest.send(
            ctrlip, port, subnet.id, path + "subnets/", "PUT", None, newsubnetpostdata
        )
        utilities.assert_equals(
            expect="203",
            actual=Putstatus,
            onpass="******",
            onfail="Update Subnet Failed " + str(Putstatus) + "," + str(result),
        )

        main.step("Get Subnet Data via HTTP")
        Getstatus, result = main.ONOSrest.send(ctrlip, port, subnet.id, path + "subnets/", "GET", None, None)
        utilities.assert_equals(
            expect="200",
            actual=Getstatus,
            onpass="******",
            onfail="Get Subnet Failed " + str(Getstatus) + "," + str(result),
        )

        IDcmpresult = subnet.JsonCompare(newsubnetpostdata, result, "subnet", "id")
        TanantIDcmpresult = subnet.JsonCompare(newsubnetpostdata, result, "subnet", "tenant_id")
        Poolcmpresult = subnet.JsonCompare(newsubnetpostdata, result, "subnet", "allocation_pools")

        main.step("Compare Subnet Data")
        Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
        utilities.assert_equals(
            expect=True,
            actual=Cmpresult,
            onpass="******",
            onfail="Compare Failed:ID compare:"
            + str(IDcmpresult)
            + ",Tenant id compare:"
            + str(TanantIDcmpresult)
            + ",Pool compare:"
            + str(Poolcmpresult),
        )

        main.step("Delete Subnet via HTTP")
        deletestatus, result = main.ONOSrest.send(ctrlip, port, network.id, path + "networks/", "DELETE", None, None)
        utilities.assert_equals(
            expect="200", actual=deletestatus, onpass="******", onfail="Delete Network Failed"
        )

        if Cmpresult != True:
            main.log.error("Update Subnet compare failed")
    def CASE13( self, main ):
        """
        Test Post Error Json Create Virtualport
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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( "ONOS Post Error Json Create Subnet test Start" )
        main.case( "Virtual Network NBI Test - Port" )
        main.caseExplanation = "Test Subnet Post With Error json " +\
                                "The wrong Json can't create port successfully"

        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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id
        # The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
        port.adminStateUp = 'tttttttttttt'

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = ctrl.REST.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 = ctrl.REST.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 Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
                                             'POST', None, portpostdata )
        utilities.assert_equals(
                expect='500',
                actual=Poststatus,
                onpass="******",
                onfail="Wrong Json can post successfully" )
Example #17
0
    def CASE9(self, main):

        """
        Test Update Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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("ONOS Port Update test Start")
        main.case("Virtual Network NBI Test - Port")
        main.caseExplanation = "Test Port Update NBI " + "Verify Stored Data is same with New Post Data"

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

        main.log.info("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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id
        port.name = "onos"

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()

        # create update data
        port.name = "onos-new"
        newportpostdata = port.DictoJson()
        # end

        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 Port Data via HTTP")
        Poststatus, result = main.ONOSrest.send(ctrlip, httpport, "", path + "ports/", "POST", None, portpostdata)
        utilities.assert_equals(
            expect="200",
            actual=Poststatus,
            onpass="******",
            onfail="Post Port Failed " + str(Poststatus) + "," + str(result),
        )

        main.step("Update Port Data via HTTP")
        Poststatus, result = main.ONOSrest.send(
            ctrlip, httpport, port.id, path + "ports/", "PUT", None, newportpostdata
        )
        utilities.assert_equals(
            expect="200",
            actual=Poststatus,
            onpass="******",
            onfail="Update Port Failed " + str(Poststatus) + "," + str(result),
        )

        main.step("Get Port Data via HTTP")
        Getstatus, result = main.ONOSrest.send(ctrlip, httpport, port.id, path + "ports/", "GET", None, None)
        utilities.assert_equals(
            expect="200",
            actual=Getstatus,
            onpass="******",
            onfail="Get Port Failed " + str(Getstatus) + "," + str(result),
        )

        main.step("Compare Update Port Data")
        IDcmpresult = subnet.JsonCompare(portpostdata, result, "port", "id")
        TanantIDcmpresult = subnet.JsonCompare(portpostdata, result, "port", "tenant_id")
        NetoworkIDcmpresult = subnet.JsonCompare(portpostdata, result, "port", "network_id")
        Nameresult = subnet.JsonCompare(newportpostdata, result, "port", "name")

        Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
        utilities.assert_equals(
            expect=True,
            actual=Cmpresult,
            onpass="******",
            onfail="Compare Failed:ID compare:"
            + str(IDcmpresult)
            + ",Tenant id compare:"
            + str(TanantIDcmpresult)
            + ",Network id compare:"
            + str(NetoworkIDcmpresult)
            + ",Name compare:"
            + str(Nameresult),
        )

        main.step("Clean Data via HTTP")
        deletestatus, result = main.ONOSrest.send(
            ctrlip, httpport, network.id, path + "networks/", "DELETE", None, None
        )
        utilities.assert_equals(
            expect="200", actual=deletestatus, onpass="******", onfail="Delete Network Failed"
        )

        if Cmpresult != True:
            main.log.error("Update port compare failed")
Example #18
0
    def CASE10( self, main ):
        """
        Test Delete Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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( "ONOS Port Delete test Start" )
        main.case( "Virtual Network NBI Test - Port" )
        main.caseExplanation = "Test Port Delete NBI " +\
                                "Verify port delete success"

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

        main.log.info( "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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post port need post network)" )
        Poststatus, result = ctrl.REST.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 = ctrl.REST.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 Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
                                             'POST', None, portpostdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Delete Port Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                             'Delete', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Get Port Data is NULL" )
        Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='VirtualPort is not found',
                actual=result,
                onpass="******",
                onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )

        if result != 'VirtualPort is not found':
            main.log.error( "Delete Port failed" )

        main.step( "Clean Data via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )
Example #19
0
    def CASE10(self, main):

        """
        Test Delete Port
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
            from tests.FUNC.FUNCvirNetNB.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("ONOS Port Delete test Start")
        main.case("Virtual Network NBI Test - Port")
        main.caseExplanation = "Test Port Delete NBI " + "Verify port delete success"

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

        main.log.info("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
        port = VirtualPortData()
        port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
        port.subnet_id = subnet.id
        port.tenant_id = network.tenant_id
        port.network_id = network.id

        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()
        portpostdata = port.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 Port Data via HTTP")
        Poststatus, result = main.ONOSrest.send(ctrlip, httpport, "", path + "ports/", "POST", None, portpostdata)
        utilities.assert_equals(
            expect="200",
            actual=Poststatus,
            onpass="******",
            onfail="Post Port Failed " + str(Poststatus) + "," + str(result),
        )

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

        main.step("Get Port Data is NULL")
        Getstatus, result = main.ONOSrest.send(ctrlip, httpport, port.id, path + "ports/", "GET", None, None)
        utilities.assert_equals(
            expect="VirtualPort is not found",
            actual=result,
            onpass="******",
            onfail="Get Port Failed " + str(Getstatus) + "," + str(result),
        )

        if result != "VirtualPort is not found":
            main.log.error("Delete Port failed")

        main.step("Clean Data via HTTP")
        deletestatus, result = main.ONOSrest.send(
            ctrlip, httpport, network.id, path + "networks/", "DELETE", None, None
        )
        utilities.assert_equals(
            expect="200", actual=deletestatus, onpass="******", onfail="Delete Network Failed"
        )
Example #20
0
    def CASE6( self, main ):
        """
        Test Post Subnet
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
        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( "ONOS Subnet Update test Start" )
        main.case( "Virtual Network NBI Test - Subnet" )
        main.caseExplanation = "Test Subnet Update NBI " +\
                                "Verify Stored Data is same with Update Data"

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

        main.log.info( "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 = "192.168.2.1"
        subnet.end = "192.168.2.255"
        networkpostdata = network.DictoJson()
        subnetpostdata = subnet.DictoJson()

        # Change allocation_poolsdata scope
        subnet.start = "192.168.102.1"
        subnet.end = "192.168.102.255"
        # end change
        newsubnetpostdata = subnet.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', 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" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
                                             'POST', None, subnetpostdata )
        utilities.assert_equals(
                expect='202',
                actual=Poststatus,
                onpass="******",
                onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )

        main.step( "Update Subnet Data via HTTP" )
        Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
                                            'PUT', None, newsubnetpostdata )
        utilities.assert_equals(
                expect='203',
                actual=Putstatus,
                onpass="******",
                onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )

        main.step( "Get Subnet Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )

        IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
        TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
        Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )

        main.step( "Compare Subnet Data" )
        Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Pool compare:" + str( Poolcmpresult ) )

        main.step( "Delete Subnet via HTTP" )
        deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )
        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update Subnet compare failed" )
Example #21
0
    def CASE3( self, main ):
        """
        Test Update Network
        """
        import os

        try:
            from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
        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( "ONOS Network Update test Start" )
        main.case( "Virtual Network NBI Test - Network" )
        main.caseExplanation = "Test Network Update NBI Verify Update Data same with Stored Data"

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

        main.log.info( "Generate Post Data" )
        network = NetworkData()
        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
        network.shared = False
        postdata = network.DictoJson()

        network.shared = True
        postdatanew = network.DictoJson()
        ctrl = main.Cluster.active( 0 )
        main.step( "Post Data via HTTP" )
        Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
                                             'POST', None, postdata )
        utilities.assert_equals(
                expect='200',
                actual=Poststatus,
                onpass="******",
                onfail="Post Failed " + str( Poststatus ) + str( result ) )

        main.step( "Update Data via HTTP" )
        Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'PUT', None, postdatanew )
        utilities.assert_equals(
                expect='200',
                actual=Updatestatus,
                onpass="******",
                onfail="Update Failed " + str( Updatestatus ) + str( result ) )

        main.step( "Get Data via HTTP" )
        Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                            'GET', None, None )
        utilities.assert_equals(
                expect='200',
                actual=Getstatus,
                onpass="******",
                onfail="Get Failed " + str( Getstatus ) + str( result ) )

        main.step( "Compare Update data." )
        IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
        TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
        Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )

        Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
        utilities.assert_equals(
                expect=True,
                actual=Cmpresult,
                onpass="******",
                onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
                       ",Tenant id compare:" + str( TanantIDcmpresult ) +
                       ",Name compare:" + str( Shareresult ) )

        deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
                                               'DELETE', None, None )

        utilities.assert_equals(
                expect='200',
                actual=deletestatus,
                onpass="******",
                onfail="Delete Network Failed" )

        if not Cmpresult:
            main.log.error( "Update Network compare failed" )