2016-08-29 2 views
0

Ich schrieb die folgende Logik zu get the Snapshot Percentage, und bekomme den folgenden Fehler. HINWEIS, ich habe dies sowohl mit Network_Storage als auch Network_Storage_Iscsi versucht und sehe für beide Fälle die gleiche Antwort. Gibt es einen Workaround oder ist das ein Fehler?Softlayer-Service-Aufruf an "getSnapshotPercentage" schlägt fehl

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; 

ERROR:

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 

Auch ich, dass auf dem Portal Strato bemerkt habe, ist die Darstellung des prozentualen Anteils manchmal falsch? Es ist gut über eine Stunde her, seit ich alle Schnappschüsse gelöscht habe.

enter image description here

Antwort

0

Die Methode veraltet ist zur Zeit, so dass Sie eine Objektmaske verwenden könnte die bytesUsed und snapshotCapacityGb Attribute abzurufen.

Das nächste Skript generiert den verfügbaren Snapshot-Speicherplatz, der im UI-Portal angezeigt wird.

""" 
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. <[email protected]> 
""" 

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)) 

In Bezug auf die Snapshot Space-Darstellung in der Benutzeroberfläche wird es jede Stunde mehr oder weniger aktualisiert.

Ich hoffe, das Ihnen helfen könnte.