mirror of
https://github.com/ceph/ceph
synced 2025-04-01 23:02:17 +00:00
Merge pull request #46207 from rkachach/fix_issue_55555
mgr/cephadm: fixing yaml parsing during bootstrap Reviewed-by: Adam King <adking@redhat.com>
This commit is contained in:
commit
e01758e75b
@ -5308,7 +5308,7 @@ def _parse_yaml_docs(f: Iterable[str]) -> List[List[str]]:
|
|||||||
docs = []
|
docs = []
|
||||||
current_doc = [] # type: List[str]
|
current_doc = [] # type: List[str]
|
||||||
for line in f:
|
for line in f:
|
||||||
if '---' in line:
|
if re.search(r'^---\s+', line):
|
||||||
if current_doc:
|
if current_doc:
|
||||||
docs.append(current_doc)
|
docs.append(current_doc)
|
||||||
current_doc = []
|
current_doc = []
|
||||||
|
@ -2018,7 +2018,8 @@ class TestPull:
|
|||||||
class TestApplySpec:
|
class TestApplySpec:
|
||||||
|
|
||||||
def test_parse_yaml(self, cephadm_fs):
|
def test_parse_yaml(self, cephadm_fs):
|
||||||
yaml = '''service_type: host
|
yaml = '''---
|
||||||
|
service_type: host
|
||||||
hostname: vm-00
|
hostname: vm-00
|
||||||
addr: 192.168.122.44
|
addr: 192.168.122.44
|
||||||
labels:
|
labels:
|
||||||
@ -2030,16 +2031,46 @@ hostname: vm-01
|
|||||||
addr: 192.168.122.247
|
addr: 192.168.122.247
|
||||||
labels:
|
labels:
|
||||||
- grafana
|
- grafana
|
||||||
---
|
---
|
||||||
service_type: host
|
service_type: host
|
||||||
hostname: vm-02
|
hostname: vm-02
|
||||||
addr: 192.168.122.165'''
|
addr: 192.168.122.165
|
||||||
|
---
|
||||||
|
---
|
||||||
|
service_type: rgw
|
||||||
|
service_id: myrgw
|
||||||
|
spec:
|
||||||
|
rgw_frontend_ssl_certificate: |
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
V2VyIGRhcyBsaWVzdCBpc3QgZG9vZi4gTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFt
|
||||||
|
ZXQsIGNvbnNldGV0dXIgc2FkaXBzY2luZyBlbGl0ciwgc2VkIGRpYW0gbm9udW15
|
||||||
|
IGVpcm1vZCB0ZW1wb3IgaW52aWR1bnQgdXQgbGFib3JlIGV0IGRvbG9yZSBtYWdu
|
||||||
|
YSBhbGlxdXlhbSBlcmF0LCBzZWQgZGlhbSB2b2x1cHR1YS4gQXQgdmVybyBlb3Mg
|
||||||
|
ZXQgYWNjdXNhbSBldCBqdXN0byBkdW8=
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
V2VyIGRhcyBsaWVzdCBpc3QgZG9vZi4gTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFt
|
||||||
|
ZXQsIGNvbnNldGV0dXIgc2FkaXBzY2luZyBlbGl0ciwgc2VkIGRpYW0gbm9udW15
|
||||||
|
IGVpcm1vZCB0ZW1wb3IgaW52aWR1bnQgdXQgbGFib3JlIGV0IGRvbG9yZSBtYWdu
|
||||||
|
YSBhbGlxdXlhbSBlcmF0LCBzZWQgZGlhbSB2b2x1cHR1YS4gQXQgdmVybyBlb3Mg
|
||||||
|
ZXQgYWNjdXNhbSBldCBqdXN0byBkdW8=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
ssl: true
|
||||||
|
---
|
||||||
|
'''
|
||||||
|
|
||||||
cephadm_fs.create_file('spec.yml', contents=yaml)
|
cephadm_fs.create_file('spec.yml', contents=yaml)
|
||||||
|
|
||||||
retdic = [{'service_type': 'host', 'hostname': 'vm-00', 'addr': '192.168.122.44', 'labels': '- example1- example2'},
|
retdic = [{'service_type': 'host', 'hostname': 'vm-00', 'addr': '192.168.122.44', 'labels': '- example1- example2'},
|
||||||
{'service_type': 'host', 'hostname': 'vm-01', 'addr': '192.168.122.247', 'labels': '- grafana'},
|
{'service_type': 'host', 'hostname': 'vm-01', 'addr': '192.168.122.247', 'labels': '- grafana'},
|
||||||
{'service_type': 'host', 'hostname': 'vm-02', 'addr': '192.168.122.165'}]
|
{'service_type': 'host', 'hostname': 'vm-02', 'addr': '192.168.122.165'},
|
||||||
|
{'service_id': 'myrgw',
|
||||||
|
'service_type': 'rgw',
|
||||||
|
'spec':
|
||||||
|
'rgw_frontend_ssl_certificate: |-----BEGIN PRIVATE '
|
||||||
|
'KEY-----V2VyIGRhcyBsaWVzdCBpc3QgZG9vZi4gTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNldGV0dXIgc2FkaXBzY2luZyBlbGl0ciwgc2VkIGRpYW0gbm9udW15IGVpcm1vZCB0ZW1wb3IgaW52aWR1bnQgdXQgbGFib3JlIGV0IGRvbG9yZSBtYWduYSBhbGlxdXlhbSBlcmF0LCBzZWQgZGlhbSB2b2x1cHR1YS4gQXQgdmVybyBlb3MgZXQgYWNjdXNhbSBldCBqdXN0byBkdW8=-----END '
|
||||||
|
'PRIVATE KEY----------BEGIN '
|
||||||
|
'CERTIFICATE-----V2VyIGRhcyBsaWVzdCBpc3QgZG9vZi4gTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNldGV0dXIgc2FkaXBzY2luZyBlbGl0ciwgc2VkIGRpYW0gbm9udW15IGVpcm1vZCB0ZW1wb3IgaW52aWR1bnQgdXQgbGFib3JlIGV0IGRvbG9yZSBtYWduYSBhbGlxdXlhbSBlcmF0LCBzZWQgZGlhbSB2b2x1cHR1YS4gQXQgdmVybyBlb3MgZXQgYWNjdXNhbSBldCBqdXN0byBkdW8=-----END '
|
||||||
|
'CERTIFICATE-----ssl: true'}]
|
||||||
|
|
||||||
with open('spec.yml') as f:
|
with open('spec.yml') as f:
|
||||||
dic = cd.parse_yaml_objs(f)
|
dic = cd.parse_yaml_objs(f)
|
||||||
|
@ -1054,8 +1054,11 @@ Usage:
|
|||||||
if inbuf:
|
if inbuf:
|
||||||
if service_type or placement or unmanaged:
|
if service_type or placement or unmanaged:
|
||||||
raise OrchestratorValidationError(usage)
|
raise OrchestratorValidationError(usage)
|
||||||
content: Iterator = yaml.safe_load_all(inbuf)
|
yaml_objs: Iterator = yaml.safe_load_all(inbuf)
|
||||||
specs: List[Union[ServiceSpec, HostSpec]] = []
|
specs: List[Union[ServiceSpec, HostSpec]] = []
|
||||||
|
# YAML '---' document separator with no content generates
|
||||||
|
# None entries in the output. Let's skip them silently.
|
||||||
|
content = [o for o in yaml_objs if o is not None]
|
||||||
for s in content:
|
for s in content:
|
||||||
spec = json_to_generic_spec(s)
|
spec = json_to_generic_spec(s)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user