File: get_filesize_by_path.py

package info (click to toggle)
psphere 0.5.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,428 kB
  • ctags: 1,254
  • sloc: python: 4,014; makefile: 72; xml: 60
file content (31 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import psphere
from psphere.client import Client
from psphere.managedobjects import HostSystem

client = Client("192.168.0.116", "root", "xxxxx")
hosts = HostSystem.all(client)
host = hosts[0]

db = host.datastoreBrowser
mor = db.SearchDatastore_Task(datastorePath="[datastore1] vCenter/",
searchSpec={"matchPattern":"vCenter.vmx",
                "details":{"fileType":True,
                                "fileSize":True,
                                "modification":True,
                                "fileOwner":True},
                "searchCaseInsensitive":False,
                "sortFoldersFirst":False,
                "query":None
        })

while True:
 info = mor.info
 if info.state in ["success"]:
        break
 mor.update(properties=["info"])

result = info.result
files = result.file

for file in files:
	print "FileName:%s, FileSize:%s" %(file.path, file.fileSize)