bootstrap: fix ovirt-node parameters and locations

currently we hold old rhev-h settings, while ovirt-node is different.

Change-Id: I3fa85dd89a3b7056aa4ed7c1ac3f5b49965c3b97
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
bootstrap: do not check connectivity nor unique id when VdsInstall=false

Change-Id: Ief74abae57c4fd7b76642df62aba7690a9f66208
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=873222
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
bootstrap: do not get unique id at canDoAction

CURRENT IMPLEMENTATION

engine has duplicate complex vdsm logic to generate the vdsm id.

    @Reloadable
    @TypeConverterAttribute(String.class)
    @DefaultValueAttribute(
        "IDFILE=/etc/vdsm/vdsm.id; " +
        "if [ -r \"${IDFILE}\" ]; then " +
            "cat \"${IDFILE}\"; " +
        "else " +
            "UUID=\"$(" +
                "dmidecode -s system-uuid 2> /dev/null | " +
                "sed -e 's/.*Not.*//' " +
            ")\"; " +
            "if [ -z \"${UUID}\" ]; then " +
                "UUID=\"$(uuidgen 2> /dev/null)\" && " +
                "mkdir -p \"$(dirname \"${IDFILE}\")\" && " +
                "echo \"${UUID}\" > \"${IDFILE}\" && " +
                "chmod 0644 \"${IDFILE}\"; " +
            "fi; " +
            "[ -n \"${UUID}\" ] && echo \"${UUID}\"; " +
        "fi"
    )
    BootstrapNodeIDCommand(372),

The command is executed synchronously (UI wise) when host is added.

ASSUMPTIONS OF CURRENT IMPLEMENTATION

 1. dmidecode exists out of the box in any distribution.

 ---> WRONG: fedora 17 has no, and other distributions may also lack.

 2. host id is only dmidecode output.

 ---> WRONG: over time we saw that we need extra logic to keep the id
      sane, especially when the hardware id does not exist or
      malformed.

 3. dmidecode utility is used for host id

 ---> WRONG: there are plans to make it more secure/robust using TPM,
      which requires software at host to generate.

PROBLEMS IN CURRENT IMPLEMENTATION

 1. if dmidecode utility is missing we cannot acquire host id before
    performing bootstrap. The whole idea of bootstrap process is to take
    vanilla distribution and install vdsm. dmidecode is missing from
    vanilla, hence cannot be executed before bootstrap.

 2. the logic of generating host id exists both in engine and vdsm, both
    implementations need to synced, and kept synced between versions,
    which in practice cannot be achieved. As there is too much static
    noise (distribute on different channels, not be able to update all
    IT components, etc...).

 3. If host id generation method is changed, the engine implementation
    should be changed as well, while engine should not really care how
    vdsm maintain its identity.

NEW IMPLEMENTATION

Acquire vdsm id during bootstrap process, at the earliest. When all
dependencies are available.

If vdsm id is duplicate:

 1. post an error to host event log.

 2. set the state of the host to "install fail".

USER VISIBLE CHANGES

The following existing scenario:

 1. user has host xxx.com with ip 1.1.1.1, he added this host using
    xxx.com as host name.
 2. user add new host, at the host field he *BY MISTAKE* writes 1.1.1.1.
 3. the user is blocked from proceeding because of duplicate uuid between
    xxx.com(existing) and 1.1.1.1(new).
 4. the confused user fixes the  host field to 1.1.1.2 and proceed.

Behaves as:

 1. user has host xxx.com with ip 1.1.1.1, he added this host using
    xxx.com as host name.
 2. user add new host, at the host field he *BY MISTAKE* writes 1.1.1.1.
 3. installation starts, and ends up with installation failed status on
    the new host.
 4. user sees the error message, and remove the host added by mistake.

REASONING

The above sequence of adding the same host with different name/address is not
common or frequent, and does not justify the need to duplicate vdsm logic into
engine, nor find a solution for distributions that locks the dmidecode utility
at their base system layout, nor to lock our-self to dmidecode utility.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875527
Change-Id: I0263dbae34aaa02c126c5ed1dc52a84f4f5e77f8
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
pki: cleanup the ca interface

VdsInstaller is about the retire, but it contains some dirty code that
is actually belongs to the ca internals.

In this patch we move this code into the ca interface so that the
VdsInstaller replacement will not contain any knowledge of the ca
internals.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875528
Change-Id: If8c9285ed3a0640fea17a4ce629d6deb532430c4
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
pki: accept subject name for certificate

