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


Python Distro.by_name方法代码示例

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


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

示例1: test_add_distro_tree

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
    def test_add_distro_tree(self):
        self.server.auth.login_password(self.lc.user.user_name, u'logmein')
        self.server.labcontrollers.add_distro_tree(self.distro_data)
        with session.begin():
            distro = Distro.by_name(u'RHEL-6-U1')
            self.assertEquals(distro.osversion.osmajor.osmajor, u'RedHatEnterpriseLinux6')
            self.assertEquals(distro.osversion.osminor, u'1')
            self.assertEquals(distro.osversion.arches,
                    [Arch.by_name(u'i386'), Arch.by_name(u'x86_64')])
            self.assertEquals(distro.date_created,
                    datetime.datetime(2011, 5, 10, 22, 53, 18))
            distro_tree = DistroTree.query.filter_by(distro=distro,
                    variant=u'Workstation', arch=Arch.by_name('x86_64')).one()
            self.assertEquals(distro_tree.date_created,
                    datetime.datetime(2011, 5, 10, 22, 53, 18))
            self.assertEquals(distro_tree.url_in_lab(self.lc, scheme='nfs'),
                    'nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/')
            self.assertEquals(distro_tree.repo_by_id('Workstation').path,
                    '')
            self.assertEquals(distro_tree.repo_by_id('ScalableFileSystem').path,
                    'ScalableFileSystem/')
            self.assertEquals(distro_tree.repo_by_id('optional').path,
                    '../../optional/x86_64/os/')
            self.assertEquals(distro_tree.repo_by_id('debuginfo').path,
                    '../debug/')
            self.assertEquals(distro_tree.image_by_type(ImageType.kernel,
                    KernelType.by_name(u'default')).path,
                    'images/pxeboot/vmlinuz')
            self.assertEquals(distro_tree.image_by_type(ImageType.initrd,
                    KernelType.by_name(u'default')).path,
                    'images/pxeboot/initrd.img')
            self.assertEquals(distro_tree.activity[0].field_name, u'lab_controller_assocs')
            self.assertEquals(distro_tree.activity[0].action, u'Added')
            self.assert_(self.lc.fqdn in distro_tree.activity[0].new_value,
                    distro_tree.activity[0].new_value)
            del distro, distro_tree

        # another lab controller adds the same distro tree
        self.server.auth.login_password(self.lc2.user.user_name, u'logmein')
        self.server.labcontrollers.add_distro_tree(self.distro_data)
        with session.begin():
            distro = Distro.by_name(u'RHEL-6-U1')
            distro_tree = DistroTree.query.filter_by(distro=distro,
                    variant=u'Workstation', arch=Arch.by_name('x86_64')).one()
            self.assertEquals(distro_tree.url_in_lab(self.lc2, scheme='nfs'),
                    'nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/')
            self.assertEquals(distro_tree.activity[0].field_name, u'lab_controller_assocs')
            self.assertEquals(distro_tree.activity[0].action, u'Added')
            self.assert_(self.lc2.fqdn in distro_tree.activity[0].new_value,
                    distro_tree.activity[0].new_value)
            del distro, distro_tree
开发者ID:sibiaoluo,项目名称:beaker,代码行数:53,代码来源:test_labcontrollers.py

