{"action":"created","issue":{"url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/480","repository_url":"https://api.github.com/repos/vmware/pyvmomi-community-samples","labels_url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/480/labels{/name}","comments_url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/480/comments","events_url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/480/events","html_url":"https://github.com/vmware/pyvmomi-community-samples/issues/480","id":317093511,"number":480,"title":"How to extract cdp information from hypervisor","user":{"login":"olex777","id":25842221,"avatar_url":"https://avatars2.githubusercontent.com/u/25842221?v=4","gravatar_id":"","url":"https://api.github.com/users/olex777","html_url":"https://github.com/olex777","followers_url":"https://api.github.com/users/olex777/followers","following_url":"https://api.github.com/users/olex777/following{/other_user}","gists_url":"https://api.github.com/users/olex777/gists{/gist_id}","starred_url":"https://api.github.com/users/olex777/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olex777/subscriptions","organizations_url":"https://api.github.com/users/olex777/orgs","repos_url":"https://api.github.com/users/olex777/repos","events_url":"https://api.github.com/users/olex777/events{/privacy}","received_events_url":"https://api.github.com/users/olex777/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-24T06:56:15Z","updated_at":"2018-04-24T17:05:31Z","closed_at":null,"author_association":"NONE","body":"Hi all, if somewhere could help me. I just began to work with pyVmomi so sorry for maybe fool questions. So I tried to use such a part of vim., https://github.com/vmware/pyvmomi/blob/master/docs/vim/host/PhysicalNic/CdpInfo.rst \r\nBut when I tryied to create ViewType for access to the thread, in such a way\r\n\r\n        # Create a view\r\n         viewType_hyper = [vim.host]\r\n \r\n        recursive = True  # whether we should look into it recursively\r\n       \r\n\r\n        # Loop through all obhects to return name and VMware tools version\r\n        containerView_hyper = content.viewManager.CreateContainerView(\r\n            container, viewType_hyper, recursive)\r\n        children_hyper=(containerView_hyper.view)\r\n        print (children_hyper)\r\n\r\nI got an error -> containerView = content.viewManager.CreateContainerView(\r\n(Pdb)\r\n> /etc/network/scripts/sdk_test.py(66)main()\r\n-> container, viewType, recursive)\r\n(Pdb)\r\n> /etc/network/scripts/sdk_test.py(67)main()\r\n-> containerView_hyper = content.viewManager.CreateContainerView(\r\n(Pdb)\r\n> /etc/network/scripts/sdk_test.py(68)main()\r\n-> container, viewType_hyper, recursive)\r\n(Pdb)\r\nTypeError: TypeErro...Module',)\r\n\r\nor TypeError: For \"type\" expected type type, but got LazyModule\r\n\r\nSomething like \r\n\r\nviewType_hyper = [vim.HostSystem] works fine but I don't know how from this root to access to thread needed for me. What is I doing wrong? I just got all needed info about cluster and it structure, about virtual machine but I also need cdp neighbours of hypervisors. Please, I need help )\r\n"},"comment":{"url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/comments/384007795","html_url":"https://github.com/vmware/pyvmomi-community-samples/issues/480#issuecomment-384007795","issue_url":"https://api.github.com/repos/vmware/pyvmomi-community-samples/issues/480","id":384007795,"user":{"login":"prziborowski","id":13127297,"avatar_url":"https://avatars2.githubusercontent.com/u/13127297?v=4","gravatar_id":"","url":"https://api.github.com/users/prziborowski","html_url":"https://github.com/prziborowski","followers_url":"https://api.github.com/users/prziborowski/followers","following_url":"https://api.github.com/users/prziborowski/following{/other_user}","gists_url":"https://api.github.com/users/prziborowski/gists{/gist_id}","starred_url":"https://api.github.com/users/prziborowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prziborowski/subscriptions","organizations_url":"https://api.github.com/users/prziborowski/orgs","repos_url":"https://api.github.com/users/prziborowski/repos","events_url":"https://api.github.com/users/prziborowski/events{/privacy}","received_events_url":"https://api.github.com/users/prziborowski/received_events","type":"User","site_admin":false},"created_at":"2018-04-24T17:05:31Z","updated_at":"2018-04-24T17:05:31Z","author_association":"CONTRIBUTOR","body":"It is a bit confusing at first I agree.\r\nvim.host is just a namespace, so you can't create a view on that. You can only create view on objects that are managed (such a vim.HostSystem, vim.VirtualMachine, vim.Folder, etc).\r\n\r\nWith a list of vim.HostSystem that you get from the CreateContainerView, you can iterate that and query about the network info.\r\n```\r\nfor host in children_hyper:\r\n   networkSystem = host.configManager.networkSystem\r\n   if networkSystem is None:\r\n      continue\r\n   if not networkSystem.capabilities. supportsNetworkHints:\r\n      continue\r\n   for hint in networkSystem.QueryNetworkHint():\r\n      print(\"Host %s, device %s, cdp info %s, lldp info %s\" %\r\n            (host.name, hint.device, hint.connectedSwitchPort,\r\n             hint.lldpInfo))\r\n```"}}
{"actor":{"display_login":"prziborowski"}}