Skip to content

upmap-remapped.py : Issues with python 3  #29

@gillarda

Description

@gillarda

Hello,
First of all, thank you for this script !
I had a few issues running the script with python 3 on Centos 7.

$ python3 -V
Python 3.6.8
  1. Error loading remapped pgs
$ python3 scripts/upmap-remapped.py
Error loading remapped pgs

The output of subprocess.check_output is of type byte, so it needs to be decoded before being able to use split:

for line in subprocess.check_output(['ceph', 'osd', 'pool', 'ls', 'detail']).split('\n'):
  1. OSDS is not a list
    For the same reason, OSDS is byte and not list :
OSDS = subprocess.check_output(['ceph', 'osd', 'ls', '-f', 'json'])
  1. Harmful cast in valid_osds
    Casting osds to str is useless and breaks the lookup in :
def valid_osds(osds):
  valid = []
  for osd in osds:
    if str (osd) in OSDS:
      valid.append(osd)
  return valid

I'll submit a PR with the various fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions