Last active
August 3, 2020 13:35
-
-
Save jschmid1/7e3b6a8b11a17e893f7bb0fd030ea5f3 to your computer and use it in GitHub Desktop.
migrate old dg to cephadm osdspecs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| deepsea_drive_group = """ | |
| drive_group_default: | |
| target: 'dc-north' | |
| data_devices: | |
| model: SSD-123-foo | |
| db_devices: | |
| model: MC-55-44-XZ | |
| format: bluestore | |
| encryption: True | |
| --- | |
| another_dg: | |
| target: 'dc-south' | |
| data_devices: | |
| model: SSD_111_FD | |
| db_devices: | |
| model: NVME_222_LD | |
| format: bluestore | |
| encryption: False | |
| """ | |
| import yaml | |
| class OrigDriveGroup: | |
| def migrate(self, data): | |
| self.__setattr__('service_type', 'osd') | |
| self.__setattr__('filter_logic', 'OR') | |
| for name, spec in data.items(): | |
| self.__setattr__('service_id', name) | |
| for k, v in spec.items(): | |
| self.__setattr__(k, v) | |
| def __setattr__(self, key, value): | |
| if key == 'format' and value not in ['bluestore']: | |
| raise Exception('Only <bluestore> is supported.') | |
| if key == 'target': | |
| self.__dict__['placement'] = dict(host_pattern=value) | |
| return | |
| # more known restrictions & changes go here | |
| self.__dict__[key] = value | |
| def to_yaml(self): | |
| return yaml.safe_dump(self.__dict__) | |
| for dg in yaml.safe_load_all(deepsea_drive_group): | |
| dg_o = OrigDriveGroup() | |
| dg_o.migrate(dg) | |
| osdspec = dg_o.to_yaml() | |
| print(osdspec) | |
| """ | |
| data_devices: | |
| model: SSD-123-foo | |
| db_devices: | |
| model: MC-55-44-XZ | |
| encryption: true | |
| filter_logic: OR | |
| format: bluestore | |
| placement: | |
| host_pattern: dc-north | |
| service_id: drive_group_default | |
| service_type: osd | |
| data_devices: | |
| model: SSD_111_FD | |
| db_devices: | |
| model: NVME_222_LD | |
| encryption: false | |
| filter_logic: OR | |
| format: bluestore | |
| placement: | |
| host_pattern: dc-south | |
| service_id: another_dg | |
| service_type: osd | |
| """ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment