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

Python utils.random_gen函数代码示例

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

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



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

示例1: createLogs

    def createLogs(self,
                   test_module_name=None,
                   log_cfg=None,
                   user_provided_logpath=None):
        '''
        @Name : createLogs
        @Desc : Gets the Logger with file paths initialized and created
        @Inputs :test_module_name: Test Module Name to use for logs while
                 creating log folder path
                 log_cfg: Log Configuration provided inside of
                 Configuration
                 user_provided_logpath:LogPath provided by user
                                       If user provided log path
                                       is available, then one in cfg
                                       will  not be picked up.
        @Output : SUCCESS\FAILED
        '''
        try:
            temp_ts = time.strftime("%b_%d_%Y_%H_%M_%S",
                                    time.localtime())
            if test_module_name is None:
                temp_path = temp_ts + "_" + random_gen()
            else:
                temp_path = str(test_module_name) + \
                    "__" + str(temp_ts) + "_" + random_gen()

            if user_provided_logpath:
                temp_dir = user_provided_logpath
            elif ((log_cfg is not None) and
                    ('LogFolderPath' in log_cfg.__dict__.keys()) and
                    (log_cfg.__dict__.get('LogFolderPath') is not None)):
                temp_dir = \
                    log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"

            self.__logFolderDir = temp_dir + "//" + temp_path
            print "\n==== Log Folder Path: %s. " \
                  "All logs will be available here ====" \
                  % str(self.__logFolderDir)
            os.makedirs(self.__logFolderDir)

            '''
            Log File Paths
            1. FailedExceptionLog
            2. RunLog contains the complete Run Information for Test Run
            3. ResultFile contains the TC result information for Test Run
            '''
            tc_failed_exception_log = \
                self.__logFolderDir + "/failed_plus_exceptions.txt"
            tc_run_log = self.__logFolderDir + "/runinfo.txt"
            if self.__setLogHandler(tc_run_log,
                                    log_level=logging.DEBUG) != FAILED:
                self.__setLogHandler(tc_failed_exception_log,
                                     log_level=logging.FATAL)
                return SUCCESS
            return FAILED
        except Exception as e:
            print "\n Exception Occurred Under createLogs :%s" % \
                  GetDetailExceptionInfo(e)
            return FAILED
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:59,代码来源:marvinLog.py


示例2: test_02_edit_iso

    def test_02_edit_iso(self):
        """Test Edit ISO
        """

        # Validate the following:
        # 1. UI should show the edited values for ISO
        # 2. database (vm_template table) should have updated values

        # Generate random values for updating ISO name and Display text
        new_displayText = random_gen()
        new_name = random_gen()

        self.debug("Updating ISO permissions for ISO: %s" % self.iso_1.id)

        cmd = updateIso.updateIsoCmd()
        # Assign new values to attributes
        cmd.id = self.iso_1.id
        cmd.displaytext = new_displayText
        cmd.name = new_name
        cmd.bootable = self.services["bootable"]
        cmd.passwordenabled = self.services["passwordenabled"]

        self.apiclient.updateIso(cmd)

        # Check whether attributes are updated in ISO using listIsos
        list_iso_response = list_isos(
            self.apiclient,
            id=self.iso_1.id
        )
        self.assertEqual(
            isinstance(list_iso_response, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            len(list_iso_response),
            0,
            "Check template available in List ISOs"
        )

        iso_response = list_iso_response[0]
        self.assertEqual(
            iso_response.displaytext,
            new_displayText,
            "Check display text of updated ISO"
        )
        self.assertEqual(
            iso_response.bootable,
            self.services["bootable"],
            "Check if image is bootable of updated ISO"
        )

        self.assertEqual(
            iso_response.ostypeid,
            self.services["ostypeid"],
            "Check OSTypeID of updated ISO"
        )
        return
开发者ID:K0zka,项目名称:cloudstack,代码行数:58,代码来源:test_iso.py


示例3: test_instance_name_with_hyphens

    def test_instance_name_with_hyphens(self):
        """ Test the instance  name with hyphens
        """

        # Validate the following
        # 1. Set the vm.instancename.flag to true.
        # 2. Add the virtual machine with display name with hyphens

        # Reading display name property
        if not is_config_suitable(
                apiclient=self.apiclient,
                name='vm.instancename.flag',
                value='true'):
            self.skipTest('vm.instancename.flag should be true. skipping')

        self.services["virtual_machine"]["displayname"] = random_gen(
            chars=string.ascii_uppercase) + "-" + random_gen(
            chars=string.ascii_uppercase)

        self.debug("Deploying an instance in account: %s" %
                   self.account.name)

        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )
        self.debug(
            "Checking if the virtual machine is created properly or not?")
        vms = VirtualMachine.list(
            self.apiclient,
            id=virtual_machine.id,
            listall=True
        )

        self.assertEqual(
            isinstance(vms, list),
            True,
            "List vms should retuen a valid name"
        )
        vm = vms[0]
        self.assertEqual(
            vm.state,
            "Running",
            "Vm state should be running after deployment"
        )
        self.debug("Display name: %s" % vm.displayname)
        return
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:50,代码来源:test_custom_hostname.py


