Skip to content

Instantly share code, notes, and snippets.

@ryumei
Last active August 29, 2015 14:03
Show Gist options
  • Save ryumei/ab0cf154d13d6adb02f3 to your computer and use it in GitHub Desktop.
Save ryumei/ab0cf154d13d6adb02f3 to your computer and use it in GitHub Desktop.
# Get number of virtual servers via SLAPI
import SoftLayer
client = SoftLayer.Client()
for user in client['Account'].getUsers(mask='id,username'):
count1 = client['User_Customer'].getVirtualGuestCount(id=user['id'])
vss = client['User_Customer'].getVirtualGuests(id=user['id'], mask='id')
count2 = len(vss)
print("user_id:%d username:%s, # of vs: %d/%d, vs: %s"
% (user['id'], user['username'], count1, count2, vss))
@ryumei
Copy link
Author

ryumei commented Jul 8, 2014

I got the following result:

user_id:17xxxx username:MASTER_ACCOUNT, # of vs: 1/1, vs: [{'id': 534xxxx}]
user_id:17yyyy username:LIMITED_USER, # of vs: 0/1, vs: [{'id': 534xxxx}]
user_id:17zzzz username:ACCESSIBLE_USER, # of vs: 1/1, vs: [{'id': 534xxxx}]

LIMITED_USER can get list of virtual servers via getVirtualGuests.

@ryumei
Copy link
Author

ryumei commented Jul 8, 2014

Discussed in https://forums.softlayer.com/forum/softlayer-developer-network/implementations/81673-getvirtualguestcount-vs-length-of-getvirtualguests

I expected

user_id:17yyyy username:LIMITED_USER, # of vs: 0/0, vs: []

for LIMITED_USER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment