RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1662483 - [RHEL 7.6 LP] virt-v2v -o rhv-upload fail with "NameError: global name 'cafile' is not defined"
Summary: [RHEL 7.6 LP] virt-v2v -o rhv-upload fail with "NameError: global name 'cafil...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.6
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard: V2V
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-28 20:54 UTC by Nir Soffer
Modified: 2019-01-24 10:05 UTC (History)
10 users (show)

Fixed In Version: libguestfs-1.38.2-12.27.lp.el7_6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-01-24 10:05:40 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nir Soffer 2018-12-28 20:54:51 UTC
Description of problem:

virt-v2v -o rhv-upload fails with:

nbdkit: error: /var/tmp/v2v.t8oS4X/rhv-upload-plugin.py: open: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.t8oS4X/rhv-upload-plugin.py", line 237, in open\n    cafile = cafile)\n', "NameError: global name 'cafile' is not defined\n"]


This error was fixed upstream in:

commit 7be28a25852ef89a078b4c6e70382fd42bcb2b7e
Author: Nir Soffer <nirsof>
Date:   Fri Dec 7 02:44:21 2018 +0200

    v2v: -o rhv-upload: Fix upload when using https
    
    Fix rhv-cafile option access, broken by commit 6694028f9827 (v2v: -o
    rhv-upload: Only set SSL context for https connections).


The commit introducing this error was backported to the rhel-7.6-lp branch:

commit c1db7d574cf07f47b39ac95a06c9758ac00d7087
Author: Richard W.M. Jones <rjones>
Date:   Wed Sep 19 15:29:13 2018 +0100

    v2v: -o rhv-upload: Only set SSL context for https connections.
    
    For real imageio servers the destination will always be https.  This
    change has no effect there.
    
    However when testing we want to use an http server for simplicity.  As
    there is no certificate or cafile in this case the call to create the
    context will fail.
    
    This also simplifies creation of the context object and recognizes the
    "insecure" flag for connecting to imageio.
    
    Thanks: Nir Soffer.
    (cherry picked from commit 6694028f9827a365385ba3ab199dc3938d8236df)


Version-Release number of selected component (if applicable):
# rpm -q virt-v2v
virt-v2v-1.38.2-12.26.lp.el7ev.x86_64


How reproducible:
Always

Steps to Reproduce:

# cat v2v/upload 
#!/bin/sh

disk=${1:?disk-image required}

virt-v2v \
    -i disk "$disk" \
    -o rhv-upload \
    -oc https://vega10.qa.lab.tlv.redhat.com/ovirt-engine/api \
    -os nsoffer \
    -op /var/tmp/nsoffer/password \
    -of raw \
    -oa preallocated \
    -oo rhv-cafile=/etc/pki/vdsm/certs/cacert.pem \
    -oo rhv-cluster=cluster1 \
    -oo rhv-direct=true

# ./v2v/upload /var/tmp/fedora-27.img
[   0.2] Opening the source -i disk /var/tmp/fedora-27.img
[   0.3] Creating an overlay to protect the source from being modified
[   0.7] Opening the overlay
[   2.1] Inspecting the overlay
[   5.8] Checking for sufficient free disk space in the guest
[   5.8] Estimating space required on target for each disk
[   5.8] Converting Fedora 27 (Twenty Seven) to run on KVM
virt-v2v: warning: /files/boot/grub2/device.map/hd0 references unknown 
device "vda".  You may have to fix this entry manually after conversion.
virt-v2v: This guest has virtio drivers installed.
[  27.1] Mapping filesystem data to avoid copying unused and blank areas
[  27.2] Closing the overlay
[  27.2] Assigning disks to buses
[  27.2] Checking if the guest needs BIOS or UEFI to boot
[  27.2] Initializing the target -o rhv-upload -oa preallocated -oc https://vega10.qa.lab.tlv.redhat.com/ovirt-engine/api -op /var/tmp/nsoffer/password -os nsoffer
[  28.6] Copying disk 1/1 to qemu URI json:{ "file.driver": "nbd", "file.path": "/var/tmp/rhvupload.1uBpHW/nbdkit0.sock", "file.export": "/" } (raw)
nbdkit: error: /var/tmp/v2v.t8oS4X/rhv-upload-plugin.py: open: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.t8oS4X/rhv-upload-plugin.py", line 237, in open\n    cafile = cafile)\n', "NameError: global name 'cafile' is not defined\n"]
qemu-img: Could not open 'json:{ "file.driver": "nbd", "file.path": "/var/tmp/rhvupload.1uBpHW/nbdkit0.sock", "file.export": "/" }': Failed to read data: Unexpected end-of-file before all bytes were read

virt-v2v: error: qemu-img command failed, see earlier errors

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

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

Comment 2 Richard W.M. Jones 2019-01-02 12:48:59 UTC
Sorry about that screw up.  I've started a scratch build of a 12.27.lp package which should fix this:

https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=19649068

Do we need this in rhevm-4.2-rhel-7?

Comment 4 Richard W.M. Jones 2019-01-17 09:45:21 UTC
Setting fixed-in-version to make it clear that this is already fixed
on the LP branch.

Comment 6 mxie@redhat.com 2019-01-22 07:16:07 UTC
By the way, can't reproduce the bug with virt-v2v-1.38.2-12.el7_6.1.x86_64


Note You need to log in before you can comment on or make changes to this bug.