当前位置: 首页>>代码示例>>Python>>正文


Python base.Router类代码示例

本文整理汇总了Python中marvin.lib.base.Router的典型用法代码示例。如果您正苦于以下问题:Python Router类的具体用法?Python Router怎么用?Python Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Router类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_08_create_policy_router_stopped

    def test_08_create_policy_router_stopped(self):
        """Test verify create stickiness policy when router is stopped state"""

        # Validate the following
        # 1. stop the router
        # 2. create stikiness policy from UI
        # 3. start the router. listLBStickinessPolicies Api should show created
        #    stikiness policy

        self.debug("Creating LB rule for account: %s" % self.account.name)
        lb_rule = self.create_LB_Rule(
            self.public_ip,
            network=self.get_Network(self.account),
            vmarray=[self.virtual_machine, self.virtual_machine_2],
        )

        self.debug("Fetching routers for the account: %s" % self.account.name)
        router = self.get_router(self.account)

        self.debug("Stopping the router: %s" % router.name)
        Router.stop(self.apiclient, id=router.id)

        policies = self.configure_Stickiness_Policy(lb_rule, method="LbCookie")
        policy = policies.stickinesspolicy[0]

        self.debug("Starting the router: %s" % router.name)
        Router.start(self.apiclient, id=router.id)

        self.debug("Policy: %s" % str(policy))
        self.debug("Validating the stickiness policy")
        self.validate_Stickiness_Policy(lb_rule, "LbCookie", self.public_ip.ipaddress.ipaddress)
        return
开发者ID:ktenzer,项目名称:cloudstack,代码行数:32,代码来源:test_haproxy.py

示例2: test_04_change_service_offerring_vpc

    def test_04_change_service_offerring_vpc(self):
        """ Tests to change service offering of the Router after
            creating a vpc
        """

        # Validate the following
        # 1. Create a VPC with cidr - 10.1.1.1/16
        # 2. Change the service offerings of the VPC Virtual Router which is
        # created as a result of VPC creation.

        self.validate_vpc_offering(self.vpc_off)
        self.validate_vpc_network(self.vpc)

        routers = Router.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        self.assertEqual(
            isinstance(routers, list),
            True,
            "List Routers should return a valid list"
        )

        # Stop the router
        router = routers[0]
        self.debug("Stopping the router with ID: %s" % router.id)
        cmd = stopRouter.stopRouterCmd()
        cmd.id = router.id
        self.api_client.stopRouter(cmd)

        service_offering = ServiceOffering.create(
            self.api_client,
            self.services["service_offering_new"]
        )
        self.debug("Changing service offering for the Router %s" % router.id)
        try:
            router = Router.change_service_offering(self.api_client,
                                                    router.id,
                                                    service_offering.id
                                                    )
        except:
            self.fail("Changing service offering failed")

        self.debug("Router %s" % router)
        routers = Router.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        router = routers[0]
        self.assertEqual(
            router.serviceofferingid,
            service_offering.id,
            "Changing service offering failed as id is %s and expected"
            "is %s" % (router.serviceofferingid, service_offering.id)
        )
        return
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:60,代码来源:test_vpc_routers.py

示例3: _disable_zone_and_delete_system_vms

    def _disable_zone_and_delete_system_vms(self, virtual_router, verify_managed_system_vm_deleted=True):
        self.zone.update(self.apiClient, id=self.zone.id, allocationstate="Disabled")

        if virtual_router is not None:
            Router.destroy(self.apiClient, virtual_router.id)

            if verify_managed_system_vm_deleted:
                cs_root_volume = self._get_root_volume_for_system_vm(virtual_router.id, 'Expunged')

                self._verify_managed_system_vm_deleted(cs_root_volume.name)

        # list_ssvms lists the secondary storage VM and the console proxy VM
        system_vms = list_ssvms(self.apiClient)

        for system_vm in system_vms:
            destroy_ssvm_cmd = destroySystemVm.destroySystemVmCmd()

            destroy_ssvm_cmd.id = system_vm.id

            self.apiClient.destroySystemVm(destroy_ssvm_cmd)

            if verify_managed_system_vm_deleted:
                cs_root_volume = self._get_root_volume_for_system_vm(system_vm.id, 'Expunged')

                self._verify_managed_system_vm_deleted(cs_root_volume.name)
开发者ID:milamberspace,项目名称:cloudstack,代码行数:25,代码来源:TestManagedSystemVMs.py

