网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

OpenStack4j中怎么实现一个对外接口

OpenStack4j中怎么实现一个对外接口 ,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

创新互联是一家专注网站建设、网络营销策划、成都小程序开发、电子商务建设、网络推广、移动互联开发、研究、服务为一体的技术型公司。公司成立十载以来,已经为成百上千家成都边坡防护网各业的企业公司提供互联网服务。现在,服务的成百上千家客户与我们一路同行,见证我们的成长;未来,我们一起分享成功的喜悦。

在项目中增加maven依赖包


  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 users = os.identity().users().list();// List all TenantsList tenants = os.identity().tenants().list();// Find all Compute FlavorsList flavors = os.compute().flavors().list();// Find all running ServersList servers = os.compute().servers().list();// Suspend a Serveros.compute().servers().action("serverId", Action.SUSPEND);// List all NetworksList networks = os.networking().network().list();// List all SubnetsList subnets = os.networking().subnet().list();// List all RoutersList routers = os.networking().router().list();// List all Images (Glance)List images = os.images().list();// Download the Image DataInputStream is = os.images().getAsStream("imageId");

看完上述内容,你们掌握OpenStack4j中怎么实现一个对外接口 的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


网页题目:OpenStack4j中怎么实现一个对外接口
网页链接:http://bjjierui.cn/article/pojdjj.html

其他资讯