调用"getSnapshotPercentage"的软层服务失败了 [英] Softlayer service call to "getSnapshotPercentage" is failing

查看:102
本文介绍了调用"getSnapshotPercentage"的软层服务失败了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向获取快照百分比编写了以下逻辑,得到以下错误.注意,我已经用Network_StorageNetwork_Storage_Iscsi进行了尝试,并且在两种情况下都看到了相同的响应.是否有解决方法或这是一个错误?

I wrote the following logic to get the Snapshot Percentage, and am getting the below error. NOTE, I have tried this with both the Network_Storage, and Network_Storage_Iscsi and am seeing the same response for both cases. Is there a workaround or is this a bug?

def get_snapshot_space(sl_config, iscsi_identifier):
    """ get the total number of Snapshot Space remaining"""
    snapshot_percentage = SL.instance(sl_config).net.getSnapshotPercentage(id=iscsi_identifier);
    print "Snapshot Space Used: \% %s " % snapshot_space;

错误:

 snapshot_percentage = SL.instance(sl_config).net.getSnapshotPercentage(id=iscsi_identifier);
  File "/usr/lib/python2.7/site-packages/SoftLayer-5.1.0-
py2.7.egg/SoftLayer/API.py", line 375, in call_handler
    return self(name, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/SoftLayer-5.1.0-

py2.7.egg/SoftLayer/API.py", line 343, in call
    return self.client.call(self.name, name, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/SoftLayer-5.1.0-

py2.7.egg/SoftLayer/API.py", line 246, in call
    return self.transport(request)
  File "/usr/lib/python2.7/site-packages/SoftLayer-5.1.0-

py2.7.egg/SoftLayer/transports.py", line 187, in __call__
    raise _ex(ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(Client): Function ("getSnapshotPercentage") is not a valid method for this service

此外,我注意到在softLayer Portal上,百分比的表示有时是不正确的?自清除所有快照以来,已经过去了一个多小时.

Also, I have noticed that on the softLayer Portal, the representation of the percentage is incorrect sometimes? It's been well over an hour since I have cleared all snapshots.

推荐答案

该方法当前已被弃用,因此您可以使用对象掩码来检索已用字节数 snapshotCapacityGb 属性

The method is currently deprecated so you could use an object mask to retrieve the bytesUsed and snapshotCapacityGb attributes.

下一个脚本生成UI门户中显示的可用快照空间.

The next script generates the snapshot space available that's displayed in the UI portal.

"""
Retrieves snapshot space.

See below references for more details.
Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage
@License: http://sldn.softlayer.com/article/License
@Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer

USERNAME = 'set me'
API_KEY = 'set me'

client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)
networkStorageService = client['SoftLayer_Network_Storage']

iscsiStorageId = 1234567
objectMask = 'mask[snapshotCapacityGb,snapshots[bytesUsed,snapshotSizeBytes,snapshotSpaceAvailable]]'

try:
    storage = networkStorageService.getObject(mask=objectMask, id=iscsiStorageId)
    capacity = long(float(storage['snapshotCapacityGb'])) * 1e+9
    used_space = 0
    for child in storage['snapshots']:
        used_space = used_space + long(float(child['snapshotSizeBytes']))
    snapshot_space = (capacity - used_space) / 1e+9    
    print snapshot_space   
except SoftLayer.SoftLayerAPIError as e:
    print('Failed ... faultCode=%s, faultString=%s'
        % (e.faultCode, e.faultString))

关于UI中的快照空间表示,每小时或多或少都会更新一次.

Regarding the snapshot space representation in the UI, it's updated each hour more or less.

我希望这可以为您提供帮助.

I hope this could help you.

这篇关于调用"getSnapshotPercentage"的软层服务失败了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