示例2: test_add_distro_tree

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
    def test_add_distro_tree(self):
        self.server.auth.login_password(self.lc.user.user_name, u"logmein")
        self.server.labcontrollers.add_distro_tree(self.distro_data)
        with session.begin():
            distro = Distro.by_name(u"RHEL-6-U1")
            self.assertEquals(distro.osversion.osmajor.osmajor, u"RedHatEnterpriseLinux6")
            self.assertEquals(distro.osversion.osminor, u"1")
            self.assertEquals(distro.osversion.arches, [Arch.by_name(u"i386"), Arch.by_name(u"x86_64")])
            self.assertEquals(distro.date_created, datetime.datetime(2011, 5, 10, 22, 53, 18))
            distro_tree = DistroTree.query.filter_by(
                distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
            ).one()
            self.assertEquals(distro_tree.date_created, datetime.datetime(2011, 5, 10, 22, 53, 18))
            self.assertEquals(
                distro_tree.url_in_lab(self.lc, scheme="nfs"), "nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/"
            )
            self.assertEquals(distro_tree.repo_by_id("Workstation").path, "")
            self.assertEquals(distro_tree.repo_by_id("ScalableFileSystem").path, "ScalableFileSystem/")
            self.assertEquals(distro_tree.repo_by_id("optional").path, "../../optional/x86_64/os/")
            self.assertEquals(distro_tree.repo_by_id("debuginfo").path, "../debug/")
            self.assertEquals(
                distro_tree.image_by_type(ImageType.kernel, KernelType.by_name(u"default")).path,
                "images/pxeboot/vmlinuz",
            )
            self.assertEquals(
                distro_tree.image_by_type(ImageType.initrd, KernelType.by_name(u"default")).path,
                "images/pxeboot/initrd.img",
            )
            self.assertEquals(distro_tree.activity[0].field_name, u"lab_controller_assocs")
            self.assertEquals(distro_tree.activity[0].action, u"Added")
            self.assert_(self.lc.fqdn in distro_tree.activity[0].new_value, distro_tree.activity[0].new_value)
            del distro, distro_tree

        # another lab controller adds the same distro tree
        self.server.auth.login_password(self.lc2.user.user_name, u"logmein")
        self.server.labcontrollers.add_distro_tree(self.distro_data)
        with session.begin():
            distro = Distro.by_name(u"RHEL-6-U1")
            distro_tree = DistroTree.query.filter_by(
                distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
            ).one()
            self.assertEquals(
                distro_tree.url_in_lab(self.lc2, scheme="nfs"),
                "nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/",
            )
            self.assertEquals(distro_tree.activity[0].field_name, u"lab_controller_assocs")
            self.assertEquals(distro_tree.activity[0].action, u"Added")
            self.assert_(self.lc2.fqdn in distro_tree.activity[0].new_value, distro_tree.activity[0].new_value)
            del distro, distro_tree
开发者ID:ShaolongHu,项目名称:beaker,代码行数:51,代码来源:test_labcontrollers.py

示例3: test_change_url

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
    def test_change_url(self):
        self.server.auth.login_password(self.lc.user.user_name, u"logmein")
        self.server.labcontrollers.add_distro_tree(self.distro_data)

        # add it again, but with different urls
        new_distro_data = dict(self.distro_data)
        new_distro_data["urls"] = [
            # nfs:// is not included here, so it shouldn't change
            "nfs+iso://example.invalid:/RHEL-6-Workstation/U1/x86_64/iso/",
            "http://moved/",
        ]
        self.server.labcontrollers.add_distro_tree(new_distro_data)
        with session.begin():
            distro = Distro.by_name(u"RHEL-6-U1")
            distro_tree = DistroTree.query.filter_by(
                distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
            ).one()
            self.assertEquals(
                distro_tree.url_in_lab(self.lc, scheme="nfs"), "nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/"
            )
            self.assertEquals(
                distro_tree.url_in_lab(self.lc, scheme="nfs+iso"),
                "nfs+iso://example.invalid:/RHEL-6-Workstation/U1/x86_64/iso/",
            )
            self.assertEquals(distro_tree.url_in_lab(self.lc, scheme="http"), "http://moved/")
            del distro, distro_tree
开发者ID:ShaolongHu,项目名称:beaker,代码行数:28,代码来源:test_labcontrollers.py

示例4: setUp

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def setUp(self):
     self.browser = self.get_browser()
     with session.begin():
         self.user = data_setup.create_user(password=u'password')
         if not Distro.by_name(u'BlueShoeLinux5-5'):
             data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         data_setup.create_product(product_name=u'the_product')
开发者ID:ustbgaofan,项目名称:beaker,代码行数:9,代码来源:test_jobs.py

