示例#1
0
文件: nc.py 项目: AsherBond/silvereye
    def postAction(self, anaconda):
        silvereye.InstallClass.postAction(self, anaconda)
        # XXX: use proper constants for path names
        shutil.copyfile('/tmp/updates/scripts/eucalyptus-nc-config.sh',
                        '/mnt/sysimage/usr/local/sbin/eucalyptus-nc-config.sh')
        os.chmod('/mnt/sysimage/usr/local/sbin/eucalyptus-nc-config.sh', 0770)
        postscriptlines = """
# Set the default Eucalyptus networking mode
sed -i -e 's/^VNET_MODE=\"SYSTEM\"/VNET_MODE=\"MANAGED-NOVLAN"/' /etc/eucalyptus/eucalyptus.conf

# Disable Eucalyptus services before first boot
/sbin/chkconfig eucalyptus-nc off

# Create a backup copy of root's .bash_profile
/bin/cp -a /root/.bash_profile /root/.bash_profile.orig

# Create a backup of /etc/rc.d/rc.local
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.orig
cat >> /etc/rc.d/rc.local <<"EOF"

# Add eucalyptus-nc-config.sh script to root's .bash_profile, and have the
# original .bash_profile moved in on the first run
echo '/bin/cp -af /root/.bash_profile.orig /root/.bash_profile' >> /root/.bash_profile
echo '/usr/local/sbin/eucalyptus-nc-config.sh' >> /root/.bash_profile

# Replace /etc/rc.d/rc.local with the original backup copy
rm -f /etc/rc.d/rc.local
cp /etc/rc.d/rc.local.orig /etc/rc.d/rc.local
EOF
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/nc-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)
示例#2
0
    def postAction(self, anaconda):
        installclass.BaseInstallClass.postAction(self, anaconda)

        shutil.copyfile('/tmp/updates/scripts/silvereye-release',
                        '/mnt/sysimage/etc/silvereye-release')

        postscriptlines = """
if [ -e /etc/libvirt/qemu/networks/autostart/default.xml ]; then
  rm -f /etc/libvirt/qemu/networks/autostart/default.xml
fi
/sbin/chkconfig ntpdate on
/sbin/chkconfig ntpd on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/euca-common-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)
示例#3
0
    def postAction(self, anaconda):
        installclass.BaseInstallClass.postAction(self, anaconda)

        shutil.copyfile('/tmp/updates/scripts/silvereye-release',
                        '/mnt/sysimage/etc/silvereye-release')

        postscriptlines ="""
if [ -e /etc/libvirt/qemu/networks/autostart/default.xml ]; then
  rm -f /etc/libvirt/qemu/networks/autostart/default.xml
fi
/sbin/chkconfig ntpdate on
/sbin/chkconfig ntpd on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/euca-common-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)
示例#4
0
    def postAction(self, anaconda):
        silvereye.InstallClass.postAction(self, anaconda)
        # XXX: use proper constants for path names
        def copy_script(src, dest, mode=0770):
            shutil.copyfile('/tmp/updates/scripts/%s' % src,
                            '%s%s' % (anaconda.rootPath, dest))
            os.chmod('%s%s' % (anaconda.rootPath, dest), mode)

        def copy_file(src, dest):
            copy_script(src, dest, mode=0644)

        copy_script('eucalyptus-frontend-config.sh',
                    '/usr/local/sbin/eucalyptus-frontend-config')
        copy_script('eucalyptus-teardown',
                    '/usr/local/sbin/eucalyptus-teardown')
        copy_script('install-unpacked-image.py',
                    '/usr/local/sbin/install-unpacked-image.py')
        copy_script('eucalyptus-setup.init',
                    '/etc/init.d/eucalyptus-setup')
        copy_script('register_cloud_start',
                    '/usr/local/sbin/register_cloud_start', mode=0755)

        os.mkdir('%s/tmp/img' % anaconda.rootPath)
        # EKI
        shutil.copyfile('/tmp/updates/scripts/vmlinuz-kexec',
                        '%s/tmp/img/vmlinuz-kexec' % anaconda.rootPath)

        # ERI
        shutil.copyfile('/tmp/updates/scripts/initramfs-kexec',
                        '%s/tmp/img/initramfs-kexec' % anaconda.rootPath)

        # Image kickstart
        newks = open('%s/tmp/ks-centos6.cfg' % anaconda.rootPath, 'w')
        ayum = anaconda.backend.ayum

        for repo in ayum.repos.listEnabled():
            newks.write('repo --name=%s --baseurl=%s\n' % (repo.name, repo.baseurl[0]))
        for line in open('/tmp/updates/ks-centos6.cfg', 'r').readlines():
            if line.startswith('repo '):
                continue
            newks.write(line)
        newks.close()

        # Image creation script
        copy_script('ami_creator.py', '/tmp/ami_creator.py')

        # XXX clean this up
        bindmount = False
        if ayum._baseRepoURL and ayum._baseRepoURL.startswith("file://"):
            os.mkdir('/mnt/sysimage/mnt/source')
            isys.mount('/mnt/source', '/mnt/sysimage/mnt/source', bindMount=True)
            bindmount = True

        # eucalyptus.conf fragment from config screen
        w = anaconda.intf.progressWindow(_("Creating EMI"), 
                                     _("Creating an initial CentOS 6 EMI."), 100)
        shutil.copyfile('/tmp/eucalyptus.conf',
                        '%s/etc/eucalyptus/eucalyptus.conf.anaconda' % anaconda.rootPath)
        copy_script('eucalyptus-firstboot-final.py',
                    '/usr/share/firstboot/modules/eucalyptus-firstboot-final.py')

        postscriptlines ="""
