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


Python Arch.lazy_create方法代码示例

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


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

示例1: test_concurrent_same_tree

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch 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_new_distro

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch import lazy_create [as 别名]
 def test_concurrent_new_distro(self):
     distro_data = dict(self.distro_data)
     # ensure osmajor and osversion 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"]]
     # ... but distro is new
     distro_data["name"] = "concurrent-new-distro"
     self.add_distro_trees_concurrently(distro_data, distro_data)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:12,代码来源:test_labcontrollers.py

示例3: test_concurrent_different_trees

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch 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

示例4: test_concurrent_different_trees

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch 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

示例5: create_distro_tree

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch import lazy_create [as 别名]
def create_distro_tree(distro=None, distro_name=None, osmajor=u'DansAwesomeLinux6',
        osminor=u'9', distro_tags=None, arch=u'i386', variant=u'Server',
        lab_controllers=None, urls=None,  harness_dir=True, osmajor_installopts_arch=None):
    if distro is None:
        distro = create_distro(name=distro_name, osmajor=osmajor, osminor=osminor,
                tags=distro_tags, harness_dir=harness_dir)
    distro_tree = DistroTree.lazy_create(distro=distro,
            arch=Arch.lazy_create(arch=arch), variant=variant)
    if distro_tree.arch not in distro.osversion.arches:
        distro.osversion.arches.append(distro_tree.arch)
    DistroTreeRepo.lazy_create(distro_tree=distro_tree,
            repo_id=variant, repo_type=u'variant', path=u'')
    DistroTreeImage.lazy_create(distro_tree=distro_tree,
            image_type=ImageType.kernel,
            kernel_type=KernelType.by_name(u'default'),
            path=u'pxeboot/vmlinuz')
    DistroTreeImage.lazy_create(distro_tree=distro_tree,
            image_type=ImageType.initrd,
            kernel_type=KernelType.by_name(u'default'),
            path=u'pxeboot/initrd')
    existing_urls = [lc_distro_tree.url for lc_distro_tree in distro_tree.lab_controller_assocs]
    # make it available in all lab controllers by default
    if lab_controllers is None:
        lab_controllers = LabController.query
    for lc in lab_controllers:
        default_urls = [u'%s://%s%s/distros/%s/%s/%s/os/' % (scheme, lc.fqdn,
                scheme == 'nfs' and ':' or '',
                distro_tree.distro.name, distro_tree.variant,
                distro_tree.arch.arch) for scheme in ['nfs', 'http', 'ftp']]
        for url in (urls or default_urls):
            if url in existing_urls:
                break
            lab_controller_distro_tree = LabControllerDistroTree(
                lab_controller=lc, url=url)
            distro_tree.lab_controller_assocs.append(lab_controller_distro_tree)

    if osmajor_installopts_arch:
        io = OSMajorInstallOptions.lazy_create(osmajor_id=distro_tree.distro.osversion.osmajor.id,
                                               arch_id=distro_tree.arch.id)
        io.ks_meta = osmajor_installopts_arch.get('ks_meta', '')
        io.kernel_options = osmajor_installopts_arch.get('kernel_options', '')
        io.kernel_options_post = osmajor_installopts_arch.get('kernel_options_post', '')

    log.debug('Created distro tree %r', distro_tree)
    return distro_tree
开发者ID:omps,项目名称:beaker,代码行数:47,代码来源:data_setup.py

示例6: create_distro_tree

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch import lazy_create [as 别名]
def create_distro_tree(distro=None, distro_name=None, osmajor=u'DansAwesomeLinux6',
        osminor=u'9', distro_tags=None, arch=u'i386', variant=u'Server',
        lab_controllers=None, urls=None,  harness_dir=True,
        osmajor_installopts_arch=None, date_created=None, **kwargs):
    if distro is None:
        distro = create_distro(name=distro_name, osmajor=osmajor, osminor=osminor,
                tags=distro_tags, harness_dir=harness_dir, date_created=date_created)
    distro_tree = DistroTree(distro=distro, arch=Arch.lazy_create(arch=arch), variant=variant)
    if date_created is not None:
        distro_tree.date_created = date_created
    if distro_tree.arch not in distro.osversion.arches:
        distro.osversion.arches.append(distro_tree.arch)
    distro_tree.repos.append(DistroTreeRepo(repo_id=variant, repo_type=u'variant', path=u''))
    distro_tree.images.append(DistroTreeImage(
            image_type=ImageType.kernel,
            kernel_type=KernelType.by_name(u'default'),
            path=u'pxeboot/vmlinuz'))
    distro_tree.images.append(DistroTreeImage(
            image_type=ImageType.initrd,
            kernel_type=KernelType.by_name(u'default'),
            path=u'pxeboot/initrd'))
    session.flush() # to get an id
    # make it available in all lab controllers by default
    if lab_controllers is None:
        lab_controllers = LabController.query
    for lc in lab_controllers:
        add_distro_tree_to_lab(distro_tree, lc, urls=urls)

    if osmajor_installopts_arch:
        io = OSMajorInstallOptions.lazy_create(osmajor_id=distro_tree.distro.osversion.osmajor.id,
                                               arch_id=distro_tree.arch.id)
        io.ks_meta = osmajor_installopts_arch.get('ks_meta', '')
        io.kernel_options = osmajor_installopts_arch.get('kernel_options', '')
        io.kernel_options_post = osmajor_installopts_arch.get('kernel_options_post', '')

    log.debug('Created distro tree %r', distro_tree)
    return distro_tree
开发者ID:beaker-project,项目名称:beaker,代码行数:39,代码来源:data_setup.py

示例7: add_distro_tree

# 需要导入模块: from bkr.server.model import Arch [as 别名]
# 或者: from bkr.server.model.Arch 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.Arch.lazy_create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。