示例4: test_09_create_policy_router_destroy

    def test_09_create_policy_router_destroy(self):
        """Test check the stickiness policy rules after destroying router"""

        # Validate the following
        # 1. create an account
        # 2. using that account,create an instances
        # 3. select the Source NAT IP  and configure the stikiness policy
        # 4. destroy the router.

        self.debug("Creating LB rule for account: %s" % self.account.name)
        lb_rule = self.create_LB_Rule(
            self.public_ip,
            network=self.get_Network(self.account),
            vmarray=[self.virtual_machine, self.virtual_machine_2],
        )

        self.debug("Fetching routers for the account: %s" % self.account.name)
        router = self.get_router(self.account)

        policies = self.configure_Stickiness_Policy(lb_rule, method="LbCookie")
        policy = policies.stickinesspolicy[0]

        self.debug("Policy: %s" % str(policy))
        self.debug("Validating the stickiness policy")
        self.validate_Stickiness_Policy(lb_rule, "LbCookie", self.public_ip.ipaddress.ipaddress)

        self.debug("Destroying the router: %s" % router.name)
        Router.destroy(self.apiclient, id=router.id)

        return
开发者ID:ktenzer,项目名称:cloudstack,代码行数:30,代码来源:test_haproxy.py

示例5: test_05_destroy_router_after_addition_of_one_guest_network

    def test_05_destroy_router_after_addition_of_one_guest_network(self):
        """ Test destroy of router after addition of one guest network
        """
        # Validations
        # 1. Create a VPC with cidr - 10.1.1.1/16
        # 2. Add network1(10.1.1.1/24) to this VPC.
        # 3. Deploy vm1,vm2 and vm3 such that they are part of network1.
        # 4. Create a PF /Static Nat/LB rule for vms in network1.
        # 5. Create ingress network ACL for allowing all the above rules from a public ip range on network1.
        # 6. Create egress network ACL for network1 to access google.com.
        # 7. Create a private gateway for this VPC and add a static route to this gateway.
        # 8. Create a VPN gateway for this VPC and add a static route to this gateway.
        # 9. Make sure that all the PF,LB and Static NAT rules work as expected.
        # 10. Make sure that we are able to access google.com from all the user Vms.
        # 11. Make sure that the newly added private gateway's and VPN
        # gateway's static routes work as expected

        self.validate_vpc_offering(self.vpc_off)
        self.validate_vpc_network(self.vpc)
        self.assertEqual(
            isinstance(self.gateways, list),
            True,
            "List private gateways should return a valid response"
        )
        self.assertEqual(
            isinstance(self.static_routes, list),
            True,
            "List static route should return a valid response"
        )

        routers = Router.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        self.assertEqual(
            isinstance(routers, list),
            True,
            "List Routers should return a valid list"
        )

        Router.destroy(self.api_client,
                       id=routers[0].id
                       )

        routers = Router.list(
            self.api_client,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )
        self.assertEqual(
            isinstance(routers, list),
            False,
            "List Routers should be empty"
        )
        return
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:58,代码来源:test_vpc_routers.py

示例6: test_13_1_egress_fr13

    def test_13_1_egress_fr13(self):
        """Test Redundant Router : Master failover
        """
        # Validate the following:
        # 1. deploy VM using network offering with egress policy false.
        # 2. create egress rule valid cidr valid port range.
        # 3. redundant router
        # 3. All should work fine.
        #TODO: setup network with RR
        self.create_vm(RR=True, egress_policy=False)
        self.createEgressRule()
        vm_network_id = self.virtual_machine.nic[0].networkid
        self.debug("Listing routers for network: %s" % vm_network_id)
        routers = Router.list(self.apiclient,
                              networkid=vm_network_id,
                              listall=True)
        self.assertEqual(isinstance(routers, list),
                         True,
                         "list router should return Master and backup routers")
        self.assertEqual(len(routers),
                         2,
                         "Length of the list router should be 2 (Backup & master)")

        if routers[0].redundantstate == 'MASTER':
            master_router = routers[0]
            backup_router = routers[1]
        else:
            master_router = routers[1]
            backup_router = routers[0]

        self.debug("Redundant states: %s, %s" % (master_router.redundantstate,
                                                backup_router.redundantstate))
        self.debug("Stopping the Master router")
        try:
            Router.stop(self.apiclient, id=master_router.id)
        except Exception as e:
            self.fail("Failed to stop master router: %s" % e)

        # wait for VR update state
        time.sleep(60)

        self.debug("Checking state of the master router in %s" % self.network.name)
        routers = Router.list(self.apiclient,
                              id=master_router.id,
                              listall=True)
        self.assertEqual(isinstance(routers, list),
                         True,
                         "list router should return Master and backup routers")

        self.exec_script_on_user_vm('ping -c 1 www.google.com',
                                    "| grep -oP \'\d+(?=% packet loss)\'",
                                    "['0']",
                                    negative_test=False)
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:53,代码来源:test_egress_fw_rules.py

