libguestfs / virt-v2v

Virt-v2v converts guests from foreign hypervisors to run on KVM
GNU General Public License v2.0
96 stars 38 forks source link

rhv-upload broken since Ovirt 4.5, cause Basic Auth has been removed #42

Closed Schamane187 closed 7 months ago

Schamane187 commented 7 months ago

Hi,

sadly it's not possible anymore to use the option rhv-upload.

It's only possible to use basic auth with virt-v2v but since Ovirt 4.5 you don't have that option anymore.

Is there a way to use a different option for authentication?

rwmjones commented 7 months ago

(Adding @nirs) That is indeed annoying.

nirs commented 7 months ago

@sandrobonazzola do you know who can help with this?

@rwmjones don't we use the ovirt sdk? I don't remember configuring anything for auth, and I tested virt-v2v and various scripts using the python sdk with ovirt 4.5.

@Schamane187 can you provide more details on what does not work? example command line and configuration? debug logs? (there is a debug option in the sdk connection)

Schamane187 commented 7 months ago

I guess this is the important part, everything before works an gives no errors

using this command gives me several thousand lines

virt-v2v -i vmx testmigwin.vmx -o rhv-upload -oc https://hostname/ovirt-engine/api -os shared_storage -op testpw -oo rhv-cafile=ca.pem -oo rhv-cluster=testcluster -v -x

I guess this is the important part, everything before looks good and gives no errors

