A simple way to create OpenStack Swift reports

存储架构 2017-07-07 阅读原文

It’s no secret that I love OpenStack Swift . While it is not always a two-way relationship, I use Swift as much as I can: mostly for long-term backups , to serve static websites and even streaming.

While the functionalities are awesome, it’s also important to get the accounting/usage information of the platform. Out of the box, Swift does not allow even an administrator to access accounting information from a given account. The “standard” approach is to use the Telemetry feature of OpenStack (aka Ceilometer), but I’m not a fan of that project either. In my opinion, telemetry is pumping so much data that in most cases is overkill; I prefer a simpler approach .

To create a report of Swift usage, we need to use the Reseller Admin concept in Swift to query account statistics from a single admin-level user. The reseller role (named “ResellerAdmin” by default) can operate on any Swift account .

While getting the concept is a bit tricky (and undocumented as well), the truth is that is quite straightforward to enable it. Create a “ResellerAdmin” role on OpenStack with the command openstack role create ResellerAdmin and grant the role to the user that need to access the containers, ex: the user admin .

Edit the Swift proxy-server.conf (filter:keystone section) and add the lines highlighted in bold.

[filter:keystone]
use = egg:swift#keystoneauth
operator_roles = admin, SwiftOperator
reseller_admin_role = ResellerAdmin
reseller_prefix = AUTH_
is_admin = true
cache = swift.cache

Now the admin user can enumerate the projects and get statistics of all the projects and containers. It’s now easy enough to cycle through all the projects and get the used bytes, as shown below:

$ swift stat --os-project-name myproject
      Account: AUTH_c9f567ce0c7f484e918ac8fc798f988f
      Containers: 4
      Objects: 325   
      Bytes: 101947377850 
      Containers in policy "policy-0": 4
      Objects in policy "policy-0": 325
      Bytes in policy "policy-0": 101947377850
      X-Account-Project-Domain-Id: default
      X-Timestamp: 1487950953.36228
      X-Trans-Id: tx49e7b3d4e1a24f529fbc6-00594fb813
      Content-Type: text/plain; charset=utf-8
      Accept-Ranges: bytes
Planet OpenStack

责编内容by:Planet OpenStack阅读原文】。感谢您的支持!

您可能感兴趣的

OpenStack 与 Kubernetes 融合架构下的优化实践... 如果你想使用Kubernetes来构建你的应用程序环境,通过OpenStack来部署Kubernetes其架构是一种推荐的方式,本文将与大家分享Kuber...
当发现你的OpenStack虚拟机网络有问题,不妨先试一下这16个步骤... 1. Security Group全部打开,这是最基本的,但是很多人容易忘记 其实遇到过无数这种场景了,Debug了半天网络问题,各种手段都...
OpenStack功能模块一览 OpenStack正在快速覆盖从数据库到安全到容器的全部云计算基础架构。这对IT界既是祝福、也是新的痛苦:随着OpenStack模块清单变得越来越长,部署和操作...
如何在OpenStack中轻松部署MySQL应用 内容来源: 2017 年 7 月 27 日,Easy Stack云解决方案架构师王璐在“2017 MySQL技术交流大会”进行《Ope...
Ubuntu OpenStack Charms: 15.01 release The Ubuntu Server team is pleased to announce their first interim release,...