Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying datastore cluster fails #24

Closed
pmitoraj opened this issue Apr 6, 2014 · 5 comments
Closed

Querying datastore cluster fails #24

pmitoraj opened this issue Apr 6, 2014 · 5 comments

Comments

@pmitoraj
Copy link

pmitoraj commented Apr 6, 2014

Hi
I am trying to get the details of the datastore cluster from vcenter. It works perfectly with RbVMomi but somehow PyVmomi does not properly recognize the StoragePod object.
In Ruby example, in datastoreFolder there is StoragePod("group-p52") which is an instance of StoragePod.
In python there is vim.Folder:group-p52 which is an instance of vim.Folder and does not respond to podStorageDrsEntry.
Any ideas?

Equivalent code samples:

RUBY:

irb(main):002:0> require 'rbvmomi'
=> true
irb(main):003:0> require 'pp'
=> false
irb(main):004:0> params = {:host => '*******',
irb(main):005:1*            :insecure => true,
irb(main):006:1*            :user => 'root',
irb(main):007:1*     :rev=>"5.5",
irb(main):008:1*            :password => '*****'}
=> OMITTED FOR BREVITY
irb(main):009:0> client = RbVmomi::VIM.connect(params)
=> OMITTED FOR BREVITY
irb(main):010:0> dc = client.serviceInstance.find_datacenter
=> Datacenter("datacenter-21")
irb(main):011:0> 
irb(main):012:0*   pp dc.datastoreFolder.childEntity
[StoragePod("group-p52"),
 Datastore("datastore-48"),
 Datastore("datastore-50"),
 Datastore("datastore-49"),
 Datastore("datastore-31"),
 Datastore("datastore-38"),
 Datastore("datastore-40"),
 Datastore("datastore-36"),
 Datastore("datastore-32")]
=> OMITTED FOR BREVITY
irb(main):013:0> pp dc.datastoreFolder.childEntity[0].class
StoragePod
=> StoragePod
irb(main):014:0> pp dc.datastoreFolder.childEntity[0].podStorageDrsEntry
PodStorageDrsEntry(
  actionHistory: [],
  drsFault: [],
  dynamicProperty: [],
  recommendation: [],
  storageDrsConfig: StorageDrsConfigInfo(
    dynamicProperty: [],
    podConfig: StorageDrsPodConfigInfo(
      defaultIntraVmAffinity: true,
      defaultVmBehavior: "automated",
      dynamicProperty: [],
      enabled: true,
      ioLoadBalanceConfig: StorageDrsIoLoadBalanceConfig(
        dynamicProperty: [],
        ioLatencyThreshold: 10,
        ioLoadImbalanceThreshold: 5
      ),
      ioLoadBalanceEnabled: true,
      loadBalanceInterval: 480,
      option: [],
      rule: [],
      spaceLoadBalanceConfig: StorageDrsSpaceLoadBalanceConfig(
        dynamicProperty: [],
        minSpaceUtilizationDifference: 5,
        spaceUtilizationThreshold: 60
      )
    ),
    vmConfig: []
  )
)

PYTHON:

>>> from pyVim import connect
>>> 
>>> si = connect.Connect('***',443,'root','***')
>>> datacenter = si.content.rootFolder.childEntity[0]
>>> datacenter.datastoreFolder.childEntity
(ManagedObject) [
   'vim.Folder:group-p52',
   'vim.Datastore:datastore-48',
   'vim.Datastore:datastore-50',
   'vim.Datastore:datastore-49',
   'vim.Datastore:datastore-31',
   'vim.Datastore:datastore-38',
   'vim.Datastore:datastore-40',
   'vim.Datastore:datastore-36',
   'vim.Datastore:datastore-32'
]
>>> datacenter.datastoreFolder.childEntity[0].__class__.__name__
'vim.Folder'
>>> datacenter.datastoreFolder.childEntity[0].podStorageDrsEntry
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'vim.Folder' object has no attribute 'podStorageDrsEntry'
@hartsock
Copy link
Member

I'm not sure how client.serviceInstance.find_datacenter works... but I'm suspecting it does some magic at the moment. I will look into this further.

@hartsock hartsock self-assigned this Apr 22, 2014
@hartsock hartsock added this to the pyVmomi 5.5.0_1 milestone Apr 24, 2014
@hartsock hartsock added the bug label Apr 24, 2014
@pmitoraj
Copy link
Author

client.serviceInstance.find_datacenter returns the first datacenter from datacenters folder. I use this when I am sure there is only one datacenter.

@hartsock hartsock assigned parthgala and unassigned hartsock May 28, 2014
@parthgala
Copy link
Contributor

I think I figured out the issue. In your connect call, please specify the latest version of your vcenter. Looking at the rbvmomi code, looks like it is 5.5 version. So in your connect call pass namespace='vim25/5.5'. This should unblock you. I will fix the bug in the connect code to use latest version soon.

@hartsock
Copy link
Member

hartsock commented Jun 4, 2014

How is this coming?

@pmitoraj
Copy link
Author

Positive, this did the trick.
No FIX:

>>> si = connect.Connect('***',443,'root','***')
>>> datacenter = si.content.rootFolder.childEntity[0]
>>> datacenter.datastoreFolder.childEntity
(ManagedObject) [
   'vim.Folder:group-p42',
   'vim.Datastore:datastore-35',
   'vim.Datastore:datastore-34',
   'vim.Datastore:datastore-36',
   'vim.Datastore:datastore-32'
]

WITH FIX:

>>> si = connect.Connect('***',443,'root','***',namespace='vim25/5.5')
>>> datacenter = si.content.rootFolder.childEntity[0]
>>> datacenter.datastoreFolder.childEntity
(ManagedObject) [
   'vim.StoragePod:group-p42',
   'vim.Datastore:datastore-35',
   'vim.Datastore:datastore-34',
   'vim.Datastore:datastore-36',
   'vim.Datastore:datastore-32'
]

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

No branches or pull requests

3 participants