Esempio n. 1
0
	def run(self, params, args):
		license = os.path.join(eval(self.__module__).__path__[0],
			'license.txt')
		file = open(license, 'r')
		for line in file.readlines():
			self.addText(line)
		file.close()
    def createSkeletonSiteAttrs(self):
        self.getSiteDotAttrs()
        if os.path.exists('/tmp/site.attrs'):
            return

        file = open('/tmp/site.attrs', 'w')

        #
        # set the language
        #
        cmdline = open('/proc/cmdline', 'r')
        args = string.split(cmdline.readline())
        cmdline.close()

        #
        # the default language
        #
        lang = 'en_US'
        langsupport = 'en_US'

        for arg in args:
            if arg.count('lang='):
                a = string.split(arg, '=')
                if len(a) > 1 and a[1] == 'ko':
                    lang = 'ko_KR'
                    langsupport = string.join(
                        ['ko_KR.UTF-8', 'ko_KR', 'ko', 'en_US.UTF-8', 'en_US'])

        file.write('Kickstart_Lang:%s\n' % lang)
        file.write('Kickstart_Langsupport:%s\n' % langsupport)

        file.close()

        return
Esempio n. 3
0
 def run(self, params, args):
     license = os.path.join(
         eval(self.__module__).__path__[0], 'license.txt')
     file = open(license, 'r')
     for line in file.readlines():
         self.addText(line)
     file.close()
Esempio n. 4
0
    def createSkeletonSiteAttrs(self):
        self.getSiteDotAttrs()
        if os.path.exists("/tmp/site.attrs"):
            return

        file = open("/tmp/site.attrs", "w")

        #
        # set the language
        #
        cmdline = open("/proc/cmdline", "r")
        args = string.split(cmdline.readline())
        cmdline.close()

        #
        # the default language
        #
        lang = "en_US"
        langsupport = "en_US"

        for arg in args:
            if arg.count("lang="):
                a = string.split(arg, "=")
                if len(a) > 1 and a[1] == "ko":
                    lang = "ko_KR"
                    langsupport = string.join(["ko_KR.UTF-8", "ko_KR", "ko", "en_US.UTF-8", "en_US"])

        file.write("Kickstart_Lang:%s\n" % lang)
        file.write("Kickstart_Langsupport:%s\n" % langsupport)

        file.close()

        return
Esempio n. 5
0
	def run(self):
		roll = self.roll
		isoname = '%s-%s-%s.%s.disk%d.iso'  % \
			(roll.getRollName(),
			roll.getRollVersionString(),
			roll.getRollReleaseString(),
			self.getArch(),
			roll.getRollDiskID())

		print 'Re-Arching %s ...' % roll.getRollName()
		tmp = self.mktemp()
		os.makedirs(tmp)
		print '\tcopying %s' % roll.getRollName()
		self.copyRoll(roll, tmp)
		
		# Fix the directory structure for the new Roll architecture
		
		src = os.path.join(tmp, roll.getRollName(), 
			roll.getRollVersionString(), roll.getRollArch())
		dst = os.path.join(tmp, roll.getRollName(),
			roll.getRollVersionString(), self.getArch())
		shutil.move(src, dst)
		
		# Fix the arch attribute in the roll XML file, and 
		# initialize the self.config to the new XML file.  We
		# unlink the file before writing to avoid any read-only
		# permission error (non-root can run this code)
		
		xml = rocks.file.RollInfoFile(os.path.join(dst, 
			'roll-%s.xml' % roll.getRollName()))
		xml.setRollArch(self.getArch())
		
		os.unlink(xml.getFullName())
		file = open(xml.getFullName(), 'w')
		file.write(xml.getXML())
		file.close()
		
		self.config = rocks.file.RollInfoFile(xml.getFullName())
		
		
		# Create a new .discinfo file and create the ISO 

		self.stampDisk(tmp, roll.getRollName(), self.getArch(), 
			roll.getRollDiskID())
		self.mkisofs(isoname, roll.getRollName(), 
			'disk%d' % roll.getRollDiskID(), tmp)

		shutil.rmtree(tmp)