示例5: create_rhel62

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
def create_rhel62():
    try:
        return Distro.by_name(u'RHEL-6.2')
    except DatabaseLookupError:
        rhel62 = data_setup.create_distro(name=u'RHEL-6.2',
                osmajor=u'RedHatEnterpriseLinux6', osminor=u'2')
        return rhel62
开发者ID:beaker-project,项目名称:beaker,代码行数:9,代码来源:kickstart_helpers.py

示例6: setUp

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def setUp(self):
     with session.begin():
         if not Distro.by_name(u'BlueShoeLinux5-5'):
             data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         self.user = data_setup.create_user(password=u'password')
     self.server = self.get_server()
     self.server.auth.login_password(self.user.user_name, 'password')
开发者ID:sibiaoluo,项目名称:beaker,代码行数:9,代码来源:test_jobs_xmlrpc.py

示例7: create_distro_tree

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
def create_distro_tree(distro=None, distro_name=None, osmajor=u'DansAwesomeLinux6',
        distro_tags=None, arch=u'i386', variant=u'Server', lab_controllers=None,
        urls=None):
    if distro is None:
        if distro_name is None:
            distro = create_distro(osmajor=osmajor, tags=distro_tags)
        else:
            distro = Distro.by_name(distro_name)
            if not distro:
                distro = create_distro(name=distro_name)
    distro_tree = DistroTree.lazy_create(distro=distro,
            arch=Arch.by_name(arch), variant=variant)
    session.add(distro_tree)
    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''))
    existing_urls = [lc_distro_tree.url for lc_distro_tree in distro_tree.lab_controller_assocs]
    # make it available in all lab controllers
    for lc in (lab_controllers or LabController.query):
        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)
    log.debug('Created distro tree %r', distro_tree)
    return distro_tree
开发者ID:ustbgaofan,项目名称:beaker,代码行数:34,代码来源:data_setup.py

示例8: get_osmajor

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def get_osmajor(self, distro):
     """ pass in a distro name and get back the osmajor is belongs to.
     """
     try:
         osmajor = '%s' % Distro.by_name(distro).osversion.osmajor
     except DatabaseLookupError:
         raise BX(_('Invalid Distro: %s' % distro))
     return osmajor
开发者ID:ShaolongHu,项目名称:beaker,代码行数:10,代码来源:distro.py

示例9: setUp

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def setUp(self):
     session.begin()
     from bkr.server.jobs import Jobs
     self.controller = Jobs()
     self.user = data_setup.create_user()
     if not Distro.by_name(u'BlueShoeLinux5-5'):
         data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     session.flush()
开发者ID:ustbgaofan,项目名称:beaker,代码行数:10,代码来源:test_update_status.py

示例10: setUp

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def setUp(self):
     from bkr.server.jobs import Jobs
     self.controller = Jobs()
     self.user = data_setup.create_user()
     group = data_setup.create_group(group_name='somegroup')
     self.user.groups.append(group)
     testutil.set_identity_user(self.user)
     if not Distro.by_name(u'BlueShoeLinux5-5'):
         data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     data_setup.create_product(product_name=u'the_product')
开发者ID:ustbgaofan,项目名称:beaker,代码行数:12,代码来源:test_jobs.py

示例11: test_existing_distro_row_with_incorrect_osversion

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def test_existing_distro_row_with_incorrect_osversion(self):
     # We want to add 'RHEL6-bz825913' with osversion
     # 'RedHatEnterpriseLinux6.1'. But that distro already exists
     # with osversion 'RedHatEnterpriseLinux6.0'.
     name = "RHEL6-bz825913"
     with session.begin():
         data_setup.create_distro(name=name, osmajor=u"RedHatEnterpriseLinux6", osminor=u"0")
     distro_data = dict(self.distro_data)
     distro_data.update({"name": name, "osmajor": "RedHatEnterpriseLinux6", "osminor": "1"})
     self.server.auth.login_password(self.lc.user.user_name, u"logmein")
     self.server.labcontrollers.add_distro_tree(distro_data)
     with session.begin():
         distro = Distro.by_name(name)
         self.assertEquals(distro.osversion.osmajor.osmajor, u"RedHatEnterpriseLinux6")
         self.assertEquals(distro.osversion.osminor, u"1")