示例4: test_02_edit_service_offering

    def test_02_edit_service_offering(self):
        """Test to update existing service offering"""

        # Validate the following:
        # 1. updateServiceOffering should return
        #    a valid information for newly created offering

        # Generate new name & displaytext from random data
        random_displaytext = random_gen()
        random_name = random_gen()

        self.debug("Updating service offering with ID: %s" %
                   self.service_offering_1.id)

        cmd = updateServiceOffering.updateServiceOfferingCmd()
        # Add parameters for API call
        cmd.id = self.service_offering_1.id
        cmd.displaytext = random_displaytext
        cmd.name = random_name
        self.apiclient.updateServiceOffering(cmd)

        list_service_response = list_service_offering(
            self.apiclient,
            id=self.service_offering_1.id
        )
        self.assertEqual(
            isinstance(list_service_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.assertNotEqual(
            len(list_service_response),
            0,
            "Check Service offering is updated"
        )

        self.assertEqual(
            list_service_response[0].displaytext,
            random_displaytext,
            "Check server displaytext in updateServiceOffering"
        )
        self.assertEqual(
            list_service_response[0].name,
            random_name,
            "Check server name in updateServiceOffering"
        )

        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:49,代码来源:test_service_offerings.py


示例5: createZone

 def createZone(self, zone, rec=0):
     try:
         zoneresponse = self.__apiClient.createZone(zone)
         if zoneresponse.id:
             self.__addToCleanUp("Zone", zoneresponse.id)
             self.__tcRunLogger.\
                 debug("Zone Name : %s Id : %s Created Successfully" %
                       (str(zone.name), str(zoneresponse.id)))
             return zoneresponse.id
         else:
             self.__tcRunLogger.\
                 exception("====Zone : %s Creation Failed=====" %
                           str(zone.name))
             print "\n====Zone : %s Creation Failed=====" % str(zone.name)
             if not rec:
                 zone.name = zone.name + "_" + random_gen()
                 self.__tcRunLogger.\
                     debug("====Recreating Zone With New Name : "
                           "%s" % zone.name)
                 print "\n====Recreating Zone With New Name ====", \
                     str(zone.name)
                 return self.createZone(zone, 1)
     except Exception as e:
         print "\nException Occurred under createZone : %s" % \
               GetDetailExceptionInfo(e)
         self.__tcRunLogger.exception("====Create Zone Failed ===")
         return FAILED
开发者ID:MountHuang,项目名称:cloudstack,代码行数:27,代码来源:deployDataCenter.py


示例6: test_05_unsupported_chars_in_display_name

    def test_05_unsupported_chars_in_display_name(self):
        """ Test Unsupported chars in the display name
            (eg: Spaces,Exclamation,yet to get unsupported chars from the dev)
        """

        # Validate the following
        # 1) Set the Global Setting vm.instancename.flag to true
        # 2) While creating VM give a Display name which has unsupported chars
        #    Gives an error message "Instance name can not be longer than 63
        #    characters. Only ASCII letters a~z, A~Z, digits 0~9, hyphen are
        #    allowed. Must start with a letter and end with a letter or digit

        self.debug("Creating VM with unsupported chars in display name")
        display_names = ["!hkzs566", "asdh asd", "!dsf d"]

        for display_name in display_names:
            self.debug("Display name: %s" % display_name)
            self.services["virtual_machine"]["displayname"] = display_name
            self.services["virtual_machine"]["name"] = random_gen(
                chars=string.ascii_uppercase)

            with self.assertRaises(Exception):
                # Spawn an instance in that network
                VirtualMachine.create(
                    self.apiclient,
                    self.services["virtual_machine"],
                    accountid=self.account.name,
                    domainid=self.account.domainid,
                    serviceofferingid=self.service_offering.id,
                )
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:31,代码来源:test_custom_hostname.py


示例7: setUp

    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()

        self.services["virtual_machine"]["name"] =\
            random_gen(chars=string.ascii_uppercase)
        self.cleanup = []
        return
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:8,代码来源:test_custom_hostname.py


示例8: setUpClass

    def setUpClass(cls):
        testClient = super(TestVmSnapshot, cls).getClsTestClient()

        hypervisor = testClient.getHypervisorInfo()
        if hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
            raise unittest.SkipTest(
                "VM snapshot feature is not supported on KVM, Hyper-V or LXC")

        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())

        template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"]
        )
        if template == FAILED:
            assert False, "get_template() failed to return template\
                    with description %s" % cls.services["ostype"]

        cls.services["domainid"] = cls.domain.id
        cls.services["server"]["zoneid"] = cls.zone.id
        cls.services["templates"]["ostypeid"] = template.ostypeid
        cls.services["zoneid"] = cls.zone.id

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

        cls.service_offering = ServiceOffering.create(
            cls.apiclient,
            cls.services["service_offerings"]
        )
        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["server"],
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.zone.networktype
        )
        cls.random_data_0 = random_gen(size=100)
        cls.test_dir = "/tmp"
        cls.random_data = "random.data"
        cls._cleanup = [
            cls.service_offering,
            cls.account,
        ]
        return
