天天看點

虛拟化平台cloudstack(8)——從UI開始UI處理http請求CloudStack API提供的三種角色API文檔的位址處理簡單列舉一下4.1中API的新特性配置8096端口使用API請求

ucloudstack采用的是前後端分離的架構,就是說前端可以選擇使用web、swing甚至其它的界面,都可以。

我們來看cloudstack的UI資訊吧,所有的cloudstack的UI都在{cloudstack_home}/cloudstack/ui目錄下。

虛拟化平台cloudstack(8)——從UI開始UI處理http請求CloudStack API提供的三種角色API文檔的位址處理簡單列舉一下4.1中API的新特性配置8096端口使用API請求

用firefox打開工程,打開firebug,找到login.js,在100行加上斷點。

虛拟化平台cloudstack(8)——從UI開始UI處理http請求CloudStack API提供的三種角色API文檔的位址處理簡單列舉一下4.1中API的新特性配置8096端口使用API請求

執行登入,這時就會觸發斷點,讓我們看看發生了什麼:

虛拟化平台cloudstack(8)——從UI開始UI處理http請求CloudStack API提供的三種角色API文檔的位址處理簡單列舉一下4.1中API的新特性配置8096端口使用API請求

最終是使用jquery的ajax來送出post請求給伺服器端,也就是說,manager server提供給我們的是一組API,我們可以通過http的請求方式送出請求。

看完了前端,我們繼續看一下後端處理。

在web.xml中,我們看到所有的api/請求都會到ApiServlet中處理。

在ApiServlet中,重點看下

這樣在web容器中就可以檢視spring中使用注解的接口了。

說實話這塊感覺設計的挺一般的,一個servlet裡邊承擔了太多的任務,我打了個斷點在

這個方法中,但是一個登入的操作就走了四次斷點,一個退出操作又走了兩次,不清楚這塊為什麼這樣設計。

而且很多業務代碼都在這個類中操作,感覺很備援。但這個不是我們重點關心的問題。

管​理​員​。​獲​得​雲​的​所​有​功​能​,包​括​虛​拟​和​物​理​資​源​管​理​。​

域​管​理​員​。​進​入​到​虛​拟​資​源​的​雲​屬​于​管​理​員​的​域​。

用​戶​。​隻​訪​問​允​許​用​戶​管​理​的​功​能​,虛​拟​實​例​,存​儲​,和​網​絡​。​

<a href="http://cloudstack.apache.org/docs/api/">http://cloudstack.apache.org/docs/api/</a>

可以看到不同角色的API的位址,進去之後,可以看到每個API的較長的描述。

在VM中重新配置實體網絡

支援IPV6

擴充VMX設定

重新設定SSH密鑰來通路虛拟機

在4.1中改變的API指令:

API Commands

Description

createNetworkOffering

The following request parameters have been added:

isPersistent

startipv6

endipv6

ip6gateway

ip6cidr

listNetworkOfferings

listNetworks

This parameter determines if the network or network offering listed are persistent or not.

createVlanIpRange

deployVirtualMachine

The following parameter has been added: ip6Address.

The following parameter is updated to accept the IPv6 address: iptonetworklist.

CreateZoneCmd

The following parameter have been added: ip6dns1, ip6dns2.

listRouters

listVirtualMachines

For nic responses, the following fields have been added.

ip6address

listVlanIpRanges

listZones

For DomainRouter and DataCenter response, the following fields have been added.

ip6dns1

ip6dns2

addF5LoadBalancer

configureNetscalerLoadBalancer

addNetscalerLoadBalancer

listF5LoadBalancers

configureF5LoadBalancer

listNetscalerLoadBalancers

The following response parameter is removed: inline.

listFirewallRules

createFirewallRule

The following request parameter is added: traffictype (optional).

listUsageRecords

The following response parameter is added: virtualsize.

deleteIso

The following request parameter is added: forced (optional).

createStoragePool

The following request parameters are made mandatory:

podid

clusterid

createAccount

The following new request parameters are added: accountid, userid

createUser

The following new request parameter is added: userid

createDomain

The following new request parameter is added: domainid

The following request parameters is added: securitygroupenabled

同時添加了一些新的API

createEgressFirewallRules (creates an egress firewall rule on the guest network.)

deleteEgressFirewallRules (deletes a egress firewall rule on the guest network.)

listEgressFirewallRules (lists the egress firewall rules configured for a guest network.)

resetSSHKeyForVirtualMachine (Resets the SSHkey for virtual machine.)

addBaremetalHost (Adds a new host.)

addNicToVirtualMachine (Adds a new NIC to the specified VM on a selected network.)

removeNicFromVirtualMachine (Removes the specified NIC from a selected VM.)

updateDefaultNicForVirtualMachine (Updates the specified NIC to be the default one for a selected VM.)

addRegion (Registers a Region into another Region.)

updateRegion (Updates Region details: ID, Name, Endpoint, User API Key, and User Secret Key.)

removeRegion (Removes a Region from current Region.)

listRegions (List all the Regions. Filter them by using the ID or Name.)

getUser (This API can only be used by the Admin. Get user details by using the API Key.)

8096端​口​, 不​需​要​驗​證​即​可​進​行​API調​用​. 在​所​有​的​3.0.1版​本​全​新​安​裝​時​, 這​個​端​口​都​是​默​認​被​禁​用​的​. 你​可​以​通​過​下​面​的​設​置​啟​用​8096(或​使​用​其​它​端​口​号​):

确​保​第​一​個​管​理​服​務​器​安​裝​并​運​行​.

設​置​你​期​望​的​端​口​号​到​全​局​配​置​參​數​ integration.api.port.

重​啟​管​理​服​務​器​.

在​管​理​服​務​器​的​節​點​上​, 創​建​一​個​防​火​牆​規​則​以​便​允​許​訪​問​這​個​端​口​.

虛拟化平台cloudstack(8)——從UI開始UI處理http請求CloudStack API提供的三種角色API文檔的位址處理簡單列舉一下4.1中API的新特性配置8096端口使用API請求

所​有​CloudStack API請​求​都​是​以​HTTP GET/POST形​式​提​交​, 同​時​附​上​相​關​的​命​令​和​參​數​. 無​論​是​HTTP或​HTTPS, 一​個​請​求​都​有​以​下​内​容​組​成​:

CloudStack API URL: 這​是​Web服​務​API入​口​(例​如​, http://www.cloud.com:8080/client/api)

命​令​: 你​想​要​執​行​的​Web服​務​命​令​, 比​如​開​啟​一​個​虛​拟​機​或​創​建​一​個​磁​盤​卷​

參​數​: 命​令​所​需​的​任​何​必​要​或​可​選​的​參​數​

一​個​API GET請​求​的​樣​例​看​起​來​像​這​樣​:

更容易讀的方式: