设为首页 收藏本站
查看: 524|回复: 0

[经验分享] libcloud----keystone----openstack SAIO

[复制链接]
发表于 2017-6-26 15:23:07 | 显示全部楼层 |阅读模式
keystone配置
  /etc/keystone/keystone.conf配置:



[DEFAULT]
admin_token=91c81bf488a68a6621a5
admin_port=35757
public_port=5005
public_endpoint=http://localhost:%(public_port)s/
admin_endpoint=http://localhost:%(admin_port)s/
verbose=True

[database]
connection = mysql://keystone:keystone@localhost/keystone

[memcache]
servers=localhost:11211

[revoke]
driver=keystone.contrib.revoke.backends.sql.Revoke

[token]
provider=keystone.token.providers.uuid.Provider
driver = keystone.token.backends.sql.Token

[extra_headers]
Distribution = Ubuntu
  /etc/apache2/apache2.conf里面添加 ServerName 127.0.0.1
  /etc/apache2/sites-available/wsgi-keystone.conf :  (改端口,免得被tcp6占用)



Listen 5005
Listen 35757
  
<VirtualHost *:5005>
     WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone display-name=%{GROUP}
     WSGIProcessGroup keystone-public
     WSGIScriptAlias / /var/www/cgi-bin/keystone/main
     WSGIApplicationGroup %{GLOBAL}
     WSGIPassAuthorization On
     <IfVersion >= 2.4>
       ErrorLogFormat "%{cu}t %M"
     </IfVersion>
     LogLevel info
     ErrorLog /var/log/apache2/keystone-error.log
     CustomLog /var/log/apache2/keystone-access.log combined
</VirtualHost>
<VirtualHost *:35757>
     WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone display-name=%{GROUP}
     WSGIProcessGroup keystone-admin
     WSGIScriptAlias / /var/www/cgi-bin/keystone/admin
     WSGIApplicationGroup %{GLOBAL}
     WSGIPassAuthorization On
     <IfVersion >= 2.4>
       ErrorLogFormat "%{cu}t %M"
     </IfVersion>
     LogLevel info
     ErrorLog /var/log/apache2/keystone-error.log
     CustomLog /var/log/apache2/keystone-access.log combined
</VirtualHost>
本地SAIO配置
  /etc/swift/proxy-server.conf:



[DEFAULT]
bind_ip = 127.0.0.1
bind_port = 8080
workers = 1
user = meow
log_facility = LOG_LOCAL1
eventlet_debug = true
swift_dir = /etc/swift

[pipeline:main]
pipeline = catch_errors healthcheck cache authtoken proxy-server

