Uploaded image for project: 'Libcloud'
  1. Libcloud
  2. LIBCLOUD-858

Unable to list nodes with Libvirt provider on Python 3

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compute
    • Labels:
      None
    • Environment:

      Ubuntu 16.04.1 LTS
      Python 3.5.2
      Libcloud installed from 1a836148250ebf852a7f28e4d93007417ee7639d

      Description

      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:

      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()
      

      It results in the following error:

      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'
      

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

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

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/894
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit f5ff0cfb080b767b542e9deec5ecc34dedcb4f0c in libcloud's branch refs/heads/trunk from Fahri Cihan Demirci
          [ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=f5ff0cf ]

          LIBCLOUD-858: Fix Listing Libvirt Nodes with Python 3

          Closes #894

          Show
          jira-bot ASF subversion and git services added a comment - Commit f5ff0cfb080b767b542e9deec5ecc34dedcb4f0c in libcloud's branch refs/heads/trunk from Fahri Cihan Demirci [ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=f5ff0cf ] LIBCLOUD-858 : Fix Listing Libvirt Nodes with Python 3 Closes #894
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user femnad opened a pull request:

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

          LIBCLOUD-858: Fix Listing Libvirt Nodes with Python 3

            1. Fix Listing Libvirt Nodes with Python 3
              1. 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.

              1. Status
          • done, ready for review
              1. Checklist (tick everything that applies)

          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 <femnad@users.noreply.github.com>
          Date: 2016-10-09T06:15:10Z

          LIBCLOUD-858: Fix Listing Libvirt Nodes with Python 3


          Show
          githubbot ASF GitHub Bot added a comment - 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 <femnad@users.noreply.github.com> Date: 2016-10-09T06:15:10Z LIBCLOUD-858 : Fix Listing Libvirt Nodes with Python 3

            People

            • Assignee:
              Unassigned
              Reporter:
              femnad Fahri Cihan Demirci
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development