• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.list_virtual_machines函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_01_add_vm_to_subdomain

    def test_01_add_vm_to_subdomain(self):
        """ Test Sub domain allowed to launch VM  when a Domain level zone is created"""

        # Validate the following
        # 1. Verify VM created by Account_1 is in Running state
        # 2. Verify VM created by Account_2 is in Running state

        vm_response = list_virtual_machines(
                                    self.apiclient,
                                    id=self.vm_1.id
                                )
        self.assertEqual(
                            isinstance(vm_response, list),
                            True,
                            "Check List VM for a valid response"
                        )
        self.assertNotEqual(
                            len(vm_response),
                            0,
                            "Check List Template response"
                            )

        for vm in vm_response:
            self.debug("VM ID: %s and state: %s" % (vm.id, vm.state))
            self.assertEqual(
                             vm.state,
                             'Running',
                             "Check State of Virtual machine"
                             )

        vm_response = list_virtual_machines(
                                    self.apiclient,
                                    id=self.vm_2.id
                                )
        self.assertNotEqual(
                            len(vm_response),
                            0,
                            "Check List Template response"
                            )

        for vm in vm_response:
            self.debug("VM ID: %s and state: %s" % (vm.id, vm.state))
            self.assertEqual(
                             vm.state,
                             'Running',
                             "Check State of Virtual machine"
                             )
        return
开发者ID:wilderrodrigues,项目名称:cloudstack_integration_tests,代码行数:48,代码来源:test_accounts.py


示例2: create_vm_in_aff_grps

    def create_vm_in_aff_grps(self, api_client=None, ag_list=[], projectid=None):
        self.debug('Creating VM in AffinityGroups=%s' % ag_list)

        if api_client is None:
           api_client = self.api_client
        if projectid is None:
           projectid = self.project.id

        vm = VirtualMachine.create(
                api_client,
                self.services["virtual_machine"],
                projectid=projectid,
                templateid=self.template.id,
                serviceofferingid=self.service_offering.id,
                affinitygroupnames=ag_list
              )
        self.debug('Created VM=%s in Affinity Group=%s' % (vm.id, tuple(ag_list)))
        list_vm = list_virtual_machines(self.api_client, id=vm.id, projectid=projectid)
        self.assertEqual(isinstance(list_vm, list), True,"Check list response returns an invalid list %s" % list_vm)
        self.assertNotEqual(len(list_vm),0, "Check VM available in TestDeployVMAffinityGroups")
        self.assertEqual(list_vm[0].id, vm.id,"Listed vm does not have the same ids")
        vm_response = list_vm[0]
        self.assertEqual(vm.state, 'Running',msg="VM is not in Running state")
        self.assertEqual(vm.projectid, projectid,msg="VM is not in project")
        self.assertNotEqual(vm_response.hostid, None, "Host id was null for vm %s" % vm_response)
        return vm, vm_response.hostid
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:26,代码来源:test_affinity_groups_projects.py


示例3: check_vm_is_moved_in_account_domainid

 def check_vm_is_moved_in_account_domainid(self, account):
     list_vm_response = list_virtual_machines(self.api_client,
                                              id=self.virtual_machine.id,
                                              account=account.name,
                                              domainid=account.domainid)
     self.debug('VM=%s moved to account=%s and domainid=%s' % (list_vm_response, account.name, account.domainid))
     self.assertNotEqual(len(list_vm_response), 0, 'Unable to move VM to account=%s domainid=%s' % (account.name, account.domainid))
开发者ID:PCextreme,项目名称:cloudstack,代码行数:7,代码来源:test_assign_vm.py