[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin,_member_
reseller_prefix=AUTH_

[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
delay_auth_decision = true
signing_dir = /home/meow/keystone-signing

auth_protocol = http
auth_host = 127.0.0.1
auth_port = 35757
service_host=127.0.0.1
service_port=5005
auth_uri=http://localhost:35757/v2.0
identity_uri=http://localhost:35757

admin_token = 91c81bf488a68a6621a5

admin_tenant_name = service
admin_user = meow
admin_password = 123456


[filter:catch_errors]
use = egg:swift#catch_errors

[filter:healthcheck]
use = egg:swift#healthcheck

[filter:proxy-logging]
use = egg:swift#proxy_logging

[filter:bulk]
use = egg:swift#bulk

[filter:ratelimit]
use = egg:swift#ratelimit

[filter:crossdomain]
use = egg:swift#crossdomain

[filter:dlo]
use = egg:swift#dlo

[filter:slo]
use = egg:swift#slo

[filter:container_sync]
use = egg:swift#container_sync
current = //saio/saio_endpoint

[filter:tempurl]
use = egg:swift#tempurl

[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3

[filter:staticweb]
use = egg:swift#staticweb

[filter:account-quotas]
use = egg:swift#account_quotas

[filter:container-quotas]
use = egg:swift#container_quotas

[filter:cache]
use = egg:swift#memcache
memcache_servers = 127.0.0.1:11211

[filter:gatekeeper]
use = egg:swift#gatekeeper

[filter:versioned_writes]
use = egg:swift#versioned_writes
allow_versioned_writes = true

[filter:copy]
use = egg:swift#copy

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
  几个出现的错误:
  错误:'NoneType' object has no attribute 'has_service_catalog'
  无法获取token
  显示'NoneType' object has no attribute 'has_service_catalog'
  解决方法:删除环境变量
  错误:"get_version_v2() got an unexpected keyword argument 'auth'\"
  解决方法:将URL:http://localhost:5000/v2.0/改为:

http://localhost:5000/
http://localhost:5000/v2.0/tokens/

本机通过CURL访问keystone查询SAIO container



curl -d '{"auth": {"tenantName": "admin", "passwordCredentials":{"username": "test", "password": "testing"}}}'
-H "Content-type: application/json" http://127.0.0.1:5005/v2.0/tokens | python -mjson.tool
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  1259  100  1159  100   100   2427    209 --:--:-- --:--:-- --:--:--  2424
{
"access": {
"metadata": {
"is_admin": 0,
"roles": [
"78c7d84b9d194b1c9ac9d38df11bc07c"
]
},
"serviceCatalog": [
{
"endpoints": [
{
"adminURL": "http://localhost:8080/v1/AUTH_a9333d8f415043709fdbf649a51c78b5",
"id": "80124aade3994f9496ae52b6a3f27bc9",
"internalURL": "http://localhost:8080/v1/AUTH_a9333d8f415043709fdbf649a51c78b5",
"publicURL": "http://localhost:8080/v1/AUTH_a9333d8f415043709fdbf649a51c78b5",
"region": "regionOne"
}
],
"endpoints_links": [],
"name": "swift",
"type": "object-stoer"
},
{
"endpoints": [
{
"adminURL": "http://localhost:35757/v2.0",
"id": "97f87268f02d4c788a86a437e7ebabd6",
"internalURL": "http://localhost:5005/v2.0",
"publicURL": "http://localhost:5005/v2.0",
"region": "regionOne"
}
],
"endpoints_links": [],
"name": "keystone",
"type": "identity"
}
],
"token": {
"expires": "2017-03-23T08:42:02Z",
"id": "eb265e79f5fa4849ab56edb60c1df884",
"issued_at": "2017-03-23T07:42:02.677553",
"tenant": {
"description": "Admin Tenant",
"enabled": true,
"id": "a9333d8f415043709fdbf649a51c78b5",
"name": "admin"
}
},
"user": {
"id": "e6d914c94a064645a7e5b97be1c08877",
"name": "test",
"roles": [
{
"name": "admin"
}
],
"roles_links": [],
"username": "test"
}
}
}
curl -v -H 'X-Auth-Token: c8d5d45c42484c7d81d6d2ddd1c1258b' http://localhost:8080/v1/AUTH_a9333d8f415043709fdbf649a51c78b5
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /v1/AUTH_a9333d8f415043709fdbf649a51c78b5 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
> X-Auth-Token: c8d5d45c42484c7d81d6d2ddd1c1258b
>
< HTTP/1.1 204 No Content
< Content-Type: text/plain; charset=utf-8
< X-Account-Object-Count: 0
< X-Timestamp: 1490255452.34606
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< X-Put-Timestamp: 1490255452.34606
< X-Trans-Id: tx95806cf5365b4b03ba1f6-0058d37e5c
< X-Openstack-Request-Id: tx95806cf5365b4b03ba1f6-0058d37e5c
< Content-Length: 0
< Date: Thu, 23 Mar 2017 07:50:52 GMT
<
* Connection #0 to host localhost left intact

本机通过libcloud链接keystone查询openstack SAIO



from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
import libcloud.security

cls = get_driver(Provider.OPENSTACK_SWIFT)

driver = cls('admin', '123456',\
region = 'regionOne',\
ex_force_auth_url='http://127.0.0.1:5005/v2.0/tokens/',\
ex_force_service_type='object-stoer',\
ex_force_service_name='swift',\
ex_force_auth_version='2.0_password',\
ex_force_auth_token='7a71c7795fe449bf994ce167760a23ee',\
ex_force_base_url='http://localhost:8080/v1/AUTH_a9333d8f415043709fdbf649a51c78b5')

print(driver.list_containers())

# get the result [] because no containers here



from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
import libcloud.security

cls = get_driver(Provider.OPENSTACK_SWIFT)

driver = cls('admin', '123456',\
region = 'regionOne',\
ex_force_auth_url='http://127.0.0.1:5005/v2.0/tokens/',\
ex_force_service_type='object-stoer',\
ex_force_service_name='swift',\
ex_force_auth_version='2.0_password')

print(driver.list_containers())

# always cant get the service and endpoint
  获取不到endpoint,如果给出token和url绕过验证,则可以访问swift。

keystone一些命令:
  创建tenant:
  keystone --os-token 91c81bf488a68a6621a5  --os-endpoint http://localhost:35357/v2.0 tenant-create --name admin --description "Admin Tenant"
  创建user:
  keystone user-create --name admin --pass 123456
  创建role:
  keystone role-create --name admin
  role添加user:
  keystone user-role-add --user admin --role admin --tenant admin
  创建service:
  keystone service-create --name keystone --type identity
  创建endpoint:
  keystone endpoint-create --service keystone --region regionOne --publicurl http://localhost:5005/v2.0 --internalurl http://localhost:5005/v2.0 --adminurl http://localhost:35757/v2.0
  显示所有的tenant:
  keystone --os-tenant-name admin --os-username admin --os-password 123456 tenant-list
  用户获取token:
  keystone --os-tenant-name admin --os-username admin --os-password 123456 --os-auth-url http://localhost:35757/v2.0 token-get

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-388235-1-1.html 上篇帖子: openstack nova 深入 下篇帖子: openstack XXX-api分析
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表