目录
2.通过分析vcenter的mob来获取相关的信息,保证能够正确获取
1.Python代码如下
from pyVim import connect
import atexit
service_instance = connect.SmartConnect(host='172.18.xx.xx',user='administrator@vsphere.local',pwd='xxxxxx',port=443)
content = service_instance.RetrieveContent()
vcontent = service_instance.content
print '{}'.format(vcontent)
print '{}'.format(type(vcontent.dvSwitchManager))
print '{}'.format(vcontent.dvSwitchManager.__dict__.items())
print '{}'.format(vcontent.dvSwitchManager.QueryAvailableDvsSpec())
2.通过分析vcenter的mob来获取相关的信息,保证能够正确获取
打开vcenter的mob,找到name为dvSwitchManager的属性,它会返回类型为DistributeVirtuaSwitchManager的类名DVSManager,
点开DVSManager,找到其相关的属性和方法
3.找到相关的属性和方法,在程序中进行调用
4.程序返回结果:
(vim.ServiceInstanceContent) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
rootFolder = 'vim.Folder:group-d1',
propertyCollector = 'vmodl.query.PropertyCollector:propertyCollector',
viewManager = 'vim.view.ViewManager:ViewManager',
about = (vim.AboutInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'VMware vCenter Server',
fullName = 'VMware vCenter Server 6.7.0 build-8170161',
vendor = 'VMware, Inc.',
version = '6.7.0',
build = '8170161',
localeVersion = 'INTL',
localeBuild = '000',
osType = 'linux-x64',
productLineId = 'vpx',
apiType = 'VirtualCenter',
apiVersion = '6.7',
instanceUuid = 'e10eb4f6-ea8e-4b00-a15b-5240175fd339',
licenseProductName = 'VMware VirtualCenter Server',
licenseProductVersion = '6.0'
},
setting = 'vim.option.OptionManager:VpxSettings',
userDirectory = 'vim.UserDirectory:UserDirectory',
sessionManager = 'vim.SessionManager:SessionManager',
authorizationManager = 'vim.AuthorizationManager:AuthorizationManager',
serviceManager = 'vim.ServiceManager:ServiceMgr',
perfManager = 'vim.PerformanceManager:PerfMgr',
scheduledTaskManager = 'vim.scheduler.ScheduledTaskManager:ScheduledTaskManager',
alarmManager = 'vim.alarm.AlarmManager:AlarmManager',
eventManager = 'vim.event.EventManager:EventManager',
taskManager = 'vim.TaskManager:TaskManager',
extensionManager = 'vim.ExtensionManager:ExtensionManager',
customizationSpecManager = 'vim.CustomizationSpecManager:CustomizationSpecManager',
customFieldsManager = 'vim.CustomFieldsManager:CustomFieldsManager',
accountManager = <unset>,
diagnosticManager = 'vim.DiagnosticManager:DiagMgr',
licenseManager = 'vim.LicenseManager:LicenseManager',
searchIndex = 'vim.SearchIndex:SearchIndex',
fileManager = 'vim.FileManager:FileManager',
datastoreNamespaceManager = 'vim.DatastoreNamespaceManager:DatastoreNamespaceManager',
virtualDiskManager = 'vim.VirtualDiskManager:virtualDiskManager',
virtualizationManager = <unset>,
snmpSystem = 'vim.host.SnmpSystem:SnmpSystem',
vmProvisioningChecker = 'vim.vm.check.ProvisioningChecker:ProvChecker',
vmCompatibilityChecker = 'vim.vm.check.CompatibilityChecker:CompatChecker',
ovfManager = 'vim.OvfManager:OvfManager',
ipPoolManager = 'vim.IpPoolManager:IpPoolManager',
dvSwitchManager = 'vim.dvs.DistributedVirtualSwitchManager:DVSManager',
hostProfileManager = 'vim.profile.host.ProfileManager:HostProfileManager',
clusterProfileManager = 'vim.profile.cluster.ProfileManager:ClusterProfileManager',
complianceManager = 'vim.profile.ComplianceManager:MoComplianceManager',
localizationManager = 'vim.LocalizationManager:LocalizationManager',
storageResourceManager = 'vim.StorageResourceManager:StorageResourceManager',
guestOperationsManager = 'vim.vm.guest.GuestOperationsManager:guestOperationsManager'
}
<class 'pyVmomi.VmomiSupport.vim.dvs.DistributedVirtualSwitchManager'>
[('_stub', <pyVmomi.SoapAdapter.SoapStubAdapter instance at 0x7fb406bdd200>), ('_moId', u'DVSManager'), ('_serverGuid', None)]
(vim.dvs.ProductSpec) [
(vim.dvs.ProductSpec) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'DVS',
vendor = 'VMware, Inc.',
version = '6.0.0',
build = <unset>,
forwardingClass = 'etherswitch',
bundleId = <unset>,
bundleUrl = <unset>
},
(vim.dvs.ProductSpec) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'DVS',
vendor = 'VMware, Inc.',
version = '6.5.0',
build = <unset>,
forwardingClass = 'etherswitch',
bundleId = <unset>,
bundleUrl = <unset>
},
(vim.dvs.ProductSpec) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'DVS',
vendor = 'VMware, Inc.',
version = '6.6.0',
build = <unset>,
forwardingClass = 'cswitch',
bundleId = <unset>,
bundleUrl = <unset>
}
]