<commit_before>Basic Deployment (CLI)
======================

With these few steps you will be able to simply deploy RDO to your environment
using our defaults in a few steps.


Prepare Your Environment
------------------------

#. Make sure you have your environment ready and undercloud running:

   * :doc:`../environments/environments`
   * :doc:`../installation/installing`

#. Log into your undercloud (instack) virtual machine as non-root user::

    ssh root@<rdo-manager-machine>

    su - stack

#. In order to use CLI commands easily you need to source needed environment
   variables::

    source stackrc


Get Images
----------

.. note::

       If you already have images built, perhaps from a previous installation of
       RDO Manager, you can simply copy those image files into your regular user's
       home directory and skip this section.

       If you do this, be aware that sometimes newer versions of RDO Manager do not
       work with older images, so if the deployment fails it may be necessary to
       delete the older images and restart the process from this step.

       The image files required are::

           deploy-ramdisk-ironic.initramfs
           deploy-ramdisk-ironic.kernel
           discovery-ramdisk.initramfs
           discovery-ramdisk.kernel
           overcloud-full.initrd
           overcloud-full.qcow2
           overcloud-full.vmlinuz

Images must be built prior to doing a deployment. A discovery ramdisk,
deployment ramdisk, and openstack-full image can all be built using
instack-undercloud.

It's recommended to build images on the installed undercloud directly since all
the dependencies are already present.

The following steps can be used to build images. They should be run as the same
non-root user that was used to install the undercloud.


#. Choose image operating system:

   The built images will automatically have the same base OS as the
   running undercloud. To choose a different OS use one of the following
   commands (make sure you have your OS specific content visible):

   .. admonition:: CentOS
      :class: centos

      ::

          export NODE_DIST=centos7

   .. admonition:: RHEL
      :class: rhel

      ::

          export NODE_DIST=rhel7


#. Build the required images:

   .. only:: internal

      .. admonition:: RHEL
         :class: rhel

         Download the RHEL 7.1 cloud image or copy it over from a different location,
         and define the needed environment variable for RHEL 7.1 prior to running
         ``openstack overcloud image build --all``::

             IMAGE=http://download.devel.redhat.com/brewroot/packages/rhel-guest-image/7.1/20150224.0/images/rhel-guest-image-7.1-20150224.0.x86_64.qcow2
             curl -O $IMAGE
             export DIB_LOCAL_IMAGE=`basename $IMAGE`
             # Enable RHOS
             export USE_DELOREAN_TRUNK=0
             export RHOS=1
             export DIB_YUM_REPO_CONF="/etc/yum.repos.d/rhos-release-7-director-rhel-7.1.repo /etc/yum.repos.d/rhos-release-7-rhel-7.1.repo"

   .. only:: external

    .. admonition:: RHEL
       :class: rhel

       Download the RHEL 7.1 cloud image or copy it over from a different location,
       for example:
       https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.1/x86_64/product-downloads,
       and define the needed environment variables for RHEL 7.1 prior to running
       ``openstack overcloud image build --all``::

            export DIB_LOCAL_IMAGE=rhel-guest-image-7.1-20150224.0.x86_64.qcow2

    .. admonition:: RHEL Portal Registration
       :class: portal

       To register the image builds to the Red Hat Portal define the following variables::

              export REG_METHOD=portal
              export REG_USER="[your username]"
              export REG_PASSWORD="[<PASSWORD>]"
              # Find this with `sudo subscription-manager list --available`
              export REG_POOL_ID="[pool id]"
              export REG_REPOS="rhel-7-server-rpms rhel-7-server-extras-rpms rhel-ha-for-rhel-7-server-rpms \
                  rhel-7-server-optional-rpms rhel-7-server-openstack-6.0-rpms"

    .. admonition:: RHEL Satellite Registration
       :class: satellite

       To register the image builds to a Satellite define the following
       variables. Only using an activation key is supported when registering to
       Satellite, username/password is not supported for security reasons. The
       activation key must enable the repos shown::

              export REG_METHOD=satellite
              # REG_SAT_URL should be in the format of:
              # http://<satellite-hostname>
              export REG_SAT_URL="[satellite url]"
              export REG_ORG="[satellite org]"
              # Activation key must enable these repos:
              # rhel-7-server-rpms
              # rhel-7-server-optional-rpms
              # rhel-7-server-extras-rpms
              # rhel-7-server-openstack-6.0-rpms
              export REG_ACTIVATION_KEY="[activation key]"

 .. note ::
    By default, images are built with the latest RDO-Manager Trunk repo which has passed CI. If you need to manually test packages before CI has passed, you can use:

    ::

      export DELOREAN_TRUNK_MGT_REPO="http://trunk-mgt.rdoproject.org/centos-kilo/current"

 ::

   openstack overcloud image build --all


 .. note::
    This script will build **overcloud-full** images (\*.qcow2, \*.initrd,
    \*.vmlinuz), **deploy-ramdisk-ironic** images (\*.initramfs, \*.kernel),
    **discovery-ramdisk** images (\*.initramfs, \*.kernel) and **testing**
    fedora-user.qcow2 (which is always Fedora based).


