【问题标题】:Get Quotas Openstack API获取配额 Openstack API
【发布时间】:2021-07-16 15:24:29
【问题描述】:

我指的是使用 Openstack API 从 Openstack Cloud 获取配额使用情况。我完全按照https://developer.openstack.org/api-ref/compute/ 上的文档进行操作。

但是没有用,用 api:

<host>/v2/{tenant_id}/os-quota-sets/{tenant_id}/detail

<host>/v2/{tenant_id}/os-quota-sets/detail

它与 api 一起工作:

<host>/v2/{tenant_id}/os-quota-sets/{tenant_id}

但是,我想了解详情。我做错什么了吗?

【问题讨论】:

  • 您收到了什么错误信息?我有Policy doesn't allow os_compute_api:os-quota-sets:detail to be performed.如果一样的话,需要修改你的nova策略文件。

标签: openstack


【解决方案1】:

可以使用 OpenStack 客户端...并且您可以使用命令行工具...。下面是可以帮助您的链接。 https://docs.openstack.org/nova/pike/admin/quotas.html

您可以安装 OpenStack SDK,您可以通过 API 文档部分进行联网。

以下是链接:

https://docs.openstack.org/openstacksdk/latest/user/proxies/network.html#openstack.network.v2._proxy.Proxy.update_quota

您可能会找到以下方法:

delete_quota(quota, ignore_missing=True)
get_quota(quota, details=False)







【讨论】:

    【解决方案2】:

    获取项目配额的API可以调用为,

    requests.get('http://'+url+':8774/v2.1/os-quota-sets/'+projectid+'/detail',headers={'content-type': 'application/json', 'X-Auth-Token': token})
    

    您必须在路径中传递您的项目 ID,并在可以提取为的标头中传递“X-Auth-Token”参数,

    url = [Your Cloud Machine IP Goes here]
    
    def gettokenForUser(username,password):
    
        payload1 = {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
                        "name": username,
                        "domain": {
                            "name": "Default"
                        },
                        "password": password
                    }
                }
            }
        }
        }
    
        response = requests.post('http://'+url+':5000/v3/auth/tokens',
                        headers={'content-type': 'application/json'},
                        data=json.dumps(payload1))
    
        return response.headers['X-Subject-Token']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      相关资源
      最近更新 更多