OpenStack4j中怎么實(shí)現(xiàn)一個(gè)對(duì)外接口 ,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
創(chuàng)新互聯(lián)是一家專注網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷策劃、成都小程序開(kāi)發(fā)、電子商務(wù)建設(shè)、網(wǎng)絡(luò)推廣、移動(dòng)互聯(lián)開(kāi)發(fā)、研究、服務(wù)為一體的技術(shù)型公司。公司成立十載以來(lái),已經(jīng)為成百上千家成都邊坡防護(hù)網(wǎng)各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務(wù)?,F(xiàn)在,服務(wù)的成百上千家客戶與我們一路同行,見(jiàn)證我們的成長(zhǎng);未來(lái),我們一起分享成功的喜悅。
org.pacesys openstack4j 3.0.3 withdeps
import org.openstack4j.api.OSClient.OSClientV3;import org.openstack4j.openstack.OSFactory;import org.openstack4j.model.common.Identifier; # use Identifier.byId("domainId") or Identifier.byName("example-domain") Identifier domainIdentifier = Identifier.byId("domainId"); # unscoped authentication # as the username is not unique across domains you need to provide the domainIdentifier OSClientV3 os = OSFactory.builderV3() .endpoint("http://127.0.0.1:5000/v3") .credentials("admin","sample", domainIdentifier) .authenticate(); # project scoped authentication OSClientV3 os = OSFactory.builderV3() .endpoint("http://127.0.0.1:5000/v3") .credentials("admin", "secret", Identifier.byName("example-domain")) .scopeToProject(Identifier.byId(projectIdentifier)) .authenticate(); # domain scoped authentication # using the unique userId does not require a domainIdentifier OSClientV3 os = OSFactory.builderV3() .endpoint("http://127.0.0.1:5000/v3") .credentials("userId", "secret") .scopeToDomain(Identifier.byId(domainIdentifier)) .authenticate(); # Scoping to a project just by name isn't possible as the project name is only unique within a domain. # You can either use this as the id of the project is unique across domains OSClientV3 os = OSFactory.builderV3() .endpoint("http://127.0.0.1:5000/v3") .credentials("userId", "secret") .scopeToProject(Identifier.byName(projectName), Identifier.byName(domainName)) .authenticate(); # Or alternatively OSClientV3 os = OSFactory.builderV3() .endpoint("http://127.0.0.1:5000/v3") .credentials("userId", "secret") .scopeToDomain(Identifier.byName(domainName)) .authenticate();
// Find all UsersList extends User> users = os.identity().users().list();// List all TenantsList extends Tenant> tenants = os.identity().tenants().list();// Find all Compute FlavorsList extends Flavor> flavors = os.compute().flavors().list();// Find all running ServersList extends Server> servers = os.compute().servers().list();// Suspend a Serveros.compute().servers().action("serverId", Action.SUSPEND);// List all NetworksList extends Network> networks = os.networking().network().list();// List all SubnetsList extends Subnet> subnets = os.networking().subnet().list();// List all RoutersList extends Router> routers = os.networking().router().list();// List all Images (Glance)List extends Image> images = os.images().list();// Download the Image DataInputStream is = os.images().getAsStream("imageId");
看完上述內(nèi)容,你們掌握OpenStack4j中怎么實(shí)現(xiàn)一個(gè)對(duì)外接口 的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!