Skip to content

DOCS-1283 Clarify and cleanup system specific installation instructions #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 66 additions & 45 deletions bin/table_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import sys
import argparse

try:
import yaml
Expand All @@ -32,20 +33,15 @@ def normalize_cell_height(rowdata):
for x in range(maxlines - len(cell)):
cell.append( ' ' )

def get_default_outputfile(inputfile):
return inputfile.rsplit('.')[0] + '.rst'


###################################
#
# Generating parts of the table.

class YamlTable(object):
def __init__(self, inputfile):
self.columnwidths = []
self.tempcolumnwidths = []
self.inputfile = inputfile
self.read_data(inputfile)
self.process_table_content()
self.format = None

def read_data(self, datafile):
with open(datafile, "rt") as f:
Expand All @@ -61,7 +57,8 @@ def read_data(self, datafile):
elif content.section != 'content':
exit('content document in "' + datafile + '" is malformed.')

rows = { 'rows': [] }
if hasattr(meta, 'format'):
format = meta.format

if layout.header:
header = []
Expand All @@ -70,14 +67,15 @@ def read_data(self, datafile):
else:
header = None

self.header = header

rows = []
for rownum in layout.rows:
parsed_cell = []
parsed_cells = []
for cell in rownum.items()[0][1]:
parsed_cell.append(eval(cell))
rows['rows'].append( dict(zip(rownum.keys(), [parsed_cell])) )
parsed_cells.append(eval(cell))
rows.append( dict(zip(rownum.keys(), [parsed_cells])) )

# return header, rows
self.header = header
self.rows = rows


Expand All @@ -104,17 +102,24 @@ def __getattr__(self, key):
#
# Interaction

class RstTable(YamlTable):
def __init__(self, inputfile):
self.inputfile = inputfile
super(RstTable, self).__init__(inputfile)
class OutputTable(object):
pass

class RstTable(OutputTable):
def __init__(self, imported_table):
self.columnwidths = []
self.tempcolumnwidths = []

self.table = imported_table

self.process_table_content()
self.output = self.render_table()

###################################
#
# Flexibility for tables of different sizes.

