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


Python Distro.lazy_create方法代码示例

本文整理汇总了Python中bkr.server.model.Distro.lazy_create方法的典型用法代码示例。如果您正苦于以下问题:Python Distro.lazy_create方法的具体用法?Python Distro.lazy_create怎么用?Python Distro.lazy_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bkr.server.model.Distro的用法示例。


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

示例1: test_concurrent_same_tree

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
 def test_concurrent_same_tree(self):
     distro_data = dict(self.distro_data)
     # ensure osmajor, osversion, and distro already exist
     with session.begin():
         osmajor = OSMajor.lazy_create(osmajor=distro_data["osmajor"])
         osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=distro_data["osminor"])
         osversion.arches = [Arch.lazy_create(arch=arch) for arch in distro_data["arches"]]
         Distro.lazy_create(name=distro_data["name"], osversion=osversion)
     self.add_distro_trees_concurrently(distro_data, distro_data)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:11,代码来源:test_labcontrollers.py

示例2: test_concurrent_different_trees

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
 def test_concurrent_different_trees(self):
     distro_data = dict(self.distro_data)
     # ensure osmajor, osversion, and distro already exist
     with session.begin():
         osmajor = OSMajor.lazy_create(osmajor=distro_data["osmajor"])
         osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=distro_data["osminor"])
         osversion.arches = [Arch.lazy_create(arch=arch) for arch in distro_data["arches"]]
         Distro.lazy_create(name=distro_data["name"], osversion=osversion)
     # ensure two different trees
     distro_data["variant"] = u"Workstation"
     distro_data2 = dict(distro_data)
     distro_data2["variant"] = u"Server"
     self.add_distro_trees_concurrently(distro_data, distro_data2)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:15,代码来源:test_labcontrollers.py

示例3: test_concurrent_different_trees

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
 def test_concurrent_different_trees(self):
     distro_data = dict(self.distro_data)
     # ensure osmajor, osversion, and distro already exist
     with session.begin():
         osmajor = OSMajor.lazy_create(osmajor=distro_data['osmajor'])
         osversion = OSVersion.lazy_create(osmajor=osmajor,
                 osminor=distro_data['osminor'])
         osversion.arches = [Arch.lazy_create(arch=arch)
                 for arch in distro_data['arches']]
         Distro.lazy_create(name=distro_data['name'], osversion=osversion)
     # ensure two different trees
     distro_data['variant'] = u'Workstation'
     distro_data2 = dict(distro_data)
     distro_data2['variant'] = u'Server'
     self.add_distro_trees_concurrently(distro_data, distro_data2)
开发者ID:sujithshankar,项目名称:beaker,代码行数:17,代码来源:test_labcontrollers.py

示例4: create_distro

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
def create_distro(name=None, osmajor=u'DansAwesomeLinux6', osminor=u'9',
                  arches=None, tags=None, harness_dir=True, osmajor_installopts=None):
    osmajor = OSMajor.lazy_create(osmajor=osmajor)
    osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=osminor)
    if arches:
        osversion.arches = arches
    if not name:
        name = unique_name(u'%s.%s-%%s' % (osmajor, osminor))
    distro = Distro.lazy_create(name=name, osversion=osversion)
    for tag in (tags or []):
        distro.add_tag(tag)
    # add distro wide install options, if any
    if osmajor_installopts:
        for arch in arches:
            io = OSMajorInstallOptions.lazy_create(osmajor_id=osmajor.id,
                                                   arch_id=Arch.by_name(arch).id)
            io.ks_meta = osmajor_installopts.get('ks_meta', '')
            io.kernel_options = osmajor_installopts.get('kernel_options', '')
            io.kernel_options_post = osmajor_installopts.get('kernel_options_post', '')

    log.debug('Created distro %r', distro)
    if harness_dir:
        harness_dir = os.path.join(turbogears.config.get('basepath.harness'), distro.osversion.osmajor.osmajor)
        if not os.path.exists(harness_dir):
            os.makedirs(harness_dir)
    return distro
开发者ID:omps,项目名称:beaker,代码行数:28,代码来源:data_setup.py

示例5: create_distro

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
def create_distro(name=None, osmajor=u'DansAwesomeLinux6', osminor=u'9',
        arches=None, tags=None):
    osmajor = OSMajor.lazy_create(osmajor=osmajor)
    osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=osminor)
    if arches:
        osversion.arches = arches
    if not name:
        name = unique_name(u'%s.%s-%%s' % (osmajor, osminor))
    distro = Distro.lazy_create(name=name, osversion=osversion)
    for tag in (tags or []):
        distro.add_tag(tag)
    log.debug('Created distro %r', distro)
    harness_dir = os.path.join(turbogears.config.get('basepath.harness'), distro.osversion.osmajor.osmajor)
    if not os.path.exists(harness_dir):
        os.makedirs(harness_dir)
    return distro