This enables generating a completely empty certificate request, setting
subject at engine machine.

This much safer (security wise) and much easier to handle at host during
bootstrap.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875528
Change-Id: I9798deff39a69f9fd25c0ab9e998b5a7b206daeb
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: tar: support long file names within tar

Change-Id: I364d67dc408af21e08a20014c6a0c99a413fe3be
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: tar: throw an exception if base does not exist

Change-Id: I25e4e41f7c68c9a6b797b7436c8565d2ad059329
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: move Tar, CachedTar classes to own package

Change-Id: Ic0227d540ede0be17f5803e3046092a7317207fc
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: tests: tar: cleanup main() entry point

People found that this unused testing only code needs to not leak.

Change-Id: I85ac69a75fdef1d5e60f7e33d79bc223535c01a0
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: tests: do not use default key alias

Allow to specify key to use as client.

Change-Id: I6242a2b6f138c3438ff95febe0b85e0b48befe65
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: ssh: don't add ssh command to exception

It results in a long unclear message to the user.

Change-Id: If4e221b423a46dcaf01ca540a4671caeedb90dce
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: ssh: fixup activity detection

Current implementation considers only the first active stream, leaving
other streams marked as active.

Activity detection should clear all streams' activity flag at every loop
iteration.

Change-Id: Ibb63134b2829ae57c902f9d3c33f10c5311bcf76
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: ssh: optimize progress streams

Default java implementation of filtered stream is byte-by-byte
operation.

Bypass behaviour to buffer methods.

Change-Id: I9a890581b324ae3f9223587e1eeb0c53675bd060
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: ssh: move to member '_' convention

We had several discussion over this.

Convention for members/static/globals is very helpful when dealing with
patch hunk and review, as every variable can be assigned to proper
context without reading the whole code.

It also avoid naming clashes between the different scope level.

I am aware that some people are not used to variable name convention,
however it is much easier to maintain and review patches in this mode.

I am enforcing this convention on bootstrap and ssh sources, and I hope
that others will see the benefit in this method as well.

Change-Id: I1bca20cec1e309105805d2c741c56abf04ab33d5
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
utils: ssh: cleanup: rename server with host

'Host' is more compatible with the other API.

Change-Id: I4b342fa033713608baa977c8e0592be2f5c35927
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
bootstrap: host add: differentiate between authentication error and other errors

New SSHClient implementation allows differentiating between these cases
as requested.

Change-Id: I0d87fdd0c8942ec39632bd4562694bd5d027cbd7
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
bootstrap: split the logic of ovirt-node upgrade out

Currently we have 4 separate bootstrap methods:
 1. Host.
 2. Node registration.
 3. Node installation.
 4. Node upgrade.

While there is something common between (1-3), node upgrade is totally
different sequence:

 1. Unlike bootstrap it is executing foreign code (not originated at
    engine machine.
 2. Unlike bootstrap it is non-customizable.

This change split the logic of the node upgrade out, to ease future
VdsInstaller retirement.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875528
Change-Id: I22dee8f1238de198abba72f576fb4ee82c513f34
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
bootstrap: handle bootstrap messages using string member

Current implementation holds the VdsInstaller object in context of
InstallVdsCommand only to extract the error message out of it.

VdsInstaller is going to be retired so we move the reference to local
scope and store the error message in string at state scope.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875528
Change-Id: I928db05fa3ca7cd5941f30af8036d598847ea7d2
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>
core: Event log - a method to bypass flow

Event log - a method to bypass flood filtering

Adding a customId field to AuditLogableBase in order to enable
distinguishing between events that have same instance references (dc,
cluster, vm etc) but still should be treated as separate events such
that the anti-flood event mechanism will not mask those events and
display just one per the defined period.
It is the responsibility of the AuditLogableBase instance creator to call
setCustomId with a different id per log message instance in order to
treat those messages as different messages.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875375
Change-Id: Iff160c4241618a2d0c475e13ea13ddefe8220f06
Signed-off-by: Eli Mesika <emesika@redhat.com>
bootstrap: allow distinguish error from non error messages

The old bootstrap xml like protocol will remain for a while until the
node upgrade script rewritten. Till then we need to know if there was an
error message to fail the command without relaying on constants within
messages as VdsInstaller had done so far.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=875528
Change-Id: I62de9fab0ae3c10d245ed6c2580bf8fcc09057d6
Signed-off-by: Alon Bar-Lev <alonbl@redhat.com>