示例#1
0
	def get_values(self):
		config = Utility.get_zfsci_config()
		kernelbasepath = config['persistent_path'] + '/kernels'

		if not os.path.isdir(kernelbasepath):
			try:
				os.makedirs(kernelbasepath)
			except OSError:
				pass

		sourcepath = Utility.get_source_dir()
		os.system("cp -a %s/misc/modules %s" % (sourcepath, kernelbasepath))

		os.chdir(kernelbasepath)

		kernels = {
			'2.6.26': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.26/',
			'2.6.27': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.27/',
			'2.6.28': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.28/',
			'2.6.29': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.29/',
			'2.6.30': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30/',
			'2.6.31': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.31/',
			'2.6.32': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.32/',
			'2.6.33': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.33/',
			'2.6.34': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/',
			'2.6.35': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.35-maverick/',
			'2.6.36': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.36-maverick/',
			'2.6.37': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.37-natty/',
			'2.6.38': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.38-natty/',
			'2.6.39': 'http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.39-rc5-oneiric/'
		}

		for kernel in kernels.iterkeys():
			if os.path.islink(kernel):
				continue

			os.system("wget -r -np -c '%s'" % (kernels[kernel]))
			os.symlink(kernels[kernel][7:], kernel)

		return kernels.keys()
示例#2
0
	def get_values(self):
		config = Utility.get_zfsci_config()
		distsbasepath = config['persistent_path'] + '/dists'

		if not os.path.isdir(distsbasepath):
			try:
				os.makedirs(distsbasepath)
			except OSError:
				pass

		distsscriptdir = Utility.get_source_dir() + '/dists'

		distributions = [
			'debian',
			#'opensuse', # broken
			#'centos', # mostly works
			#'scientific' # horribly broken
		]

		for distribution in distributions:
			if not os.path.isfile("%s/%s.tar.gz" % (distsbasepath, distribution)):
				os.system("%s/%s.sh %s/%s.tar.gz" % (distsscriptdir, distribution, distsbasepath, distribution))

		return distributions
示例#3
0
class PartitionBuilder(object):
	_config = Utility.get_zfsci_config()

	@staticmethod
	def get_install_device():
		return PartitionBuilder._config['install_device']

	@staticmethod
	def get_rootpart():
		return PartitionBuilder.get_install_device() + '1'

	@staticmethod
	def get_swappart():
		return PartitionBuilder.get_install_device() + '2'

	@staticmethod
	def get_testpart():
		return PartitionBuilder.get_install_device() + '3'

	@staticmethod
	def setup_partitions():
		install_device = PartitionBuilder.get_install_device()

		if os.system("dd if=/dev/zero of=%s bs=512 count=1" % (install_device)) != 0:
			raise Error("Could not erase old partition table.")

		if os.system("parted --script -- %s mktable msdos" % (install_device)) != 0:
			raise Error("Could not create new partition table.")

		rootpart = PartitionBuilder.get_rootpart()
		if os.system("parted --script -- %s mkpart primary ext2 1M 10G" % (install_device)) != 0:
			raise Error("Could not create new / partition.")

		swappart = PartitionBuilder.get_swappart()
		if os.system("parted --script -- %s mkpart primary linux-swap 10G 14G" % (install_device)) != 0:
			raise Error("Could not create new swap partition.")

		testpart = PartitionBuilder.get_testpart()
		if os.system("parted --script -- %s mkpart primary sun-ufs 14G -1s" % (install_device)) != 0:
			raise Error("Could not create new test partition.")

		if os.system("mke2fs -j -m 0 -L / -I 128 %s" % (rootpart)) != 0:
			raise Error("Create not create new / filesystem.")

		if os.system("mkswap %s" % (swappart)) != 0:
			raise Error("Could not create new swap filesystem.")

	@staticmethod
	def mount_partitions():
		if os.system("mountpoint -q /mnt") != 0 or os.system("mount -o remount,rw /mnt") != 0:
			try:
				os.makedirs("/mnt")
			except OSError:
				pass

			if os.system("mount %s /mnt" % (PartitionBuilder.get_rootpart())) != 0:
				raise Error("Could not mount node filesystem.")

		if os.system("mountpoint -q /mnt/dev") != 0:
			try:
				os.makedirs("/mnt/dev")
			except OSError:
				pass

			if os.system("mount --bind /dev /mnt/dev") != 0:
				raise Error("Could not mount /mnt/dev")

		if os.system("mountpoint -q /mnt/sys") != 0:
			try:
				os.makedirs("/mnt/sys")
			except OSError:
				pass

			if os.system("mount --bind /sys /mnt/sys") != 0:
				raise Error("Could not mount /mnt/sys")

		if os.system("mountpoint -q /mnt/proc") != 0:
			try:
				os.makedirs("/mnt/proc")
			except OSError:
				pass

			if os.system("mount -t proc none /mnt/proc") != 0:
				raise Error("Could not mount /mnt/proc")

		persistent_dir = Utility.get_persistent_dir()
		if os.system("mountpoint -q /mnt/%s" % (persistent_dir)) != 0:
			try:
				os.makedirs("/mnt/%s" % (persistent_dir))
			except OSError:
				pass

			if os.system("mount --bind %s /mnt/%s" % (persistent_dir, persistent_dir)) != 0:
				raise Error("Could not mount /mnt/%s" % (persistent_dir))

	@staticmethod
	def unmount_partitions():
		persistent_dir = Utility.get_persistent_dir()
		os.system("umount /mnt/%s /mnt/dev /mnt/sys /mnt/proc /mnt" % (persistent_dir))