开发者ID:K0zka,项目名称:cloudstack,代码行数:56,代码来源:test_vm_snapshots.py


示例9: configure_Stickiness_Policy

 def configure_Stickiness_Policy(self, lb_rule, method, paramDict=None):
     """Configure the stickiness policy on lb rule"""
     try:
         result = lb_rule.createSticky(
             self.apiclient, methodname=method, name="-".join([method, random_gen()]), param=paramDict
         )
         self.debug("Response: %s" % result)
         return result
     except Exception as e:
         self.fail("Configure sticky policy failed with exception: %s" % e)
开发者ID:ktenzer,项目名称:cloudstack,代码行数:10,代码来源:test_haproxy.py


示例10: create_aff_grp

    def create_aff_grp(self, aff_grp=None,
                  acc=None, domainid=None):

        aff_grp["name"] = "aff_grp_" + random_gen(size=6)

        try:
            aff_grp = AffinityGroup.create(self.apiclient,
                                           aff_grp, acc, domainid)
            return aff_grp
        except Exception as e:
            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
开发者ID:Accelerite,项目名称:cloudstack,代码行数:11,代码来源:test_vmware_drs.py


示例11: finalize

 def finalize(self, result):
     try:
         if not self.__userLogPath:
             src = self.__logFolderPath
             log_cfg = self.__parsedConfig.logger
             tmp = log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
             dst = tmp + "//" + random_gen()
             mod_name = "test_suite"
             if self.__testModName:
                 mod_name = self.__testModName.split(".")
                 if len(mod_name) > 2:
                     mod_name = mod_name[-2]
             if mod_name:
                 dst = tmp + "/" + mod_name + "_" + random_gen()
             cmd = "mv " + src + " " + dst
             os.system(cmd)
             print "===final results are now copied to: %s===" % str(dst)
     except Exception, e:
         print "=== Exception occurred under finalize :%s ===" % \
               str(GetDetailExceptionInfo(e))
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:20,代码来源:marvinPlugin.py