Esempio n. 6
0
	def createPopt(self, dir=None):
		if dir == None:
			dir = self.rootdir

		if not os.path.exists(dir):
			os.system('mkdir -p %s' % (dir))

		filename = os.path.join(dir, '.popt')

		if not os.path.exists(filename):
			file = open(filename, 'w')
			file.write("rpm alias --dbpath --define '_dbpath !#:+'")
			file.write("\n")
			file.close()

		return
    def createPopt(self, dir=None):
        if dir == None:
            dir = self.rootdir

        if not os.path.exists(dir):
            os.system('mkdir -p %s' % (dir))

        filename = os.path.join(dir, '.popt')

        if not os.path.exists(filename):
            file = open(filename, 'w')
            file.write("rpm alias --dbpath --define '_dbpath !#:+'")
            file.write("\n")
            file.close()

        return
Esempio n. 8
0
    def run(self):
        roll = self.roll
        isoname = '%s-%s-%s.%s.disk%d.iso'  % \
         (roll.getRollName(),
         roll.getRollVersionString(),
         roll.getRollReleaseString(),
         self.getArch(),
         roll.getRollDiskID())

        print 'Re-Arching %s ...' % roll.getRollName()
        tmp = self.mktemp()
        os.makedirs(tmp)
        print '\tcopying %s' % roll.getRollName()
        self.copyRoll(roll, tmp)

        # Fix the directory structure for the new Roll architecture

        src = os.path.join(tmp, roll.getRollName(),
                           roll.getRollVersionString(), roll.getRollArch())
        dst = os.path.join(tmp, roll.getRollName(),
                           roll.getRollVersionString(), self.getArch())
        shutil.move(src, dst)

        # Fix the arch attribute in the roll XML file, and
        # initialize the self.config to the new XML file.  We
        # unlink the file before writing to avoid any read-only
        # permission error (non-root can run this code)

        xml = rocks.file.RollInfoFile(
            os.path.join(dst, 'roll-%s.xml' % roll.getRollName()))
        xml.setRollArch(self.getArch())

        os.unlink(xml.getFullName())
        file = open(xml.getFullName(), 'w')
        file.write(xml.getXML())
        file.close()

        self.config = rocks.file.RollInfoFile(xml.getFullName())

        # Create a new .discinfo file and create the ISO

        self.stampDisk(tmp, roll.getRollName(), self.getArch(),
                       roll.getRollDiskID())
        self.mkisofs(isoname, roll.getRollName(),
                     'disk%d' % roll.getRollDiskID(), tmp)

        shutil.rmtree(tmp)
Esempio n. 9
0
File: build.py Progetto: hocks/core
    def makeDirListing(self):	
	#
	# make sure a known CGI exists in the roll directory so we can
	# reliably list all the rolls present on a system. this is useful
	# when the directory listing output is different between different
	# web servers
	#
	path = os.path.join(self.dist.getRootPath(), 'rolls')
	if os.path.exists(path):
		filename = os.path.join(path, 'index.cgi')

		file = open(filename, 'w')
		file.write('%s' % (directory_listing_cgi))
		file.close()

		os.chmod(path, 755)
		os.chmod(filename, 755)

	return
Esempio n. 10
0
File: build.py Progetto: Sudoka/base
    def makeDirListing(self):	
	#
	# make sure a known CGI exists in the roll directory so we can
	# reliably list all the rolls present on a system. this is useful
	# when the directory listing output is different between different
	# web servers
	#
	path = os.path.join(self.dist.getRootPath(), 'rolls')
	if os.path.exists(path):
		filename = os.path.join(path, 'index.cgi')

		file = open(filename, 'w')
		file.write('%s' % (directory_listing_cgi))
		file.close()

		os.chmod(path, 755)
		os.chmod(filename, 755)

	return
Esempio n. 11
0
	def createSkeletonSiteAttrs(self):
		self.getSiteDotAttrs()
		if os.path.exists('/tmp/site.attrs'):
			return

		file = open('/tmp/site.attrs', 'w')

		#
		# set the language
		#
		cmdline = open('/proc/cmdline', 'r')
		args = string.split(cmdline.readline())
		cmdline.close()

		#
		# the default language
		#
		lang = 'en_US'
		langsupport = 'en_US'

		for arg in args:
			if arg.count('lang='):
				a = string.split(arg, '=')
				if len(a) > 1 and a[1] == 'ko':
					lang = 'ko_KR'
					langsupport = string.join([
						'ko_KR.UTF-8',
						'ko_KR',
						'ko',
						'en_US.UTF-8',
						'en_US'
						])

		file.write('Kickstart_Lang:%s\n' % lang)
		file.write('Kickstart_Langsupport:%s\n' % langsupport)

		file.close()

		return