开发者ID:sujithshankar,项目名称:beaker,代码行数:18,代码来源:data_setup.py

示例6: add_distro_tree

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import lazy_create [as 别名]
    def add_distro_tree(self, new_distro):
        lab_controller = identity.current.user.lab_controller

        # osmajor is required
        if 'osmajor' in new_distro:
            osmajor = OSMajor.lazy_create(osmajor=new_distro['osmajor'])
        else:
            return ''

        if 'osminor' in new_distro:
            osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=new_distro['osminor'])
        else:
            return ''

        if 'arches' in new_distro:
            for arch_name in new_distro['arches']:
                try:
                   arch = Arch.by_name(arch_name)
                   if arch not in osversion.arches:
                       osversion.arches.append(arch)
                except NoResultFound:
                   pass

        distro = Distro.lazy_create(name=new_distro['name'], osversion=osversion)
        arch = Arch.lazy_create(arch=new_distro['arch'])
        variant = new_distro.get('variant')
        distro_tree = DistroTree.lazy_create(distro=distro,
                variant=variant, arch=arch)

        # Automatically tag the distro if tags exists
        if 'tags' in new_distro:
            for tag in new_distro['tags']:
                if tag not in distro.tags:
                    distro.tags.append(tag)

        if arch not in distro.osversion.arches:
            distro.osversion.arches.append(arch)
        distro_tree.date_created = datetime.utcfromtimestamp(float(new_distro['tree_build_time']))
        distro.date_created = datetime.utcfromtimestamp(float(new_distro['tree_build_time']))

        if 'repos' in new_distro:
            for repo in new_distro['repos']:
                dtr = distro_tree.repo_by_id(repo['repoid'])
                if dtr is None:
                    dtr = DistroTreeRepo(repo_id=repo['repoid'])
                    distro_tree.repos.append(dtr)
                dtr.repo_type = repo['type']
                dtr.path = repo['path']

        if 'kernel_options' in new_distro:
            distro_tree.kernel_options = new_distro['kernel_options']

        if 'kernel_options_post' in new_distro:
            distro_tree.kernel_options_post = new_distro['kernel_options_post']

        if 'ks_meta' in new_distro:
            distro_tree.ks_meta = new_distro['ks_meta']

        if 'images' in new_distro:
            for image in new_distro['images']:
                try:
                    image_type = ImageType.from_string(image['type'])
                except ValueError:
                    continue # ignore
                if 'kernel_type' not in image:
                    image['kernel_type'] = 'default'
                try:
                    kernel_type = KernelType.by_name(image['kernel_type'])
                except NoResultFound:
                    continue # ignore
                dti = distro_tree.image_by_type(image_type, kernel_type)
                if dti is None:
                    dti = DistroTreeImage(image_type=image_type,
                                          kernel_type=kernel_type)
                    distro_tree.images.append(dti)
                dti.path = image['path']

        new_urls_by_scheme = dict((urlparse.urlparse(url).scheme, url)
                for url in new_distro['urls'])
        if None in new_urls_by_scheme:
            raise ValueError('URL %r is not absolute' % new_urls_by_scheme[None])
        for lca in distro_tree.lab_controller_assocs:
            if lca.lab_controller == lab_controller:
                scheme = urlparse.urlparse(lca.url).scheme
                new_url = new_urls_by_scheme.pop(scheme, None)
                if new_url != None and lca.url != new_url:
                    distro_tree.activity.append(DistroTreeActivity(
                            user=identity.current.user, service=u'XMLRPC',
                            action=u'Changed', field_name=u'lab_controller_assocs',
                            old_value=u'%s %s' % (lca.lab_controller, lca.url),
                            new_value=u'%s %s' % (lca.lab_controller, new_url)))
                    lca.url = new_url
        for url in new_urls_by_scheme.values():
            distro_tree.lab_controller_assocs.append(LabControllerDistroTree(
                    lab_controller=lab_controller, url=url))
            distro_tree.activity.append(DistroTreeActivity(
                    user=identity.current.user, service=u'XMLRPC',
                    action=u'Added', field_name=u'lab_controller_assocs',
                    old_value=None, new_value=u'%s %s' % (lab_controller, url)))

#.........这里部分代码省略.........
开发者ID:sibiaoluo,项目名称:beaker,代码行数:103,代码来源:labcontroller.py


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