示例#4
0
def get_job_session(debug=False):
	config = Utility.get_zfsci_config()
	engine = create_engine(config['job_dsn'], echo=debug)
	ModelBase.metadata.create_all(engine)

	return JobSession(bind=engine)
示例#5
0
    def get_values(self):
        repositories = [{
            'name': 'behlendorf',
            'spl': 'git://github.com/behlendorf/spl.git',
            'zfs': 'git://github.com/behlendorf/zfs.git',
            'zfs-ignore-branches': ['gh-pages']
        }, {
            'name': 'gunnarbeutner',
            'spl': 'git://github.com/gunnarbeutner/pkg-spl.git',
            'zfs': 'git://github.com/gunnarbeutner/pkg-zfs.git'
        }]

        config = Utility.get_zfsci_config()
        repobasepath = config['persistent_path'] + '/repositories'

        if not os.path.isdir(repobasepath):
            try:
                os.makedirs(repobasepath)
            except OSError:
                pass

        os.chdir(repobasepath)

        values = [None]
        for repository in repositories:
            for subrepo in ['spl', 'zfs']:
                repodir = '%s-%s' % (repository['name'], subrepo)
                repopath = repobasepath + '/' + repodir

                if not os.path.isdir(repopath):
                    os.chdir(repobasepath)
                    os.system('git clone --mirror %s %s' %
                              (repository[subrepo], repopath))

                os.chdir(repopath)
                os.system('git fetch')

                args = [
                    'git', 'for-each-ref', '--format=%(refname:short)',
                    'refs/heads/'
                ]
                output = subprocess.Popen(
                    args, stdout=subprocess.PIPE).communicate()[0]
                branches = output.strip().split('\n')

                for branch in branches:
                    if subrepo + '-ignore-branches' in repository and \
                      branch in repository[subrepo + '-ignore-branches']:
                        continue

                    args = [
                        'git', 'rev-list', '--max-count=5', '--timestamp',
                        branch
                    ]
                    output = subprocess.Popen(
                        args, stdout=subprocess.PIPE).communicate()[0]

                    commits = output.strip().split('\n')

                    for commitinfo in commits:
                        (timestamp, commit) = commitinfo.split(' ', 1)

                        value = {
                            'spl-repository': '%s-spl' % (repository['name']),
                            'zfs-repository': '%s-zfs' % (repository['name']),
                            'spl-branch': 'master',
                            'zfs-branch': 'master',
                            'timestamp': timestamp
                        }

                        value[subrepo + '-branch'] = branch

                        values.append(value)

        return values
示例#6
0
    def get_values(self):
        repositories = [
            {
                "name": "behlendorf",
                "spl": "git://github.com/behlendorf/spl.git",
                "zfs": "git://github.com/behlendorf/zfs.git",
                "zfs-ignore-branches": ["gh-pages"],
            },
            {
                "name": "gunnarbeutner",
                "spl": "git://github.com/gunnarbeutner/pkg-spl.git",
                "zfs": "git://github.com/gunnarbeutner/pkg-zfs.git",
            },
        ]

        config = Utility.get_zfsci_config()
        repobasepath = config["persistent_path"] + "/repositories"

        if not os.path.isdir(repobasepath):
            try:
                os.makedirs(repobasepath)
            except OSError:
                pass

        os.chdir(repobasepath)

        values = [None]
        for repository in repositories:
            for subrepo in ["spl", "zfs"]:
                repodir = "%s-%s" % (repository["name"], subrepo)
                repopath = repobasepath + "/" + repodir

                if not os.path.isdir(repopath):
                    os.chdir(repobasepath)
                    os.system("git clone --mirror %s %s" % (repository[subrepo], repopath))

                os.chdir(repopath)
                os.system("git fetch")

                args = ["git", "for-each-ref", "--format=%(refname:short)", "refs/heads/"]
                output = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
                branches = output.strip().split("\n")

                for branch in branches:
                    if (
                        subrepo + "-ignore-branches" in repository
                        and branch in repository[subrepo + "-ignore-branches"]
                    ):
                        continue

                    args = ["git", "rev-list", "--max-count=5", "--timestamp", branch]
                    output = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]

                    commits = output.strip().split("\n")

                    for commitinfo in commits:
                        (timestamp, commit) = commitinfo.split(" ", 1)

                        value = {
                            "spl-repository": "%s-spl" % (repository["name"]),
                            "zfs-repository": "%s-zfs" % (repository["name"]),
                            "spl-branch": "master",
                            "zfs-branch": "master",
                            "timestamp": timestamp,
                        }

                        value[subrepo + "-branch"] = branch

                        values.append(value)

        return values