Esempio n. 12
0
    def copy_foreign_cd_linux(self, clean):
        """Copy a Linux OS CD. This is when the CD is a standard CentOS
		RHEL or Scientific Linux CD"""

        disc_info_file = os.path.join(self.cdrom_mount, '.discinfo')
        if not os.path.exists(disc_info_file):
            self.abort('Cannot read disk information')

        file = open(disc_info_file, 'r')
        t = file.readline()
        n = file.readline()
        a = file.readline()
        d = file.readline()
        file.close()

        timestamp = t[:-1]
        roll_name = n[:-1].replace(' ', '_')
        roll_arch = a[:-1]
        diskid = d[:-1]

        roll_vers = rocks.version
        roll_os = 'linux'

        dst = os.path.join(
            self.db.getHostAttr('', 'Kickstart_DistroDir'),
            self.db.getHostAttr('', 'Kickstart_PrivateKickstartBasedir'),
            'rolls')

        roll_dir = os.path.join(dst, roll_name, roll_vers, roll_arch)
        destdir = os.path.join(roll_dir, 'RedHat', 'RPMS')

        if os.path.exists(roll_dir) and clean:
            str = 'Cleaning %s version %s ' % \
             (roll_name, roll_vers)
            str += 'for %s from Rolls directory' % roll_arch
            print str

            self.clean_dir(roll_dir)
            os.makedirs(roll_dir)

        print 'Copying "%s" (%s,%s) roll...' % (roll_name, roll_vers,
                                                roll_arch)
        if not os.path.exists(destdir):
            os.makedirs(destdir)

        cdtree = rocks.file.Tree(self.cdrom_mount)
        for dir in cdtree.getDirs():
            for file in cdtree.getFiles(dir):
                if not file.getName().endswith('.rpm'):
                    continue
                if file.getPackageArch() != 'src' and \
                 file.getBaseName() != 'comps' and \
                 file.getName() != 'comps.rpm' and \
                 file.getBaseName() != 'anaconda' and \
                 file.getBaseName() != 'anaconda-runtime' \
                 and not (roll_arch == 'i386' and \
                 re.match('^kudzu.*', file.getBaseName())):
                    subprocess.call('cp -p %s %s' %
                                    (file.getFullName(), destdir),
                                    shell=True)

        # Add roll information to the database
        rows = self.db.execute(
            "select * from rolls where"
            " name='%s' and Arch='%s' and OS='%s' and version='%s'" %
            (roll_name, roll_arch, roll_os, roll_vers))
        if rows:
            pass
        else:
            self.db.execute("""insert into rolls (name, arch, os,
				version, enabled) values ('%s','%s','%s',
				'%s', 'no')""" % (roll_name, roll_arch, roll_os, roll_vers))
Esempio n. 13
0
	def copy_foreign_cd_linux(self, clean):
		"""Copy a Linux OS CD. This is when the CD is a standard CentOS
		RHEL or Scientific Linux CD"""

		disc_info_file = os.path.join(self.cdrom_mount, '.discinfo')
		if not os.path.exists(disc_info_file):
			self.abort('Cannot read disk information')

		file = open(disc_info_file, 'r')
		t = file.readline()
		n = file.readline()
		a = file.readline()
		d = file.readline()
		file.close()

		timestamp = t[:-1]
		roll_name = n[:-1].replace(' ', '_')
		roll_arch = a[:-1]
		diskid = d[:-1]

		roll_vers = rocks.version
		roll_os = 'linux'

		dst = os.path.join(self.db.getHostAttr('',
			'Kickstart_DistroDir'),
			self.db.getHostAttr('',
			'Kickstart_PrivateKickstartBasedir'), 'rolls')

		roll_dir = os.path.join(dst, roll_name, roll_vers, roll_arch)
		destdir = os.path.join(roll_dir, 'RedHat', 'RPMS')

		if os.path.exists(roll_dir) and clean:
			str = 'Cleaning %s version %s ' % \
				(roll_name, roll_vers)
			str += 'for %s from Rolls directory' % roll_arch
			print str

			self.clean_dir(roll_dir)
			os.makedirs(roll_dir)

		print 'Copying "%s" (%s,%s) roll...' % (roll_name,
			roll_vers, roll_arch)
		if not os.path.exists(destdir):
			os.makedirs(destdir)

		cdtree = rocks.file.Tree(self.cdrom_mount)
		for dir in cdtree.getDirs():
			for file in cdtree.getFiles(dir):
				if not file.getName().endswith('.rpm'):
					continue
				if file.getPackageArch() != 'src' and \
					file.getBaseName() != 'comps' and \
					file.getName() != 'comps.rpm' and \
					file.getBaseName() != 'anaconda' and \
					file.getBaseName() != 'anaconda-runtime' \
					and not (roll_arch == 'i386' and \
					re.match('^kudzu.*', file.getBaseName())):
						subprocess.call('cp -p %s %s' % (
							file.getFullName(), 
							destdir), shell=True)

		# Add roll information to the database
		rows = self.db.execute(
			"select * from rolls where"
			" name='%s' and Arch='%s' and OS='%s' and version='%s'"
			% (roll_name, roll_arch, roll_os, roll_vers))
		if rows:
			pass
		else:
			self.db.execute("""insert into rolls (name, arch, os,
				version, enabled) values ('%s','%s','%s',
				'%s', 'no')""" % (roll_name, roll_arch,
				roll_os, roll_vers))