示例12: create_aff_grp

    def create_aff_grp(self, api_client=None, aff_grp=None, aff_grp_name=None, projectid=None):

       if not api_client:
          api_client = self.api_client
       if aff_grp is None:
          aff_grp = self.services["host_anti_affinity"]
       if aff_grp_name is None:
          aff_grp["name"] = "aff_grp_" + random_gen(size=6)
       else:
          aff_grp["name"] = aff_grp_name
       if projectid is None:
          projectid = self.project.id
       try:
          return AffinityGroup.create(api_client, aff_grp, None, None, projectid)
       except Exception as e:
          raise Exception("Error: Creation of Affinity Group failed : %s" % e)
开发者ID:CIETstudents,项目名称:cloudstack,代码行数:16,代码来源:test_affinity_groups_projects.py


示例13: create_Volume_from_Snapshot

    def create_Volume_from_Snapshot(self, snapshot):
        try:
            self.debug("Creating volume from snapshot: %s" % snapshot.name)

            cmd = createVolume.createVolumeCmd()
            cmd.name = "-".join([
                                self.services["volume"]["diskname"],
                                random_gen()])
            cmd.snapshotid = snapshot.id
            cmd.zoneid = self.zone.id
            cmd.size = self.services["volume"]["size"]
            cmd.account = self.account.name
            cmd.domainid = self.account.domainid
            return cmd
        except Exception as e:
            self.fail("Failed to create volume from snapshot: %s - %s" %
                                                        (snapshot.name, e))
开发者ID:K0zka,项目名称:cloudstack,代码行数:17,代码来源:test_snapshots_improvement.py


示例14: test_vm_instance_name_duplicate_different_accounts

    def test_vm_instance_name_duplicate_different_accounts(self):
        """
        @Desc: Test whether cloudstack allows duplicate vm instance
               names in the diff networks
        @Steps:
        Step1: Set the vm.instancename.flag to true.
        Step2: Deploy a VM with name say webserver01 from account1
               Internal name should be i-<userid>-<vmid>-webserver01
        Step3: Now deploy VM with the same name "webserver01" from account2.
        Step4: Deployment of VM with same name should fail
        """

        if not is_config_suitable(
                apiclient=self.apiclient,
                name='vm.instancename.flag',
                value='true'):
            self.skipTest('vm.instancename.flag should be true. skipping')
        # Step2: Deploy a VM with name say webserver01 from account1
        self.debug("Deploying VM in account: %s" % self.account.name)
        self.services["virtual_machine2"][
            "displayname"] = random_gen(chars=string.ascii_uppercase)
        self.services["virtual_machine2"]["zoneid"] = self.zone.id
        self.services["virtual_machine2"]["template"] = self.template.id
        vm1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine2"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
        )
        self.cleanup.append(vm1)

        # Step3: Now deploy VM with the same name "webserver01" from account2.
        self.debug("Deploying VM in account: %s" % self.account_2.name)
        with self.assertRaises(Exception):
            vm2 = VirtualMachine.create(
                self.apiclient,
                self.services["virtual_machine2"],
                accountid=self.account_2.name,
                domainid=self.account_2.domainid,
                serviceofferingid=self.service_offering.id,
            )
            self.cleanup.append(vm2)
        # Step4: Deployment of VM with same name should fail
        return
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:45,代码来源:test_custom_hostname.py


示例15: deploy_domain

    def deploy_domain(self, domain_data):
        if domain_data['name'] == 'ROOT':
            domain_list = Domain.list(
                api_client=self.api_client,
                name=domain_data['name']
            )
            domain = domain_list[0]
        else:
            self.logger.debug('>>>  DOMAIN  =>  Creating "%s"...', domain_data['name'])
            domain = Domain.create(
                api_client=self.api_client,
                name=domain_data['name'] + ('-' + random_gen() if self.randomizeNames else '')
            )

        self.logger.debug('>>>  DOMAIN  =>  ID: %s  =>  Name: %s  =>  Path: %s  =>  State: %s', domain.id, domain.name,
                          domain.path, domain.state)

        self.deploy_accounts(domain_data['accounts'], domain)
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:testScenarioManager.py


