Start_Process() issue - processes run under different session then remote desktop session

614 views
Skip to first unread message

RecursiveCptHook

unread,
Jan 23, 2014, 5:49:27 PM1/23/14
to pysp...@googlegroups.com
Hey all,

I have a script to do the following:
1. Copy local file/binary to VM
2. Run the copied remote binary using Start_Process()

When attempting to run a process using the Start_Process(), it creates the process, however that process is not visible under the same user account when using remote desktop.

The process appears with the owner being the same user, however looking in the taskmgr the process does not appear under the user account in the user tab (user session).

How does one go about remotely starting a process in the same session as the Remote Desktop account (same user account)?

Any help would be greatly appreciated.

Thanks!

bg.k...@gmail.com

unread,
Jan 28, 2014, 2:26:05 PM1/28/14
to pysp...@googlegroups.com
Not sure if this is exactly what you are looking for, but if you are just trying to get the process to appear in the interactive session you need to log in interactively using PySphere. To do this you need to modify PySphere a bit because the login_in_guest() function does not expose the ability for interactive logins.

Here is my modified function, I have basically just added an additional optional parameter to allow for interactive logins.

def login_in_guest(self, user, password,interactive=False):
        """Authenticates in the guest with the acquired credentials for use in
        subsequent guest operation calls."""
        auth = VI.ns0.NamePasswordAuthentication_Def("NameAndPwd").pyclass()
        auth.set_element_interactiveSession(interactive)
        auth.set_element_username(user)
        auth.set_element_password(password)
        self.__validate_authentication(auth)
        self._auth_obj = auth

So your script would be:

1. Login with interactive=True
2. Copy file/binary to VM
3. Start process call.

RecursiveCptHook

unread,
Jan 28, 2014, 11:00:33 PM1/28/14
to pysp...@googlegroups.com
Hey BG,

Thanks a bunch for the information! Very much appreciated!

Made the changes to vi_virtual_machine.py however when trying it an exception occurs:

File "C:\Python276\lib\site-packages\pysphere\vi_virtual_machine.py", line 1743, in __validate_authentication
raise VIApiException(e)
pysphere.resources.vi_exception.VIApiException:  [GuestOperationsUnavailableFault]: The guest operations agent could not be contacted.

VM is up and running (visible without any issues in VSphere Web Client).

Any ideas?

Thanks!

bg.k...@gmail.com

unread,
Jan 29, 2014, 2:20:15 PM1/29/14
to pysp...@googlegroups.com
That shouldnt be because of the changes, that error happens normally when the host vm gets really busy or some sort of connection issue occurs so the one time communication fails. You could try adding some retry/polling logic around your calls to hopefully get some more consistent behavior.

RecursiveCptHook

unread,
Feb 4, 2014, 4:36:44 PM2/4/14
to pysp...@googlegroups.com
Been trying to resolve that exception for the past several days and nothing appears to work. To your knowledge are there any specific settings that need to be enabled on the Vm or even within Vsphere to enable/support said functionality? 

RecursiveCptHook

unread,
Feb 12, 2014, 5:25:48 PM2/12/14
to pysp...@googlegroups.com
Anyone have any ideas? Any help figuring this out would be greatly appreciated. :)

Vishnulal B.

unread,
Feb 13, 2014, 4:21:47 AM2/13/14
to pysp...@googlegroups.com
Hi All,

Me too stuck in the same issue. But the exception description is a bit different .

File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 1027, in login_in_guest
    self.__validate_authentication(auth)
  File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 1706, in __validate_authentication
    raise VIApiException(e)
pysphere.resources.vi_exception.VIApiException: [SystemErrorFault]: A general system error occurred: The specified guest user does not match the user currently logged in interactively.

Is this a bug???

Nitin Kshirsagar

unread,
Apr 19, 2015, 12:12:18 AM4/19/15
to pysp...@googlegroups.com


Hi all,

Please try to login guest vm multiple times in loop will solve your problem.

ex.

def connect_vm(self,vmobj):
        timeout = self._timeout
        sec = 10
        while (timeout >= 0):
        try:
                vmobj.login_in_guest(self._vmuser, self._vmpass)
                break
            except:
                Log.info("Guest vm network is still down try after seconds [%s]" %(sec))
                time.sleep(sec)
                timeout = timeout - sec
                pass
        if (timeout <= 0):
            Log.error("Failed to connect VM after [%d] seconds time out"%(self._timeout))
            raise

       return True 




Thanks
Nitin





 

 

big...@gmail.com

unread,
Aug 28, 2015, 3:39:22 PM8/28/15
to pysphere
Even with the retry loop, the library fails to connect the VM whenever I set

auth.set_element_interactiveSession(True)

Did anyone solve this problem ?

Jogid Gis

unread,
Mar 13, 2018, 3:02:39 AM3/13/18
to pysphere
Hello,
Did you solve this problem?






2014년 1월 24일 금요일 오전 7시 49분 27초 UTC+9, RecursiveCptHook 님의 말:
Reply all
Reply to author
Forward
0 new messages