Openstack Swift Quotasプローブ(Grizzly)


SwiftコンポーネントはOpenstackのオブジェクトストレージソリューションです.以前のバージョンでは、swiftは割当額に制限がなく、異なるユーザーが使用する空間を制限することはできなかった.その後、オープンソースのミドルウェアswquota(https://github.com/cschwede/swquota)swiftに割り当てを制限することができ、現在2013年4月に発表されたGrizzlyバージョンOpenstackでは、swift(1.8.0)がswquotaミドルウェアを統合しており、以下はこの機能の初歩的な探究である.
新バージョンのswiftでの割当額は主にContainer QuotasとAccount Quotasの2つの機能に現れ、それぞれContainerとAccountアップロードファイルのサイズ、個数などの面で制限されており、この機能を使用するにはまず/etc/swift/proxy-server.confファイルで構成し、変更後にswiftサービスを再起動します.
#1.修正[pipeline:main][pipeline:main]
pipeline = catch_errors healthcheck cache ratelimit authtoken keystoneauth account-quotas container-quotas proxy-logging proxy-server
#2.[filter:container-quotas]と[filter:account-quotas]を加える
[filter:container-quotas]
use = egg:swift#container_quotas
[filter:account-quotas]
use = egg:swift#account_quotas
構成の再起動が完了したら、割当を設定する必要があります.このプロセスではresellerユーザーロールを設定する必要があります.
1.bingoというtenantを追加すると仮定
keystone --os-username admin --os_password adminpwd --os_tenant_name admin --os_auth_url http://localhost:5000/v2.0 tenant-create --name bingo --description bingo_tenant --enabled true
2.bingoでのユーザーresellerの追加
keystone --os-username admin --os_password adminpwd --os_tenant_name admin --os_auth_url http://localhost:5000/v2.0 user-create --name reseller --tenant-id tenant_id --pass bingo --email [email protected] --enabled true
3.resellerをResellerAdminロールに追加
keystone role-list
keystone user-role-add --user-id xxxxx --role-id xxxxx --tenant-id xxxxx
resellerユーザーを追加すると、関連する割当額を設定できます.
Container_Quotas:
1.X-Container-Meta-Quota-Bytes--ターゲットcontainerがアップロードできる最大バイト数
2.X-Container-Meta-Quota-Count--ターゲットcontainerがアップロードできる最大ファイル数
Account_Quotas:
1.X-Account-Meta-Quota-Bytes--単一アップロード最大バイト数
2.Quota-Byes--1は2を合わせてこそ効果がある
設定方法:
swift -V 2 -A http://192.168.65.203:5000/v2.0 -U test:reseller -K reseller post -m quota-bytes:5000
注意:resellerユーザーはResellerAdminロールに存在する必要があります.この限度額はtest tenantのみに有効です.
設定解除
swift -V 2 -A http://192.168.65.203:5000/v2.0 -U test:reseller -K reseller post -m quota-bytes:
Bug fix:
keystoneを使用して認証を行う場合、Quota-Byesの設定に[403 Forbidden]エラーが発生する可能性があります.
swift/common/middleware/account_の変更quotas.pyファイル
new_quota = request.headers.get('X-Account-Meta-Quota-Bytes')

#Add by kevin start
eccp_roles = request.environ.get('HTTP_X_ROLES', '')
if isinstance(eccp_roles, basestring):
    if (set(eccp_roles.split(',')) & set({'reseller','reseller_admin','ResellerAdmin'})):
        request.environ['reseller_request'] = True
#Add by kevin end

if request.environ.get('reseller_request') is True:
    if new_quota and not new_quota.isdigit():
        return HTTPBadRequest()
    return self.app

ユーザーがResellerAdminロールに参加した後、検証を通過できるようにします.
さらに,実験中にswiftとkeystone検証401 Unauthorizedの問題が絶えず発生し,デバッグによりkeystoneのswiftに関するendpointの登録IPアドレスは仮想マシン割り当てのアドレスを使用していることが判明した(本人は仮想マシンの環境下で仮想マシン実験を再インストールしているため、第1層の仮想マシンのアドレスはopenstackによって自動的に割り当てられたfixed ip 10.0.0.xタイプであり、他のいくつかのマシンがこのアドレスで権限検証を行うと問題が発生する可能性があり、解決策はendpointのアドレスをフローティングipに変更することである)、winpdb(http://winpdb.org/)をデバッグするのはとてもいいです.
Good luck