<commit_before>Dependencies: 
=============
There are a few things that HaaS expects the operating system to have::

  yum install bridge-utils
  yum install gcc
  yum install httpd
  yum install ipmitool
  yum install libvirt
  yum install libxml2-devel
  yum install libxslt-devel 
  yum install mod_wsgi
  yum install net-tools
  yum install python-pip
  yum install python-psycopg2
  yum install python-virtinst
  yum install python-virtualenv
  yum install qemu-kvm
  yum install telnet
  yum install vconfig
  yum install virt-install


HaaS also expects there to be a database.  Currently, HaaS supports SQLite and PostgreSQL.  Details to setup a database can be found in `INSTALL.rst <INSTALL.rst>`_

Getting Started:
================
First you will need to fork and clone the HaaS repo into your dev VM.::

  git clone https://github.com/**username**/haas.git
  cd haas


The first time you start working in the repository, set up a clean test
environment::

  virtualenv .venv

Enter the environment (do this each time start)::

  source .venv/bin/activate

Then, proceed with installing the HaaS and its dependencies into the virtual
environment::

  sudo python setup.py install
  pip install -e .


For older systems:
==================

On systems with older versions of ``pip``, such as Debian Wheezy and Ubuntu
12.04, this install will fail with the following error::

  AttributeError: 'NoneType' object has no attribute 'skip_requirements_regex'

Fix this by upgrading ``pip`` within the virtual environment::

  pip install --upgrade pip

Versions of python prior to 2.7 don't have importlib as part of their
standard library, but it is possible to install it separately. If you're
using python 2.6 (which is what is available on CentOS 6, for example),
you may need to run::

  pip install importlib


Setting up the Database:
========================
By default dev environment uses SQLite as a database, so if you're using it you can skip this section.

If you wish to use postgreSQL instead, you may get an error ``psycopg2 package not found``.
  
When you do ``haas-admin db create`` in the next step, you may need to install 
following package on your system 

CentOS::  

  yum install postgresql-devel

Ubuntu::
  
  sudo apt-get install libpq-dev

before installing ``psycopg2`` in the virtualenv for HaaS::

  pip install psycopg2

After this follow instructions provided in `Install_configure_postgreSQL_CENTOS7.md <Install_configure_postgreSQL_CENTOS7.md>`_

Configuring HaaS
================

Now the ``haas`` executable should be in your path.  First, create a
configuration file ``haas.cfg``. There are two examples for you to work from,
``examples/haas.cfg.dev-no-hardware``, which is oriented towards development, and
``examples/haas.cfg`` which is more production oriented.  These config
files are well commented; read them carefully.

HaaS can be configured to not perform state-changing operations on nodes,
headnodes and networks, allowing developers to run and test parts of a haas
server without requiring physical hardware. To suppress actual node and headnode
operations, set ``dry_run = True`` in the ``[devel]`` section. For suppressing
actual network switch operations, use the ``mock`` switch driver.

Next initialize the database with the required tables::

  haas-admin db create
  
Run the server with 

  haas serve 
  
and in a separate window terminal

  haas serve_networks
  
Finally, ``haas help`` lists the various API commands one can use.
Here is an example session, testing ``headnode_delete_hnic``::

  haas project_create proj
  haas headnode_create hn proj
  haas headnode_create_hnic hn hn-eth0
  haas headnode_delete_hnic hn hn-eth0

Additionally, before each commit, run the automated test suite with ``py.test<commit_msg>Provides explicit instructions on setting HaaS dev env.<commit_after>Dependencies: 
=============
There are a few things that HaaS expects the operating system to have::

  yum install bridge-utils  gcc  httpd  ipmitool libvirt libxml2-devel  libxslt-devel  mod_wsgi \
  net-tools python-pip python-psycopg2 python-virtinst python-virtualenv qemu-kvm telnet vconfig virt-install


HaaS also expects there to be a database.  Currently, HaaS supports SQLite and PostgreSQL.  For instruction to set up a database see section ''Setting up the Database''


Getting Started:
================
First you will need to fork and clone the HaaS repo into your dev VM.::

  git clone https://github.com/**username**/haas.git
  cd haas


The first time you start working in the repository, set up a clean test
environment::

  virtualenv .venv

Enter the environment (do this every time you start working with HaaS dev environment)::

  source .venv/bin/activate

Then, proceed with installing the HaaS and its dependencies into the virtual
environment::

  sudo python setup.py install
  pip install -e .


For older systems:
==================

On systems with older versions of ``pip``, such as Debian Wheezy and Ubuntu
12.04, this install will fail with the following error::

  AttributeError: 'NoneType' object has no attribute 'skip_requirements_regex'

Fix this by upgrading ``pip`` within the virtual environment::

  pip install --upgrade pip

Versions of python prior to 2.7 don't have importlib as part of their
standard library, but it is possible to install it separately. If you're
using python 2.6 (which is what is available on CentOS 6, for example),
you may need to run::

  pip install importlib


Setting up the Database:
========================
By default dev environment uses SQLite as a database, so if you're using it you can skip this section.

If you wish to use postgreSQL instead, you may get an error ``psycopg2 package not found``.
  
When you do ``haas-admin db create`` in the next step, you may need to install 
following package on your system 

CentOS::  

  yum install postgresql-devel

Ubuntu::
  
  sudo apt-get install libpq-dev

before installing ``psycopg2`` in the virtualenv for HaaS::

  pip install psycopg2

After this follow instructions provided in `Install_configure_postgreSQL_CENTOS7.md <Install_configure_postgreSQL_CENTOS7.md>`_

Configuring HaaS
================

Now the ``haas`` executable should be in your path.  First, create a
configuration file ``haas.cfg``. There are two examples for you to work from,
``examples/haas.cfg.dev-no-hardware``, which is oriented towards development, and
``examples/haas.cfg`` which is more production oriented.  These config
files are well commented; read them carefully.

HaaS can be configured using ``haas.cfg`` to not perform state-changing operations on nodes,
headnodes and networks, allowing developers to run and test parts of a haas
server without requiring physical hardware. To suppress actual node and headnode
operations, set ``dry_run = True`` in the ``[devel]`` section. 

Most customization require including directives under section ``[extensions]``

For suppressing actual network switch operations, use the ``mock`` switch driver :: 
  haas.ext.switches.mock =

You can choose to disable authentication mechanism by setting::
  haas.ext.auth.null =

To enable authentication mechanism, set appropriate authentication backend.
Authentication directives are mutually exclusive. To choose database as an 
authentication backend::
  haas.ext.auth.database =


Next initialize the database with the required tables::

  haas-admin db create
  
Run the server with the port number as defined in ``haas.cfg``

  haas serve <port no> 
  
and in a separate window terminal

  haas serve_networks
  
Finally, ``haas help`` lists the various API commands one can use.
Here is an example session, testing ``headnode_delete_hnic``::

  haas project_create proj
  haas headnode_create hn proj
  haas headnode_create_hnic hn hn-eth0
  haas headnode_delete_hnic hn hn-eth0

Additionally, before each commit, run the automated test suite with ``py.test
{'fraction_non_alphanumeric': 0.07873817034700316, 'fraction_numerical': 0.004542586750788643, 'mean_word_length': 4.399182561307902, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3181430', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2145, 'n_words': 1049}