xxh親測openstack的api操做

案例一:抓包構造出新建雲主機(實例)的url
1.wireshark打開抓vmware vmnet8的網卡,過濾條件tcp.port == 8774 && http.request.method == POST 開始啓動!
python

2.web上新建名稱爲wireshark的實例
xxh親測openstack的api操做
3.過濾條件tcp.port == 8774 && http.request.method == POST有數據了,打開此http流,圖片以下:
xxh親測openstack的api操做


web

POST /v2.1/c0e784c602af4b40933a78bc3dcda542/servers HTTP/1.1
Host: controller:8774
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: application/json
User-Agent: python-novaclient
X-Auth-Project-Id: c0e784c602af4b40933a78bc3dcda542
Content-Type: application/json
X-Auth-Token: gAAAAABfol5E8fphn3g-q4zoqt089FHoSefQL1OFeTIg6JqFPvB53mHZMX6-qPK0pNYYa0ce86z_3g_yNNEWh2HlkEVaZq16CIC6MmVcQeyTy69fpRlOYfZp90-FiEDiHFQlPMPoZlDb0yrhraaxKPW4jck9cbzAltnTCYkd8IEfu2R8JYFG0kBuZmQp-1-8Ksd_ZwQQS8O0
Content-Length: 349








json

{"server": {"name": "wireshark", "imageRef": "4dea33ea-a34f-4e07-845a-4c212deee901", "availability_zone": "nova", "key_name": "mykey", "flavorRef": "0", "OS-DCF:diskConfig": "AUTO", "max_count": 1, "min_count": 1, "networks": [{"uuid": "a730ba59-ca28-48e6-a7f6-11703e879b30"}], "security_groups": [{"name": "04a70b53-eea2-4b45-a11a-d66624b2c612"}]}}api

經過上面信息,構建一個api的url,用此url構建出第二臺虛擬機wireshark2,我構造出來的api url以下:
curl -X POST -H "Content-Type: application/json" -H "X-Auth-Token: gAAAAABfol5E8fphn3g-q4zoqt089FHoSefQL1OFeTIg6JqFPvB53mHZMX6-qPK0pNYYa0ce86z_3g_yNNEWh2HlkEVaZq16CIC6MmVcQeyTy69fpRlOYfZp90-FiEDiHFQlPMPoZlDb0yrhraaxKPW4jck9cbzAltnTCYkd8IEfu2R8JYFG0kBuZmQp-1-8Ksd_ZwQQS8O0" -d '
{
"server": {
"name": "wireshark2",
"imageRef": "4dea33ea-a34f-4e07-845a-4c212deee901",
"availability_zone": "nova",
"key_name": "mykey",
"flavorRef": "0",
"OS-DCF:diskConfig": "AUTO",
"max_count": 1,
"min_count": 1,
"networks": [{
"uuid": "a730ba59-ca28-48e6-a7f6-11703e879b30"
}],
"security_groups": [{
"name": "04a70b53-eea2-4b45-a11a-d66624b2c612"
}]
}
}' http://controller:8774/v2.1/c0e784c602af4b40933a78bc3dcda542/servers
以後也成功創建出來虛擬機了!(注意格式化的json串在cli執行前用文本工具吧tab替換爲空格哈!)
xxh親測openstack的api操做




















app

案例二:抓包構造出刪除雲主機(實例)的urlcurl

(2)刪除主機抓包獲得api
抓包過濾條件是tcp.port == 8774 && http.request.method == DELETE
獲得抓包信息以下:

tcp

DELETE /v2.1/c0e784c602af4b40933a78bc3dcda542/servers/e22e0fd1-44e2-487d-a37c-5d36c721ec1b HTTP/1.1
Host: controller:8774
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: application/json
User-Agent: python-novaclient
X-Auth-Project-Id: c0e784c602af4b40933a78bc3dcda542
X-Auth-Token: gAAAAABfol5E8fphn3g-q4zoqt089FHoSefQL1OFeTIg6JqFPvB53mHZMX6-qPK0pNYYa0ce86z_3g_yNNEWh2HlkEVaZq16CIC6MmVcQeyTy69fpRlOYfZp90-FiEDiHFQlPMPoZlDb0yrhraaxKPW4jck9cbzAltnTCYkd8IEfu2R8JYFG0kBuZmQp-1-8Ksd_ZwQQS8O0
Content-Length: 0







ide

下面是我經過上面的包構建出來的!
準備刪除wireshark4 他的標識是 c7a8e5bc-34d8-4373-a7b8-3b6f6de01aec
curl -X DELETE -H "Content-Type: application/json" -H "X-Auth-Token: gAAAAABfol5E8fphn3g-q4zoqt089FHoSefQL1OFeTIg6JqFPvB53mHZMX6-qPK0pNYYa0ce86z_3g_yNNEWh2HlkEVaZq16CIC6MmVcQeyTy69fpRlOYfZp90-FiEDiHFQlPMPoZlDb0yrhraaxKPW4jck9cbzAltnTCYkd8IEfu2R8JYFG0kBuZmQp-1-8Ksd_ZwQQS8O0" http://controller:8774/v2.1/c0e784c602af4b40933a78bc3dcda542/servers/c7a8e5bc-34d8-4373-a7b8-3b6f6de01aec

工具

備註:後面http是http://controller:8774/v2.1/c0e784c602af4b40933a78bc3dcda542/servers/[id]
其中c0e784c602af4b40933a78bc3dcda542是admin項目的id
xxh親測openstack的api操做
xxh親測openstack的api操做


ui

案例三:抓包構造出刪除卷、刪除鏡像等等操做的url均可以相似方法弄出來
此外那個token也能夠像老師那樣先抓出來利用$token變量存儲起來直接引用就不須要那麼長一段書寫了

明天再補充

(3) 刪除一個卷抓包獲得api
tcp.port == 8776 && http.request.method == DELETE

(4)新建卷 tcp.port == 8776 && http.request.method == POST

相關文章
相關標籤/搜索