IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
In server_test started_imageio fixture
creates servers with built ovirt-imageio,
and terminates the process at the end,
between runs.
However, if runs do happen too fast
it may try to create the next server socket
before the previous is closed, resulting in
an "address already in use" error.
Add a wait() after terminate() to ensure we do
not run into such issue.
Fixes: e6ed8210c19c98f3edb2ba8909bf83ca3571c57b
Signed-off-by: Albert Esteve <aesteve@redhat.com>
If a user runs ovirt-imageio or ovirt-imageioctl with invalid
configuration directory, we silently ignored the directory since it has
no configuration files, and failed later when with a confusing error
message.
Change server.load_config() to validate that the configuration directory
contains at least one configuration file. This will also fail if the
default configuration directory (/etc/ovirt-imageio) becomes broken.
Failing fast will help users to fix the issue quickly.
Example failure with this change:
$ ./ovirt-imageio -c test/conf
Server failed
Traceback (most recent call last):
File "/home/nsoffer/src/ovirt-imageio/ovirt_imageio/_internal/server.py", line 38, in main
cfg = load_config(args.conf_dir)
File "/home/nsoffer/src/ovirt-imageio/ovirt_imageio/_internal/server.py", line 93, in load_config
raise ValueError(f"Cound not find {pattern}")
ValueError: Cound not find test/conf/conf.d/*.conf
The change removes the server.find_config(), since we can test the
behavior using server.load_config(), add tests for various failure
cases, and improve documentation in server.load_config().
Fixes#33
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The implementation for loading server configuration belongs to the
server module, but it is useful for other modules that want to connect
with the server.
We already have a public server.load_config() function, but it accepted
an argument parser object, while it need just the configuration
directory (/etc/ovirt-imageio). Change the function to accept the
configuration directory.
Callers of server.load_config() need to know the default configuration
directory, available at server.DEFAULT_CONF_DIR.
Change-Id: I0f0b71eb91fa0a866c32353b4c4718ea98d41078
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
This make it easier to work with the project and to improve packaging.
For example, README.md is now at the expected location, so it is
packaged automatically for pypi.
Change-Id: Ib1a456054de34146bf2a4f39a69ccf1756b99e41
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
After migrating image-proxy to this project, it is now being moved to a
specific directory in order to prevent functionallity faults caused by
the code migration.
Next phase will be to extract common code to an "ovirt-image-common"
project, and make a proper setup.
Change-Id: Ic6799c7d53e6e2610bf62f84d2336aeac273240d
Signed-off-by: Amit Aviram <aaviram@redhat.com>
If a webob caller assigns a stream as the response body, webob will then
clear the Content-Length header for the outgoing response and will not
create one automatically, expecting it to be supplied by the caller.
To compensate, manually copy the Content-Length as returned from
ovirt-image-daemon. Add unit tests to ensure it works.
Change-Id: I79fa94112c0509a35c512b0b8d2721b2bea5ac4c
Signed-off-by: Greg Padgett <gpadgett@redhat.com>
Add tests for HTTP PUT requests. Ensure that both successful and
failed responses from imaged are properly propagated to the client.
Change-Id: I43d93fbf83c2a21bcfbf958c01a4517a4dba2e1d
Signed-off-by: Greg Padgett <gpadgett@redhat.com>
Add unit tests for the server module, which indirectly tests the
image_handler module as well. This set of tests covers HTTP GET and
OPTIONS.
Some supplementary files are also added, providing a valid configuration
for the server to run during testing along with a pre-generated auth
ticket acceptable as input to the server. (This test ticket will be
valid for approximately 30 years.)
This also requires the python-requests-mock extension module:
The proxy uses python-requests to send http[s] requests to imaged, and
in order to fully test the functionality it expects certain responses
from imaged, otherwise it will fail early preventing us from testing all
code paths. Requests-mock is designed as an adapter for python-requests
which crafts configurable responses to queries so that unit testing code
using python-requests doesn't require the availability of an external
network resource.
An alternative, HTTPretty, was ruled out because its monkey-patching
around the socket layer caused problems with webob, which prevented the
image server from starting up. Requests-mock doesn't interfere with
webob's access to the network, while allowing us to emulate responses
from the vdsm-image-daemon.
For more documentation on python-requests-mock, see:
http://requests-mock.readthedocs.org/en/latest/overview.html
Change-Id: I8cdf9bfa08cc488033277f90758764b3b0c71c81
Signed-off-by: Greg Padgett <gpadgett@redhat.com>
Some tests were copied from the vdsm-imaged project; these should be
removed before new tests for the proxy are added.
Change-Id: I4b23ce07ab573705e7d3409f96f653c4ddbe3cf0
Signed-off-by: Greg Padgett <gpadgett@redhat.com>
As a decision was made to move image-proxy and image-daemon under the
same repository, this patch moves image-daemon related files to its
specific directory.
Once this change is done, the next phase will be to start migrating code
from the image-proxy project into this one. The proxy code will also
reside in its own directory.
After that, common code and setup scripts will be made for easy setup.
Change-Id: I49a58d933272ee17e27666ba4a7ff55300dcadfe
Signed-off-by: Amit Aviram <aaviram@redhat.com>
Upload string instead of creating a temporary file and uploading its
contents. We are testing the server and not the uhttp client.
Change-Id: I5b91edb74b099ce646e3a10973ca9838de7c29c7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Use the more common "read" and "write" for ticket operations instead of
"get" and "put" which are about http.
Change-Id: Ief7ecc25eb8869271caab437a3898851c64393be
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Create destination image using same helper we use to create the payload.
Change-Id: I50e5278f76c964b2c369f926c9340db2367f09c2
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The create_repo and create_volume are not used, remove them.
Change-Id: Ie8d96b3b2bc74e09a026dc8fdcc0db7698362872
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
When we remove the request_id parameter, we forget to remove it from the
tests.
Change-Id: I2ce280906a3d80006a2e49c015ca8e57d29e0223
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
When validating a request with the ticket, reject requests that try to
write after the last byte of the image.
Change-Id: I9ef8cb9491ee6359aa7408546c3004692b0c50f9
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
We used to fail with internal server error instead of not found.
Change-Id: I437da69f24e29669236411e0362c0df7e8d0b056
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
When adding or extending a ticket, we validate that timeout is an
integer value.
Change-Id: I5afebee4937238a99cced8d1eea2644a56225be1
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Previously we used to accept an expire timestamp, which may break if
engine and host clocks are not synchronized. Also, this force usage of
time.time(), which may change backward or forward, invalidating tickets
or giving them more time.
We accept now a timeout in seconds, and compute the expire time when a
ticket is added. When a ticket is extended, we add extend the expire
time by the timeout.
Since we create the expire time, we can use now monotonic clock source
so ticket are not effected now by system time changes.
Change-Id: I13f5de9ac99827d937b9d2899e96cf86f12cabe4
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
We want to merge this project with ovirt-image-proxy, and have
consistent names. This also more consistent with other ovirt projects
(e.g. ovirt-engine, ovirt-hosted-engine-ha).
Change-Id: I7efd46413cc4dd4cc70e72eabc3c25e8ea986929
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Parse content-range header and use the "start" byte range for offset.
We support also invalid ranges such as */length for now, writing from
the start of the image.
Change-Id: I7553415eb88b50921b42b0e73fa1815f96b789a9
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Save about 2 seconds by running imaged server once for all server test,
removing lot of unneeded boilerplate.
Change-Id: I32040aa28961281d93df32acc35d4b8a19c95fe1
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Python 2.7.9 changed the behavior in an incompatible way, enabling
client certificate by default, breaking the HTTPS tests. Since we trust
our certificates, disable the verification when running on Python
version that verify certificates by default.
For more info see https://www.python.org/dev/peps/pep-0476
Change-Id: Ibda25e04d72c91d81935ad317b9b0db9617f8336
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
On the host, the socket is created in /run/vdsm, and can be accessed
only by the user vdsm, so SSL is not needed.
Change-Id: Ie53aa97ef6d771cbf4d33cf6b1edc1d2014d92dc
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
vdsm-imaged provides direct access to oVirt disks using HTTPS protocol.
Together with ovirt-image-proxy, it allows uploading a disk image
directly into an oVirt disk, or downloading an oVirt disk.
See the README for the big picture.
Change-Id: I58c6471e700dfdae6ce643dcc0852935da56a962
Signed-off-by: Nir Soffer <nsoffer@redhat.com>