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.

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


OpenStack排错常用步骤和命令 1.查看日志 OpenStack的日志系统设计的非常棒。大多数的问题都能从日志中找到原因。日志路径在/var/log/下。 哪里有问题就去哪里找:去相应的日志文件夹查看日志。 比如上传镜像报错,就去/var/log/glance/ 如果实例启动失败,就去/var/lo...
Goals for the second half of 2017 The customary update about my blogging and learning goals is here. Status of 2017 first half goals Enhance my OpenStack install scripts for ...
2016中国SDC软件本土厂商扩张迅速 浪潮增速最快... 至顶网服务器频道 06月27日 新闻消息): 近日,IDC发布了2016下半年&全年中国SDC1软件市场调查报告,数据显示2016年下半年中国SDC软件销售额达到1.78亿美元,全年销售额达到3.08亿美元,全年同比增长24.7%,较全球平均水平增长显著,表明中国已经成为全球SDC软...
Using Ansible Validations With Red Hat OpenStack P... In the previous two blogposts (Part 1 andPart 2) we demonstrated how to create a dynamic Ansible inventory file for a running OpenStack cloud. We ...
Deploying OpenShift with Kuryr on a DevStack multi... In this post I will describe the steps I followed to be able to install (with openshift-ansible playbooks), test and play with an OpenShift deploy...