Tweak doctests a little for the new wrapper

Instantiated models come out differently

Change-Id: I8322882f371e1465362ad9e5f73c204f778e948a
Signed-off-by: Ryan Barry <rbarry@redhat.com>
mount_config: fix non-default directory persistence

Currently mount_config fails to restore directories that are not
present in the original image of the root filesystem. E.g.

    mkdir -p /var/lib/vdsm/foobar/moo
    echo "123" > /var/lib/vdsm/foobar/moo/cow.txt
    persist /var/lib/vdsm/foobar

Then, after reboot, ovirt_start_early will call mount_config which
will result in
    mkdir -p /var/lib/vdsm
    touch foobar
    mount -n --bind /config/var/lib/vdsm/foobar /var/lib/vdsm/foobar

This will fail because one can't bind mount a directory on a file.

This patch fixes this issue.

Change-Id: Ifa2b854980ee28cce5d55e0faf30442e6c01a4b8
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
mount_config: Add support for symbolic links

Up until now, symbolic links used to be treated like regular files
(just as directories were before the preceding patch of the branch).
This meant that trying to restore a persisted symlink would try to
bind mount whatever the symbolic link was pointing at originally.
However, some application might rely on a symbolic link being a
symbolic link and not whatever that symbolic link was pointing at.

With this patch, if we persisted a symbolic link as:

    /config/files:
        /absolute/path/to/the/symbolic/link

    /config/absolute/path/to/the/symbolic/link linking to:
        /absolute/path/to/target/of/symbolic/link

we'll get

    /absolute/path/to/the/symbolic/link linking to:
        /absolute/path/to/target/of/symbolic/link

Once the persist is fixed for symbolic links, it will behave like
file persistence does now, you should call persist after changes
to the link.

Change-Id: I8e009e3039b2df80d57e60460d6cc888a91f7577
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
utils_fs: Make fs into a package

There will be different filesystem related utilities that will
benefit from separation in modules.

Change-Id: I59097e19fadd04b5a9283e315044ca9cb675d515
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
utils_fs: Add mount/umount c bindings

This commit adds ctypes bindings for the glibc mount and umount
methods so that we do not need to branch out to the cli for our
mounting and unmounting needs. It also raises the appropriate
OSError with code and message when it fails.

Change-Id: I48d2a14a37811c1f7c952c0485c4dd9ffb981d44
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
utils_fs: add ismount isbindmount python implementation

python's os.path.ismount does not properly work with bind mounts that
are withing the same device nor does it support file bind mounts.
This patch adds convenience methods that support these cases.

Change-Id: I92e3b9368f795bda587d5de1d61a3a0266038d8f
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
utils_fs: Add symlink support

This patch ports the ovirt_store_config functionality to the new
ovirt/node package (src/ovirt/node/utils/fs/__init__.py) and by
the way of doing so makes it support persisting symbolic links

Change-Id: Ibcc52e9e5cd99bb7f342bb024d1aae12831ddc60
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
make src/ovirt/node/ package use the new Config.persist

ovirt_store_config is part of the old and deprecated ovirtnode
package. This patch removes the direct usage of it by substituting
its usages with the recently added Config.persist that has symlink
support.

Change-Id: I4b153524496e278e97cb7e0a6f88392d5aad26ba
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
pythonize scripts/persist and make it use Config.persist

Change-Id: I118f981ef1b1f1b663a176a4e64850ad97248497
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
utils_fs: make unpersist support symlinks

Substitute the usage of src/ovirtnode/ovirtfunctions remove_config
in the src/ovirt/node package with its own implementation that is
able to deal with symlinks.

Change-Id: I719304b37a17dfc47427fe1c0bb9a4e14cb88a9b
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
ovirt_node: substitute remove_config usage with Config.unpersist

Change-Id: I99bd4af6fc21247560f4667e43539d65ebe6a2e4
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>