def create_tarball(self, temp_dir_path):
        """
        Create tarball with the contents of temp_dir_path.

        Tarball will be written to self.output_path, if set. Otherwise it will
        be written to /tmp a name generated according to OUTPUT_FILENAME_TEMPLATE.

        :param temp_dir_path: Base directory to include in tarbal.
        :type temp_dir_path: ``str``

        :return: Path to the created tarball.
        :rtype: ``str``
        """
        LOG.info('Creating tarball...')
        if self.output_path:
            output_file_path = self.output_path
        else:
            date = date_utils.get_datetime_utc_now().strftime(DATE_FORMAT)
            values = {'hostname': socket.gethostname(), 'date': date}

            output_file_name = OUTPUT_FILENAME_TEMPLATE % values
            output_file_path = os.path.join('/tmp', output_file_name)

        with tarfile.open(output_file_path, 'w:gz') as tar:
            tar.add(temp_dir_path, arcname='')

        return output_file_path
dataset/ETHPy150Open StackStorm/st2/st2debug/st2debug/cmd/submit_debug_info.py/DebugInfoCollector.create_tarball/original