0

我面临 yaml 转储的问题。

我的输入:

{"Controller_node1_external_port": {"block_device_mapping": [{"device_name": "/dev/vda1", "volume_id": "helloooo", "delete_on_termination": "False"}],"properties": {"fixed_ips": [{"ip_address": "12.0.0.1"}],"network_id": {"get_param": ["ex_net_map_param",{"get_param": "ex_net_param"}]}},"type": "OS::Neutron::Port"}}

这里的 block_device_mapping 是一个列表。

yaml.dump(test,default_flow_style=False) 给我以下输出:

  Controller_node1_external_port: 
    block_device_mapping: 
      - device_name: "/dev/vda1"
      - volume_id: "helloooo"
      - delete_on_termination: "False"
    properties:
      fixed_ips:
      - ip_address: 12.0.0.1
      network_id:
        get_param:
        - ex_net_map_param
        - {get_param: ex_net_param}
    type: OS::Neutron::Port

期望的输出:

  Controller_node1_external_port: 
    block_device_mapping: 
      - device_name: "/dev/vda1"
        volume_id: "helloooo"
        delete_on_termination: "False"
    properties:
      fixed_ips:
      - ip_address: 12.0.0.1
      network_id:
        get_param:
        - ex_net_map_param
        - {get_param: ex_net_param}
    type: OS::Neutron::Port
4

0 回答 0