Merge "Read GPT label using sgdisk rather than udev"

This commit is contained in:
Jenkins 2016-07-08 15:22:24 +00:00 committed by Gerrit Code Review
commit 0f9534bc23
7 changed files with 38 additions and 7 deletions

View File

@ -1,6 +1,6 @@
--- ---
- name: Looking up disks to bootstrap for Ceph OSDs - name: Looking up disks to bootstrap for Ceph OSDs
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost command: docker exec -t kolla_toolbox sudo -E /usr/bin/ansible localhost
-m find_disks -m find_disks
-a "partition_name='KOLLA_CEPH_OSD_BOOTSTRAP' match_mode='prefix'" -a "partition_name='KOLLA_CEPH_OSD_BOOTSTRAP' match_mode='prefix'"
register: osd_lookup register: osd_lookup
@ -12,7 +12,7 @@
osds_bootstrap: "{{ (osd_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).disks|from_json }}" osds_bootstrap: "{{ (osd_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).disks|from_json }}"
- name: Looking up disks to bootstrap for Ceph Cache OSDs - name: Looking up disks to bootstrap for Ceph Cache OSDs
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost command: docker exec -t kolla_toolbox sudo -E /usr/bin/ansible localhost
-m find_disks -m find_disks
-a "partition_name='KOLLA_CEPH_OSD_CACHE_BOOTSTRAP' match_mode='prefix'" -a "partition_name='KOLLA_CEPH_OSD_CACHE_BOOTSTRAP' match_mode='prefix'"
register: osd_cache_lookup register: osd_cache_lookup

View File

@ -10,7 +10,7 @@
- { name: ceph_mon, group: ceph-mon } - { name: ceph_mon, group: ceph-mon }
- name: Looking up OSDs for Ceph - name: Looking up OSDs for Ceph
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost command: docker exec -t kolla_toolbox sudo -E /usr/bin/ansible localhost
-m find_disks -m find_disks
-a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'" -a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'"
register: osd_lookup register: osd_lookup

View File

@ -1,6 +1,6 @@
--- ---
- name: Looking up OSDs for Ceph - name: Looking up OSDs for Ceph
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost command: docker exec -t kolla_toolbox sudo -E /usr/bin/ansible localhost
-m find_disks -m find_disks
-a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'" -a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'"
register: osd_lookup register: osd_lookup

View File

@ -1,6 +1,6 @@
--- ---
- name: Looking up disks for Swift - name: Looking up disks for Swift
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost command: docker exec -t kolla_toolbox sudo -E /usr/bin/ansible localhost
-m find_disks -m find_disks
-a "name={{ swift_devices_name }} -a "name={{ swift_devices_name }}
match_mode={{ swift_devices_match_mode }}" match_mode={{ swift_devices_match_mode }}"

View File

@ -7,6 +7,7 @@ MAINTAINER {{ maintainer }}
RUN yum -y install \ RUN yum -y install \
gcc \ gcc \
gdisk \
git \ git \
libffi-devel \ libffi-devel \
libxml2-devel \ libxml2-devel \
@ -23,6 +24,7 @@ RUN yum -y install \
RUN apt-get -y --no-install-recommends install \ RUN apt-get -y --no-install-recommends install \
build-essential \ build-essential \
ca-certificates \ ca-certificates \
gdisk \
git \ git \
libffi-dev \ libffi-dev \
libmariadbclient-dev \ libmariadbclient-dev \
@ -56,6 +58,9 @@ RUN useradd -m --user-group ansible --groups kolla \
COPY find_disks.py kolla_keystone_service.py kolla_keystone_user.py kolla_sanity.py kolla_zookeeper.py /usr/share/ansible/ COPY find_disks.py kolla_keystone_service.py kolla_keystone_user.py kolla_sanity.py kolla_zookeeper.py /usr/share/ansible/
COPY ansible.cfg /home/ansible/.ansible.cfg COPY ansible.cfg /home/ansible/.ansible.cfg
COPY ansible_sudoers /etc/sudoers.d/ansible_sudoers
RUN chmod 440 /etc/sudoers.d/ansible_sudoers
CMD ["/bin/sleep", "infinity"] CMD ["/bin/sleep", "infinity"]
{{ include_footer }} {{ include_footer }}

View File

@ -0,0 +1 @@
ansible ALL=(root) NOPASSWD: /usr/bin/ansible localhost -m find_disks -a *

View File

@ -67,11 +67,36 @@ EXAMPLES = '''
import json import json
import pyudev import pyudev
import re import re
import subprocess
def get_id_part_entry_name(dev):
# NOTE(pbourke): Old versions of udev have trouble retrieving GPT partition
# labels. In this case shell out to sgdisk.
try:
udev_version = pyudev.udev_version()
except (ValueError, EnvironmentError, subprocess.CalledProcessError):
udev_version = -1
if udev_version >= 180:
dev_name = dev.get('ID_PART_ENTRY_NAME', '')
else:
part = re.sub(r'.*[^\d]', '', dev.device_node)
parent = dev.find_parent('block').device_node
# NOTE(Mech422): Need to use -i as -p truncates the partition name
out = subprocess.Popen(['/usr/sbin/sgdisk', '-i', part, parent],
stdout=subprocess.PIPE).communicate()
match = re.search(r'Partition name: \'(\w+)\'', out[0])
if match:
dev_name = match.group(1)
else:
dev_name = ''
return dev_name
def is_dev_matched_by_name(dev, name, mode): def is_dev_matched_by_name(dev, name, mode):
if dev.get('DEVTYPE', '') == 'partition': if dev.get('DEVTYPE', '') == 'partition':
dev_name = dev.get('ID_PART_ENTRY_NAME', '') dev_name = get_id_part_entry_name(dev)
else: else:
dev_name = dev.get('ID_FS_LABEL', '') dev_name = dev.get('ID_FS_LABEL', '')
@ -107,7 +132,7 @@ def extract_disk_info(ct, dev, name):
kwargs['journal_num'] = 2 kwargs['journal_num'] = 2
else: else:
kwargs['external_journal'] = True kwargs['external_journal'] = True
journal_name = dev.get('ID_PART_ENTRY_NAME', '') + '_J' journal_name = get_id_part_entry_name(dev) + '_J'
for journal in find_disk(ct, journal_name, 'strict'): for journal in find_disk(ct, journal_name, 'strict'):
kwargs['journal'] = journal.device_node kwargs['journal'] = journal.device_node
kwargs['journal_device'] = \ kwargs['journal_device'] = \