Esempio n. 14
0
	def run(self, params, args):
		if len(args):
			self.abort('command does not take arguments')

		ver	= self.db.getHostAttr('localhost', 'rocks_version')
		url	= self.db.getHostAttr('localhost', 'updates_url')
		path	= self.db.getHostAttr('localhost', 'updates_path')
		
		if not ver:
			self.abort('unknown rocks version')

		if not url:
			url  = 'http://www.rocksclusters.org/'
			url += 'ftp-site/pub/rocks/rocks-%s/%s/updates/' % \
				(ver, self.os)

		if not path:
			path = '/export/rocks/updates'

		try:
			host = url.split('//', 1)[1].split('/')[0]
		except:
			self.abort('invalid url')

		if not os.path.exists(path):
			os.system('mkdir -p %s' % path)
		
		if not self.httpExists(url) : 
			print "No updates are available at the moment..."
			return
		os.chdir(path)
		self.command('create.mirror', [ url, 'rollname=rocks-updates' ])
		os.system('createrepo %s' % host)

		# Always re-write the rocks-updates.repo yum file

		repo = '/etc/yum.repos.d/rocks-updates.repo'
		file = open(repo, 'w')
		file.write('[Rocks-%s-Updates]\n' % ver)
		file.write('name=Rocks %s Updates\n' % ver)
		file.write('baseurl=file://%s/%s\n' % (path, host))
		file.close()

		# Add the updates roll and enable it, but do not rebuild the
		# distribution.  The user should do this when they are ready.
		# We also nuke the .iso since it is not really safe to use
		# outside of this command.

		self.command('add.roll', [
			'rocks-updates-%s-0.%s.disk1.iso' % (ver, self.arch),
			'clean=yes'
			])
		os.unlink('rocks-updates-%s-0.%s.disk1.iso' % (ver, self.arch))
		os.unlink('roll-rocks-updates.xml')
		self.command('enable.roll', [
			'rocks-updates',
			'arch=%s' % self.arch,
			'version=%s' % ver
			])

		# Update the packages on the frontend, but only from this new
		# YUM repository.

		os.system('yum --disablerepo="*" '
			'--enablerepo=Rocks-%s-Updates update' % ver)

		# Determine what Rolls are on the disk and remove the XML
		# and update scripts from Rolls that we do not have enabled

		self.db.execute("""select name from rolls where
			enabled='yes' and version='%s'""" % ver)
		rolls = []
		for roll, in self.db.fetchall():
			rolls.append(roll)
	
		# Go into the rocks-updates Roll and remove the
		# kickstart profile rpms that are for rolls we are not
		# using (not enabled).

		tree = rocks.file.Tree(os.path.join('..', 'install', 'rolls',
			'rocks-updates', ver, self.arch,
			'RedHat', 'RPMS'))
		for file in tree.getFiles():
			name, ext  = os.path.splitext(file.getName())
                        try:
	                        file.getPackageName()
                        except AttributeError:
				continue
			tokens = file.getBaseName().split('-')
			if len(tokens) != 3:
				continue
			if tokens[0] == 'roll' and tokens[2] == 'kickstart':
				if tokens[2] in rolls:
					continue
				print '+ roll not enabled, removed %s' \
					% file.getName()
				os.unlink(file.getFullName())


		# Scan the updates for any .sh files and run these to update
		# the Frontend after the RPMs are installed.
		# Skip update scripts for Rolls that are not enabled.

		dir = url.split('//', 1)[1]
		for file in os.listdir(dir):
			if os.path.splitext(file)[1] != '.sh':
				continue
			tokens = file.split('-', 1)
			if tokens[0] == 'update':
				if not tokens[1] in rolls:
					print '+ roll not enabled, ignored %s' \
					      % file
					continue
			os.system('sh -x %s' % os.path.join(dir, file))