示例4: test_08_removeNic_in_sharedNetwork_scope_all_as_domain_parentAdmin

    def test_08_removeNic_in_sharedNetwork_scope_all_as_domain_parentAdmin(
            self):
        """Validate that Parent domain admin is able to remove a NIC  which is
        added by child domain user
        """

        self.api_client.connection.apiKey = self.user_d1_apikey
        self.api_client.connection.securityKey = self.user_d1_secretkey
        self.debug("Removing NIC od shared Network as user d1")

        vm_list = list_virtual_machines(self.api_client, id=self.vmvpc1.id)
        vm_list_validation_result = validateList(vm_list)
        self.assertEqual(vm_list_validation_result[0], PASS,
                         "vm list validation failed due to %s" %
                         vm_list_validation_result[2])
        self.debug("virtual machine nics: %s" % vm_list[0].nic)
        for nic in vm_list[0].nic:
            if nic.networkid == self.shared_network_all.id:
                reqNic = nic

        self.vmvpc1.remove_nic(self.api_client, reqNic.id)

        if not self.verify_nic(self.shared_network_all, self.vmvpc1):
            self.debug(
                "virtual machine has mot NIC is SharedNetwork: %s" %
                self.shared_network_all.name)
        else:
            self.fail("network %s NIC is present in the virtual Machine %s" %
                      (self.shared_network_all.name, self.vmvpc1.id))
开发者ID:Accelerite,项目名称:cloudstack,代码行数:29,代码来源:test_nuage_sharednetwork_vpc_vm_monitor.py


示例5: create_vm

    def create_vm(self, pfrule=False, egress_policy=True, RR=False):
        self.create_network_offering(egress_policy, RR)
        # Creating network using the network offering created
        self.debug("Creating network with network offering: %s" % self.network_offering.id)
        self.network = Network.create(
            self.apiclient,
            self.services["network"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            networkofferingid=self.network_offering.id,
            zoneid=self.zone.id,
        )
        self.debug("Created network with ID: %s" % self.network.id)
        self.debug("Deploying instance in the account: %s" % self.account.name)

        project = None
        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.domain.id,
            serviceofferingid=self.service_offering.id,
            mode=self.zone.networktype if pfrule else "basic",
            networkids=[str(self.network.id)],
            projectid=project.id if project else None,
        )
        self.debug("Deployed instance %s in account: %s" % (self.virtual_machine.id, self.account.name))

        # Checking if VM is running or not, in case it is deployed in error state, test case fails
        self.vm_list = list_virtual_machines(self.apiclient, id=self.virtual_machine.id)

        self.assertEqual(validateList(self.vm_list)[0], PASS, "vm list validation failed, vm list is %s" % self.vm_list)
        self.assertEqual(
            str(self.vm_list[0].state).lower(),
            "running",
            "VM state should be running, it is %s" % self.vm_list[0].state,
        )

        self.public_ip = PublicIPAddress.create(
            self.apiclient,
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            networkid=self.network.id,
        )

        # Open up firewall port for SSH
        FireWallRule.create(
            self.apiclient,
            ipaddressid=self.public_ip.ipaddress.id,
            protocol=self.services["natrule"]["protocol"],
            cidrlist=["0.0.0.0/0"],
            startport=self.services["natrule"]["publicport"],
            endport=self.services["natrule"]["publicport"],
        )

        self.debug("Creating NAT rule for VM ID: %s" % self.virtual_machine.id)
        # Create NAT rule
        NATRule.create(self.apiclient, self.virtual_machine, self.services["natrule"], self.public_ip.ipaddress.id)
        return
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:60,代码来源:test_egress_fw_rules.py


