You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/10/09 06:26:20 UTC

[jira] [Commented] (LIBCLOUD-858) Unable to list nodes with Libvirt provider on Python 3

    [ https://issues.apache.org/jira/browse/LIBCLOUD-858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15559390#comment-15559390 ] 

ASF GitHub Bot commented on LIBCLOUD-858:
-----------------------------------------

GitHub user femnad opened a pull request:

    https://github.com/apache/libcloud/pull/894

    LIBCLOUD-858: Fix Listing Libvirt Nodes with Python 3

    ## Fix Listing Libvirt Nodes with Python 3
    
    ### Description
    
    Listing nodes with the `Libvirt` provider fails on Python 3 because of a `split` operation on a `bytes` object where the delimiter is not a `bytes` object.
    
    Use the `ensure_string` function from the `py3` module to ensure that the output of a `subprocess.Popen` call is always a string for Python 2 and 3. Also add a test to convert the mock command output results to `bytes` objects if the active Python version is 3.
    
    ### Status
    
    - done, ready for review
    
    ### Checklist (tick everything that applies)
    
    - [ ] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks)
    - [ ] Documentation
    - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
    - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes)
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/femnad/libcloud LIBCLOUD-858_fix-libvirt-node-listing-with-python-3

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/libcloud/pull/894.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #894
    
----
commit 9c01bf6eb970eb3ba315d135ffd6fb5ee7b45b7e
Author: Fahri Cihan Demirci <fe...@users.noreply.github.com>
Date:   2016-10-09T06:15:10Z

    LIBCLOUD-858: Fix Listing Libvirt Nodes with Python 3

----


> Unable to list nodes with Libvirt provider on Python 3
> ------------------------------------------------------
>
>                 Key: LIBCLOUD-858
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-858
>             Project: Libcloud
>          Issue Type: Bug
>          Components: Compute
>         Environment: Ubuntu 16.04.1 LTS
> Python 3.5.2
> Libcloud installed from 1a836148250ebf852a7f28e4d93007417ee7639d
>            Reporter: Fahri Cihan Demirci
>
> Using the {{list_nodes}} methods of the Libvirt provider driver results in an error when using Python 3. A simple script to trigger this is as follows:
> {code}
> from libcloud.compute.providers import get_driver
> from libcloud.compute.types import Provider
> cls = get_driver(Provider.LIBVIRT)
> driver = cls('qemu:///system')
> nodes = driver.list_nodes()
> {code}
> It results in the following error:
> {code}
> Traceback (most recent call last):
>   File "libcloud_list_nodes.py", line 6, in <module>
>     nodes = driver.list_nodes()
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 120, in list_nodes
>     nodes = self._to_nodes(domains=domains)
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 276, in _to_nodes
>     nodes = [self._to_node(domain=domain) for domain in domains]
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 276, in <listcomp>
>     nodes = [self._to_node(domain=domain) for domain in domains]
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 285, in _to_node
>     ip_addresses = self._get_ip_addresses_for_domain(domain)
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 333, in _get_ip_addresses_for_domain
>     arp_table = self._parse_ip_table_arp(arp_output=stdout)
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 410, in _parse_ip_table_arp
>     return self._parse_mac_addr_table(arp_output, arp_regex)
>   File "/home/femnad/v/libcloud3-pristine/lib/python3.5/site-packages/apache_libcloud-1.2.1-py3.5.egg/libcloud/compute/drivers/libvirt_driver.py", line 431, in _parse_mac_addr_table
>     lines = cmd_output.split('\n')
> TypeError: a bytes-like object is required, not 'str'
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)