示例16: create_from_snapshot

 def create_from_snapshot(cls, apiclient, snapshot_id, services,
                          account=None, domainid=None):
         """Create volume from snapshot"""
         cmd = createVolume.createVolumeCmd()
         cmd.isAsync = "false"
         cmd.name = "-".join([services["diskname"], random_gen()])
         cmd.snapshotid = snapshot_id
         cmd.zoneid = services["zoneid"]
         if "size" in services:
             cmd.size = services["size"]
         if services["ispublic"]:
             cmd.ispublic = services["ispublic"]
         else:
             cmd.ispublic = False
         if account:
             cmd.account = account
         else:
             cmd.account = services["account"]
         if domainid:
             cmd.domainid = domainid
         else:
             cmd.domainid = services["domainid"]
         return Volume(apiclient.createVolume(cmd).__dict__)
开发者ID:Accelerite,项目名称:cloudstack,代码行数:23,代码来源:test_concurrent_create_volume_from_snapshot.py


示例17: create_Template_from_Snapshot

    def create_Template_from_Snapshot(self, snapshot):
        try:
            self.debug("Creating template from snapshot: %s" % snapshot.name)

            cmd = createTemplate.createTemplateCmd()
            cmd.displaytext = self.services["template"]["displaytext"]
            cmd.name = "-".join([self.services["template"]["name"],
                                 random_gen()])

            ncmd = listOsTypes.listOsTypesCmd()
            ncmd.description = self.services["template"]["ostype"]
            ostypes = self.apiclient.listOsTypes(ncmd)

            if not isinstance(ostypes, list):
                raise Exception(
                    "Unable to find Ostype id with desc: %s" %
                                        self.services["template"]["ostype"])
            cmd.ostypeid = ostypes[0].id
            cmd.snapshotid = snapshot.id

            return cmd
        except Exception as e:
            self.fail("Failed to create template from snapshot: %s - %s" %
                                                        (snapshot.name, e))
开发者ID:K0zka,项目名称:cloudstack,代码行数:24,代码来源:test_snapshots_improvement.py


