调用flavor
import requests
import json
headers={}
headers['Content-Type']='application/json'
headers['X-Auth-Token']=''
a={
'flavor':{
'id':'1234',
'name':'pvm_flavor',
'ram':2048,
'vcpus':2,
'disk':20
}
}
a=requests.post(url='http://172.25.253.17:8774/v2.1/flavors',data=json.dumps(a),headers=headers)
print(a.text)
print("云主机类型创建成功")
# python3 create_flavor.py
{"flavor": {"name": "pvm_flavor", "links": [{"href": "http://172.25.253.17:8774/v2.1/flavors/1234", "rel": "self"}, {"href": "http://172.25.253.17:8774/flavors/1234", "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 20, "id": "1234"}}
云主机类型创建成功