示例6: test_01_native_to_native_network_migration

    def test_01_native_to_native_network_migration(self):
        """
        Verify Migration for an isolated network nativeOnly
        1. create native non-persistent isolated network
        2. migrate to other non-persistent isolated network
        3. migrate back to first native non-persistent network
        4. deploy VM in non-persistent isolated network
        5. migrate to native persistent isolated network
        6. migrate back to native non-persistent network
        """

        isolated_network = Network.create(
                self.apiclient,
                self.test_data["isolated_network"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=self.network_offering_all.id,
                zoneid=self.zone.id
        )

        self.migrate_network(
                self.network_offering_nouserdata,
                isolated_network, resume=False)

        self.migrate_network(
                self.network_offering_all,
                isolated_network, resume=False)

        deployVmResponse = VirtualMachine.create(
                self.apiclient,
                services=self.test_data["virtual_machine_userdata"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                serviceofferingid=self.service_offering.id,
                networkids=[str(isolated_network.id)],
                templateid=self.template.id,
                zoneid=self.zone.id
        )
        vms = list_virtual_machines(
                self.apiclient,
                account=self.account.name,
                domainid=self.account.domainid,
                id=deployVmResponse.id
        )
        self.assert_(len(vms) > 0, "There are no Vms deployed in the account"
                                   " %s" % self.account.name)
        vm = vms[0]
        self.assert_(vm.id == str(deployVmResponse.id),
                     "Vm deployed is different from the test")
        self.assert_(vm.state == "Running", "VM is not in Running state")

        self.migrate_network(
                self.network_offering_nouserdata,
                isolated_network, resume=False)

        self.migrate_network(
                self.network_offering_all,
                isolated_network, resume=False)
开发者ID:PCextreme,项目名称:cloudstack,代码行数:58,代码来源:test_migration.py


示例7: MigrateRootVolume

def MigrateRootVolume(self,
                      vm,
                      destinationHost,
                      expectexception=False):
    """ Migrate given volume to type of storage pool mentioned in migrateto:

        Inputs:
            1. vm:               VM to be migrated
                                 is to be migrated
            2. expectexception:  If exception is expected while migration
            3. destinationHost:  Destination host where the VM\
                                 should get migrated
    """

    if expectexception:
        with self.assertRaises(Exception):
            VirtualMachine.migrate(
                vm,
                self.apiclient,
                hostid=destinationHost.id,
            )
    else:
        VirtualMachine.migrate(
            vm,
            self.apiclient,
            hostid=destinationHost.id,
        )

        migrated_vm_response = list_virtual_machines(
            self.apiclient,
            id=vm.id
        )

        self.assertEqual(
            isinstance(migrated_vm_response, list),
            True,
            "Check list virtual machines response for valid list"
        )

        self.assertNotEqual(
            migrated_vm_response,
            None,
            "Check if virtual machine exists in ListVirtualMachines"
        )

        migrated_vm = migrated_vm_response[0]

        vm_list = VirtualMachine.list(
            self.apiclient,
            id=migrated_vm.id
        )

        self.assertEqual(
            vm_list[0].hostid,
            destinationHost.id,
            "Check volume is on migrated pool"
        )
    return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:58,代码来源:testpath_volume_cuncurrent_snapshots.py


示例8: verify_vm

def verify_vm(self, vmid):
        list_vm = list_virtual_machines(self.userapiclient,
                                        account=self.account.name,
                                        domainid=self.account.domainid,
                                        id=vmid
                                        )
        self.assertEqual(validateList(list_vm)[0], PASS, "Check List vm response for vmid: %s" % vmid)
        self.assertGreater(len(list_vm), 0, "Check the list vm response for vm id:  %s" % vmid)
        vm = list_vm[0]
        self.assertEqual(vm.id, str(vmid), "Vm deployed is different from the test")
        self.assertEqual(vm.state, "Running", "VM is not in Running state")
        self.debug("VM got created successfully %s" % vmid)
开发者ID:woduxi,项目名称:cloudstack,代码行数:12,代码来源:testpath_volumelifecycle.py


示例9: test_deployvm_multinic

    def test_deployvm_multinic(self):
        """Test userdata update when non default nic is without userdata for deploy and update
        """

        self.userdata = base64.b64encode(self.userdata)

        network1 = Network.create(
            self.apiclient,
            self.test_data["isolated_network"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            networkofferingid=self.network_offering_all.id,
            zoneid=self.zone.id,
        )

        self.test_data["network_without_acl"]["netmask"] = "255.255.255.128"

        network2 = Network.create(
            self.apiclient,
            self.test_data["network_without_acl"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            networkofferingid=self.network_offering_nouserdata.id,
            gateway="10.2.1.1",
            zoneid=self.zone.id,
        )

        deployVmResponse = VirtualMachine.create(
            self.apiclient,
            services=self.test_data["virtual_machine_userdata"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            networkids=[str(network1.id), str(network2.id)],
            templateid=self.template.id,
            zoneid=self.zone.id,
        )

        vms = list_virtual_machines(
            self.apiclient, account=self.account.name, domainid=self.account.domainid, id=deployVmResponse.id
        )
        self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name)
        vm = vms[0]
        self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test")
        self.assert_(vm.state == "Running", "VM is not in Running state")

        try:
            updateresponse = deployVmResponse.update(self.apiclient, userdata=self.userdata)
        except Exception as e:
            self.fail("Failed to update userdata: %s" % e)

        self.debug("virtual machine update response is: %s" % updateresponse)
开发者ID:bheuvel,项目名称:cloudstack,代码行数:52,代码来源:test_deploy_vm_userdata_multi_nic.py


示例10: create_vm

 def create_vm(self,
               account,
               domain,
               isRunning=False,
               project  =None,
               limit    =None,
               pfrule   =False,
               lbrule   =None,
               natrule  =None,
               volume   =None,
               snapshot =False):
     #TODO: Implemnt pfrule/lbrule/natrule
     self.debug("Deploying instance in the account: %s" % account.name)
     self.virtual_machine = VirtualMachine.create(self.apiclient,
                                                  self.services["virtual_machine"],
                                                  accountid=account.name,
                                                  domainid=domain.id,
                                                  serviceofferingid=self.service_offering.id,
                                                  mode=self.zone.networktype if pfrule else 'basic',
                                                  projectid=project.id if project else None)
     self.debug("Deployed instance in account: %s" % account.name)
     list_virtual_machines(self.apiclient,
                           id=self.virtual_machine.id)
     if snapshot:
        volumes = list_volumes(self.apiclient,
                               virtualmachineid=self.virtual_machine.id,
                               type='ROOT',
                               listall=True)
        self.snapshot = Snapshot.create(self.apiclient,
                                   volumes[0].id,
                                   account=account.name,
                                   domainid=account.domainid)
     if volume:
         self.virtual_machine.attach_volume(self.apiclient,
                                            volume)
     if not isRunning:
         self.virtual_machine.stop(self.apiclient)
     self.cleanup.append(self.virtual_machine)
开发者ID:PCextreme,项目名称:cloudstack,代码行数:38,代码来源:test_assign_vm.py


示例11: verify_nic

 def verify_nic(self, network, vm):
     """verify required nic is present in the VM"""
     self.debug(
         "Going to verify if %s Network nic is present in virtual machine "
         "%s" % (network.name, vm.id))
     vm_list = list_virtual_machines(self.api_client, id=vm.id)
     vm_list_validation_result = validateList(vm_list)
     self.assertEqual(vm_list_validation_result[0], PASS,
                      "vm list validation failed due to %s" %
                      vm_list_validation_result[2])
     self.debug("virtual machine nics: %s" % vm_list[0].nic)
     # filter nic of virtual machine based on Network
     nics = [x for x in vm_list[0].nic if x.networkid == network.id]
     self.debug("Filtered nics list: %s:" % nics)
     if len(nics) == 1:
         return True
     else:
         return False
开发者ID:Accelerite,项目名称:cloudstack,代码行数:18,代码来源:test_nuage_sharednetwork_vpc_vm_monitor.py


示例12: tearDown

    def tearDown(self):
        try:
            if self.egressruleid:
                self.debug('remove egress rule id=%s' % self.egressruleid)
                self.deleteEgressRule()

            self.debug("Cleaning up the resources")

            #below components is not a part of cleanup because to mandate the order and to cleanup network
            try:
                for vm in self.cleanup_vms:
                    if str(vm.state).lower() != "error":
                        vm.delete(self.api_client)
            except Exception as e:
                self.fail("Warning: Exception during virtual machines cleanup : %s" % e)

            # Wait for VMs to expunge
            wait_for_cleanup(self.api_client, ["expunge.delay", "expunge.interval"])

            if len(self.cleanup_vms) > 0:
                retriesCount = 10
                while True:
                    vms = list_virtual_machines(self.api_client, id=self.virtual_machine.id)
                    if vms is None:
                        break
                    elif retriesCount == 0:
                        self.fail("Failed to expunge vm even after 10 minutes")
                    time.sleep(60)
                    retriesCount -= 1

            try:
                for network in self.cleanup_networks:
                    network.delete(self.api_client)
            except Exception as e:
                self.fail("Warning: Exception during networks cleanup : %s" % e)

            self.debug("Sleep for Network cleanup to complete.")
            wait_for_cleanup(self.apiclient, ["network.gc.wait", "network.gc.interval"])

            cleanup_resources(self.apiclient, reversed(self.cleanup))
            self.debug("Cleanup complete!")
        except Exception as e:
            self.fail("Warning! Cleanup failed: %s" % e)
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:43,代码来源:test_egress_fw_rules.py


示例13: create_another_vm

    def create_another_vm(self):
        self.debug("Deploying instance in the account: %s and network: %s" % (self.account.name, self.network.id))

        project = None
        self.virtual_machine1 = VirtualMachine.create(self.apiclient,
                                                         self.services["virtual_machine"],
                                                         accountid=self.account.name,
                                                         domainid=self.domain.id,
                                                         serviceofferingid=self.service_offering.id,
                                                         mode=self.zone.networktype,
                                                         networkids=[str(self.network.id)],
                                                         projectid=project.id if project else None)
        self.debug("Deployed instance %s in account: %s" % (self.virtual_machine.id,self.account.name))

        # Checking if VM is running or not, in case it is deployed in error state, test case fails
        self.vm_list = list_virtual_machines(self.apiclient, id=self.virtual_machine.id)

        self.assertEqual(validateList(self.vm_list)[0], PASS, "vm list validation failed, vm list is %s" % self.vm_list)
        self.assertEqual(str(self.vm_list[0].state).lower(),'running',"VM state should be running, it is %s" % self.vm_list[0].state)
开发者ID:Accelerite,项目名称:cloudstack,代码行数:19,代码来源:test_egress_fw_rules.py


示例14: test_deploy_vm_l2network

    def test_deploy_vm_l2network(self):
        """Creates an l2 network and verifies user is able to deploy a VM in it"""

        # Validate the following:
        # 1. Deploys a VM
        # 2. There are no network services available since this is L2 Network

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=self.template.id,
            serviceofferingid=self.service_offering.id,
            networkids=self.l2_network.id,
            zoneid=self.zone.id
        )

        self.cleanup.insert(0, self.virtual_machine)

        list_vm = list_virtual_machines(
            self.apiclient,
            id = self.virtual_machine.id
        )
        self.assertEqual(
            isinstance(list_vm, list),
            True,
            "Check if virtual machine is present"
        )

        self.assertEqual(
            list_vm[0].nic[0].type,
            'L2',
            "Check Correct Network type is available"
        )

        self.assertFalse(
            'gateway' in str(list_vm[0].nic[0])
        )

        self.assertFalse(
            'ipaddress' in str(list_vm[0].nic[0])
        )

        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:43,代码来源:test_network.py


示例15: test_deployvm_userdata

 def test_deployvm_userdata(self):
     """Test userdata as GET, size > 2k
     """
     deployVmResponse = VirtualMachine.create(
         self.apiClient,
         services=self.services["virtual_machine"],
         accountid=self.account.name,
         domainid=self.account.domainid,
         serviceofferingid=self.service_offering.id,
         templateid=self.template.id,
         zoneid=self.zone.id
     )
     vms = list_virtual_machines(
         self.apiClient,
         account=self.account.name,
         domainid=self.account.domainid,
         id=deployVmResponse.id
     )
     self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name)
     vm = vms[0]
     self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test")
     self.assert_(vm.state == "Running", "VM is not in Running state")
开发者ID:K0zka,项目名称:cloudstack,代码行数:22,代码来源:test_deploy_vm_with_userdata.py


示例16: test_delete_network_while_vm_on_it

    def test_delete_network_while_vm_on_it(self):
        """It verifies the user is not able to delete network which has running vms"""

        # Validate the following:
        # 1. Deploys a VM
        # 2. Tries to delete network and expects exception to appear

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=self.template.id,
            serviceofferingid=self.service_offering.id,
            networkids=self.l2_network.id,
            zoneid=self.zone.id
        )

        self.cleanup.insert(0, self.virtual_machine)

        list_vm = list_virtual_machines(
            self.apiclient,
            id = self.virtual_machine.id
        )
        self.assertEqual(
            isinstance(list_vm, list),
            True,
            "Check if virtual machine is present"
        )

        try:
            self.l2_network.delete(self.apiclient)
        except Exception:
            pass
        else:
            self.fail("Expected an exception to be thrown, failing")

        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:36,代码来源:test_network.py


示例17: setUpClass

    def setUpClass(cls):
        cls.testClient = super(TestVMPasswordEnabled, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        domain = get_domain(cls.api_client)
        zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services['mode'] = zone.networktype
        template = get_template(
            cls.api_client,
            zone.id,
            cls.services["ostype"]
        )
        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = zone.id
        cls.services["small"]["template"] = template.id

        # Create VMs, NAT Rules etc
        cls.account = Account.create(
            cls.api_client,
            cls.services["account"],
            domainid=domain.id
        )

        cls.small_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offerings"]["small"]
        )

        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering.id,
            mode=cls.services["mode"]
        )

        networkid = cls.virtual_machine.nic[0].networkid
        cls.hypervisor = cls.testClient.getHypervisorInfo()

        # create egress rule to allow wget of my cloud-set-guest-password
        # script
        if zone.networktype.lower() == 'advanced':
            EgressFireWallRule.create(
                cls.api_client,
                networkid=networkid,
                protocol=cls.services["egress"]["protocol"],
                startport=cls.services["egress"]["startport"],
                endport=cls.services["egress"]["endport"],
                cidrlist=cls.services["egress"]["cidrlist"])

        cls.virtual_machine.password = cls.services["small"]["password"]
        ssh = cls.virtual_machine.get_ssh_client()

        # below steps are required to get the new password from VR
        # (reset password)
        # http://cloudstack.org/dl/cloud-set-guest-password
        # Copy this file to /etc/init.d
        # chmod +x /etc/init.d/cloud-set-guest-password
        # chkconfig --add cloud-set-guest-password

        cmds = [
            "cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password",
            "chmod +x /etc/init.d/cloud-set-guest-password",
            "chkconfig --add cloud-set-guest-password",
        ]
        for c in cmds:
            ssh.execute(c)

        # Adding delay of 120 sec to avoid data loss due to timing issue
        time.sleep(120)

        # Stop virtual machine
        cls.virtual_machine.stop(cls.api_client)

        # Poll listVM to ensure VM is stopped properly
        timeout = cls.services["timeout"]
        while True:
            time.sleep(cls.services["sleep"])

            # Ensure that VM is in stopped state
            list_vm_response = list_virtual_machines(
                cls.api_client,
                id=cls.virtual_machine.id
            )

            if isinstance(list_vm_response, list):

                vm = list_vm_response[0]
                if vm.state == 'Stopped':
                    break

            if timeout == 0:
                raise Exception(
                    "Failed to stop VM (ID: %s) " %
                    vm.id)

            timeout = timeout - 1
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:101,代码来源:test_vm_passwdenabled.py


