<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Clone Session using Python in vSphere Client SDK Discussions</title>
    <link>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2926635#M6100</link>
    <description>&lt;P&gt;The below code worked for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#imports
from pyVmomi import vim, vmodl
from pyVim import connect
import ssl

#Use below code after fetching session clone ticket from "/vcenter/session/clone-ticket" API
    if hasattr(ssl, '_create_unverified_context'):
        ssl._create_default_https_context = ssl._create_unverified_context
    stub = connect.SmartStubAdapter(host="vcenter-fqdn/IP")
    si = vim.ServiceInstance("ServiceInstance", stub)
    content = si.RetrieveContent()
    try:
        user_session = content.sessionManager.CloneSession(session_clone_ticket)
        session_id = si.content.sessionManager.currentSession.key
        auth_manager = si.content.authorizationManager
        root_folder = si.content.rootFolder
        privileges = ["VcIntegrity.lifecycleSettings.Read","VcIntegrity.Baseline.com.vmware.vcIntegrity.AssignBaselines","VcIntegrity.Baseline.com.vmware.vcIntegrity.ManageBaselines","VcIntegrity.General.com.vmware.vcIntegrity.Configure"]
        result = auth_manager.HasPrivilegeOnEntity(root_folder, session_id, privileges)
    except Exception as ex:
        print(f'Something went wrong cloning the session {ex}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2022 10:43:37 GMT</pubDate>
    <dc:creator>vedaniks</dc:creator>
    <dc:date>2022-08-31T10:43:37Z</dc:date>
    <item>
      <title>Clone Session using Python</title>
      <link>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2922693#M6085</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to clone session from plugin UI to back end using python for back-end development. [basically &lt;A href="https://developer.vmware.com/docs/14560/developing-remote-plug-ins-with-the-vsphere-client-sdk--7-0-update-3-/GUID-ED253BD0-E9B1-4588-958D-577A667F5AD9.html" target="_self"&gt;this&lt;/A&gt;]&lt;/P&gt;&lt;P&gt;I've successfully retrieved the clone ticket from vCenter API endpoint and but struggling to clone the session using it.&lt;/P&gt;&lt;P&gt;I've come across &lt;A href="https://communities.vmware.com/t5/vCenter-Server-Discussions/Remote-Plugin-Development-SOAP-CloneSession-call-returns-session/m-p/2902100#M92965" target="_self"&gt;this post&lt;/A&gt; which details the problem of cloning the session using clone ticket with python.&lt;/P&gt;&lt;PRE&gt;I've seen in the pyvmomi sample code where there is code to convert python suds cookies over to pyvmomi session cookies. &lt;BR /&gt;The comments in the pyvmomi code note that there is no way to connect to call the CloneSession() function on vCenter through &lt;BR /&gt;pyvmomi without having already been logged in. Is this actually true?&lt;BR /&gt;&lt;BR /&gt;This seems like a chicken or the egg problem. How can I call CloneSession() without already being logged in? &lt;BR /&gt;Because if I could be already logged then I wouldn't need to call CloneSession().&lt;BR /&gt;&lt;BR /&gt;Any suggestions on what course to take to resolve this little puzzle?&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has done the "Clone Session using Python" already, can you please show how to do it?&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 04:58:00 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2922693#M6085</guid>
      <dc:creator>vedaniks</dc:creator>
      <dc:date>2022-08-08T04:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Clone Session using Python</title>
      <link>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2926635#M6100</link>
      <description>&lt;P&gt;The below code worked for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#imports
from pyVmomi import vim, vmodl
from pyVim import connect
import ssl

#Use below code after fetching session clone ticket from "/vcenter/session/clone-ticket" API
    if hasattr(ssl, '_create_unverified_context'):
        ssl._create_default_https_context = ssl._create_unverified_context
    stub = connect.SmartStubAdapter(host="vcenter-fqdn/IP")
    si = vim.ServiceInstance("ServiceInstance", stub)
    content = si.RetrieveContent()
    try:
        user_session = content.sessionManager.CloneSession(session_clone_ticket)
        session_id = si.content.sessionManager.currentSession.key
        auth_manager = si.content.authorizationManager
        root_folder = si.content.rootFolder
        privileges = ["VcIntegrity.lifecycleSettings.Read","VcIntegrity.Baseline.com.vmware.vcIntegrity.AssignBaselines","VcIntegrity.Baseline.com.vmware.vcIntegrity.ManageBaselines","VcIntegrity.General.com.vmware.vcIntegrity.Configure"]
        result = auth_manager.HasPrivilegeOnEntity(root_folder, session_id, privileges)
    except Exception as ex:
        print(f'Something went wrong cloning the session {ex}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 10:43:37 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2926635#M6100</guid>
      <dc:creator>vedaniks</dc:creator>
      <dc:date>2022-08-31T10:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Clone Session using Python</title>
      <link>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2947538#M6136</link>
      <description>&lt;P&gt;Hi vedaniks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for sharing a working python example for cloning a user session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Denis&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 10:35:57 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Client-SDK-Discussions/Clone-Session-using-Python/m-p/2947538#M6136</guid>
      <dc:creator>Denis_Chorbadzh</dc:creator>
      <dc:date>2023-01-09T10:35:57Z</dc:date>
    </item>
  </channel>
</rss>