Upload Images
-------------

Load the images into the undercloud Glance::

    openstack overcloud image upload


Register Nodes
--------------

Register nodes for your deployment with Ironic::

    openstack baremetal import --json instackenv.json

.. note::
   It's not recommended to delete nodes and/or rerun this command after
   you have proceeded to the next steps. Particularly, if you start introspection
   and then re-register nodes, you won't be able to retry introspection until
   the previous one times out (1 hour by default). If you are having issues
   with nodes after registration, please follow
   :ref:`node_registration_problems`.

.. note::
   By default Ironic will not sync the power state of the nodes,
   because in our HA (high availability) model Pacemaker is the
   one responsible for controlling the power state of the nodes
   when fencing.  If you are using a non-HA setup and want Ironic
   to take care of the power state of the nodes please change the
   value of the "force_power_state_during_sync" configuration option
   in the /etc/ironic/ironic.conf file to "True" and restart the
   openstack-ironic-conductor service.

   Also, note that if "openstack undercloud install" is re-run the value
   of the "force_power_state_during_sync" configuration option will be
   set back to the default, which is "False".

Assign kernel and ramdisk to nodes::

    openstack baremetal configure boot


Introspect Nodes
----------------

Introspect hardware attributes of nodes::

    openstack baremetal introspection bulk start

.. note:: **Introspection has to finish without errors.**
   The process can take up to 5 minutes for VM / 15 minutes for baremetal. If
   the process takes longer, see :ref:`introspection_problems`.


Create Flavors
--------------

Create the necessary flavor::

    openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal
    openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal

Configure a nameserver for the Overcloud
----------------------------------------

Overcloud nodes need to have a configured nameserver so that they can resolve
hostnames via DNS. The nameserver is defined in the undercloud's neutron
subnet. Define the nameserver to be used for the environment::

    # List the available subnets
    neutron subnet-list
    neutron subnet-update <subnet-uuid> --dns-nameserver <nameserver-ip>
<commit_msg>Document how to introspect one node<commit_after>Basic Deployment (CLI)
======================

With these few steps you will be able to simply deploy RDO to your environment
using our defaults in a few steps.


Prepare Your Environment
------------------------

#. Make sure you have your environment ready and undercloud running:

   * :doc:`../environments/environments`
   * :doc:`../installation/installing`

#. Log into your undercloud (instack) virtual machine as non-root user::

    ssh root@<rdo-manager-machine>

    su - stack

#. In order to use CLI commands easily you need to source needed environment
   variables::

    source stackrc


Get Images
----------

.. note::

       If you already have images built, perhaps from a previous installation of
       RDO Manager, you can simply copy those image files into your regular user's
       home directory and skip this section.

       If you do this, be aware that sometimes newer versions of RDO Manager do not
       work with older images, so if the deployment fails it may be necessary to
       delete the older images and restart the process from this step.

       The image files required are::

           deploy-ramdisk-ironic.initramfs
           deploy-ramdisk-ironic.kernel
           discovery-ramdisk.initramfs
           discovery-ramdisk.kernel
           overcloud-full.initrd
           overcloud-full.qcow2
           overcloud-full.vmlinuz

Images must be built prior to doing a deployment. A discovery ramdisk,
deployment ramdisk, and openstack-full image can all be built using
instack-undercloud.

It's recommended to build images on the installed undercloud directly since all
the dependencies are already present.

The following steps can be used to build images. They should be run as the same
non-root user that was used to install the undercloud.


#. Choose image operating system:

   The built images will automatically have the same base OS as the
   running undercloud. To choose a different OS use one of the following
   commands (make sure you have your OS specific content visible):

   .. admonition:: CentOS
      :class: centos

      ::

          export NODE_DIST=centos7

   .. admonition:: RHEL
      :class: rhel

      ::

          export NODE_DIST=rhel7


