如何关闭或无效的连接由vSphere-automation-sdk-python创建
我正在关注https://github.com/vmware/vsphere-automation-sdk-python/tree/master/master/samples/vsphere/vcenter/vcenter/vm
创建我的python库来做我的python图书馆VMS的操作。示例提供了获得新连接的代码。我在这里粘贴样本。
# Connect to vAPI Endpoint on vCenter system
session = get_unverified_session() if args.skipverification else None
client = create_vsphere_client(server=server,
username=username,
password=password],
session=session)
我缺少的是,一旦我在VM上完成操作,我应该如何关闭连接或无效连接。我可以简单地说为client = none
即可无效连接吗?还是有记录的方法可以做到这一点?
谢谢, 马哈夫
I am following the samples provided at https://github.com/vmware/vsphere-automation-sdk-python/tree/master/samples/vsphere/vcenter/vm
to create my python library for doing operations on the VMs. The examples provide the code to get a new connection. I am pasting the sample here.
# Connect to vAPI Endpoint on vCenter system
session = get_unverified_session() if args.skipverification else None
client = create_vsphere_client(server=server,
username=username,
password=password],
session=session)
What I am missing is once I finish my operation on the VM, how should I close the connection or invalidate the connection. Can I simply say as client = None
to invalidate the connection ? or is there a documented way to do this ?
Thanks,
Madhav
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
希望这会有所帮助。
呼叫“ create_vsphere_client”返回的对象具有2种方法: exit ()和 del ()。调用这些方法中的任何一种以删除会话。就您而言,只需运行客户端即可。 del ()最后。
Dibleiamer:我来自Java World,因此上面的术语受到此影响。
Hope this helps.
The object returned by the call 'create_vsphere_client' has 2 methods: exit() and del(). Invoke any of these methods to delete the session. In your case, simply run client.del() at the end.
Discliamer: I come from Java world, so the terminology above is influenced by this.