示例18: test_l2network_restart

    def test_l2network_restart(self):
        """This test covers a few scenarios around restarting a network"""

        # Validate the following:
        # 1. Creates a l2 network
        # 2. Tries to restart a network with no VMs, which trows error 'not in the right state'
        # 3. Deploys a VM
        # 4. Restarts the network without cleanup
        # 5. Restarts the network with cleanup

        try:
            self.l2_network.restart(self.apiclient, cleanup=True)
        except Exception:
            pass
        else:
            self.fail("Expected an exception to be thrown, failing")

        li_net = self.l2_network.list(self.apiclient)[0]

        self.assertTrue(
            li_net.state,
            'Allocated'
            "Not the correct state"
        )

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=self.template.id,
            serviceofferingid=self.service_offering.id,
            networkids=self.l2_network.id,
            zoneid=self.zone.id
        )

        self.cleanup.insert(0, self.virtual_machine)

        list_vm = list_virtual_machines(
            self.apiclient,
            id = self.virtual_machine.id
        )
        self.assertEqual(
            isinstance(list_vm, list),
            True,
            "Check if virtual machine is present"
        )

        self.l2_network.restart(self.apiclient, cleanup=False)

        li_net = self.l2_network.list(self.apiclient)[0]

        self.assertTrue(
            li_net.state,
            'Implemented'
            "Not the correct state"
        )

        self.l2_network.restart(self.apiclient, cleanup=True)

        li_net = self.l2_network.list(self.apiclient)[0]

        self.assertTrue(
            li_net.state,
            'Implemented'
            "Not the correct state"
        )

        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:67,代码来源:test_network.py