示例7: test_01_deploy_vm_no_startvm

    def test_01_deploy_vm_no_startvm(self):
        """Test Deploy Virtual Machine with no startVM parameter
        """

        # Validate the following:
        # 1. deploy Vm  without specifying the startvm parameter
        # 2. Should be able to login to the VM.
        # 3. listVM command should return the deployed VM.State of this VM
        #    should be "Running".

        self.debug("Deploying instance in the account: %s" % self.account.name)
        self.virtual_machine_1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            diskofferingid=self.disk_offering.id,
            startvm=False,
        )

        response = self.virtual_machine_1.getState(self.apiclient, VirtualMachine.STOPPED)
        self.assertEqual(response[0], PASS, response[1])
        self.debug("Checking the router state after VM deployment")
        routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
        self.assertEqual(routers, None, "List routers should return empty response")
        self.debug("Deploying another instance (startvm=true) in the account: %s" % self.account.name)
        self.virtual_machine_2 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            diskofferingid=self.disk_offering.id,
            startvm=True,
        )

        response = self.virtual_machine_2.getState(self.apiclient, VirtualMachine.RUNNING)
        self.assertEqual(response[0], PASS, response[1])
        self.debug("Checking the router state after VM deployment")
        routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
        self.assertEqual(isinstance(routers, list), True, "List routers should not return empty response")
        for router in routers:
            self.debug("Router state: %s" % router.state)
            self.assertEqual(
                router.state, "Running", "Router should be in running state when instance is running in the account"
            )
        self.debug("Destroying the running VM:%s" % self.virtual_machine_2.name)
        self.virtual_machine_2.delete(self.apiclient, expunge=True)
        routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
        self.assertNotEqual(routers, None, "Router should get deleted after expunge delay+wait")
        return
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:52,代码来源:test_stopped_vm.py

示例8: VerifyRouterState

def VerifyRouterState(apiclient, account, domainid, desiredState,
                      retries=0):
    """List the router associated with the account and
       verify that router state matches with the desired state
       Return PASS/FAIL depending upon whether router state matches
       or not"""

    isRouterStateDesired = False
    failureMessage = ""
    while retries >= 0:
        routers = Router.list(
            apiclient,
            account=account,
            domainid=domainid,
            listall=True
        )
        if str(routers[0].state).lower() == str(desiredState).lower():
            isRouterStateDesired = True
            break
        time.sleep(60)
        retries -= 1
    # whileEnd

    if not isRouterStateDesired:
        failureMessage = "Router state should be %s,\
                but it is %s" %\
            (desiredState, routers[0].state)
    return [isRouterStateDesired, failureMessage]
开发者ID:K0zka,项目名称:cloudstack,代码行数:28,代码来源:testpath_stopped_vm.py

示例9: test_03_deploy_vm_startvm_false

    def test_03_deploy_vm_startvm_false(self):
        """Test Deploy Virtual Machine with startVM=false parameter
        """

        # Validate the following:
        # 1. deploy Vm  with the startvm=false
        # 2. Should not be able to login to the VM.
        # 3. listVM command should return the deployed VM.State of this VM
        #    should be "Stopped".
        # 4. Check listRouters call for that account. List routers should
        #    return empty response

        self.debug("Deploying instance in the account: %s" % self.account.name)
        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            startvm=False,
            diskofferingid=self.disk_offering.id,
        )

        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
        self.assertEqual(response[0], PASS, response[1])
        routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
        self.assertEqual(routers, None, "List routers should return empty response")
        self.debug("Destroying instance: %s" % self.virtual_machine.name)
        self.virtual_machine.delete(self.apiclient, expunge=True)
        return
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:30,代码来源:test_stopped_vm.py

