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
Example #2
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
Example #3
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)
Example #4
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
Example #6
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)
Example #7
0
File: build.py Project: 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
Example #8
0
File: build.py Project: 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
Example #9
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
Example #10
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))
Example #11
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))