libnbd: debug: nbd1: nbd_close: closing handle python3 '-c' 'import ovirtsdk4' nbdkit --dump-config nbdkit version: 1.34.2 nbdkit python '/tmp/v2v.cLjugF/rhv-upload-plugin.py' --dump-plugin >/dev/null python3 '/tmp/v2v.UXHEWs/rhv-upload-precheck.py' '/tmp/v2v.UXHEWs/params2.json' Traceback (most recent call last): File "/tmp/v2v.UXHEWs/rhv-upload-precheck.py", line 73, in data_centers = system_service.data_centers_service().list( File "/usr/lib64/python3.9/site-packages/ovirtsdk4/services.py", line 6887, in list return self._internal_get(headers, query, wait) File "/usr/lib64/python3.9/site-packages/ovirtsdk4/service.py", line 202, in _internal_get context = self._connection.send(request) File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 371, in send return self.send(request) File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 389, in send self.authenticate() File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 382, in authenticate self._sso_token = self._get_access_token() File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 624, in _get_access_token raise AuthError( ovirtsdk4.AuthError: Error during SSO authentication access_denied : Cannot authenticate user Invalid user credentials. virt-v2v: error: failed server prechecks, see earlier errors rm -rf -- '/tmp/v2v.OslNBF' rm -rf -- '/tmp/v2v.n6UwUo' rm -rf -- '/tmp/v2v.NgxuNR' rm -rf -- '/tmp/v2v.S63DZr' rm -rf -- '/tmp/v2v.cLjugF' rm -rf -- '/tmp/v2v.4Oz1qK' rm -rf -- '/tmp/v2v.UXHEWs' rm -rf -- '/tmp/v2vqemunbd.r6xEQ7' rm -rf -- '/tmp/vmx.Td3Epd' rm -rf -- '/tmp/v2v.GET9rm'

I also had to switch my RestAPI scripts to OAuth authentication but, in virt-v2v I can't or at least don't know how to use another authentication see Oauth in point 3.1 https://www.ovirt.org/documentation/doc-REST_API_Guide/#authentication

cause as say said in the documentation under point 3.2

"Basic authentication is supported only for backwards compatibility; it is deprecated since version 4.0 of oVirt, and will be removed in the future"

This step has been done in 4.5.4

if u need further infos let me know

Schamane187 commented 7 months ago

I guess I found the change which makes virt-v2v unusable

https://www.ovirt.org/release/4.5.1/#keycloak-sso-setup-for-ovirt-engine

under Ovirt engine change Enhancements

Please note that default ovirt administrator user name has been changed from ‘admin’ to ‘admin@ovirt’ (Administrator Panel, VM Portal) and from ‘admin@internal’ to ‘admin@ovirt@internalsso’ (REST API)

I tried to manipulate to URL in many ways like

https://admin@ovirt@internalsso@hostname/ovirt-engine/api https://admin%40ovirt%40internalsso@hostname/ovirt-engine/api

etc etc sadly without any success.

I really appreciate your help

nirs commented 7 months ago

@Schamane187, thanks for looking this up!

I remember this old change, but I don't think I ever used "admin@ovirt@internalsso" with ovirt 4.5. Maybe I always disabled this feature when installing in a development environment, when you don't care about authentication.

I tried to manipulate to URL in many ways like

https://admin@ovirt@internalsso@hostname/ovirt-engine/api

This looks correct but output/rhv-upload-*.py do not handle such url correctly.

In output/rhv-upload-createvm.py we see that we parse the username from the connection url, and pass the url (with the username) to the sdk.Connection:

# Parse out the username from the output_conn URL.
parsed = urlparse(params['output_conn'])
username = parsed.username or "admin@internal"

# Connect to the server.
connection = sdk.Connection(                                                                        
    url=params['output_conn'],
    username=username,
    password=output_password,
    ca_file=params['rhv_cafile'],
    log=logging.getLogger(),
    insecure=params['insecure'],
)

Testing shows that this does parse correctly the username:

>>> urlparse("https://admin@ovirt@internalsso@example.com/ovirt-engine/api").username
'admin@ovirt@internalsso'

But looking in sdk.Connection() - it expect the get the username in a variable and not as part of the url:

From lib/ovirtsdk4/__init__.py

        """                                                                                         
        Creates a new connection to the API server.

        This method supports the following parameters:

        `url`:: A string containing the base URL of the server, usually
        something like `https://server.example.com/ovirt-engine/api`.

        `username`:: The name of the user, something like `admin@internal`.

This may fix the issue if you provide the right username in the url:

diff --git a/output/rhv-upload-createvm.py b/output/rhv-upload-createvm.py
index 50bb7e34..4be79871 100644
--- a/output/rhv-upload-createvm.py
+++ b/output/rhv-upload-createvm.py
@@ -18,11 +18,11 @@

 import json
 import logging
 import sys

-from urllib.parse import urlparse
+from urllib.parse import urlparse, urlunparse

 import ovirtsdk4 as sdk
 import ovirtsdk4.types as types

 # Parameters are passed in via a JSON doc from the OCaml code.
@@ -48,14 +48,15 @@ with open(sys.argv[2], 'r') as fp:
     ovf = fp.read()

 # Parse out the username from the output_conn URL.
 parsed = urlparse(params['output_conn'])
 username = parsed.username or "admin@internal"
+netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname

 # Connect to the server.
 connection = sdk.Connection(
-    url=params['output_conn'],
+    url=urlunparse(parsed._replace(netloc=netlock)),
     username=username,
     password=output_password,
     ca_file=params['rhv_cafile'],
     log=logging.getLogger(),
     insecure=params['insecure'],

Unfortunately this must be applied to all output/rhv-upload-*.py since this code is duplicated many times.

I think the right way to fix it is to add a username parameter to virt-v2v and access it via the params dict instead of depending on complicated url format.

rwmjones commented 7 months ago

Your comment reminded me of something mentioned in the manual: https://libguestfs.org/virt-v2v-input-vmware.1.html#create-ova-with-ovftool That's a different mode (input from VMware), but the idea is the same. Can you %-encode the username in the URL, ie. admin%40ovirt%40internalsso@host?

nirs commented 7 months ago

Your comment reminded me of something mentioned in the manual: https://libguestfs.org/virt-v2v-input-vmware.1.html#create-ova-with-ovftool That's a different mode (input from VMware), but the idea is the same. Can you %-encode the username in the URL, ie. admin%40ovirt%40internalsso@host?

Looks like @Schamane187 already tried that:

I tried to manipulate to URL in many ways like

https://admin@ovirt@internalsso@hostname/ovirt-engine/api https://admin%40ovirt%40internalsso@hostname/ovirt-engine/api

Schamane187 commented 7 months ago

Yes, I tried several possibilities without success

Ok, I changed the rhv-upload*.py files

sadly at the moment I am failing to build virt-v2v on a rocky 9.3

Making all in convert make[2]: Entering directory '/home/virt-v2v/convert' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/virt-v2v/convert' Making all in v2v make[2]: Entering directory '/home/virt-v2v/v2v' GEN virt-v2v /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libvirt.so: undefined reference to symbol 'g_error_free' /usr/bin/ld: /usr/lib64/libglib-2.0.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status File "caml_startup", line 1: Error: Error during linking (exit code 1) make[2]: [Makefile:948: virt-v2v] Error 2 make[2]: Leaving directory '/home/virt-v2v/v2v' make[1]: [Makefile:849: all-recursive] Error 1 make[1]: Leaving directory '/home/virt-v2v' make: *** [Makefile:767: all] Error 2

rwmjones commented 7 months ago

You need to supply the entire build log, not just extracts. Everything from the configure, make and error, with nothing left out. Also what versions of the dependencies you installed etc.

Schamane187 commented 7 months ago

ok, small update

changed the following files

rhv-upload-cancel.py
23c23
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
55d54
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
59c58
<     url=urlunparse(parsed._replace(netloc=netlock)),
---
>     url=params['output_conn'],

rhv-upload-createvm.py
25c25
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
95d94
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
99c98
<     url=urlunparse(parsed._replace(netloc=netlock)),
---
>     url=params['output_conn'],

rhv-upload-finalize.py
23c23
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
158d157
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
162c161
<     url=urlunparse(parsed._replace(netloc=netlock)),
---
>     url=params['output_conn'],

rhv-upload-plugin.py
28c28
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
rhv-upload-precheck.py
24c24
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
49d48
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
62d60
<     url=urlunparse(parsed._replace(netloc=netlock)),

rhv-upload-transfer.py
25c25
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
262d261
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
265c264
<     url=urlunparse(parsed._replace(netloc=netlock)),
---
>     url=params['output_conn'],

rhv-upload-vmcheck.py
23c23
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
48d47
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
52c51
<     url=urlunparse(parsed._replace(netloc=netlock)),
---
>     url=params['output_conn'],

compiled it

virt-v2v -v
virt-v2v: virt-v2v 2.5.1 (x86_64)
libvirt version: 9.5.0

But still no success

virt-v2v -i vmx testmigwin.vmx -o rhv-upload -oc https://admin%40ovirt%40internalsso@hostname/ovirt-engine/api -os shared_storage -op testpw -oo rhv-cafile=ca.pem -oo rhv-cluster=testcluster -v -x

still gives me


libnbd: debug: nbd2: nbd_close: closing handle
python3 '-c' 'import ovirtsdk4'
nbdkit --dump-config
nbdkit version: 1.34.2
nbdkit python '/tmp/v2v.YJHbeh/rhv-upload-plugin.py' --dump-plugin >/dev/null
python3 '/tmp/v2v.17X6bJ/rhv-upload-precheck.py' '/tmp/v2v.17X6bJ/params3.json'
Traceback (most recent call last):
  File "/tmp/v2v.17X6bJ/rhv-upload-precheck.py", line 73, in <module>
    data_centers = system_service.data_centers_service().list(
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/services.py", line 6887, in list
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/service.py", line 202, in _internal_get
    context = self._connection.send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 371, in send
    return self.__send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 389, in __send
    self.authenticate()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 382, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 624, in _get_access_token
    raise AuthError(
ovirtsdk4.AuthError: Error during SSO authentication access_denied : Cannot authenticate user Invalid user credentials.
virt-v2v: error: failed server prechecks, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]
rm -rf -- '/tmp/v2v.FOQR77'
rm -rf -- '/tmp/v2v.udsQtU'
rm -rf -- '/tmp/v2v.oW3Dwl'
rm -rf -- '/tmp/v2v.wLsb07'
rm -rf -- '/tmp/v2v.YJHbeh'
rm -rf -- '/tmp/v2v.D8awTU'
rm -rf -- '/tmp/v2v.17X6bJ'
rm -rf -- '/tmp/v2vqemunbd.uYS99F'
Unix.Unix_error(Unix.ENOENT, "unlink", "/tmp/v2v.6CgCnI/in1")
rm -rf -- '/tmp/v2vqemunbd.gR3FvS'
rm -rf -- '/tmp/vmx.90LEWI'
rm -rf -- '/tmp/v2v.6CgCnI'
libguestfs: closing guestfs handle 0x562dfc501dd0 (state 0)
libguestfs: closing guestfs handle 0x562dfc502160 (state 0)

Using it unencoded also still can't resolve

virt-v2v -i vmx testmigwin.vmx -o rhv-upload -oc https://admin@ovirt@internalsso@hostname/ovirt-engine/api -os shared_storage -op testpw -oo rhv-cafile=ca.pem -oo rhv-cluster=testcluster -v -

python3 '-c' 'import ovirtsdk4'
nbdkit --dump-config
nbdkit version: 1.34.2
nbdkit python '/tmp/v2v.vol9zN/rhv-upload-plugin.py' --dump-plugin >/dev/null
python3 '/tmp/v2v.8S535o/rhv-upload-precheck.py' '/tmp/v2v.8S535o/params3.json'
Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 382, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 617, in _get_access_token
    sso_response = self._get_sso_response(self._sso_url, post_data)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 694, in _get_sso_response
    curl.perform()
pycurl.error: (6, 'Could not resolve host: ovirt@internalsso@hostname')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/v2v.8S535o/rhv-upload-precheck.py", line 73, in <module>
    data_centers = system_service.data_centers_service().list(
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/services.py", line 6887, in list
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/service.py", line 202, in _internal_get
    context = self._connection.send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 371, in send
    return self.__send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 389, in __send
    self.authenticate()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 385, in authenticate
    self.__parse_error(e)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 932, in __parse_error
    six.reraise(clazz, clazz(error_msg), sys.exc_info()[2])
  File "/usr/lib/python3.9/site-packages/six.py", line 708, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 382, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 617, in _get_access_token
    sso_response = self._get_sso_response(self._sso_url, post_data)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 694, in _get_sso_response
    curl.perform()
ovirtsdk4.ConnectionError: Error while sending HTTP request: (6, 'Could not resolve host: ovirt@internalsso@hostname')
virt-v2v: error: failed server prechecks, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]
rm -rf -- '/tmp/v2v.daOIpt'
rm -rf -- '/tmp/v2v.sSz6Dz'
rm -rf -- '/tmp/v2v.7xh0i9'
rm -rf -- '/tmp/v2v.AWvUbL'
rm -rf -- '/tmp/v2v.vol9zN'
rm -rf -- '/tmp/v2v.Zx6F2g'
rm -rf -- '/tmp/v2v.8S535o'
rm -rf -- '/tmp/v2vqemunbd.BpsrhK'
Unix.Unix_error(Unix.ENOENT, "unlink", "/tmp/v2v.qCBOh6/in1")
rm -rf -- '/tmp/v2vqemunbd.qbmrKz'
rm -rf -- '/tmp/vmx.iTKCDL'
rm -rf -- '/tmp/v2v.qCBOh6'
libguestfs: closing guestfs handle 0x55a0414c1dd0 (state 0)
libguestfs: closing guestfs handle 0x55a0414c2160 (state 0)
rwmjones commented 7 months ago

Are you running the version you compiled (using ./run virt-v2v ...)?

Schamane187 commented 7 months ago

Hi,

no I did a make install after compiling it

rwmjones commented 7 months ago

Yeah don't do that, you've probably got two versions installed now and confusion over which is being used. I would recreate your system, compile virt-v2v from source, do not install it, and run it locally using ./run ...

nirs commented 7 months ago

@Schamane187, There was a typo in my example - netlock should be netloc. This likely raises in runtime.


rhv-upload-cancel.py
23c23
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
55d54
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
59c58
<     url=urlunparse(parsed._replace(netloc=netlock)),

Should be

url=urlunparse(parsed._replace(netloc=netloc)),

But still no success

virt-v2v -i vmx testmigwin.vmx -o rhv-upload -oc https://admin%40ovirt%40internalsso@hostname/ovirt-engine/api -os shared_storage -op testpw -oo rhv-cafile=ca.pem -oo rhv-cluster=testcluster -v -x

still gives me



libnbd: debug: nbd2: nbd_close: closing handle
python3 '-c' 'import ovirtsdk4'
nbdkit --dump-config
nbdkit version: 1.34.2
nbdkit python '/tmp/v2v.YJHbeh/rhv-upload-plugin.py' --dump-plugin >/dev/null
python3 '/tmp/v2v.17X6bJ/rhv-upload-precheck.py' '/tmp/v2v.17X6bJ/params3.json'
Traceback (most recent call last):
  File "/tmp/v2v.17X6bJ/rhv-upload-precheck.py", line 73, in <module>
    data_centers = system_service.data_centers_service().list(
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/services.py", line 6887, in list
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/service.py", line 202, in _internal_get
    context = self._connection.send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 371, in send
    return self.__send(request)
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 389, in __send
    self.authenticate()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 382, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python3.9/site-packages/ovirtsdk4/__init__.py", line 624, in _get_access_token
    raise AuthError(
ovirtsdk4.AuthError: Error during SSO authentication access_denied : Cannot authenticate user Invalid user credentials.

Did you fix my typo before trying? with the typo it should fail before trying to authenticate.

virt-v2v: error: failed server prechecks, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the complete output:

virt-v2v -v -x [...] rm -rf -- '/tmp/v2v.FOQR77' rm -rf -- '/tmp/v2v.udsQtU' rm -rf -- '/tmp/v2v.oW3Dwl' rm -rf -- '/tmp/v2v.wLsb07' rm -rf -- '/tmp/v2v.YJHbeh' rm -rf -- '/tmp/v2v.D8awTU' rm -rf -- '/tmp/v2v.17X6bJ' rm -rf -- '/tmp/v2vqemunbd.uYS99F' Unix.Unix_error(Unix.ENOENT, "unlink", "/tmp/v2v.6CgCnI/in1") rm -rf -- '/tmp/v2vqemunbd.gR3FvS' rm -rf -- '/tmp/vmx.90LEWI' rm -rf -- '/tmp/v2v.6CgCnI' libguestfs: closing guestfs handle 0x562dfc501dd0 (state 0) libguestfs: closing guestfs handle 0x562dfc502160 (state 0)


Using it unencoded also still can't resolve

`virt-v2v -i vmx testmigwin.vmx -o rhv-upload -oc https://admin@ovirt@internalsso@hostname/ovirt-engine/api -os shared_storage -op testpw -oo rhv-cafile=ca.pem -oo rhv-cluster=testcluster -v -`

python3 '-c' 'import ovirtsdk4' nbdkit --dump-config nbdkit version: 1.34.2 nbdkit python '/tmp/v2v.vol9zN/rhv-upload-plugin.py' --dump-plugin >/dev/null python3 '/tmp/v2v.8S535o/rhv-upload-precheck.py' '/tmp/v2v.8S535o/params3.json' Traceback (most recent call last): File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 382, in authenticate self._sso_token = self._get_access_token() File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 617, in _get_access_token sso_response = self._get_sso_response(self._sso_url, post_data) File "/usr/lib64/python3.9/site-packages/ovirtsdk4/init.py", line 694, in _get_sso_response curl.perform() pycurl.error: (6, 'Could not resolve host: ovirt@internalsso@hostname')

This means the url was not rebuilt - did you change also rhv-upload-precheck.py?

Schamane187 commented 7 months ago

ok, will try to change that.

is

netloc = f"{parsed.hotname:parsed.port}" if

is hotname correct? was wondering about that as well.

and yes I changed

rhv-upload-precheck.py
24c24
< from urllib.parse import urlparse, urlunparse
---
> from urllib.parse import urlparse
49d48
< netloc = f"{parsed.hotname:parsed.port}" if parsed.port else parsed.hostname
62d60
<     url=urlunparse(parsed._replace(netloc=netlock)),
nirs commented 7 months ago

ok, will try to change that.

is

netloc = f"{parsed.hotname:parsed.port}" if

is hotname correct? was wondering about that as well.

No, another typo.

and yes I changed


rhv-upload-precheck.py

Ok, lets see how it works with correct code.

Schamane187 commented 7 months ago

after the change I get

libnbd: debug: nbd2: nbd_close: closing handle
python3 '-c' 'import ovirtsdk4'
nbdkit --dump-config
nbdkit version: 1.34.2
nbdkit python '/tmp/v2v.iUKf2m/rhv-upload-plugin.py' --dump-plugin >/dev/null
python3 '/tmp/v2v.41nm5t/rhv-upload-precheck.py' '/tmp/v2v.41nm5t/params3.json'
  File "/tmp/v2v.41nm5t/rhv-upload-precheck.py", line 62
    connection = sdk.Connection(
        ^
SyntaxError: keyword argument repeated: url
virt-v2v: error: failed server prechecks, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]
rm -rf -- '/tmp/v2v.TlOLbJ'

those are the lines mentioned above

61: # Connect to the server.
62: connection = sdk.Connection(
63:     url=urlunparse(parsed._replace(netloc=netloc)),
64:     url=params['output_conn'],
65:     username=username,
66:     password=output_password,

maybe 63 shouldn't be in rhv-upload-precheck.py?

nirs commented 7 months ago

after the change I get


libnbd: debug: nbd2: nbd_close: closing handle
python3 '-c' 'import ovirtsdk4'
nbdkit --dump-config
nbdkit version: 1.34.2
nbdkit python '/tmp/v2v.iUKf2m/rhv-upload-plugin.py' --dump-plugin >/dev/null
python3 '/tmp/v2v.41nm5t/rhv-upload-precheck.py' '/tmp/v2v.41nm5t/params3.json'
  File "/tmp/v2v.41nm5t/rhv-upload-precheck.py", line 62
    connection = sdk.Connection(
        ^
SyntaxError: keyword argument repeated: url

Good, this means your actual run the modified code...

those are the lines mentioned above

61: # Connect to the server.
62: connection = sdk.Connection(
63:     url=urlunparse(parsed._replace(netloc=netloc)),
64:     url=params['output_conn'],
65:     username=username,
66:     password=output_password,

maybe 63 shouldn't be in rhv-upload-precheck.py?

The old url line should be replaced by the new line - you should have:

61: # Connect to the server.
62: connection = sdk.Connection(
63:     url=urlunparse(parsed._replace(netloc=netloc)),
65:     username=username,
66:     password=output_password,
Schamane187 commented 7 months ago

oh lord, it works

I get another Error now, but this isn't about logging in to the API anymore

ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot add Virtual Disk. Disk configuration (RAW Sparse backup-None) is incompatible with the storage domain type.]". HTTP response code is 409.
virt-v2v: error: failed to start transfer, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

thanks a lot guys, I am really thankful for your help with this. Now I can hopefully solve the rest on my own

rwmjones commented 7 months ago

Please push your working version to a fork so we can see the final changes needed.

The error you're seeing now is because certain RHV storage backends only support certain formats. You can play with the -of option to adjust the format that you're writing (eg. -of qcow2). Nir knows more about this, it was always rather opaque to me.

Schamane187 commented 7 months ago

I will create a fork tomorrow and push the version

but I still get an error

[  19.7] Setting up the destination: -o rhv-upload -oc https://admin@ovirt@internalsso@hostname/ovirt-engine/api -os hosted_storage
nbdkit: error: /tmp/v2v.f2G0Lj/rhv-upload-plugin.py: after_fork: error: Traceback (most recent call last):
   File "/tmp/v2v.f2G0Lj/rhv-upload-plugin.py", line 94, in after_fork
    http = create_http(url)
   File "/tmp/v2v.f2G0Lj/rhv-upload-plugin.py", line 478, in create_http
    ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH,
   File "/usr/lib64/python3.9/ssl.py", line 746, in create_default_context
    context.load_verify_locations(cafile, capath, cadata)
 FileNotFoundError: [Errno 2] No such file or directory

nbdkit: error: /tmp/v2v.f2G0Lj/rhv-upload-plugin.py: after_fork: error: Traceback (most recent call last):
   File "/tmp/v2v.f2G0Lj/rhv-upload-plugin.py", line 94, in after_fork
    http = create_http(url)
   File "/tmp/v2v.f2G0Lj/rhv-upload-plugin.py", line 478, in create_http
    ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH,
   File "/usr/lib64/python3.9/ssl.py", line 746, in create_default_context
    context.load_verify_locations(cafile, capath, cadata)
 FileNotFoundError: [Errno 2] No such file or directory

[  44.3] Copying disk 1/2
nbdcopy: nbd+unix:///?socket=/tmp/v2v.0IFTnT/out0: nbd_connect_uri: connect: Connection refused
virt-v2v: error: nbdcopy command failed, see earlier error messages

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]

pretty unsure if this is still something with authentification

File "/tmp/v2v.f2G0Lj/rhv-upload-plugin.py", line 478, in create_http ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, File "/usr/lib64/python3.9/ssl.py", line 746, in create_default_context context.load_verify_locations(cafile, capath, cadata) FileNotFoundError: [Errno 2] No such file or directory

Schamane187 commented 7 months ago

forget about that, was my fault, didn't gove the coreect path to ca.

it uploading like a dream :)

thx again

rwmjones commented 7 months ago

virt-v2v: error: nbdcopy command failed, see earlier error messages

You need to install nbdcopy (dnf install libnbd).

Actually no that's not what's happening. nbdcopy is just reflecting the earlier error from the rhv-upload plugin.

Schamane187 commented 7 months ago

yeah, with the correct path to ca it uploads, but it creates the vm and does not attach the disks

and with local path virt-v2v creates testmig-sda testmig-sdb, now it creates tesmig-000, testmig-001 and does not attach those to the created testmig vm

Schamane187 commented 7 months ago

ok, it names them weird, but I can live with that number 000x instead of sdx, as long as it works.

after giving the correct path for /usr/share/virtio-win it attaches the disk.

wish u a happy rest of the weekend, mine is very good thx to u

sandrobonazzola commented 7 months ago

@sandrobonazzola do you know who can help with this?

Looks like the issue got solved in the meanwhile.

Schamane187 commented 7 months ago

yes, has been solved.

As discussed, I created a pull request for that fix

https://github.com/libguestfs/virt-v2v/pull/43