Magnum群集创建

时间:2018-06-15 10:13:14

标签: openstack

根据https://developer.openstack.org/api-ref/container-infrastructure-management/#create-new-cluster所有我需要创建群集的方法是传递像:

这样的参数
 curl --header "X-Auth-Token: blah" \
 -X POST https://myopenstack:9511/v1/clusters -d name="Swarm-cluster-ansible" -d cluster_template_id="7402f9d3-4881-440f-8496-08d420935f58" -d node_count=2 -d keypair="k8s-gitlab-ci"

它给了我:

{"errors": [{"status": 400, "code": "client", "links": [], "title": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "detail": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "request_id": ""}]}

如果我这样试试:

curl --header "X-Auth-Token: blah" \
 -X POST https://myopenstack:9511/v1/clusters -d cluster='{
   "name":"swarm",
   "master_count":1,
   "discovery_url":null,
   "cluster_template_id":"7402f9d3-4881-440f-8496-08d420935f58",
   "node_count":1,
   "keypair":"k8s-gitlab-ci",
   "master_flavor_id":null,
   "labels":{
   },
   "flavor_id":null
}'


{"errors": [{"status": 400, "code": "client", "links": [], "title": "Invalid input for field/attribute cluster", "detail": "Invalid input for field/attribute cluster. Value: '{\n   \"name\":\"swarm\",\n   \"master_count\":1,\n   \"discovery_url\":null,\n   \"cluster_template_id\":\"7402f9d3-4881-440f-8496-08d420935f58\",\n   \"node_count\":1,\n   \"keypair\":\"k8s-gitlab-ci\",\n   \"master_flavor_id\":null,\n   \"labels\":{\n   },\n   \"flavor_id\":null\n}'. unable to convert to Cluster. Error: __init__() takes exactly 1 argument (2 given)", "request_id": ""}]}

有什么想法吗?

编辑:我能够进行GET并检索现有集群的列表。

1 个答案:

答案 0 :(得分:1)

在这种情况下,

-H "Content-Type: application/json"已足够,因此正文被解释为JSON。