Getting objects instead of string for few properties
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am retrieving tasks from vCenter using:
from pyVmomi import vim
from pyVim import connect
import datetime
si = connect.SmartConnectNoSSL(host="1.2.3.4", user="user@domain", pwd="password")
time = datetime.datetime.now()
time2 = time - datetime.timedelta(hours=1)
tfs = vim.TaskFilterSpec(entity=None, userName=None, alarm=None, scheduledTask=None,
time=vim.TaskFilterSpec.ByTime(beginTime=time2,
timeType=vim.TaskFilterSpec.TimeOption("queuedTime")))
tc = si.content.taskManager.CreateCollectorForTasks(tfs)
tlist = tc.ReadNextTasks(maxCount=100)
print tlist
I am getting one of the tasks as below:
(vim.TaskInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'task-22649',
task = 'vim.Task:task-22649',
description = <unset>,
name = vim.host.DatastoreSystem.RemoveDatastore,
descriptionId = 'host.DatastoreSystem.removeDatastore',
entity = 'vim.Datastore:datastore-2013',
entityName = 'Test123-VMware',
locked = (vim.ManagedEntity) [],
state = 'error',
cancelled = false,
cancelable = false,
error = (vim.fault.ResourceInUse) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = "The resource 'Test123-VMware' is in use.",
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) [],
type = vim.Datastore,
name = 'Test123-VMware'
},
result = <unset>,
progress = <unset>,
reason = (vim.TaskReasonUser) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
userName = 'CDS.COM\\pratik.makwana'
},
queueTime = 2017-11-23T12:39:48.048Z,
startTime = 2017-11-23T12:39:48.054999Z,
completeTime = 2017-11-23T12:39:48.064999Z,
eventChainId = 2746540,
changeTag = <unset>,
parentTaskKey = <unset>,
rootTaskKey = <unset>,
activationId = ''
}
So, I am getting objects as the value in "name" and "error.type", while they are documented as Strings in documentation.
We are facing an issue when we try to convert this task object to a JSON.
e.g. for "name" attribute JSON have something like this:
<pyVmomi.VmomiSupport.ManagedMethod object at 0x0342BB50>
Is there any way to convert these properties to string?
Thanks,
Kashyap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported vim.TaskInfo output and the JSON conversion attempt, focusing on the name and error.type properties. Inspect how pyVmomi exposes these values and whether the project documents a supported serialization path; done means the behavior is explained and a reproducible conversion outcome is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100