#. Build the required images:

   .. only:: internal

      .. admonition:: RHEL
         :class: rhel

         Download the RHEL 7.1 cloud image or copy it over from a different location,
         and define the needed environment variable for RHEL 7.1 prior to running
         ``openstack overcloud image build --all``::

             IMAGE=http://download.devel.redhat.com/brewroot/packages/rhel-guest-image/7.1/20150224.0/images/rhel-guest-image-7.1-20150224.0.x86_64.qcow2
             curl -O $IMAGE
             export DIB_LOCAL_IMAGE=`basename $IMAGE`
             # Enable RHOS
             export USE_DELOREAN_TRUNK=0
             export RHOS=1
             export DIB_YUM_REPO_CONF="/etc/yum.repos.d/rhos-release-7-director-rhel-7.1.repo /etc/yum.repos.d/rhos-release-7-rhel-7.1.repo"

   .. only:: external

    .. admonition:: RHEL
       :class: rhel

       Download the RHEL 7.1 cloud image or copy it over from a different location,
       for example:
       https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.1/x86_64/product-downloads,
       and define the needed environment variables for RHEL 7.1 prior to running
       ``openstack overcloud image build --all``::

            export DIB_LOCAL_IMAGE=rhel-guest-image-7.1-20150224.0.x86_64.qcow2

    .. admonition:: RHEL Portal Registration
       :class: portal

       To register the image builds to the Red Hat Portal define the following variables::

              export REG_METHOD=portal
              export REG_USER="[your username]"
              export REG_PASSWORD="[<PASSWORD>]"
              # Find this with `sudo subscription-manager list --available`
              export REG_POOL_ID="[pool id]"
              export REG_REPOS="rhel-7-server-rpms rhel-7-server-extras-rpms rhel-ha-for-rhel-7-server-rpms \
                  rhel-7-server-optional-rpms rhel-7-server-openstack-6.0-rpms"

    .. admonition:: RHEL Satellite Registration
       :class: satellite

       To register the image builds to a Satellite define the following
       variables. Only using an activation key is supported when registering to
       Satellite, username/password is not supported for security reasons. The
       activation key must enable the repos shown::

              export REG_METHOD=satellite
              # REG_SAT_URL should be in the format of:
              # http://<satellite-hostname>
              export REG_SAT_URL="[satellite url]"
              export REG_ORG="[satellite org]"
              # Activation key must enable these repos:
              # rhel-7-server-rpms
              # rhel-7-server-optional-rpms
              # rhel-7-server-extras-rpms
              # rhel-7-server-openstack-6.0-rpms
              export REG_ACTIVATION_KEY="[activation key]"

 .. note ::
    By default, images are built with the latest RDO-Manager Trunk repo which has passed CI. If you need to manually test packages before CI has passed, you can use:

    ::

      export DELOREAN_TRUNK_MGT_REPO="http://trunk-mgt.rdoproject.org/centos-kilo/current"

 ::

   openstack overcloud image build --all


 .. note::
    This script will build **overcloud-full** images (\*.qcow2, \*.initrd,
    \*.vmlinuz), **deploy-ramdisk-ironic** images (\*.initramfs, \*.kernel),
    **discovery-ramdisk** images (\*.initramfs, \*.kernel) and **testing**
    fedora-user.qcow2 (which is always Fedora based).


Upload Images
-------------

Load the images into the undercloud Glance::

    openstack overcloud image upload


Register Nodes
--------------

Register nodes for your deployment with Ironic::

    openstack baremetal import --json instackenv.json

.. note::
   It's not recommended to delete nodes and/or rerun this command after
   you have proceeded to the next steps. Particularly, if you start introspection
   and then re-register nodes, you won't be able to retry introspection until
   the previous one times out (1 hour by default). If you are having issues
   with nodes after registration, please follow
   :ref:`node_registration_problems`.

.. note::
   By default Ironic will not sync the power state of the nodes,
   because in our HA (high availability) model Pacemaker is the
   one responsible for controlling the power state of the nodes
   when fencing.  If you are using a non-HA setup and want Ironic
   to take care of the power state of the nodes please change the
   value of the "force_power_state_during_sync" configuration option
   in the /etc/ironic/ironic.conf file to "True" and restart the
   openstack-ironic-conductor service.

   Also, note that if "openstack undercloud install" is re-run the value
   of the "force_power_state_during_sync" configuration option will be
   set back to the default, which is "False".

Assign kernel and ramdisk to nodes::

    openstack baremetal configure boot


Introspect Nodes
----------------

Introspect hardware attributes of nodes::

    openstack baremetal introspection bulk start

.. note:: **Introspection has to finish without errors.**
   The process can take up to 5 minutes for VM / 15 minutes for baremetal. If
   the process takes longer, see :ref:`introspection_problems`.

Introspecting a single node
^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can also introspect nodes one by one.
When doing so, you must take care to set the correct node states manually.
Use ``ironic node-show UUID`` command to figure out whether nodes are in
``manageable`` or ``available`` state. For all nodes in ``available`` state,
start with putting a node to ``manageable`` state::

    ironic node-set-provision-state UUID manage

Then you can run introspection::

    openstack baremetal introspection start UUID

This command won't poll for the introspection result, use the following command
to check the current introspection state::

    openstack baremetal introspection status UUID

Repeat it for every node until you see ``True`` in the ``finished`` field.
The ``error`` field will contain an error message if introspection failed,
or ``None`` if introspection succeeded for this node.

Do not forget to make nodes available for deployment afterwards::

    ironic node-set-provision-state UUID provide

Create Flavors
--------------

Create the necessary flavor::

    openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal
    openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal

Configure a nameserver for the Overcloud
----------------------------------------

Overcloud nodes need to have a configured nameserver so that they can resolve
hostnames via DNS. The nameserver is defined in the undercloud's neutron
subnet. Define the nameserver to be used for the environment::

    # List the available subnets
    neutron subnet-list
    neutron subnet-update <subnet-uuid> --dns-nameserver <nameserver-ip>

{'fraction_non_alphanumeric': 0.08943089430894309, 'fraction_numerical': 0.01173054587688734, 'mean_word_length': 2.6883701006639535, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211640', 'n_tokens_mistral': 4963, 'n_tokens_neox': 4590, 'n_words': 1866}