コード例 #1
0
    def _unpack(self):
        parts = self.download_name.split('.')

        if self.download_name.endswith('.tgz') \
                or self.download_name.endswith('.tar.gz'):

            LOG.info('Extracting %s', self.download_file_name)
            self.image_name = self.download_name\
                .replace('.tgz', '').replace('.tar.gz', '')
            self.tmp_folder = shell.joinpths(Image.tmpdir, parts[0])
            shell.mkdir(self.tmp_folder)

            tar = tarfile.open(self.download_file_name)
            tar.extractall(self.tmp_folder)

            for file_ in shell.listdir(self.tmp_folder):
                if file_.find('vmlinuz') != -1:
                    self.kernel = shell.joinpths(self.tmp_folder, file_)
                elif file_.find('initrd') != -1:
                    self.initrd = shell.joinpths(self.tmp_folder, file_)
                elif file_.endswith('.img'):
                    self.image = shell.joinpths(self.tmp_folder, file_)
                else:
                    pass

        elif self.download_name.endswith('.img') \
                or self.download_name.endswith('.img.gz'):
            self.image_name = self.download_name.split('.img')[0]
            self.image = self.download_file_name

        else:
            raise IOError('Unknown image format for download %s' % (self.download_name))
コード例 #2
0
def _check_root(action, rootdir):
    if not rootdir:
        return False
    if action == settings.INSTALL:
        if sh.isdir(rootdir):
            dir_list = sh.listdir(rootdir)
            if len(dir_list) > 0:
                cprint("Root directory [%s] already exists (and it's not empty)! "\
                          "Please remove it or uninstall components!" % (rootdir), "red")
                return False
    return True
コード例 #3
0
def _check_roots(action, rootdir, components):
    to_skip = list()
    if action == settings.INSTALL:
        if sh.isdir(rootdir):
            to_skip = list()
            for c in components:
                check_pth = sh.joinpths(rootdir, c)
                if sh.isdir(check_pth) and len(sh.listdir(check_pth)) != 0:
                    LOG.warn("Component directory [%s] already exists and its not empty (skipping installing that component)!" % check_pth)
                    LOG.warn("If this is undesired please remove it or uninstall %s!" % (c))
                    to_skip.append(c)
    return to_skip
コード例 #4
0
 def _fix_log_dir(self):
     # This seems needed...
     #
     # Due to the following:
     # <<< Restarting rabbitmq-server: RabbitMQ is not running
     # <<< sh: /var/log/rabbitmq/startup_log: Permission denied
     # <<< FAILED - check /var/log/rabbitmq/startup_{log, _err}
     #
     # See: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-March/011916.html
     # This seems like a bug, since we are just using service init and service restart...
     # And not trying to run this service directly...
     base_dir = sh.joinpths("/", 'var', 'log', 'rabbitmq')
     if sh.isdir(base_dir):
         with sh.Rooted(True):
             # Seems like we need root perms to list that directory...
             for fn in sh.listdir(base_dir):
                 if re.match("(.*?)(err|log)$", fn, re.I):
                     sh.chmod(sh.joinpths(base_dir, fn), 0666)
コード例 #5
0
 def _fix_log_dir(self):
     # This seems needed...
     #
     # Due to the following:
     # <<< Restarting rabbitmq-server: RabbitMQ is not running
     # <<< sh: /var/log/rabbitmq/startup_log: Permission denied
     # <<< FAILED - check /var/log/rabbitmq/startup_{log, _err}
     #
     # See: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-March/011916.html
     # This seems like a bug, since we are just using service init and service restart...
     # And not trying to run this service directly...
     base_dir = sh.joinpths("/", "var", "log", "rabbitmq")
     if sh.isdir(base_dir):
         with sh.Rooted(True):
             # Seems like we need root perms to list that directory...
             for fn in sh.listdir(base_dir):
                 if re.match("(.*?)(err|log)$", fn, re.I):
                     sh.chmod(sh.joinpths(base_dir, fn), 0666)