DiegoSanjuan / pysphere

Automatically exported from code.google.com/p/pysphere
0 stars 0 forks source link

get_properties() - Storage #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Is there any way to get the allocated disk space for a specific host?
I need to run a comprehensive Python script against a few thousand machines and 
one of the key things i need to fetch is allocated disk space.

I can not find any documentation on it, nor can i find anything in the source 
codes, is this feature completely left out?

Original issue reported on code.google.com by Anton.Do...@gmail.com on 5 Dec 2011 at 8:36

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Is there a way to get the ammount of vCPU's _and_, most imporantly, the current 
ammount of SWAP being used on a host? When counting disk quota and expenses it 
is IMO mandatory to count the SWAP+HDD when counting disk costs for each vhost.

So, is there any way to fetch the ammount of SWAP space being used?

Original comment by Anton.Do...@gmail.com on 5 Dec 2011 at 1:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

     ***PATCH*** (Total Disk usage, internal Operating System disk)

Found a container which, didn't give specifics but it DID give me the disk 
quotas i need to do my cost sheet.

prop.Name == 'storage' is the container but has very limited information, but 
just what you need.

I'll attach a  patch for:
C:\Python26\Lib\site-packages\pysphere-0.1.0-py2.6-win32.egg\pysphere\vi_virtual
_machine.py

I think i followed the code standard in this file, at least as well as i could.

Original comment by Anton.Do...@gmail.com on 5 Dec 2011 at 2:12

Attachments:

GoogleCodeExporter commented 8 years ago
currently in the trunk version you can do this

from pysphere import *
s = VIServer()
s.connect("hostname", "user", "password")

vm = s.get_vm_by_path("...vmx path...")

#num of cpus:
print vm.properties.config.hardware.numCPU

#to get swap data
pm = s.get_performance_manager()
stats = pm.get_entity_statistic(vm._mor, ['swapin', 'swapout', 'swapped'])
for stat in stats:
    print stat.description
    print stat.value

#to get a full list of the stats you can get for this vm object run
pm.get_entity_counters(vm._mor)

Original comment by argo...@gmail.com on 5 Dec 2011 at 5:27

GoogleCodeExporter commented 8 years ago
Regarding disk space utilization you can run:

from pysphere import *
s = VIServer()
s.connect("hostname", "user", "password")

vm = s.get_vm_by_path("...vmx path...")
print vm._disks

Original comment by argo...@gmail.com on 5 Dec 2011 at 5:29