Esempio n. 15
0
    def run(self, params, args):
        if len(args):
            self.abort('command does not take arguments')

        ver = self.db.getHostAttr('localhost', 'rocks_version')
        url = self.db.getHostAttr('localhost', 'updates_url')
        path = self.db.getHostAttr('localhost', 'updates_path')

        if not ver:
            self.abort('unknown rocks version')

        if not url:
            url = 'http://www.rocksclusters.org/'
            url += 'ftp-site/pub/rocks/rocks-%s/%s/updates/' % \
             (ver, self.os)

        if not path:
            path = '/export/rocks/updates'

        try:
            host = url.split('//', 1)[1].split('/')[0]
        except:
            self.abort('invalid url')

        if not os.path.exists(path):
            os.system('mkdir -p %s' % path)

        if not self.httpExists(url):
            print "No updates are available at the moment..."
            return
        os.chdir(path)
        self.command('create.mirror', [url, 'rollname=rocks-updates'])
        os.system('createrepo %s' % host)

        # Always re-write the rocks-updates.repo yum file

        repo = '/etc/yum.repos.d/rocks-updates.repo'
        file = open(repo, 'w')
        file.write('[Rocks-%s-Updates]\n' % ver)
        file.write('name=Rocks %s Updates\n' % ver)
        file.write('baseurl=file://%s/%s\n' % (path, host))
        file.close()

        # Add the updates roll and enable it, but do not rebuild the
        # distribution.  The user should do this when they are ready.
        # We also nuke the .iso since it is not really safe to use
        # outside of this command.

        self.command('add.roll', [
            'rocks-updates-%s-0.%s.disk1.iso' % (ver, self.arch), 'clean=yes'
        ])
        os.unlink('rocks-updates-%s-0.%s.disk1.iso' % (ver, self.arch))
        os.unlink('roll-rocks-updates.xml')
        self.command(
            'enable.roll',
            ['rocks-updates',
             'arch=%s' % self.arch,
             'version=%s' % ver])

        # Update the packages on the frontend, but only from this new
        # YUM repository.

        os.system('yum --disablerepo="*" '
                  '--enablerepo=Rocks-%s-Updates update' % ver)

        # Determine what Rolls are on the disk and remove the XML
        # and update scripts from Rolls that we do not have enabled

        self.db.execute("""select name from rolls where
			enabled='yes' and version='%s'""" % ver)
        rolls = []
        for roll, in self.db.fetchall():
            rolls.append(roll)

        # Go into the rocks-updates Roll and remove the
        # kickstart profile rpms that are for rolls we are not
        # using (not enabled).

        tree = rocks.file.Tree(
            os.path.join('..', 'install', 'rolls', 'rocks-updates', ver,
                         self.arch, 'RedHat', 'RPMS'))
        for file in tree.getFiles():
            name, ext = os.path.splitext(file.getName())
            try:
                file.getPackageName()
            except AttributeError:
                continue
            tokens = file.getBaseName().split('-')
            if len(tokens) != 3:
                continue
            if tokens[0] == 'roll' and tokens[2] == 'kickstart':
                if tokens[2] in rolls:
                    continue
                print '+ roll not enabled, removed %s' \
                 % file.getName()
                os.unlink(file.getFullName())

        # Scan the updates for any .sh files and run these to update
        # the Frontend after the RPMs are installed.
        # Skip update scripts for Rolls that are not enabled.

        dir = url.split('//', 1)[1]
        for file in os.listdir(dir):
            if os.path.splitext(file)[1] != '.sh':
                continue
            tokens = file.split('-', 1)
            if tokens[0] == 'update':
                if not tokens[1] in rolls:
                    print '+ roll not enabled, ignored %s' \
                          % file
                    continue
            os.system('sh -x %s' % os.path.join(dir, file))