示例18: test_01_clusters

    def test_01_clusters(self):
        """Test Add clusters & hosts


        # Validate the following:
        # 1. Verify hypervisortype returned by API is Xen/KVM/VWare
        # 2. Verify that the cluster is in 'Enabled' allocation state
        # 3. Verify that the host is added successfully and in Up state
        #    with listHosts API response

        #Create clusters with Hypervisor type XEN/KVM/VWare
        """
        for k, v in self.services["clusters"].items():
            v["clustername"] = v["clustername"] + "-" + random_gen()
            cluster = Cluster.create(
                self.apiclient,
                v,
                zoneid=self.zone.id,
                podid=self.pod.id,
                hypervisor=v["hypervisor"].lower()
            )
            self.debug(
                "Created Cluster for hypervisor type %s & ID: %s" % (
                    v["hypervisor"],
                    cluster.id
                ))
            self.assertEqual(
                cluster.hypervisortype.lower(),
                v["hypervisor"].lower(),
                "Check hypervisor type is " + v["hypervisor"] + " or not"
            )
            self.assertEqual(
                cluster.allocationstate,
                'Enabled',
                "Check whether allocation state of cluster is enabled"
            )

            # If host is externally managed host is already added with cluster
            response = list_hosts(
                self.apiclient,
                clusterid=cluster.id
            )

            if not response:
                hypervisor_type = str(cluster.hypervisortype.lower())
                host = Host.create(
                    self.apiclient,
                    cluster,
                    self.services["hosts"][hypervisor_type],
                    zoneid=self.zone.id,
                    podid=self.pod.id,
                    hypervisor=v["hypervisor"].lower()
                )
                if host == FAILED:
                    self.fail("Host Creation Failed")
                self.debug(
                    "Created host (ID: %s) in cluster ID %s" % (
                        host.id,
                        cluster.id
                    ))
                # Cleanup Host & Cluster
                self.cleanup.append(host)
            self.cleanup.append(cluster)

            list_hosts_response = list_hosts(
                self.apiclient,
                clusterid=cluster.id
            )
            self.assertEqual(
                isinstance(list_hosts_response, list),
                True,
                "Check list response returns a valid list"
            )
            self.assertNotEqual(
                len(list_hosts_response),
                0,
                "Check list Hosts response"
            )

            host_response = list_hosts_response[0]
            # Check if host is Up and running
            self.assertEqual(
                host_response.state,
                'Up',
                "Check if state of host is Up or not"
            )
            # Verify List Cluster Response has newly added cluster
            list_cluster_response = list_clusters(
                self.apiclient,
                id=cluster.id
            )
            self.assertEqual(
                isinstance(list_cluster_response, list),
                True,
                "Check list response returns a valid list"
            )
            self.assertNotEqual(
                len(list_cluster_response),
                0,
                "Check list Hosts response"
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:101,代码来源:test_hosts.py


示例19: test_07_template_from_snapshot

    def test_07_template_from_snapshot(self):
        """Create Template from snapshot
        """

        # 1. Login to machine; create temp/test directories on data volume
        # 2. Snapshot the Volume
        # 3. Create Template from snapshot
        # 4. Deploy Virtual machine using this template
        # 5. Login to newly created virtual machine
        # 6. Compare data in the root disk with the one that was written on the
        # volume, it should match

        if self.hypervisor.lower() in ['hyperv']:
            self.skipTest("Snapshots feature is not supported on Hyper-V")

        userapiclient = self.testClient.getUserApiClient(
            UserName=self.account.name,
            DomainName=self.account.domain)

        random_data_0 = random_gen(size=100)
        random_data_1 = random_gen(size=100)

        try:
            # Login to virtual machine
            ssh_client = self.virtual_machine.get_ssh_client()

            cmds = [
                "mkdir -p %s" % self.services["paths"]["mount_dir"],
                "mount %s1 %s" % (
                    self.services["volume"][self.hypervisor]["rootdiskdevice"],
                    self.services["paths"]["mount_dir"]
                ),
                "mkdir -p %s/%s/{%s,%s} " % (
                    self.services["paths"]["mount_dir"],
                    self.services["paths"]["sub_dir"],
                    self.services["paths"]["sub_lvl_dir1"],
                    self.services["paths"]["sub_lvl_dir2"]
                ),
                "echo %s > %s/%s/%s/%s" % (
                    random_data_0,
                    self.services["paths"]["mount_dir"],
                    self.services["paths"]["sub_dir"],
                    self.services["paths"]["sub_lvl_dir1"],
                    self.services["paths"]["random_data"]
                ),
                "echo %s > %s/%s/%s/%s" % (
                    random_data_1,
                    self.services["paths"]["mount_dir"],
                    self.services["paths"]["sub_dir"],
                    self.services["paths"]["sub_lvl_dir2"],
                    self.services["paths"]["random_data"]
                ),
                "sync",
            ]

            for c in cmds:
                self.debug(c)
                result = ssh_client.execute(c)
                self.debug(result)

        except Exception as e:
            self.fail("SSH failed for VM with IP address: %s" %
                      self.virtual_machine.ipaddress)

        # Unmount the Volume
        cmds = [
            "umount %s" % (self.services["paths"]["mount_dir"]),
        ]
        for c in cmds:
            self.debug(c)
            ssh_client.execute(c)

        volumes = list_volumes(
            userapiclient,
            virtualmachineid=self.virtual_machine.id,
            type='ROOT',
            listall=True
        )
        self.assertEqual(
            isinstance(volumes, list),
            True,
            "Check list response returns a valid list"
        )

        volume = volumes[0]

        # Create a snapshot of volume
        snapshot = Snapshot.create(
            userapiclient,
            volume.id,
            account=self.account.name,
            domainid=self.account.domainid
        )

        self.debug("Snapshot created from volume ID: %s" % volume.id)
        # Generate template from the snapshot
        template = Template.create_from_snapshot(
            userapiclient,
            snapshot,
            self.services["templates"]
#.........这里部分代码省略.........
开发者ID:vaddanak,项目名称:challenges,代码行数:101,代码来源:test_snapshots.py


示例20: setUp

 def setUp(self):
     self.apiClient = self.testClient.getApiClient()
     self.userApiClient = self.testClient.getUserApiClient(account='test'+utils.random_gen(), 'ROOT')
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:3,代码来源:testCreateAccount.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.validateList函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_process_status函数代码示例发布时间: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