/usr/sbin/euca_conf --upgrade-conf /etc/eucalyptus/eucalyptus.conf.anaconda
chkconfig dnsmasq off
chkconfig eucalyptus-cloud off
chkconfig eucalyptus-setup on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/frontend-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)

        # TODO: Add status line for text mode
        pkgstatus = None
        if anaconda.id.displayMode == 'g':
            import gtk
            pkgstatus = gtk.Label("Preparing to install...")
            w.window.child.add(pkgstatus)
            pkgstatus.show()

        messages = '/root/ami-creation.log'
        rc = iutil.execWithCallback('/bin/sh' , ['-c', 'cd /tmp/img; /tmp/ami_creator.py -c /tmp/ks-centos6.cfg'],
                                    stdin = messages, stdout = messages, stderr = messages,
                                    root = '/mnt/sysimage', callback=imageProgress, 
                                    callback_data=ImageProgress(w, pkgstatus))

        if bindmount:
            isys.umount('/mnt/sysimage/mnt/source')
        w.pop()
示例#5
0
    def postAction(self, anaconda):
        silvereye.InstallClass.postAction(self, anaconda)

        # XXX: use proper constants for path names
        def copy_script(src, dest, mode=0770):
            shutil.copyfile('/tmp/updates/scripts/%s' % src,
                            '%s%s' % (anaconda.rootPath, dest))
            os.chmod('%s%s' % (anaconda.rootPath, dest), mode)

        def copy_file(src, dest):
            copy_script(src, dest, mode=0644)

        copy_script('eucalyptus-frontend-config.sh',
                    '/usr/local/sbin/eucalyptus-frontend-config')
        copy_script('eucalyptus-teardown',
                    '/usr/local/sbin/eucalyptus-teardown')
        copy_script('install-unpacked-image.py',
                    '/usr/local/sbin/install-unpacked-image.py')
        copy_script('eucalyptus-setup.init', '/etc/init.d/eucalyptus-setup')
        copy_script('register_cloud_start',
                    '/usr/local/sbin/register_cloud_start',
                    mode=0755)

        os.mkdir('%s/tmp/img' % anaconda.rootPath)
        # EKI
        shutil.copyfile('/tmp/updates/scripts/vmlinuz-kexec',
                        '%s/tmp/img/vmlinuz-kexec' % anaconda.rootPath)

        # ERI
        shutil.copyfile('/tmp/updates/scripts/initramfs-kexec',
                        '%s/tmp/img/initramfs-kexec' % anaconda.rootPath)

        # Image kickstart
        newks = open('%s/tmp/ks-centos6.cfg' % anaconda.rootPath, 'w')
        ayum = anaconda.backend.ayum

        for repo in ayum.repos.listEnabled():
            newks.write('repo --name=%s --baseurl=%s\n' %
                        (repo.name, repo.baseurl[0]))
        for line in open('/tmp/updates/ks-centos6.cfg', 'r').readlines():
            if line.startswith('repo '):
                continue
            newks.write(line)
        newks.close()

        # Image creation script
        copy_script('ami_creator.py', '/tmp/ami_creator.py')

        # XXX clean this up
        bindmount = False
        if ayum._baseRepoURL and ayum._baseRepoURL.startswith("file://"):
            os.mkdir('/mnt/sysimage/mnt/source')
            isys.mount('/mnt/source',
                       '/mnt/sysimage/mnt/source',
                       bindMount=True)
            bindmount = True

        # eucalyptus.conf fragment from config screen
        w = anaconda.intf.progressWindow(
            _("Creating EMI"), _("Creating an initial CentOS 6 EMI."), 100)
        shutil.copyfile(
            '/tmp/eucalyptus.conf',
            '%s/etc/eucalyptus/eucalyptus.conf.anaconda' % anaconda.rootPath)
        copy_script(
            'eucalyptus-firstboot-final.py',
            '/usr/share/firstboot/modules/eucalyptus-firstboot-final.py')

        postscriptlines = """
/usr/sbin/euca_conf --upgrade-conf /etc/eucalyptus/eucalyptus.conf.anaconda
chkconfig dnsmasq off
chkconfig eucalyptus-cloud off
chkconfig eucalyptus-setup on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/frontend-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)

        # TODO: Add status line for text mode
        pkgstatus = None
        if anaconda.id.displayMode == 'g':
            import gtk
            pkgstatus = gtk.Label("Preparing to install...")
            w.window.child.add(pkgstatus)
            pkgstatus.show()

        messages = '/root/ami-creation.log'
        rc = iutil.execWithCallback(
            '/bin/sh',
            ['-c', 'cd /tmp/img; /tmp/ami_creator.py -c /tmp/ks-centos6.cfg'],
            stdin=messages,
            stdout=messages,
            stderr=messages,
            root='/mnt/sysimage',
            callback=imageProgress,
            callback_data=ImageProgress(w, pkgstatus))

        if bindmount:
            isys.umount('/mnt/sysimage/mnt/source')
        w.pop()