cli: allow username to be passed in

This is necessary for authentication schemes on the backend (LDAP, etc.).

Changes from v1:
 * Fixed unittests

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
cli/autotest-rpc-migrate-host: Fix host migration script

This script was broken - using wrong web_server parameter when calling
frontend.AFE; also added user that can be specified on the command line
and removed the code that deletes the host from original server -
it is easy to do using other means but there are use cases when one
might want to keep it.

Signed-off-by: Julius Gawlas <julius.gawlas@hp.com>
set the username that is passed to rpc based on options

set the username for rpc call based on --username passed
in command arguments, also added a unit test

Signed-off-by: Julius Gawlas <julius.gawlas@hp.com>
Acked-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
contrib/site_rpc_client_lib: provide authorization_headers that allow authentication

In my environment, I am authenticating users against an LDAP server. The CLI
does not currently allow users to authenticate, though, so provide an example
site_rpc_client_lib that does.

Changes from v1:
     * Moved authorship info from __author__ attribute to docstring.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
pkgdeps: Add protobuf-python to the list of packages

We missed that dependency to build the tko_pdb2 module
properly on both Fedora and Ubuntu.

CC: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
tko/job_serializer: Improve install dependencies notes

Make a generic mention of the packages needed to run
the unittest appropriately, rather than mentioning
specifics. Also, point out the install dependencies
script, that will install the right packages for
Ubuntu and Fedora at this point.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
tko/job_serializer_unittest.py: Print better error message

Print a more helpful message when the system lacks
the dependencies needed to run this unittest.

CC: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client/job.py: parameterize the sleep time before reboot

Some older machines are taking longer than 5 seconds to sync before
reboot.  To accomodate these machines the sleep time is parameterized.
The default sleep time is 5 seconds, but if additional time is needed,
the sleep_before_reboot variable in global_config.ini can be adjusted
to allow for more time.

Fixed the sleep command so that it is compatible with python 2.4.

Signed-off-by: Cheri Van Pelt <cheri.vanpelt@hp.com>
Tested-by: Julius Gawlas <julius.gawlas@hp.com>
unittest_suite: fix --skip-tests

skip-tests current fails to run correctly, because the list type has no
"update" method. Change it to just a straight assignemnt.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
unittest_suite: match skipped tests by name not file name

Strip off .py from the possible filename to see if it needs to be
skipped. It seems rather user-unfriendly to require the user to know to
add the suffix, especially when the output doesn't include it.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
kernelexpand_unittest: override local configuration

If an end-user has configured a local gitweb source or kernel mirrors,
this can lead to the unittest failing, because the tests assume the
settings are the default ones (for comparison to the expected results).
Fix this by overriding the settings values with the default ones.
Without this change, the unittest always fails with local gitweb/mirror
configuration.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
frontend/afe: fix sort when metahosts are selected

When we sort by a column in the selected table, we assume the objects in
the table have certain properties. However, the meta-host objects have
the wrong names for those properties.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
afe/HostSelector: add "id" to metaObjects

A following change will rely on all objects in the selectedHostData to
have an "id" property to guarantee a way to identify them when rows are
clicked.  Meta-host objects don't have one, so add one that starts
(effectively) at -1 and decrements. This should avoid collisions with
the actual host objects, which all have positive ids.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
frontend/afe: fix bug with profile selection in create job

There is a bug in the onClick handler in SelectionManager. We assume the
row index is 1:1 with the available table objects. However, this is not
true in two cases, at least:

1) Re-sorting the table causes the "current" row to be sent in, but the
underlying object collection does not change its order.

2) When metahosts are added to the table, they are not present in the
available table.

We therefore end up altering arbitrary available host row objects, which
leads to eventual errors in execution.

To fix this, associated the "id" of the underlying row object with the
widget, and notify listeners onClick that a given "id" has been updated
to a given "profile". Add an implementation of the onClick handler in
HostSelector that updates the selectedHostData, looked-up by that "id".
Stop modifying the SelectionManager's row objects, which represent the
available table's rows.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
frontend/afe: add support for meta-host objects to have associated profiles

Use an RPC call, just like for specific hosts, for finding all possible
profiles. We let the user shoot themselves in the foot (that is, they
might select a profile that doesn't apply to that server), but that's
the nature of selecting by label -- unless the label is a platform, we
won't be able to do the lookup anyways in the install server.

Changes from v1:
 * Fix up various parameters in the RPC interfaces to be lists rather than
   tuples.
 * Fix-up unittests to pass in lists rather than tuples.
 * Fix logging exception.
 * Fix monitor_db.py call of create_new_job.
 * Fix indentation issue.
 * Refactor code so install server is available for get_num_profiles().

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
frontend/afe: fix one-time-hosts and profile selection

Similar to meta-hosts, populate the one-time host object, but use a
"N/A" profile only, as there's no guarantee the host exists in the
install server.  Also add entries for the other fields needed for table
sorting to work.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
frontend/install_server: remove filter in profile look-up

Depending on your environment, you may not have access to Cobbler to
always manipulate the profile comments. Also, you may not want to ever
limit the user from selecting a profile, and the filtered search is
slower than just grabbing them all. So, for now, simply grab all defined
profiles.

Eventually (working on it now), we should provide an extensible way to
filter the profiles.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
control files: always reinstall hosts

Locally, I always want to reinstall hosts when I run a job. I imagine
others might also like this. Given that reinstallation depends on
profile availability (of which, "Do_not_install" and "N/A" are valid
depending on the configuration), we can just always reinstall in the
client and server control file templates.

Changes from v1:
 * Fix-up the unit-tests.
 * Adjust machine_install to no throw an exception if no install server is
   configured (just becomes a no-op)

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
migrations: Fix no newline at the end of file
database_legacy: Finish module rename

Some of the files in database_legacy refer to the libs
in that dir, with the rename the files got broken. Let's
fix it.

CC: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>