示例19: test_01_createVM_snapshotTemplate


#.........这里部分代码省略.........
        self.debug("Snapshot created: ID - %s" % snapshot.id)
        self.cleanup.append(snapshot)

        snapshots = list_snapshots(
            userapiclient,
            id=snapshot.id
        )
        self.assertEqual(
            isinstance(snapshots, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            snapshots,
            None,
            "Check if result exists in list snapshots call"
        )
        self.assertEqual(
            snapshots[0].id,
            snapshot.id,
            "Check snapshot id in list resources call"
        )
        self.debug(
            "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" %
            snapshot.id)
        snapshot_uuid = snapshot.id

        # Generate template from the snapshot
        template = Template.create_from_snapshot(
            userapiclient,
            snapshot,
            self.services["templates"]
        )
        self.debug("Created template from snapshot: %s" % template.id)
        self.cleanup.append(template)

        templates = list_templates(
            userapiclient,
            templatefilter=self.services["templates"]["templatefilter"],
            id=template.id
        )

        self.assertNotEqual(
            templates,
            None,
            "Check if result exists in list item call"
        )

        self.assertEqual(
            templates[0].isready,
            True,
            "Check new template state in list templates call"
        )

        # Deploy new virtual machine using template
        new_virtual_machine = VirtualMachine.create(
            userapiclient,
            self.services["server"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id
        )
        self.debug("Created VM with ID: %s from template: %s" % (
            new_virtual_machine.id,
            template.id
        ))
        self.cleanup.append(new_virtual_machine)

        # Newly deployed VM should be 'Running'
        virtual_machines = list_virtual_machines(
            userapiclient,
            id=new_virtual_machine.id,
            account=self.account.name,
            domainid=self.account.domainid
        )
        self.assertEqual(
            isinstance(virtual_machines, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            len(virtual_machines),
            0,
            "Check list virtual machines response"
        )
        for virtual_machine in virtual_machines:
            self.assertEqual(
                virtual_machine.state,
                'Running',
                "Check list VM response for Running state"
            )
        self.assertTrue(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                snapshot_uuid))
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:101,代码来源:test_snapshots.py


示例20: test_DeployVmAntiAffinityGroup

    def test_DeployVmAntiAffinityGroup(self):
        """
        test DeployVM in anti-affinity groups

        deploy VM1 and VM2 in the same host-anti-affinity groups
        Verify that the vms are deployed on separate hosts
        """
        #deploy VM1 in affinity group created in setUp
        vm1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=self.template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            affinitygroupnames=[self.ag.name]
        )

        list_vm1 = list_virtual_machines(
            self.apiclient,
            id=vm1.id
        )
        self.assertEqual(
            isinstance(list_vm1, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            len(list_vm1),
            0,
            "Check VM available in List Virtual Machines"
        )
        vm1_response = list_vm1[0]
        self.assertEqual(
            vm1_response.state,
            'Running',
            msg="VM is not in Running state"
        )
        host_of_vm1 = vm1_response.hostid

        #deploy VM2 in affinity group created in setUp
        vm2 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=self.template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            affinitygroupnames=[self.ag.name]
        )
        list_vm2 = list_virtual_machines(
            self.apiclient,
            id=vm2.id
        )
        self.assertEqual(
            isinstance(list_vm2, list),
            True,
            "Check list response returns 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.list_volumes函数代码示例发布时间:2022-05-27
下一篇:
Python common.list_ssvms函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap