psphere is a Python interface for the VMware vSphere Web Services SDK, a
powerful API for programatically managing your VMware infrastructure.
IP of ESXi-5 Hots : 192.168.0.144
>>>
>>>
>>> from psphere.client import Client
>>>
>>> clnt = Client(server="192.168.0.144", username="root", password="xxxxx")
Logging to ~/.psphere/psphere.log at INFO level
>>>
>>>
>>> import psphere.managedobjects as mo
>>>
>>>
>>> mo.__dict__.keys()
['ResourcePool', 'HostActiveDirectoryAuthentication', 'SessionManager', 'HostDirectoryStore', 'EventHistoryCollector', 'AuthorizationManager', 'ViewManager', 'LicenseManager', 'HostLocalAccountManager', 'VirtualApp', 'Datacenter', 'InventoryView', 'ProfileComplianceManager', 'ClusterProfileManager', '__file__', 'TaskManager', 'HostPciPassthruSystem', 'HostFirmwareSystem', 'classmapper', 'EnvironmentBrowser', 'HostBootDeviceSystem', 'FileManager', 'PropertyCollector', 'HostProfile', 'EventManager', 'Datastore', 'HostPowerSystem', 'VirtualMachineSnapshot', 'ScheduledTask', 'Network', 'ClusterComputeResource', 'VirtualDiskManager', 'HostServiceSystem', 'SearchIndex', 'VirtualMachineProvisioningChecker', 'ClusterProfile', 'HostFirewallSystem', 'TaskHistoryCollector', 'IpPoolManager', 'ServiceInstance', '__builtins__', 'HostMemorySystem', 'PerformanceManager', '__name__', 'HttpNfcLease', 'CustomFieldsManager', 'DistributedVirtualSwitchManager', 'StorageResourceManager', 'HistoryCollector', 'ScheduledTaskManager', 'AlarmManager', 'HostSystem', 'ResourcePlanningManager', 'DistributedVirtualPortgroup', 'ManagedEntity', 'ComputeResource', 'HostPatchManager', 'HostSnmpSystem', 'HostDiagnosticSystem', 'UserDirectory', 'VmwareDistributedVirtualSwitch', 'ManagedObject', '__doc__', 'HostKernelModuleSystem', 'cached_property', 'HostDatastoreBrowser', 'classmap', 'ListView', 'HostVirtualNicManager', 'ProfileManager', 'LocalizationManager', 'HostDatastoreSystem', 'HostAutoStartManager', 'HostProfileManager', 'DiagnosticManager', 'Folder', 'OptionManager', 'Profile', 'VirtualMachine', 'HostHealthStatusSystem', 'ExtensibleManagedObject', 'CustomizationSpecManager', 'HostVMotionSystem', '__package__', 'Task', 'VirtualMachineCompatibilityChecker', 'OvfManager', 'HostLocalAuthentication', 'HostCpuSchedulerSystem', 'PropertyFilter', 'Alarm', 'HostStorageSystem', 'ContainerView', 'ManagedObjectView', 'HostAuthenticationManager', 'View', 'DistributedVirtualSwitch', 'LicenseAssignmentManager', 'VirtualizationManager', 'HostAuthenticationStore', 'ExtensionManager', 'HostDateTimeSystem', 'HostNetworkSystem']
>>>
>>>
>>>
>>> from psphere.managedobjects import HostSystem
>>>
>>>
>>> hosts = HostSystem.all(clnt)
>>>
>>>
>>> for host in hosts:
... host.name
...
localhost.localdomain
>>>
>>>
>>>
>>> host = HostSystem.get(clnt, name="localhost.localdomain")
>>>
>>>
>>>
>>> host.name
localhost.localdomain
>>>
>>>
>>>
>>> host.summary.hardware
(HostHardwareSummary){
vendor = "BIOSTAR Group"
model = "A770E3"
uuid = "00020003-0004-0005-0006-000700080009"
otherIdentifyingInfo[] =
(HostSystemIdentificationInfo){
identifierValue = " None"
identifierType =
(ElementDescription){
label = "AssetTag"
summary = "AssetTag"
key = "AssetTag"
}
},
(HostSystemIdentificationInfo){
identifierValue = "None"
identifierType =
(ElementDescription){
label = "ServiceTag"
summary = "ServiceTag"
key = "ServiceTag"
}
},
memorySize = 17179070464
cpuModel = "AMD Athlon(tm) II X3 435 Processor"
cpuMhz = 2900
numCpuPkgs = 1
numCpuCores = 3
numCpuThreads = 3
numNics = 1
numHBAs = 6
}
>>>
>>>
>>>
>>> host.summary.hardware.cpuModel
AMD Athlon(tm) II X3 435 Processor
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.name
...
ubuntu 12.04 real
vCenter Server Appliance5
vShield Manager
vCloud Director
vCD-1
cli-vm
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.summary.config
...
(VirtualMachineConfigSummary){
name = "ubuntu 12.04 real"
template = False
vmPathName = "[datastore1] vm1/vm1.vmx"
memorySizeMB = 1024
numCpu = 1
numEthernetCards = 1
numVirtualDisks = 1
uuid = "564d4e0a-3ca8-ebd9-8750-493b7136948b"
instanceUuid = "52fe007b-291a-657a-3f42-ed77fb362c32"
guestId = "ubuntu64Guest"
guestFullName = "Ubuntu Linux (64-bit)"
annotation = None
}
--------------
(VirtualMachineConfigSummary){
name = "vCenter Server Appliance5"
template = False
vmPathName = "[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx"
memorySizeMB = 8192
numCpu = 2
numEthernetCards = 1
numVirtualDisks = 2
uuid = "564d0c4f-990f-5dea-6d5a-9d09cdfa26b2"
instanceUuid = "526c78a5-d0ff-6470-3f04-09065a628d35"
guestId = "sles11_64Guest"
guestFullName = "Novell SUSE Linux Enterprise 11 (64-bit)"
annotation = "VMware vCenter Server Appliance
Version 5.0 of VC running on SLES 11"
}
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.summary.config.name
... vm.summary.config.memorySizeMB
... vm.summary.config.vmPathName
... vm.summary.config.numCpu
...
ubuntu 12.04 real
1024
[datastore1] vm1/vm1.vmx
1
--------------
vCenter Server Appliance5
8192
[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx
2
>>>
>>>
>>>
>>>
IP of ESXi-5 Hots : 192.168.0.144
>>>
>>>
>>> from psphere.client import Client
>>>
>>> clnt = Client(server="192.168.0.144", username="root", password="xxxxx")
Logging to ~/.psphere/psphere.log at INFO level
>>>
>>>
>>> import psphere.managedobjects as mo
>>>
>>>
>>> mo.__dict__.keys()
['ResourcePool', 'HostActiveDirectoryAuthentication', 'SessionManager', 'HostDirectoryStore', 'EventHistoryCollector', 'AuthorizationManager', 'ViewManager', 'LicenseManager', 'HostLocalAccountManager', 'VirtualApp', 'Datacenter', 'InventoryView', 'ProfileComplianceManager', 'ClusterProfileManager', '__file__', 'TaskManager', 'HostPciPassthruSystem', 'HostFirmwareSystem', 'classmapper', 'EnvironmentBrowser', 'HostBootDeviceSystem', 'FileManager', 'PropertyCollector', 'HostProfile', 'EventManager', 'Datastore', 'HostPowerSystem', 'VirtualMachineSnapshot', 'ScheduledTask', 'Network', 'ClusterComputeResource', 'VirtualDiskManager', 'HostServiceSystem', 'SearchIndex', 'VirtualMachineProvisioningChecker', 'ClusterProfile', 'HostFirewallSystem', 'TaskHistoryCollector', 'IpPoolManager', 'ServiceInstance', '__builtins__', 'HostMemorySystem', 'PerformanceManager', '__name__', 'HttpNfcLease', 'CustomFieldsManager', 'DistributedVirtualSwitchManager', 'StorageResourceManager', 'HistoryCollector', 'ScheduledTaskManager', 'AlarmManager', 'HostSystem', 'ResourcePlanningManager', 'DistributedVirtualPortgroup', 'ManagedEntity', 'ComputeResource', 'HostPatchManager', 'HostSnmpSystem', 'HostDiagnosticSystem', 'UserDirectory', 'VmwareDistributedVirtualSwitch', 'ManagedObject', '__doc__', 'HostKernelModuleSystem', 'cached_property', 'HostDatastoreBrowser', 'classmap', 'ListView', 'HostVirtualNicManager', 'ProfileManager', 'LocalizationManager', 'HostDatastoreSystem', 'HostAutoStartManager', 'HostProfileManager', 'DiagnosticManager', 'Folder', 'OptionManager', 'Profile', 'VirtualMachine', 'HostHealthStatusSystem', 'ExtensibleManagedObject', 'CustomizationSpecManager', 'HostVMotionSystem', '__package__', 'Task', 'VirtualMachineCompatibilityChecker', 'OvfManager', 'HostLocalAuthentication', 'HostCpuSchedulerSystem', 'PropertyFilter', 'Alarm', 'HostStorageSystem', 'ContainerView', 'ManagedObjectView', 'HostAuthenticationManager', 'View', 'DistributedVirtualSwitch', 'LicenseAssignmentManager', 'VirtualizationManager', 'HostAuthenticationStore', 'ExtensionManager', 'HostDateTimeSystem', 'HostNetworkSystem']
>>>
>>>
>>>
>>> from psphere.managedobjects import HostSystem
>>>
>>>
>>> hosts = HostSystem.all(clnt)
>>>
>>>
>>> for host in hosts:
... host.name
...
localhost.localdomain
>>>
>>>
>>>
>>> host = HostSystem.get(clnt, name="localhost.localdomain")
>>>
>>>
>>>
>>> host.name
localhost.localdomain
>>>
>>>
>>>
>>> host.summary.hardware
(HostHardwareSummary){
vendor = "BIOSTAR Group"
model = "A770E3"
uuid = "00020003-0004-0005-0006-000700080009"
otherIdentifyingInfo[] =
(HostSystemIdentificationInfo){
identifierValue = " None"
identifierType =
(ElementDescription){
label = "AssetTag"
summary = "AssetTag"
key = "AssetTag"
}
},
(HostSystemIdentificationInfo){
identifierValue = "None"
identifierType =
(ElementDescription){
label = "ServiceTag"
summary = "ServiceTag"
key = "ServiceTag"
}
},
memorySize = 17179070464
cpuModel = "AMD Athlon(tm) II X3 435 Processor"
cpuMhz = 2900
numCpuPkgs = 1
numCpuCores = 3
numCpuThreads = 3
numNics = 1
numHBAs = 6
}
>>>
>>>
>>>
>>> host.summary.hardware.cpuModel
AMD Athlon(tm) II X3 435 Processor
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.name
...
ubuntu 12.04 real
vCenter Server Appliance5
vShield Manager
vCloud Director
vCD-1
cli-vm
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.summary.config
...
(VirtualMachineConfigSummary){
name = "ubuntu 12.04 real"
template = False
vmPathName = "[datastore1] vm1/vm1.vmx"
memorySizeMB = 1024
numCpu = 1
numEthernetCards = 1
numVirtualDisks = 1
uuid = "564d4e0a-3ca8-ebd9-8750-493b7136948b"
instanceUuid = "52fe007b-291a-657a-3f42-ed77fb362c32"
guestId = "ubuntu64Guest"
guestFullName = "Ubuntu Linux (64-bit)"
annotation = None
}
--------------
(VirtualMachineConfigSummary){
name = "vCenter Server Appliance5"
template = False
vmPathName = "[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx"
memorySizeMB = 8192
numCpu = 2
numEthernetCards = 1
numVirtualDisks = 2
uuid = "564d0c4f-990f-5dea-6d5a-9d09cdfa26b2"
instanceUuid = "526c78a5-d0ff-6470-3f04-09065a628d35"
guestId = "sles11_64Guest"
guestFullName = "Novell SUSE Linux Enterprise 11 (64-bit)"
annotation = "VMware vCenter Server Appliance
Version 5.0 of VC running on SLES 11"
}
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
... vm.summary.config.name
... vm.summary.config.memorySizeMB
... vm.summary.config.vmPathName
... vm.summary.config.numCpu
...
ubuntu 12.04 real
1024
[datastore1] vm1/vm1.vmx
1
--------------
vCenter Server Appliance5
8192
[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx
2
>>>
>>>
>>>
>>>
No comments:
Post a Comment