第 5 章 故障排除

5.1. 测试 Keystone 映射规则

建议您验证映射规则是否按预期工作。keystone-manage 命令行工具允许您对从文件中读取的断言数据执行一组映射规则(从文件读取)。例如:

  1. 文件 mapping_rules.json 具有此内容:

    [
        {
            "local": [
                {
                    "user": {
                        "name": "{0}"
                    },
                    "group": {
                        "domain": {
                            "name": "Default"
                        },
                        "name": "federated_users"
                    }
                }
            ],
            "remote": [
                {
                    "type": "MELLON_NAME_ID"
                },
                {
                    "type": "MELLON_groups",
                    "any_one_of": ["openstack-users"]
                }
            ]
        }
    ]
  2. 文件 assertion_data.txt 具有此内容:

    MELLON_NAME_ID: 'G-90eb44bc-06dc-4a90-aa6e-fb2aa5d5b0de
    MELLON_groups: openstack-users;ipausers
  3. 如果运行此命令,请运行以下命令:

    $ keystone-manage mapping_engine --rules mapping_rules.json --input assertion_data.txt
  4. 您应该获得此映射的结果:

    {
      "group_ids": [],
      "user": {
        "domain": {
          "id": "Federated"
        },
        "type": "ephemeral",
        "name": "'G-90eb44bc-06dc-4a90-aa6e-fb2aa5d5b0de"
      },
      "group_names": [
        {
          "domain": {
            "name": "Default"
          },
          "name": "federated_users"
        }
      ]
    }
注意

您还可以包含 --engine-debug 命令行参数,该参数将输出描述如何评估映射规则的诊断信息。