开发者ID:ShaolongHu,项目名称:beaker,代码行数:17,代码来源:test_labcontrollers.py

示例12: get_arch

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def get_arch(self, filter):
     """ pass in a dict() with either distro or osmajor to get possible arches
     """
     if 'distro' in filter:
         # look up distro
         try:
             arches = [arch.arch for arch in Distro.by_name(filter['distro']).osversion.arches]
         except DatabaseLookupError:
             raise BX(_('Invalid Distro: %s' % filter['distro']))
     elif 'osmajor' in filter:
         # look up osmajor
         try:
             arches = [arch.arch for arch in OSMajor.by_name(filter['osmajor']).osversions[0].arches]
         except InvalidRequestError:
             raise BX(_('Invalid OSMajor: %s' % filter['osmajor']))
     return arches
开发者ID:ShaolongHu,项目名称:beaker,代码行数:18,代码来源:distro.py

示例13: _get_distro_tree_options

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def _get_distro_tree_options(self, distro=None, system=None, **kwargs):
     """
     Returns a list of distro trees for the given distro.
     """
     if not distro:
         return []
     try:
         distro = Distro.by_name(distro)
     except DatabaseLookupError:
         return []
     trees = distro.dyn_trees.join(DistroTree.arch)\
             .filter(DistroTree.lab_controller_assocs.any())\
             .order_by(DistroTree.variant, Arch.arch)
     if system:
         try:
             system = System.by_fqdn(system, identity.current.user)
         except NoResultFound:
             return []
         trees = system.distro_trees(query=trees)
     return [(tree.id, unicode(tree)) for tree in trees]
开发者ID:ShaolongHu,项目名称:beaker,代码行数:22,代码来源:reserve_workflow.py

示例14: test_existing_distro_row_with_incorrect_osversion

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def test_existing_distro_row_with_incorrect_osversion(self):
     # We want to add 'RHEL6-bz825913' with osversion
     # 'RedHatEnterpriseLinux6.1'. But that distro already exists
     # with osversion 'RedHatEnterpriseLinux6.0'.
     name = 'RHEL6-bz825913'
     with session.begin():
         data_setup.create_distro(name=name,
                 osmajor=u'RedHatEnterpriseLinux6', osminor=u'0')
     distro_data = dict(self.distro_data)
     distro_data.update({
         'name': name,
         'osmajor': 'RedHatEnterpriseLinux6',
         'osminor': '1',
     })
     self.server.auth.login_password(self.lc.user.user_name, u'logmein')
     self.server.labcontrollers.add_distro_tree(distro_data)
     with session.begin():
         distro = Distro.by_name(name)
         self.assertEquals(distro.osversion.osmajor.osmajor,
                 u'RedHatEnterpriseLinux6')
         self.assertEquals(distro.osversion.osminor, u'1')
开发者ID:sibiaoluo,项目名称:beaker,代码行数:23,代码来源:test_labcontrollers.py

示例15: _get_distro_tree_options

# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_name [as 别名]
 def _get_distro_tree_options(self, distro=None, lab_controller_id=None, **kwargs):
     """
     Returns a list of distro trees for the given distro.
     """
     if not distro:
         return []
     try:
         distro = Distro.by_name(distro)
     except NoResultFound:
         return []
     trees = distro.dyn_trees.join(DistroTree.arch)\
             .order_by(DistroTree.variant, Arch.arch)
     if lab_controller_id:
         try:
             lc = LabController.by_id(lab_controller_id)
         except NoResultFound:
             return []
         trees = trees.filter(DistroTree.lab_controller_assocs.any(
                 LabControllerDistroTree.lab_controller == lc))
     else:
         trees = trees.filter(DistroTree.lab_controller_assocs.any())
     return [(tree.id, unicode(tree)) for tree in trees]
开发者ID:sibiaoluo,项目名称:beaker,代码行数:24,代码来源:reserve_workflow.py


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