示例#1
0
    def test_distro_overrides_recipe(self):
        with session.begin():
            lc = data_setup.create_labcontroller()
            system1 = data_setup.create_system(lab_controller=lc,
                                               arch=u'x86_64')
            i386_distro = self._create_i386_distro(lc)
            osmajor = i386_distro.osversion.osmajor
            io = OSMajorInstallOptions.lazy_create(
                osmajor_id=osmajor.id, arch_id=Arch.by_name('i386').id)
            io.ks_meta = 'lang=en_UK.UTF-8'
            session.expire(osmajor, ['install_options_by_arch'])
        recipe = self._create_recipe(system1)
        distro_tree_id = i386_distro.trees[0].id
        kickstart = self._run_create_kickstart([
            '--recipe-id',
            str(recipe.id),
            '--distro-tree-id',
            str(distro_tree_id),
        ])

        # Make sure we are using the tree from --distro-tree-id
        self.assertIn(
            'url=http://lab.test-kickstart.example.com/distros/'
            'RHEL-6.3/Workstation/i386/os/', kickstart)
        self.assertNotIn(
            'url=http://lab.test-kickstart.invalid/distros/'
            'RHEL-6.2/Server/x86_64/os/', kickstart)
        self.assertIn('lang en_UK.UTF-8', kickstart)
        self.assertNotIn('lang en_US.UTF-8', kickstart)
示例#2
0
文件: data_setup.py 项目: omps/beaker
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
示例#3
0
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
示例#4
0
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.lazy_create(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)
    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')
    # 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
示例#5
0
 def save_osmajor_installopts(self, osmajor_id=None, installopts=None):
     try:
         osmajor = OSMajor.by_id(osmajor_id)
     except InvalidRequestError:
         flash(_(u"Invalid OSMajor ID %s" % id))
         redirect(".")
     for arch, options in installopts.iteritems():
         # arch=None means applied to all arches
         io = OSMajorInstallOptions.lazy_create(osmajor_id=osmajor.id,
                 arch_id=Arch.by_name(arch).id if arch else None)
         io.ks_meta = options['ks_meta']
         io.kernel_options = options['kernel_options']
         io.kernel_options_post = options['kernel_options_post']
     flash(_(u'Install options saved for %s') % osmajor)
     redirect('.')
示例#6
0
文件: data_setup.py 项目: omps/beaker
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
示例#7
0
def create_distro(name=None,
                  osmajor=u'DansAwesomeLinux6',
                  osminor=u'9',
                  arches=None,
                  tags=None,
                  harness_dir=True,
                  osmajor_installopts=None,
                  date_created=None):
    osmajor = OSMajor.lazy_create(osmajor=osmajor)
    osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=osminor)
    if arches:
        # list arches may contains unicode name or instance
        # Comparing instance to attribute is prohibited in SQLAlchemy 1.1 and later
        osversion.arches = [
            Arch.by_name(arch.arch if isinstance(arch, Arch) else arch)
            for arch in arches
        ]
    if not name:
        name = unique_name(u'%s.%s-%%s' % (osmajor, osminor))
    distro = Distro.lazy_create(name=name, osversion=osversion)
    if date_created is not None:
        distro.date_created = date_created
    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
    def test_distro_overrides_recipe(self):
        with session.begin():
            lc = data_setup.create_labcontroller()
            system1 = data_setup.create_system(lab_controller=lc,
                arch=u'x86_64')
            i386_distro = self._create_i386_distro(lc)
            io = OSMajorInstallOptions.lazy_create(osmajor_id=
                i386_distro.osversion.osmajor.id,
                arch_id=Arch.by_name('i386').id)
            io.ks_meta = 'lang=en_UK.UTF-8'
        recipe = self._create_recipe(system1)
        distro_tree_id = i386_distro.trees[0].id
        kickstart = self._run_create_kickstart(['--recipe-id', str(recipe.id),
            '--distro-tree-id', str(distro_tree_id),])

        # Make sure we are using the tree from --distro-tree-id
        self.assertIn('url=http://lab.test-kickstart.example.com/distros/'
            'RHEL-6.3/Workstation/i386/os/', kickstart)
        self.assertNotIn('url=http://lab.test-kickstart.invalid/distros/'
            'RHEL-6.2/Server/x86_64/os/', kickstart)
        self.assertIn('lang en_UK.UTF-8', kickstart)
        self.assertNotIn('lang en_US.UTF-8', kickstart)
示例#9
0
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
示例#10
0
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