示例10: test_03_reconnect_host

    def test_03_reconnect_host(self):
        """ Test reconnect Host which has VPC elements
        """

        # Steps:
        # 1.Reconnect one of the host on which VPC Virtual Router is present.
        # Validate the following
        # 1. Host should successfully reconnect.
        # 2. Network connectivity to all the VMs on the host should not be
        #    effected due to reconnection.

        self.debug("Reconnecting the host where VPC VR is running")
        try:
            Host.reconnect(self.apiclient, id=self.vpcvr.hostid)
        except Exception as e:
            self.fail("Failed to reconnect to host: %s" % e)

        self.debug("Check the status of router after migration")
        routers = Router.list(
                              self.apiclient,
                              id=self.vpcvr.id,
                              listall=True
                              )
        self.assertEqual(
                         isinstance(routers, list),
                         True,
                         "List routers shall return the valid response"
                         )
        self.assertEqual(
                         routers[0].state,
                         "Running",
                         "Router state should be running"
                         )
        #  TODO: Check for the network connectivity
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:35,代码来源:test_vpc_host_maintenance.py

示例11: test_03_reconnect_host

    def test_03_reconnect_host(self):
        """ Test reconnect Host which has VPC elements
        """

        # Steps:
        # 1.Reconnect one of the host on which VPC Virtual Router is present.
        # Validate the following
        # 1. Host should successfully reconnect.
        # 2. Network connectivity to all the VMs on the host should not be
        #    effected due to reconnection.

        try:
            timeout = self.services["timeout"]        
            while True:
                list_host_response = Host.list(
                    self.apiclient,
                    id=self.vpcvr.hostid,
                    resourcestate="Enabled")
                
                if list_host_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Failed to list the Host in Up State")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1
            
            self.debug("Verified that the Host is in Up State")
            
        except:
            self.fail("Failed to find the Host in Up State")

        self.debug("Reconnecting the host where VPC VR is running")
        try:
            Host.reconnect(self.apiclient, id=self.vpcvr.hostid)
        except Exception as e:
            self.fail("Failed to reconnect to host: %s" % e)

        self.debug("Check the status of router after migration")
        routers = Router.list(
                              self.apiclient,
                              id=self.vpcvr.id,
                              listall=True
                              )
        self.assertEqual(
                         isinstance(routers, list),
                         True,
                         "List routers shall return the valid response"
                         )
        self.assertEqual(
                         routers[0].state,
                         "Running",
                         "Router state should be running"
                         )
        #  TODO: Check for the network connectivity
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:56,代码来源:test_vpc_host_maintenance.py

示例12: get_router

    def get_router(self, account):
        """Returns a default router for account"""

        routers = Router.list(self.apiclient,
                              account=self.account.name,
                              domainid=self.account.domainid,
                              listall=True)
        self.assertIsInstance(routers, list,
                              "List routers should return a valid repsonse")
        return routers[0]
开发者ID:diejiazhao,项目名称:cloudstack,代码行数:10,代码来源:test_haproxy.py

示例13: setUp

    def setUp(self):

        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        self.debug("Check the status of VPC virtual router")
        routers = Router.list(
                              self.apiclient,
                              networkid=self.network_1.id,
                              listall=True
                              )
        if not isinstance(routers, list):
            raise Exception("No response from list routers API")

        self.router = routers[0]
        if self.router.state == "Running":
            Router.stop(self.apiclient, id=self.router.id)

        self.cleanup = []
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:19,代码来源:test_vpc_host_maintenance.py

示例14: get_Router

 def get_Router(self, network):
     self.debug("Finding the virtual router for network with ID - %s" % network.id)
     routers = Router.list(self.api_client,
                           networkid=network.id,
                           listall=True
                           )
     self.assertEqual(isinstance(routers, list), True,
                      "List routers should return a valid virtual router for network"
                      )
     return routers[0]
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:10,代码来源:nuageTestCase.py

示例15: check_router_state

 def check_router_state(self, router, state=None):
     self.debug("Check if the virtual router is in state - %s" % state)
     routers = Router.list(self.api_client,
                           id=router.id,
                           listall=True
                           )
     self.assertEqual(isinstance(routers, list), True,
                      "List router should return a valid list"
                      )
     if state:
         self.assertEqual(routers[0].state, state,
                          "Virtual router is not in the expected state"
                          )
     self.debug("Virtual router is in the expected state - %s" % state)
开发者ID:DKrul,项目名称:cloudstack,代码行数:14,代码来源:nuageTestCase.py


注:本文中的marvin.lib.base.Router类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。