02、openstack4j建立通用的认证连接公共方法
02、openstack4j建立通用的认证连接公共方法
翰霖学院 发表于5个月前
02、openstack4j建立通用的认证连接公共方法
  • 发表于 5个月前
  • 阅读 8
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

keystone基本概念的介绍

这里写图片描述

To access some service, users provide their credentials to Keystone and receive a token. The token is just a string that is connected to the user and tenant internally by Keystone. This token travels between services with every user request or requests generated by a service to another service to process the user’s request.The users find a URL of a service that they need. If the user, for example, wants to spawn a new VM instance in Nova, one can find an URL to Nova in the list of endpoints provided by Keystone and send an appropriate request.After that, Nova verifies the validity of the token in Keystone and should create an instance from some image by the provided image ID and plug it into some network. At first Nova passes this token to Glance to get the image stored somewhere in there. After that, it asks Quantum to plug this new instance into a network; Quantum verifies whether the user has access to the network in its own database and to the interface of VM by requesting info in Nova. All the way this token travels between services so that they can ask Keystone or each other for additional information or some actions.

直接上代码

/** *建立认证连接 **/
public OSClientV3 getOSClientV3(String tenantId,String userid,
                                     String password,String region){
        String url = "http://127.0.0.1:5000/v3";

        if (tenantId == null || tenantId.equals("")) {
            tenantId = "defaultTenantId";
        }
        OSClientV3 osv3 = OSFactory.builderV3().endpoint(url)
                                                 .credentials(userid, password)
                .scopeToProject(Identifier.byId(tenantId)).authenticate();
        if (region != null && !"".equals(region)) {
            osv3.useRegion(region);
        }
        return osv3;

}
标签: OpenStack
共有 人打赏支持
粉丝 0
博文 67
码字总数 45112
×
翰霖学院
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: