Python client/server for managing a pool of Bare Metal machines.
Go to file
Mark Hamzy 24bf07c892 Fix --output=json so that it prints out JSON
The program was actually printing out a Python map variable
instead.

Change-Id: I6802bdac30a915f9643164fe6bbb5136844900e7
2016-11-01 14:00:34 -05:00
doc/source Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
molteniron Fix --output=json so that it prints out JSON 2016-11-01 14:00:34 -05:00
releasenotes Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
utils Add Continuous Integration (CI) example 2016-10-13 10:28:40 -05:00
.gitreview Add .gitreview file 2016-10-21 13:28:39 +00:00
CONTRIBUTING.rst Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
HACKING.rst Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
LICENSE Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
MANIFEST.in Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
README.rst Update documentation for how to configure your machine for a clean install 2016-10-29 19:35:15 -05:00
babel.cfg Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
conf.yaml Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
createDB.py Support both Python 2.x and Python 3.x 2016-10-27 10:45:29 -05:00
requirements.txt Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
setup.cfg Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
setup.py Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
test-requirements.txt Add files that were created running Python's cookiecutter program 2016-10-27 10:18:47 -05:00
tox.ini Enable testcases 2016-10-28 07:44:13 -05:00

README.rst

MoltenIron overview

MoltenIron maintains a pool of bare metal nodes.

Installation

With a clean installation of an Ununtu system, do the following::

ubuntu@hamzy-test:~$ sudo apt-get install -y build-essential python-dev python3-dev libmysqlclient-dev tox python2.7 python3.5 mysql-server

If you see::

E: Unable to locate package tox

then remove tox and reinstall. Next. do the following::

ubuntu@molten-iron:~$ sudo pip install --upgrade tox

Next, check out the MoltenIron project::

ubuntu@hamzy-test:~$ git clone git://git.openstack.org/openstack/molteniron.git ubuntu@hamzy-test:~$ cd molteniron/

Before you can install the package requirements, you may need to install a prerequisite::

ubuntu@molten-iron:~/molteniron$ hash mysql_config || sudo apt install -y libmysqlclient-dev

Then install the package requirements::

ubuntu@hamzy-test:~/molteniron$ sudo pip install --upgrade --force-reinstall --requirement requirements.txt

Before starting the server for the first time, the createDB.py script must be run as follows:: ubuntu@hamzy-test:~/molteniron$ createDB.py

You can run the suite of testcases to make sure everything works::

ubuntu@molten-iron:~/molteniron$ (rm -rf .tox/py27/ testenv/; tox -epy27)

Starting

To start the server:

moltenirond-helper start

To stop the server:

moltenirond-helper stop

MoltenIron client

Use the molteniron client (molteniron) to communicate with the server. For usage information type:

molteniron -h

For usage of a specific command use:

molteniron [command] -h

MoltenIron commands

command description
add Add a node
allocate Allocate a node
release Release a node
get_field Get a specific field in a node
set_field Set a specific field with a value in a node
status Return the status of every node
delete_db Delete every database entry

Configuration of MoltenIron

Configuration of MoltenIron is specified in the file conf.yaml.

"Both" means that this configuration option is required for both the client and the server. "Client" means that it is required only for the client. "Server" means it is only required for the server.

usage key description
Both mi_port the port that the server uses to respond to commands.
Client serverIP The IP address of the server. This is only used by clients.
Server maxTime The maximum amount of time, in seconds, that a node is allowed to be allocated to a particular BM node.
Server logdir The path to the directory where the logs should be stored.
Server maxLogDays The amount of time, in days, to keep old logs.
Server sqlUser The username to use for the MI server. This user will automatically be generated when createDB.py is run.
Server sqlPass The password of sqlUser

Running testcases

The suite of testcases is checked by tox. But, before you can run tox, you need to change the local yaml configuration file to point to the log directory. An example:

(LOG=$(pwd)/testenv/log; sed -i -r -e 's,^(logdir: )(.*)$,\1'${LOG}',' conf.yaml; rm -rf testenv/; tox -e testenv)

Running inside a Continuous Integration environment

During the creation of a job, in the pre_test_hook.sh, add the following snippet of bash code:

# Setup MoltenIron and all necessary prerequisites.
# And then call the MI script to allocate a node.
(
  REPO_DIR=/opt/stack/new/molteniron
  MI_CONF_DIR=/usr/local/etc/molteniron
  MI_IP=10.1.2.3     # @TODO - Replace with your IP addr here!
  MI_SQLUSER=user    # @TODO - Replace with your mysql user here!
  MI_SQLPASS=passwd  # @TODO - Replace with your mysql password here!

  # Grab molteniron and install it
  git clone https://git.openstack.org/openstack/molteniron ${REPO_DIR} || exit 1

  cd ${REPO_DIR}

  # @BUG Install prerequisite before running pip to install the requisites
  hash mysql_config || sudo apt install -y libmysqlclient-dev

  # Install the requisites for this package
  sudo pip install --upgrade --force-reinstall --requirement requirements.txt

  # Run the python package installation program
  sudo python setup.py install

  if [ -n "${MI_IP}" ]
  then
    # Set the molteniron server IP in the conf file
    sudo sed -i "s/127.0.0.1/${MI_IP}/g" ${MI_CONF_DIR}/conf.yaml
  fi

  if [ -n "${MI_SQLUSER}" ]
  then
    # Set the molteniron database user in the conf file
    sudo sed -r -i -e 's,(^sqlUser: ")([a-zA-Z_]+)("$),\1'${MI_SQLUSER}'\3,' ${MI_CONF_DIR}/conf.yaml
  fi

  if [ -n "${MI_SQLPASS}" ]
  then
    # Set the molteniron database password in the conf file
    sudo sed -r -i -e 's,(^sqlPass: ")([a-zA-Z_]+)("$),\1'${MI_SQLPASS}'\3,' ${MI_CONF_DIR}/conf.yaml
  fi

  export dsvm_uuid
  # NOTE: dsvm_uuid used in the following script, hence the -E
  sudo -E ${REPO_DIR}/utils/test_hook_configure_mi.sh
) || exit $?

and change the MI_IP environment variable to be your MoltenIron server!

During the destruction of a job, in the post_test_hook.sh, add the following snippet of bash code:

DSVM_UUID="$(</etc/nodepool/uuid)"
echo "Cleaning up resources associated with node: ${DSVM_UUID}"
molteniron release ${DSVM_UUID}