kernel: fix commit hash matching in need_to_install(), take 2

Commit 10d7f9095fbb ("kernel: fix commit hash matching in
need_to_install()") switched startswith() around to accommodate
a shorter "want" version.  That however broke the opposite case: when
installing from gitbuilders "want" is actually a full 40-char hash.
Do away with starswith() and just compare substrings.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: get_sha1_from_pkg_name()

Move package name parsing into its own routine and make the regex more
robust:
  - match only hex chars
  - don't limit ourselves to 7 chars, match up to 40 chars
  - accept 'g' prefixed with either _ (rpm) or - (deb)

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: gitbuilder_pkg_name(), remote_pkg_path()

In preparation for local rpm support, encapsulate package naming.
Using sudo to rm copied/downloaded package is not necessary.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: fix 'sha1: distro' vs per role configs

We may want to setup different kernels for different roles (as long as
all roles on the same node agree on their choice), so returning as soon
as 'distro' is seen is not right.  Also, no need to use find() as
'distro' is always an exact match.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: download_kernel() shouldn't install kernels

Stop using rpm http url capabilities and download packages ourselves.
This keeps the structure the same for both rpms and debs and makes it
possible to fit in local rpm support.  Drop the "rpm already installed"
check for the same reasons.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: get_image_version()

Use 'dpkg-deb -c' for debs instead of rolling our own.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: local rpm support

install_kernel() now takes a path to a package in /tmp and can use
get_image_version() to obtain image version.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: get_latest_image_version_{rpm, deb}()

A bit of refactoring to make things more clear and align distro case
with the rest of the code.  get_version_from_pkg() is renamed to
get_latest_image_version_deb() and get_latest_image_version_rpm() is
introduced to match it.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: maybe_generate_initrd_rpm()

gitbuilder and local packages may not have initrd hooks in them,
depending on how old is the kernel - an appropriate %post section was
added to upstream spec only in 3.12.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
kernel: add rpm: key

Add 'rpm:' key to not confuse people with stuff like

  kernel:
    deb: /path/to/foo.rpm

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
More logging in get_distro_from_downburst()

Signed-off-by: Zack Cerza <zack@redhat.com>
Properly ignore site-specific lab_domain in tests

Signed-off-by: Zack Cerza <zack@redhat.com>
kernel: update main docstring

Revise examples, document local kernel package support.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
Merge pull request #391 from ceph/wip-kernel-local-rpm

kernel: local rpm support
Fix TestResultsEmail

Signed-off-by: Zack Cerza <zack@redhat.com>
Respect --os-version and --os-type in teuthology.run.

Remove default value of 'ubuntu' for --os-type for teuthology.run and
make sure that teuthology.misc.get_distro accounts for ctx.os_type now
defaulting to None instead of 'ubuntu'.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
include the os_type in the log message when it's invalid

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
Clean up tests that were importing teuthology modules as teuthology to avoid confusion

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
There were two different code paths used to get the os_type and
os_version for bare metal machines and vps machines.  This moves
get_distro and get_distro_version back into teuthology.misc and uses
those functions to retrieve os_version and os_type for both bare metal
and vps machines.

When the bare metal machines weren't using get_distro for os_type it
would set os_type to None when there were was not a os_type in the
config or a --os-type flag given.  Now, os_type will be properly
defaulted to ubuntu for bare metal machines.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
cleaning up some rebase weirdness

Signed-off-by: Andrew Schoen <aschoen@redhat.com>