def check_column_width(self, rowdata):
def _check_column_width(self, rowdata):
"""
Compares the cell widths of the row with the curren max cell
width in the global variables. Then updates
Expand All @@ -134,13 +139,13 @@ def check_column_width(self, rowdata):
#
# Building the table representation

def get_row_line(self, delim='-'):
def _get_row_line(self, delim='-'):
"""
Produces and returns row deliminiters for restructured text tables.
"""
return '+' + delim + str(delim + '+' + delim).join([ delim * width for width in self.columnwidths ]) + delim + '+'

def get_row(self, rowdata):
def _get_row(self, rowdata):
"""
Returns rows given ``rowdata`` properly formated for restructured text tables.
"""
Expand All @@ -158,19 +163,19 @@ def process_table_content(self):
# Compare cell widths of the header with the
# max cell widths stored in the global var tempcolumnwidths
# and swap out value(s) if necessary.
if self.header is not None:
self.check_column_width(self.header)
if self.table.header is not None:
self._check_column_width(self.table.header)

for index in range(len(self.rows['rows'])):
for index in range(len(self.table.rows)):
parsed_row = []

# Append each cell to the parsed_row list, breaking multi-line
# cell data as needed.
for cell in self.rows['rows'][index][index + 1]:
for cell in self.table.rows[index][index + 1]:
parsed_row.append(cell.split('\n'))

# process the data to ensure the table is big enough.
self.check_column_width(parsed_row)
self._check_column_width(parsed_row)
normalize_cell_height(parsed_row)

# add the processed data to the table
Expand All @@ -183,22 +188,22 @@ def process_table_content(self):

def render_table(self):
o = []
o.append(self.get_row_line())
o.append(self._get_row_line())

if self.header is not None:
o.append(self.get_row(self.header))
o.append(self.get_row_line('='))
if self.table.header is not None:
o.append(self._get_row(self.table.header))
o.append(self._get_row_line('='))

for self.row in self.tabledata:
o.append(self.get_row(self.row))
o.append(self.get_row_line())
for row in self.tabledata:
o.append(self._get_row(row))
o.append(self._get_row_line())

return o

class ListTable(YamlTable):
class ListTable(OutputTable):
pass

class HtmlTable(YamlTable):
class HtmlTable(OutputTable):
pass

class TableBuilder(object):
Expand All @@ -221,22 +226,38 @@ def print_table(self):
#
# Interface.

def get_outputfile(inputfile, outputfile):
if outputfile is None:
return inputfile.rsplit('.')[0] + '.rst'
else:
return outputfile

def user_input(formats):
parser = argparse.ArgumentParser('YAML to (RST/HTML) Table Builder')
parser.add_argument('input', nargs='?', help='path of source yaml file.')

output_help = 'path of output file. by default, the input file name with an ".rst" extension.'
parser.add_argument('output', nargs='?', default=None, help=output_help)
parser.add_argument('--type', '-t', choices=formats, default='rst',
help='output table format.')

return parser.parse_args()

def main():
# the following is a total hack to avoid argparse. first argument
# is input, second is output. we'll have to break down and use
# argparse if we want any other options, just for sanity.
formats = { 'rst': RstTable,
'list': ListTable,
'html': HtmlTable }

ui = user_input(formats.keys())

inputfile = sys.argv[1]
table_data = YamlTable(ui.input)

try:
outputfile = sys.argv[2]
except IndexError:
outputfile = get_default_outputfile(inputfile)
if table_data.format is None:
table_data.format = ui.type

table = RstTable(inputfile)
output = TableBuilder(table)
table = TableBuilder(formats[table_data.format](table_data))

output.write(outputfile)
table.write(get_outputfile(ui.input, ui.output))

if __name__ == '__main__':
main()
8 changes: 4 additions & 4 deletions source/release-notes/2.4-index-types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ did not exist. In these situations, MongoDB would create an ascending
strings that do not refer to an existing index type, and all numbers
other than ``1`` and ``-1``. [#grandfathered-indexes]_

In 2.4, after you create the first ``2dsphere`` or ``text`` index,
creating any invalid index will result in an error. Furthermore, you
cannot create a ``2dsphere`` or ``text`` index if your databases have
any invalid index types. [#grandfathered-indexes]_
In 2.4, creating any invalid index will result in an error.
Furthermore, you cannot create a ``2dsphere`` or ``text`` index on a
collection if its containing database has any invalid index types.
[#grandfathered-indexes]_

.. [#grandfathered-indexes] In 2.4, indexes that specify a type of
``"1"`` or ``"-1"`` (the strings ``"1"`` and ``"-1"``) will continue
Expand Down
4 changes: 0 additions & 4 deletions source/release-notes/2.4-upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,6 @@ Considerations and Compatibility
If you upgrade to MongoDB 2.4, and then need to run MongoDB 2.2 with
the same data files, consider the following limitations.

- ``2dsphere`` and ``text`` indexes do not exist in 2.2. If you
downgrade to 2.2, you cannot use these indexes in 2.2. and you will
need to rebuild these indexes if you later upgrade to 2.4.

- If you use a ``hashed`` index as the shard key index, which is only
possible under 2.4 you will not be able to query data in this
sharded collection. Furthermore, a 2.2 :program:`mongos` cannot
Expand Down
21 changes: 9 additions & 12 deletions source/tutorial/install-mongodb-on-debian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ configuration and operation.

.. note::

If you're running a version of Ubuntu Linux prior to 9.10 "Karmic,"
use this tutorial. Other Ubuntu users will want to follow
the :doc:`/tutorial/install-mongodb-on-ubuntu` tutorial.
This tutorial applies to both Debian systems and versions of Ubuntu
Linux prior to 9.10 "Karmic" which do not use Upstart. Other Ubuntu
users will want to follow the :doc:`/tutorial/install-mongodb-on-ubuntu`
tutorial.

.. seealso:: The documentation of following related processes and
concepts.

Other installation tutorials:
.. see:: Additional installation tutorials:

- :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux`
- :doc:`/tutorial/install-mongodb-on-ubuntu`
Expand All @@ -46,12 +44,11 @@ Package Options
---------------

The 10gen repository provides the ``mongodb-10gen`` package,
which contains the latest **stable** release. Use this for production
deployments. Additionally you can :ref:`install previous
releases <install-debian-version-pinning>` of MongoDB.
which contains the latest **stable** release. Additionally you can
:ref:`install previous releases <install-debian-version-pinning>` of MongoDB.

You cannot install these packages concurrently with each other or with
the ``mongodb`` package that your release of Debian may include.
You cannot install this package concurrently with the ``mongodb`` package that
your release of Debian may include.

Installing MongoDB
------------------
Expand Down
5 changes: 1 addition & 4 deletions source/tutorial/install-mongodb-on-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ that provides a simple option for users who cannot use packages. This
tutorial outlines the basic installation of MongoDB using these
compiled versions and an initial usage guide.

.. seealso:: The documentation of following related processes and
concepts.

Other installation tutorials:
.. see:: Additional installation tutorials:

- :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux`
- :doc:`/tutorial/install-mongodb-on-ubuntu`
Expand Down
5 changes: 1 addition & 4 deletions source/tutorial/install-mongodb-on-os-x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ main methods of installing the MongoDB server
community package management tools, and second using builds of MongoDB
provided by 10gen.

.. seealso:: The documentation of following related processes and
concepts.

Other installation tutorials:
.. see:: Additional installation tutorials:

- :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux`
- :doc:`/tutorial/install-mongodb-on-ubuntu`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ instructions for configuring the package manager, the process install
packages from the 10gen repository, and preliminary MongoDB
configuration and operation.

.. seealso:: The documentation of following related processes and
concepts.

Other installation tutorials:
.. see:: Additional installation tutorials:

- :doc:`/tutorial/install-mongodb-on-debian-or-ubuntu-linux`
- :doc:`/tutorial/install-mongodb-on-debian`
Expand All @@ -48,15 +45,15 @@ The 10gen repository contains two packages:
This package contains the :program:`mongod` and :program:`mongos`
daemons from the latest **stable** release and associated
configuration and init scripts. Additionally, you can use this
package to :ref:`install tools from a previous release
package to :ref:`install daemons from a previous release
<install-rhel-version-pinning>` of MongoDB.

- ``mongo-10gen``

By default, this package contains all MongoDB tools from latest
**stable** release and you can use this package to :ref:`install
previous releases <install-rhel-version-pinning>` of
MongoDB. Install this package on all production MongoDB hosts and
This package contains all MongoDB tools from the latest **stable**
release. Additionally, you can use this package to :ref:`install tools from a previous
release <install-rhel-version-pinning>` of MongoDB.
Install this package on all production MongoDB hosts and
optionally on other systems from which you may need to administer
MongoDB systems.

Expand Down
16 changes: 6 additions & 10 deletions source/tutorial/install-mongodb-on-ubuntu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This tutorial outlines the basic installation process for installing
:term:`MongoDB` on Ubuntu Linux systems. This tutorial uses
``.deb`` packages as the basis of the installation. 10gen publishes
packages of the MongoDB releases as ``.deb`` packages for easy
installation and management for users of Ubuntu systems. Ubuntu does
installation and management for users of Ubuntu systems. Although Ubuntu does
include MongoDB packages, the 10gen
packages are generally more up to date.

Expand All @@ -26,10 +26,7 @@ configuration and operation.
version before 9.10 "Karmic") please follow the instructions on the
:doc:`install-mongodb-on-debian` tutorial.

.. seealso:: The documentation of following related processes and
concepts.

Other installation tutorials:
.. see:: Additional installation tutorials:

- :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux`
- :doc:`/tutorial/install-mongodb-on-debian`
Expand All @@ -46,12 +43,11 @@ Package Options
---------------

The 10gen repository provides the ``mongodb-10gen`` package,
which contains the latest **stable** release. Use this for production
deployments. Additionally you can :ref:`install previous
releases <install-ubuntu-version-pinning>` of MongoDB.
which contains the latest **stable** release. Additionally you can
:ref:`install previous releases <install-ubuntu-version-pinning>` of MongoDB.

You cannot install these packages concurrently with each other or with
the ``mongodb`` package that your release of Ubuntu may include.
You cannot install this package concurrently with the ``mongodb`` package
provided by Ubuntu.

Installing MongoDB
------------------
Expand Down