예제 #1
0
 def set_suite(self, suite):
     self.options['paellasuite'] = suite
     self.installer = ProfileInstaller(self.conn, suite, self.cfg)
예제 #2
0
 def set_suite(self, suite):
     self.check_guest()
     self.installer = ProfileInstaller(self.conn, self.paellarc)
     self._suite = suite
예제 #3
0
class UmlInstaller(UmlChroot):
    def __init__(self, conn, cfg=None):
        self.conn = conn
        UmlChroot.__init__(self, cfg=cfg)

    def set_suite(self, suite):
        self.options['paellasuite'] = suite
        self.installer = ProfileInstaller(self.conn, suite, self.cfg)

    def set_profile(self, profile):
        self.options['paellaprofile'] = profile
        self.set_suite(get_suite(self.conn, profile))
        self.installer.set_profile(profile)

    def set_template_path(self, path=None):
        if path is None:
            path = self.cfg['template_path']
        self.installer.set_template_path(path)

    def process(self):
        self.installer.process()

    def make_base_image(self, path, size=3000, mkfs='mke2fs'):
        suite = self.options['paellasuite'].value
        basepath = join(self.cfg['basetarball_path'], suite + '.base')
        print 'making root filesystem %s' % path
        create_root_filesystem(path, size)
        self.set_rootimage(path)

    def copy_base_image(self, path):
        suite = self.options['paellasuite'].value
        basepath = join(self.cfg['basetarball_path'], suite + '.base')
        if basepath != path:
            print 'copying %s to %s' % (basepath, path)
            os.system('cp %s %s' % (basepath, path))
        self.set_rootimage(path)

    def install_profile(self, profile, path):
        self.set_profile(profile)
        self.make_base_image(path)
        self.run_uml()

    def set_target(self, target='/tmp/target'):
        UmlChroot.set_target(self, target)

    def setup_target(self, target='/tmp/target'):
        self.installer.set_target(target)

    def apt_update(self):
        os.system(self.installer.command('apt-get update'))

    def extract_base_tarball(self):
        suite = self.options['paellasuite'].value
        basetarball = join(self.cfg['bkuptarball_path'], '%s.base.tar' % suite)
        if False:
            tar = tarfile.open(mode='r|', fileobj=file(basetarball))
            for info in tar:
                if len(info.name) < 5:
                    print 'extracting', info.name
                tar.extract(info, self.target)
            tar.close()
        else:
            here = os.getcwd()
            print 'extracting with tar'
            os.chdir(self.target)
            os.system('tar xf %s' % basetarball)
            os.chdir(here)

    def mkrootfs(self):
        os.system('mke2fs /dev/ubd/1')
예제 #4
0
class UmlInstaller(UmlChroot):
    def __init__(self, conn=None, cfg=None):
        self.conn = conn
        UmlChroot.__init__(self, cfg=cfg)
        self.options['paella_action'] = 'install'
        self.paellarc = PaellaConfig(files=[self.cfg['paellarc']])
        
        
    def set_suite(self, suite):
        self.check_guest()
        self.installer = ProfileInstaller(self.conn, self.paellarc)
        self._suite = suite
        
    def set_profile(self, profile):
        if self.mode == 'host':
            self.options['paellaprofile'] = profile
        else:
            self.check_guest()
            self.set_suite(get_suite(self.conn, profile))
            self.installer.set_profile(profile)
            if hasattr(self, 'target'):
                self.installer.set_target(self.target)

    def set_template_path(self, path=None): 
        self.check_guest()
        self.installer.set_template_path(path)

    def process(self):
        self.check_guest()
        self.installer.process()

    def make_root_device(self, path, size=None):
        self.check_host()
        if size is None:
            size = self.cfg['basefile_size']
        msg = 'making uml root device of size %s at %s' % (size, path)
        print msg
        create_sparse_file(path, size)
        self.set_targetimage(path)
        
    def install_profile(self, profile, path):
        self.check_host()
        self.set_profile(profile)
        self.make_root_device(path)
        self.run_uml()

    def restore_profile(self, name, path):
        self.check_host()
        self.options['paella_action'] = 'restore'
        self.options['paellaprofile'] = name
        self.options['paellasuite'] = 'none'
        self.make_root_device(path)
        self.run_uml()
        
    def extract_base_tarball(self):
        self.check_guest()
        suite = self._suite
        fstype = self.cfg.get('umlmachines', 'backup_filesystem')
        if fstype == 'hostfs':
            backup_path = self.cfg.get('umlmachines', 'hostfs_backup_path')
        else:
            backup_path = '/mnt'
        basetarball = join(backup_path, '%s.base.tar' % suite)
        extract_tarball(self.target, basetarball)

    def ready_base_for_install(self):
        ready_base_for_install(self.target, self.paellarc, self._suite)