Merge "Read GPT label using sgdisk rather than udev"
This commit is contained in:
commit
0f9534bc23
@ -1,6 +1,6 @@
|
||||
---
|
||||
- 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
|
||||
-a "partition_name='KOLLA_CEPH_OSD_BOOTSTRAP' match_mode='prefix'"
|
||||
register: osd_lookup
|
||||
@ -12,7 +12,7 @@
|
||||
osds_bootstrap: "{{ (osd_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).disks|from_json }}"
|
||||
|
||||
- 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
|
||||
-a "partition_name='KOLLA_CEPH_OSD_CACHE_BOOTSTRAP' match_mode='prefix'"
|
||||
register: osd_cache_lookup
|
||||
|
@ -10,7 +10,7 @@
|
||||
- { name: ceph_mon, group: ceph-mon }
|
||||
|
||||
- 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
|
||||
-a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'"
|
||||
register: osd_lookup
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- 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
|
||||
-a "partition_name='KOLLA_CEPH_DATA' match_mode='prefix'"
|
||||
register: osd_lookup
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- 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
|
||||
-a "name={{ swift_devices_name }}
|
||||
match_mode={{ swift_devices_match_mode }}"
|
||||
|
@ -7,6 +7,7 @@ MAINTAINER {{ maintainer }}
|
||||
|
||||
RUN yum -y install \
|
||||
gcc \
|
||||
gdisk \
|
||||
git \
|
||||
libffi-devel \
|
||||
libxml2-devel \
|
||||
@ -23,6 +24,7 @@ RUN yum -y install \
|
||||
RUN apt-get -y --no-install-recommends install \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
gdisk \
|
||||
git \
|
||||
libffi-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 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"]
|
||||
|
||||
{{ include_footer }}
|
||||
|
1
docker/kolla-toolbox/ansible_sudoers
Normal file
1
docker/kolla-toolbox/ansible_sudoers
Normal file
@ -0,0 +1 @@
|
||||
ansible ALL=(root) NOPASSWD: /usr/bin/ansible localhost -m find_disks -a *
|
@ -67,11 +67,36 @@ EXAMPLES = '''
|
||||
import json
|
||||
import pyudev
|
||||
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):
|
||||
if dev.get('DEVTYPE', '') == 'partition':
|
||||
dev_name = dev.get('ID_PART_ENTRY_NAME', '')
|
||||
dev_name = get_id_part_entry_name(dev)
|
||||
else:
|
||||
dev_name = dev.get('ID_FS_LABEL', '')
|
||||
|
||||
@ -107,7 +132,7 @@ def extract_disk_info(ct, dev, name):
|
||||
kwargs['journal_num'] = 2
|
||||
else:
|
||||
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'):
|
||||
kwargs['journal'] = journal.device_node
|
||||
kwargs['journal_device'] = \
|
||||
|
Loading…
Reference in New Issue
Block a user