Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-25 Thread Petr Viktorin
On 04/23/2016 02:21 AM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/21/2016 03:04 PM, Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/21/2016 07:25 AM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/20/2016 06:11 AM, Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/18/2016 12:39 PM, Niranjan wrote:
> Niranjan wrote:
>> Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/06/2016 10:55 AM, Niranjan wrote:
> Greetings,
>
> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> have proposed
> a patch, I think this patch is more of a workaround , than a 
> solution. I would
> like to get more inputs on how to use pytest-multihost to execute 
> commands 
> on Windows. The method i am using requires cygwin with 
> openssh/bash to be
> installed. 

>> [...]

 If this works for you, I'll commit it and release.
>>>
>>> With this latest patch it worked after removing the line "transport_class =
>>> transport.SSHTransport" from QeBaseHost class. 
>>>
>>> Please go ahead and commit it.
>>
>> I've commited it and released version 1.1. Packages for Fedora Rawhide
>> are being built; if you need this for older Fedoras let me know so I
>> don't forget to build there too.
> No for fedora it's fine, but mostly we are using this in RHEL7, so if you
> can build it for epel7 it would be great, else it's fine, i will build
> this for RHEL7, i intend to use this for sssd functional testing.

I'll leave the RHEL version to you.

> Also i tried to pull the latest from python-pytest-multihost.git from
> git.fedoraproject.org, i could not see it merged. 

My mistake. It should be fixed now.



-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-22 Thread Niranjan
Petr Viktorin wrote:
> On 04/21/2016 03:04 PM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/21/2016 07:25 AM, Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/20/2016 06:11 AM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/18/2016 12:39 PM, Niranjan wrote:
> >>> Niranjan wrote:
>  Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/06/2016 10:55 AM, Niranjan wrote:
> >>> Greetings,
> >>>
> >>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> >>> have proposed
> >>> a patch, I think this patch is more of a workaround , than a 
> >>> solution. I would
> >>> like to get more inputs on how to use pytest-multihost to execute 
> >>> commands 
> >>> on Windows. The method i am using requires cygwin with 
> >>> openssh/bash to be
> >>> installed. 
> >>
> [...]
> >>
> >> If this works for you, I'll commit it and release.
> > 
> > With this latest patch it worked after removing the line "transport_class =
> > transport.SSHTransport" from QeBaseHost class. 
> > 
> > Please go ahead and commit it.
> 
> I've commited it and released version 1.1. Packages for Fedora Rawhide
> are being built; if you need this for older Fedoras let me know so I
> don't forget to build there too.
No for fedora it's fine, but mostly we are using this in RHEL7, so if you
can build it for epel7 it would be great, else it's fine, i will build
this for RHEL7, i intend to use this for sssd functional testing.

Also i tried to pull the latest from python-pytest-multihost.git from
git.fedoraproject.org, i could not see it merged. 
> 
> Thanks for your assistance!
> 
You're welcome. 
> 
> -- 
> Petr Viktorin


Regards
Niranjan


pgpzMWPh1aXZf.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-22 Thread Petr Viktorin
On 04/21/2016 03:04 PM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/21/2016 07:25 AM, Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/20/2016 06:11 AM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/18/2016 12:39 PM, Niranjan wrote:
>>> Niranjan wrote:
 Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/06/2016 10:55 AM, Niranjan wrote:
>>> Greetings,
>>>
>>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
>>> have proposed
>>> a patch, I think this patch is more of a workaround , than a 
>>> solution. I would
>>> like to get more inputs on how to use pytest-multihost to execute 
>>> commands 
>>> on Windows. The method i am using requires cygwin with openssh/bash 
>>> to be
>>> installed. 
>>
[...]
>>
>> If this works for you, I'll commit it and release.
> 
> With this latest patch it worked after removing the line "transport_class =
> transport.SSHTransport" from QeBaseHost class. 
> 
> Please go ahead and commit it.

I've commited it and released version 1.1. Packages for Fedora Rawhide
are being built; if you need this for older Fedoras let me know so I
don't forget to build there too.

Thanks for your assistance!


-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-21 Thread Niranjan
Petr Viktorin wrote:
> On 04/21/2016 07:25 AM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/20/2016 06:11 AM, Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/18/2016 12:39 PM, Niranjan wrote:
> > Niranjan wrote:
> >> Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> >
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> > have proposed
> > a patch, I think this patch is more of a workaround , than a 
> > solution. I would
> > like to get more inputs on how to use pytest-multihost to execute 
> > commands 
> > on Windows. The method i am using requires cygwin with openssh/bash 
> > to be
> > installed. 
> 
>  Wow. I'm surprised the only problem on Windows is the "set -e".
> 
>  Regarding the patch:
> 
>  - Why is get_winhost_class needed? I don't see it called anywhere.
>  - Similarly, why is host_type needed? Your patch only sets it.
> 
>  If run_command of WinHost and Unix hosts are this similar, I would 
>  put
>  the 'set -e\n' for Unix (and an empty string for Windows) in a class
>  attribute named e.g. "command_prelude", use it in run_command, and 
>  move
>  run_command from Host to BaseHost.
>  Would that work, or am I missing something?
> >>> How do we detect the host is windows/unix then , we still need 
> >>> host_type 
> >>> to know what the type of host is (unix/windows)?
> 
> 
>  -- 
>  Petr Viktorin
> >> Please review the attached patch.
> 
>  Sorry for the delay.
> 
>  The information about whether the host is Unix or Windows is available:
>  the class is either Host or WinHost, so I don't think an extra host_type
>  is necessary.
>  I'd be open to adding host_type as *configuration* (and corresponding
>  attribute) if it also selected the actual Host class. Currently to use
>  WinHost you need to write custom code.
> >>> I would like to have host_type available. We would like to add more
> >>> functions in classes that override Host/WinHost class , which 
> >>> can be then called depending upon the host_type. 
> >>
> >> Ah, I see; you're not using the WinHost subclass right now.
> >>
> >> I added a host_type; it is used to select the Host class.
> >> You can define a "host_classes" dict in your Domain class to list Host
> >> classes, and the particular Host class will be selected according to the
> >> host_type.
> >>
> >> The usage would be like this:
> >>
> >> -
> >>
> >> class QeHost(QeBaseHost):
> >>"""Linux host class"""
> >> @classmethod
> >> def gethostname(self):
> >> """ Return system hostname """
> >> cmd = self.run_command(['hostname'], raiseonerr=False)
> >> return cmd.stdout_text.strip()
> >>...
> >>
> >> class QeWinHost(QeBaseHost, pytest_multihost.host.WinHost):
> >>"""Windows host class"""
> >>
> >>@classmethod
> >>def gethostname(self):
> >>""" Return system hostname """
> >>cmd = self.run_command(['hostname', '-A'], set_env=False,
> >> raiseonerr=False)
> >>return cmd.stdout_text.strip()
> >>...
> >>
> >>
> >> class QeDomain:
> >>...
> >>host_classes = {'default': QeHost, 'windows': QeWinHost}
> >>
> >># remove your existing "get_host_class" method when host_classes is
> >> defined
> >>...
> >>
> >> -
> >>
> >> And in the config, define host_type to 'windows'.
> >>
> >>
> >> Would it work for you like this?
> > Most of the things worked [...]
> > 
> > Specifically i see that you have "transport_class = transport.SSHTransport" 
> > added to Host Class
> > but not in WinHost class. So initially it failed transport class not 
> > available,  but after i added below lines
> > it worked:
> > 
> > class QeBaseHost(pytest_multihost.host.BaseHost):
> > """ QeBaseHost subclass of multhost plugin BaseHost class """
> > transport_class = transport.SSHTransport
> > 
> > Apart from the above minor thing, Everything else works. Again the above 3 
> > lines solves the minor issue, 
> > just wanted to know if the above lines are to be added and is by design. 
> 
> Right, since SSHTransport works for Windows hosts as well, I've added it
> to BaseHost. With this version of patch it shouldn't be necessary to add
> it in your code.
> 
> If this works for you, I'll commit it and release.

With this latest patch it worked after removing the line "transport_class =
transport.SSHTransport" from QeBaseHost class. 

Please go ahead and commit it.
> 
> 
> -- 
> Petr Viktorin

> From 7eb346c0bf29b1fddfd962675258a3895fbc8300 Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] Add 'host_type', make it possible 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-21 Thread Niranjan
Petr Viktorin wrote:
> On 04/21/2016 07:25 AM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/20/2016 06:11 AM, Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/18/2016 12:39 PM, Niranjan wrote:
> > Niranjan wrote:
> >> Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> >
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> > have proposed
> > a patch, I think this patch is more of a workaround , than a 
> > solution. I would
> > like to get more inputs on how to use pytest-multihost to execute 
> > commands 
> > on Windows. The method i am using requires cygwin with openssh/bash 
> > to be
> > installed. 
> 
>  Wow. I'm surprised the only problem on Windows is the "set -e".
> 
>  Regarding the patch:
> 
>  - Why is get_winhost_class needed? I don't see it called anywhere.
>  - Similarly, why is host_type needed? Your patch only sets it.
> 
>  If run_command of WinHost and Unix hosts are this similar, I would 
>  put
>  the 'set -e\n' for Unix (and an empty string for Windows) in a class
>  attribute named e.g. "command_prelude", use it in run_command, and 
>  move
>  run_command from Host to BaseHost.
>  Would that work, or am I missing something?
> >>> How do we detect the host is windows/unix then , we still need 
> >>> host_type 
> >>> to know what the type of host is (unix/windows)?
> 
> 
>  -- 
>  Petr Viktorin
> >> Please review the attached patch.
> 
>  Sorry for the delay.
> 
>  The information about whether the host is Unix or Windows is available:
>  the class is either Host or WinHost, so I don't think an extra host_type
>  is necessary.
>  I'd be open to adding host_type as *configuration* (and corresponding
>  attribute) if it also selected the actual Host class. Currently to use
>  WinHost you need to write custom code.
> >>> I would like to have host_type available. We would like to add more
> >>> functions in classes that override Host/WinHost class , which 
> >>> can be then called depending upon the host_type. 
> >>
> >> Ah, I see; you're not using the WinHost subclass right now.
> >>
> >> I added a host_type; it is used to select the Host class.
> >> You can define a "host_classes" dict in your Domain class to list Host
> >> classes, and the particular Host class will be selected according to the
> >> host_type.
> >>
> >> The usage would be like this:
> >>
> >> -
> >>
> >> class QeHost(QeBaseHost):
> >>"""Linux host class"""
> >> @classmethod
> >> def gethostname(self):
> >> """ Return system hostname """
> >> cmd = self.run_command(['hostname'], raiseonerr=False)
> >> return cmd.stdout_text.strip()
> >>...
> >>
> >> class QeWinHost(QeBaseHost, pytest_multihost.host.WinHost):
> >>"""Windows host class"""
> >>
> >>@classmethod
> >>def gethostname(self):
> >>""" Return system hostname """
> >>cmd = self.run_command(['hostname', '-A'], set_env=False,
> >> raiseonerr=False)
> >>return cmd.stdout_text.strip()
> >>...
> >>
> >>
> >> class QeDomain:
> >>...
> >>host_classes = {'default': QeHost, 'windows': QeWinHost}
> >>
> >># remove your existing "get_host_class" method when host_classes is
> >> defined
> >>...
> >>
> >> -
> >>
> >> And in the config, define host_type to 'windows'.
> >>
> >>
> >> Would it work for you like this?
> > Most of the things worked [...]
> > 
> > Specifically i see that you have "transport_class = transport.SSHTransport" 
> > added to Host Class
> > but not in WinHost class. So initially it failed transport class not 
> > available,  but after i added below lines
> > it worked:
> > 
> > class QeBaseHost(pytest_multihost.host.BaseHost):
> > """ QeBaseHost subclass of multhost plugin BaseHost class """
> > transport_class = transport.SSHTransport
> > 
> > Apart from the above minor thing, Everything else works. Again the above 3 
> > lines solves the minor issue, 
> > just wanted to know if the above lines are to be added and is by design. 
> 
> Right, since SSHTransport works for Windows hosts as well, I've added it
> to BaseHost. With this version of patch it shouldn't be necessary to add
> it in your code.
> 
> If this works for you, I'll commit it and release.
I will test and let you know asap
> 
> 
> -- 
> Petr Viktorin

> From 7eb346c0bf29b1fddfd962675258a3895fbc8300 Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] Add 'host_type', make it possible to use Windows hosts
> 
> Add global parameter windows_test_dir to specify test directory
> for Windows
> Windows hosts 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-21 Thread Petr Viktorin
On 04/21/2016 07:25 AM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/20/2016 06:11 AM, Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/18/2016 12:39 PM, Niranjan wrote:
> Niranjan wrote:
>> Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/06/2016 10:55 AM, Niranjan wrote:
> Greetings,
>
> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> have proposed
> a patch, I think this patch is more of a workaround , than a 
> solution. I would
> like to get more inputs on how to use pytest-multihost to execute 
> commands 
> on Windows. The method i am using requires cygwin with openssh/bash 
> to be
> installed. 

 Wow. I'm surprised the only problem on Windows is the "set -e".

 Regarding the patch:

 - Why is get_winhost_class needed? I don't see it called anywhere.
 - Similarly, why is host_type needed? Your patch only sets it.

 If run_command of WinHost and Unix hosts are this similar, I would put
 the 'set -e\n' for Unix (and an empty string for Windows) in a class
 attribute named e.g. "command_prelude", use it in run_command, and move
 run_command from Host to BaseHost.
 Would that work, or am I missing something?
>>> How do we detect the host is windows/unix then , we still need 
>>> host_type 
>>> to know what the type of host is (unix/windows)?


 -- 
 Petr Viktorin
>> Please review the attached patch.

 Sorry for the delay.

 The information about whether the host is Unix or Windows is available:
 the class is either Host or WinHost, so I don't think an extra host_type
 is necessary.
 I'd be open to adding host_type as *configuration* (and corresponding
 attribute) if it also selected the actual Host class. Currently to use
 WinHost you need to write custom code.
>>> I would like to have host_type available. We would like to add more
>>> functions in classes that override Host/WinHost class , which 
>>> can be then called depending upon the host_type. 
>>
>> Ah, I see; you're not using the WinHost subclass right now.
>>
>> I added a host_type; it is used to select the Host class.
>> You can define a "host_classes" dict in your Domain class to list Host
>> classes, and the particular Host class will be selected according to the
>> host_type.
>>
>> The usage would be like this:
>>
>> -
>>
>> class QeHost(QeBaseHost):
>>"""Linux host class"""
>> @classmethod
>> def gethostname(self):
>> """ Return system hostname """
>> cmd = self.run_command(['hostname'], raiseonerr=False)
>> return cmd.stdout_text.strip()
>>...
>>
>> class QeWinHost(QeBaseHost, pytest_multihost.host.WinHost):
>>"""Windows host class"""
>>
>>@classmethod
>>def gethostname(self):
>>""" Return system hostname """
>>cmd = self.run_command(['hostname', '-A'], set_env=False,
>> raiseonerr=False)
>>return cmd.stdout_text.strip()
>>...
>>
>>
>> class QeDomain:
>>...
>>host_classes = {'default': QeHost, 'windows': QeWinHost}
>>
>># remove your existing "get_host_class" method when host_classes is
>> defined
>>...
>>
>> -
>>
>> And in the config, define host_type to 'windows'.
>>
>>
>> Would it work for you like this?
> Most of the things worked [...]
> 
> Specifically i see that you have "transport_class = transport.SSHTransport" 
> added to Host Class
> but not in WinHost class. So initially it failed transport class not 
> available,  but after i added below lines
> it worked:
> 
> class QeBaseHost(pytest_multihost.host.BaseHost):
> """ QeBaseHost subclass of multhost plugin BaseHost class """
> transport_class = transport.SSHTransport
> 
> Apart from the above minor thing, Everything else works. Again the above 3 
> lines solves the minor issue, 
> just wanted to know if the above lines are to be added and is by design. 

Right, since SSHTransport works for Windows hosts as well, I've added it
to BaseHost. With this version of patch it shouldn't be necessary to add
it in your code.

If this works for you, I'll commit it and release.


-- 
Petr Viktorin
From 7eb346c0bf29b1fddfd962675258a3895fbc8300 Mon Sep 17 00:00:00 2001
From: Niranjan MR 
Date: Tue, 12 Apr 2016 17:18:10 +0530
Subject: [PATCH] Add 'host_type', make it possible to use Windows hosts

Add global parameter windows_test_dir to specify test directory
for Windows
Windows hosts (WinHost) use this directory by default.
test_dir can now be set individually for each host.
Move run_command from Host class to BaseHost class
Add a "host_type" configuration option and Host attribute. This
is used to select the Host subclass. By default it can
be 'default' or 'windows' (but Config subclasses can define more).

Signed-off-by: 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-20 Thread Niranjan
Petr Viktorin wrote:
> On 04/20/2016 06:11 AM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/18/2016 12:39 PM, Niranjan wrote:
> >>> Niranjan wrote:
>  Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/06/2016 10:55 AM, Niranjan wrote:
> >>> Greetings,
> >>>
> >>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i 
> >>> have proposed
> >>> a patch, I think this patch is more of a workaround , than a 
> >>> solution. I would
> >>> like to get more inputs on how to use pytest-multihost to execute 
> >>> commands 
> >>> on Windows. The method i am using requires cygwin with openssh/bash 
> >>> to be
> >>> installed. 
> >>
> >> Wow. I'm surprised the only problem on Windows is the "set -e".
> >>
> >> Regarding the patch:
> >>
> >> - Why is get_winhost_class needed? I don't see it called anywhere.
> >> - Similarly, why is host_type needed? Your patch only sets it.
> >>
> >> If run_command of WinHost and Unix hosts are this similar, I would put
> >> the 'set -e\n' for Unix (and an empty string for Windows) in a class
> >> attribute named e.g. "command_prelude", use it in run_command, and move
> >> run_command from Host to BaseHost.
> >> Would that work, or am I missing something?
> > How do we detect the host is windows/unix then , we still need 
> > host_type 
> > to know what the type of host is (unix/windows)?
> >>
> >>
> >> -- 
> >> Petr Viktorin
>  Please review the attached patch.
> >>
> >> Sorry for the delay.
> >>
> >> The information about whether the host is Unix or Windows is available:
> >> the class is either Host or WinHost, so I don't think an extra host_type
> >> is necessary.
> >> I'd be open to adding host_type as *configuration* (and corresponding
> >> attribute) if it also selected the actual Host class. Currently to use
> >> WinHost you need to write custom code.
> > I would like to have host_type available. We would like to add more
> > functions in classes that override Host/WinHost class , which 
> > can be then called depending upon the host_type. 
> 
> Ah, I see; you're not using the WinHost subclass right now.
> 
> I added a host_type; it is used to select the Host class.
> You can define a "host_classes" dict in your Domain class to list Host
> classes, and the particular Host class will be selected according to the
> host_type.
> 
> The usage would be like this:
> 
> -
> 
> class QeHost(QeBaseHost):
>"""Linux host class"""
> @classmethod
> def gethostname(self):
> """ Return system hostname """
> cmd = self.run_command(['hostname'], raiseonerr=False)
> return cmd.stdout_text.strip()
>...
> 
> class QeWinHost(QeBaseHost, pytest_multihost.host.WinHost):
>"""Windows host class"""
> 
>@classmethod
>def gethostname(self):
>""" Return system hostname """
>cmd = self.run_command(['hostname', '-A'], set_env=False,
> raiseonerr=False)
>return cmd.stdout_text.strip()
>...
> 
> 
> class QeDomain:
>...
>host_classes = {'default': QeHost, 'windows': QeWinHost}
> 
># remove your existing "get_host_class" method when host_classes is
> defined
>...
> 
> -
> 
> And in the config, define host_type to 'windows'.
> 
> 
> Would it work for you like this?
Most of the things worked by doing this:

class QeBaseHost(pytest_multihost.host.BaseHost):
""" QeBaseHost subclass of multhost plugin BaseHost class """
transport_class = transport.SSHTransport

class QeHost(QeBaseHost):
""" 

  
QeHost subclass of multihost plugin host class.  This extends functionality 

  
of the host class for SSSD QE purposes.  Here we add support functions that 

  
will be very widely used across tests and must be run on any or all hosts   

  
in the environment. 

  
"""
def gethostname(self):
   """ Return system hostname """
   cmd = self.run_command(['hostname'], raiseonerr=False)
   return cmd.stdout_text.strip()


Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-20 Thread Petr Viktorin
On 04/20/2016 06:11 AM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/18/2016 12:39 PM, Niranjan wrote:
>>> Niranjan wrote:
 Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/06/2016 10:55 AM, Niranjan wrote:
>>> Greetings,
>>>
>>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
>>> proposed
>>> a patch, I think this patch is more of a workaround , than a solution. 
>>> I would
>>> like to get more inputs on how to use pytest-multihost to execute 
>>> commands 
>>> on Windows. The method i am using requires cygwin with openssh/bash to 
>>> be
>>> installed. 
>>
>> Wow. I'm surprised the only problem on Windows is the "set -e".
>>
>> Regarding the patch:
>>
>> - Why is get_winhost_class needed? I don't see it called anywhere.
>> - Similarly, why is host_type needed? Your patch only sets it.
>>
>> If run_command of WinHost and Unix hosts are this similar, I would put
>> the 'set -e\n' for Unix (and an empty string for Windows) in a class
>> attribute named e.g. "command_prelude", use it in run_command, and move
>> run_command from Host to BaseHost.
>> Would that work, or am I missing something?
> How do we detect the host is windows/unix then , we still need host_type 
> to know what the type of host is (unix/windows)?
>>
>>
>> -- 
>> Petr Viktorin
 Please review the attached patch.
>>
>> Sorry for the delay.
>>
>> The information about whether the host is Unix or Windows is available:
>> the class is either Host or WinHost, so I don't think an extra host_type
>> is necessary.
>> I'd be open to adding host_type as *configuration* (and corresponding
>> attribute) if it also selected the actual Host class. Currently to use
>> WinHost you need to write custom code.
> I would like to have host_type available. We would like to add more
> functions in classes that override Host/WinHost class , which 
> can be then called depending upon the host_type. 

Ah, I see; you're not using the WinHost subclass right now.

I added a host_type; it is used to select the Host class.
You can define a "host_classes" dict in your Domain class to list Host
classes, and the particular Host class will be selected according to the
host_type.

The usage would be like this:

-

class QeHost(QeBaseHost):
   """Linux host class"""
@classmethod
def gethostname(self):
""" Return system hostname """
cmd = self.run_command(['hostname'], raiseonerr=False)
return cmd.stdout_text.strip()
   ...

class QeWinHost(QeBaseHost, pytest_multihost.host.WinHost):
   """Windows host class"""

   @classmethod
   def gethostname(self):
   """ Return system hostname """
   cmd = self.run_command(['hostname', '-A'], set_env=False,
raiseonerr=False)
   return cmd.stdout_text.strip()
   ...


class QeDomain:
   ...
   host_classes = {'default': QeHost, 'windows': QeWinHost}

   # remove your existing "get_host_class" method when host_classes is
defined
   ...

-

And in the config, define host_type to 'windows'.


Would it work for you like this?

-- 
Petr Viktorin
From b010bfca67a9aa985728f7d60ada713db9cf1b1e Mon Sep 17 00:00:00 2001
From: Niranjan MR 
Date: Tue, 12 Apr 2016 17:18:10 +0530
Subject: [PATCH] Add 'host_type', make it possible to use Windows hosts

Add global parameter windows_test_dir to specify test directory
for Windows
Windows hosts (WinHost) use this directory by default.
test_dir can now be set individually for each host.
Move run_command from Host class to BaseHost class
Add a "host_type" configuration option and Host attribute. This
is used to select the Host subclass. By default it can
be 'default' or 'windows' (but Config subclasses can define more).

Signed-off-by: Petr Viktorin 
---
 pytest_multihost/config.py  | 15 +++--
 pytest_multihost/host.py| 56 -
 test_pytestmultihost/test_testconfig.py | 12 ++-
 3 files changed, 58 insertions(+), 25 deletions(-)

diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
index 31045c2..197d7ad 100644
--- a/pytest_multihost/config.py
+++ b/pytest_multihost/config.py
@@ -45,6 +45,7 @@ class Config(object):
 self.ssh_password = kwargs.get('ssh_password')
 self.ssh_username = kwargs.get('ssh_username', 'root')
 self.ipv6 = bool(kwargs.get('ipv6', False))
+self.windows_test_dir = kwargs.get('windows_test_dir', '/home/Administrator')
 
 if not self.ssh_password and not self.ssh_key_filename:
 self.ssh_key_filename = '~/.ssh/id_rsa'
@@ -80,6 +81,8 @@ class Config(object):
 dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
 if 'root_password' in dct:
 dct['ssh_password'] = dct.pop('root_password')
+if 'windows_test_dir' in dct:
+

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-19 Thread Niranjan
Petr Viktorin wrote:
> On 04/18/2016 12:39 PM, Niranjan wrote:
> > Niranjan wrote:
> >> Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> >
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > proposed
> > a patch, I think this patch is more of a workaround , than a solution. 
> > I would
> > like to get more inputs on how to use pytest-multihost to execute 
> > commands 
> > on Windows. The method i am using requires cygwin with openssh/bash to 
> > be
> > installed. 
> 
>  Wow. I'm surprised the only problem on Windows is the "set -e".
> 
>  Regarding the patch:
> 
>  - Why is get_winhost_class needed? I don't see it called anywhere.
>  - Similarly, why is host_type needed? Your patch only sets it.
> 
>  If run_command of WinHost and Unix hosts are this similar, I would put
>  the 'set -e\n' for Unix (and an empty string for Windows) in a class
>  attribute named e.g. "command_prelude", use it in run_command, and move
>  run_command from Host to BaseHost.
>  Would that work, or am I missing something?
> >>> How do we detect the host is windows/unix then , we still need host_type 
> >>> to know what the type of host is (unix/windows)?
> 
> 
>  -- 
>  Petr Viktorin
> >> Please review the attached patch.
> 
> Sorry for the delay.
> 
> The information about whether the host is Unix or Windows is available:
> the class is either Host or WinHost, so I don't think an extra host_type
> is necessary.
> I'd be open to adding host_type as *configuration* (and corresponding
> attribute) if it also selected the actual Host class. Currently to use
> WinHost you need to write custom code.
I would like to have host_type available. We would like to add more
functions in classes that override Host/WinHost class , which 
can be then called depending upon the host_type. 
> 
> I modified the patch so BaseHost takes test_dir as an argument, and sets
> it as self.test_dir, so that users don't need to choose between
> self.config.windows_test_dir/self.config.test_dir themselves.
> (Unfortunately I don't have Windows to test on; I hope the change is
> correct.) Would this approach work for you?
> 
> -- 
> Petr Viktorin
> 

> From f4e8290beb217aba60f1caf7e69b472e1e8e Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] modify run_command to execute on Windows
> 
> Add global parameter windows_test_dir to specify test directory
> for Windows
> Windows hosts (WinHost) use this directory by default.
> test_dir can now be set individually for each host.
> Move run_command from Host class to BaseHost class
> 
> Signed-off-by: Petr Viktorin 
> ---
>  pytest_multihost/config.py |  3 +++
>  pytest_multihost/host.py   | 41 ++---
>  2 files changed, 25 insertions(+), 19 deletions(-)
> 
> diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
> index 31045c2..58a3a5f 100644
> --- a/pytest_multihost/config.py
> +++ b/pytest_multihost/config.py
> @@ -45,6 +45,7 @@ class Config(object):
>  self.ssh_password = kwargs.get('ssh_password')
>  self.ssh_username = kwargs.get('ssh_username', 'root')
>  self.ipv6 = bool(kwargs.get('ipv6', False))
> +self.windows_test_dir = kwargs.get('windows_test_dir', 
> '/home/Administrator')
>  
>  if not self.ssh_password and not self.ssh_key_filename:
>  self.ssh_key_filename = '~/.ssh/id_rsa'
> @@ -80,6 +81,8 @@ class Config(object):
>  dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
>  if 'root_password' in dct:
>  dct['ssh_password'] = dct.pop('root_password')
> +if 'windows_test_dir' in dct:
> +dct['windows_test_dir'] = dct.pop('windows_test_dir')
>  
>  all_init_args = set(init_args) | set(cls.extra_init_args)
>  extra_args = set(dct) - all_init_args
> diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
> index e6c0db5..f82ff33 100644
> --- a/pytest_multihost/host.py
> +++ b/pytest_multihost/host.py
> @@ -25,9 +25,11 @@ class BaseHost(object):
>  See README for an overview of the core classes.
>  """
>  transport_class = None
> +command_prelude = ''
>  
>  def __init__(self, domain, hostname, role, ip=None,
> - external_hostname=None, username=None, password=None):
> + external_hostname=None, username=None, password=None,
> + test_dir=None):
>  self.domain = domain
>  self.role = str(role)
>  if username is None:
> @@ -40,6 +42,10 @@ class BaseHost(object):
>  else:
>  self.ssh_key_filename = None
>  self.ssh_password = password
> +if test_dir is None:
> +self.test_dir = 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-19 Thread Niranjan
Petr Viktorin wrote:
> On 04/18/2016 12:39 PM, Niranjan wrote:
> > Niranjan wrote:
> >> Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> >
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > proposed
> > a patch, I think this patch is more of a workaround , than a solution. 
> > I would
> > like to get more inputs on how to use pytest-multihost to execute 
> > commands 
> > on Windows. The method i am using requires cygwin with openssh/bash to 
> > be
> > installed. 
> 
>  Wow. I'm surprised the only problem on Windows is the "set -e".
> 
>  Regarding the patch:
> 
>  - Why is get_winhost_class needed? I don't see it called anywhere.
>  - Similarly, why is host_type needed? Your patch only sets it.
> 
>  If run_command of WinHost and Unix hosts are this similar, I would put
>  the 'set -e\n' for Unix (and an empty string for Windows) in a class
>  attribute named e.g. "command_prelude", use it in run_command, and move
>  run_command from Host to BaseHost.
>  Would that work, or am I missing something?
> >>> How do we detect the host is windows/unix then , we still need host_type 
> >>> to know what the type of host is (unix/windows)?
> 
> 
>  -- 
>  Petr Viktorin
> >> Please review the attached patch.
> 
> Sorry for the delay.
> 
> The information about whether the host is Unix or Windows is available:
> the class is either Host or WinHost, so I don't think an extra host_type
> is necessary.
Sorry, but i still not sure how to invoke WinHost, did you mean in 
the file where i override the host class and WinHost class ?
> I'd be open to adding host_type as *configuration* (and corresponding
> attribute) if it also selected the actual Host class. Currently to use
> WinHost you need to write custom code.
Can you show any example code. 
> 
> I modified the patch so BaseHost takes test_dir as an argument, and sets
> it as self.test_dir, so that users don't need to choose between
> self.config.windows_test_dir/self.config.test_dir themselves.
> (Unfortunately I don't have Windows to test on; I hope the change is
> correct.) Would this approach work for you?
> 
> -- 
> Petr Viktorin
> 

> From f4e8290beb217aba60f1caf7e69b472e1e8e Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] modify run_command to execute on Windows
> 
> Add global parameter windows_test_dir to specify test directory
> for Windows
> Windows hosts (WinHost) use this directory by default.
> test_dir can now be set individually for each host.
> Move run_command from Host class to BaseHost class
> 
> Signed-off-by: Petr Viktorin 
> ---
>  pytest_multihost/config.py |  3 +++
>  pytest_multihost/host.py   | 41 ++---
>  2 files changed, 25 insertions(+), 19 deletions(-)
> 
> diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
> index 31045c2..58a3a5f 100644
> --- a/pytest_multihost/config.py
> +++ b/pytest_multihost/config.py
> @@ -45,6 +45,7 @@ class Config(object):
>  self.ssh_password = kwargs.get('ssh_password')
>  self.ssh_username = kwargs.get('ssh_username', 'root')
>  self.ipv6 = bool(kwargs.get('ipv6', False))
> +self.windows_test_dir = kwargs.get('windows_test_dir', 
> '/home/Administrator')
>  
>  if not self.ssh_password and not self.ssh_key_filename:
>  self.ssh_key_filename = '~/.ssh/id_rsa'
> @@ -80,6 +81,8 @@ class Config(object):
>  dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
>  if 'root_password' in dct:
>  dct['ssh_password'] = dct.pop('root_password')
> +if 'windows_test_dir' in dct:
> +dct['windows_test_dir'] = dct.pop('windows_test_dir')
>  
>  all_init_args = set(init_args) | set(cls.extra_init_args)
>  extra_args = set(dct) - all_init_args
> diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
> index e6c0db5..f82ff33 100644
> --- a/pytest_multihost/host.py
> +++ b/pytest_multihost/host.py
> @@ -25,9 +25,11 @@ class BaseHost(object):
>  See README for an overview of the core classes.
>  """
>  transport_class = None
> +command_prelude = ''
>  
>  def __init__(self, domain, hostname, role, ip=None,
> - external_hostname=None, username=None, password=None):
> + external_hostname=None, username=None, password=None,
> + test_dir=None):
>  self.domain = domain
>  self.role = str(role)
>  if username is None:
> @@ -40,6 +42,10 @@ class BaseHost(object):
>  else:
>  self.ssh_key_filename = None
>  self.ssh_password = password
> +if test_dir is None:
> +self.test_dir = domain.config.test_dir
> + 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-18 Thread Niranjan
Petr Viktorin wrote:
> On 04/18/2016 12:39 PM, Niranjan wrote:
> > Niranjan wrote:
> >> Niranjan wrote:
> >>> Petr Viktorin wrote:
>  On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> >
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > proposed
> > a patch, I think this patch is more of a workaround , than a solution. 
> > I would
> > like to get more inputs on how to use pytest-multihost to execute 
> > commands 
> > on Windows. The method i am using requires cygwin with openssh/bash to 
> > be
> > installed. 
> 
>  Wow. I'm surprised the only problem on Windows is the "set -e".
> 
>  Regarding the patch:
> 
>  - Why is get_winhost_class needed? I don't see it called anywhere.
>  - Similarly, why is host_type needed? Your patch only sets it.
> 
>  If run_command of WinHost and Unix hosts are this similar, I would put
>  the 'set -e\n' for Unix (and an empty string for Windows) in a class
>  attribute named e.g. "command_prelude", use it in run_command, and move
>  run_command from Host to BaseHost.
>  Would that work, or am I missing something?
> >>> How do we detect the host is windows/unix then , we still need host_type 
> >>> to know what the type of host is (unix/windows)?
> 
> 
>  -- 
>  Petr Viktorin
> >> Please review the attached patch.
> 
> Sorry for the delay.
> 
> The information about whether the host is Unix or Windows is available:
> the class is either Host or WinHost, so I don't think an extra host_type
> is necessary.
> I'd be open to adding host_type as *configuration* (and corresponding
> attribute) if it also selected the actual Host class. Currently to use
> WinHost you need to write custom code.
> 
> I modified the patch so BaseHost takes test_dir as an argument, and sets
> it as self.test_dir, so that users don't need to choose between
> self.config.windows_test_dir/self.config.test_dir themselves.
> (Unfortunately I don't have Windows to test on; I hope the change is
> correct.) Would this approach work for you?
I am testing the patch with windows AD , Will update with my observations
> 
> -- 
> Petr Viktorin
> 

> From f4e8290beb217aba60f1caf7e69b472e1e8e Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] modify run_command to execute on Windows
> 
> Add global parameter windows_test_dir to specify test directory
> for Windows
> Windows hosts (WinHost) use this directory by default.
> test_dir can now be set individually for each host.
> Move run_command from Host class to BaseHost class
> 
> Signed-off-by: Petr Viktorin 
> ---
>  pytest_multihost/config.py |  3 +++
>  pytest_multihost/host.py   | 41 ++---
>  2 files changed, 25 insertions(+), 19 deletions(-)
> 
> diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
> index 31045c2..58a3a5f 100644
> --- a/pytest_multihost/config.py
> +++ b/pytest_multihost/config.py
> @@ -45,6 +45,7 @@ class Config(object):
>  self.ssh_password = kwargs.get('ssh_password')
>  self.ssh_username = kwargs.get('ssh_username', 'root')
>  self.ipv6 = bool(kwargs.get('ipv6', False))
> +self.windows_test_dir = kwargs.get('windows_test_dir', 
> '/home/Administrator')
>  
>  if not self.ssh_password and not self.ssh_key_filename:
>  self.ssh_key_filename = '~/.ssh/id_rsa'
> @@ -80,6 +81,8 @@ class Config(object):
>  dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
>  if 'root_password' in dct:
>  dct['ssh_password'] = dct.pop('root_password')
> +if 'windows_test_dir' in dct:
> +dct['windows_test_dir'] = dct.pop('windows_test_dir')
>  
>  all_init_args = set(init_args) | set(cls.extra_init_args)
>  extra_args = set(dct) - all_init_args
> diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
> index e6c0db5..f82ff33 100644
> --- a/pytest_multihost/host.py
> +++ b/pytest_multihost/host.py
> @@ -25,9 +25,11 @@ class BaseHost(object):
>  See README for an overview of the core classes.
>  """
>  transport_class = None
> +command_prelude = ''
>  
>  def __init__(self, domain, hostname, role, ip=None,
> - external_hostname=None, username=None, password=None):
> + external_hostname=None, username=None, password=None,
> + test_dir=None):
>  self.domain = domain
>  self.role = str(role)
>  if username is None:
> @@ -40,6 +42,10 @@ class BaseHost(object):
>  else:
>  self.ssh_key_filename = None
>  self.ssh_password = password
> +if test_dir is None:
> +self.test_dir = domain.config.test_dir
> +else:
> +self.test_dir = test_dir
>  
>  shortname, dot, 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-18 Thread Petr Viktorin
On 04/18/2016 12:39 PM, Niranjan wrote:
> Niranjan wrote:
>> Niranjan wrote:
>>> Petr Viktorin wrote:
 On 04/06/2016 10:55 AM, Niranjan wrote:
> Greetings,
>
> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> proposed
> a patch, I think this patch is more of a workaround , than a solution. I 
> would
> like to get more inputs on how to use pytest-multihost to execute 
> commands 
> on Windows. The method i am using requires cygwin with openssh/bash to be
> installed. 

 Wow. I'm surprised the only problem on Windows is the "set -e".

 Regarding the patch:

 - Why is get_winhost_class needed? I don't see it called anywhere.
 - Similarly, why is host_type needed? Your patch only sets it.

 If run_command of WinHost and Unix hosts are this similar, I would put
 the 'set -e\n' for Unix (and an empty string for Windows) in a class
 attribute named e.g. "command_prelude", use it in run_command, and move
 run_command from Host to BaseHost.
 Would that work, or am I missing something?
>>> How do we detect the host is windows/unix then , we still need host_type 
>>> to know what the type of host is (unix/windows)?


 -- 
 Petr Viktorin
>> Please review the attached patch.

Sorry for the delay.

The information about whether the host is Unix or Windows is available:
the class is either Host or WinHost, so I don't think an extra host_type
is necessary.
I'd be open to adding host_type as *configuration* (and corresponding
attribute) if it also selected the actual Host class. Currently to use
WinHost you need to write custom code.

I modified the patch so BaseHost takes test_dir as an argument, and sets
it as self.test_dir, so that users don't need to choose between
self.config.windows_test_dir/self.config.test_dir themselves.
(Unfortunately I don't have Windows to test on; I hope the change is
correct.) Would this approach work for you?

-- 
Petr Viktorin

From f4e8290beb217aba60f1caf7e69b472e1e8e Mon Sep 17 00:00:00 2001
From: Niranjan MR 
Date: Tue, 12 Apr 2016 17:18:10 +0530
Subject: [PATCH] modify run_command to execute on Windows

Add global parameter windows_test_dir to specify test directory
for Windows
Windows hosts (WinHost) use this directory by default.
test_dir can now be set individually for each host.
Move run_command from Host class to BaseHost class

Signed-off-by: Petr Viktorin 
---
 pytest_multihost/config.py |  3 +++
 pytest_multihost/host.py   | 41 ++---
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
index 31045c2..58a3a5f 100644
--- a/pytest_multihost/config.py
+++ b/pytest_multihost/config.py
@@ -45,6 +45,7 @@ class Config(object):
 self.ssh_password = kwargs.get('ssh_password')
 self.ssh_username = kwargs.get('ssh_username', 'root')
 self.ipv6 = bool(kwargs.get('ipv6', False))
+self.windows_test_dir = kwargs.get('windows_test_dir', '/home/Administrator')
 
 if not self.ssh_password and not self.ssh_key_filename:
 self.ssh_key_filename = '~/.ssh/id_rsa'
@@ -80,6 +81,8 @@ class Config(object):
 dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
 if 'root_password' in dct:
 dct['ssh_password'] = dct.pop('root_password')
+if 'windows_test_dir' in dct:
+dct['windows_test_dir'] = dct.pop('windows_test_dir')
 
 all_init_args = set(init_args) | set(cls.extra_init_args)
 extra_args = set(dct) - all_init_args
diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
index e6c0db5..f82ff33 100644
--- a/pytest_multihost/host.py
+++ b/pytest_multihost/host.py
@@ -25,9 +25,11 @@ class BaseHost(object):
 See README for an overview of the core classes.
 """
 transport_class = None
+command_prelude = ''
 
 def __init__(self, domain, hostname, role, ip=None,
- external_hostname=None, username=None, password=None):
+ external_hostname=None, username=None, password=None,
+ test_dir=None):
 self.domain = domain
 self.role = str(role)
 if username is None:
@@ -40,6 +42,10 @@ class BaseHost(object):
 else:
 self.ssh_key_filename = None
 self.ssh_password = password
+if test_dir is None:
+self.test_dir = domain.config.test_dir
+else:
+self.test_dir = test_dir
 
 shortname, dot, ext_domain = hostname.partition('.')
 self.shortname = shortname
@@ -78,7 +84,7 @@ class BaseHost(object):
 self.host_key = None
 self.ssh_port = 22
 
-self.env_sh_path = os.path.join(domain.config.test_dir, 'env.sh')
+self.env_sh_path = os.path.join(self.test_dir, 'env.sh')
 
 self.log_collectors = 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-18 Thread Niranjan
Niranjan wrote:
> Niranjan wrote:
> > Petr Viktorin wrote:
> > > On 04/06/2016 10:55 AM, Niranjan wrote:
> > > > Greetings,
> > > > 
> > > > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > > > proposed
> > > > a patch, I think this patch is more of a workaround , than a solution. 
> > > > I would
> > > > like to get more inputs on how to use pytest-multihost to execute 
> > > > commands 
> > > > on Windows. The method i am using requires cygwin with openssh/bash to 
> > > > be
> > > > installed. 
> > > 
> > > Wow. I'm surprised the only problem on Windows is the "set -e".
> > > 
> > > Regarding the patch:
> > > 
> > > - Why is get_winhost_class needed? I don't see it called anywhere.
> > > - Similarly, why is host_type needed? Your patch only sets it.
> > > 
> > > If run_command of WinHost and Unix hosts are this similar, I would put
> > > the 'set -e\n' for Unix (and an empty string for Windows) in a class
> > > attribute named e.g. "command_prelude", use it in run_command, and move
> > > run_command from Host to BaseHost.
> > > Would that work, or am I missing something?
> > How do we detect the host is windows/unix then , we still need host_type 
> > to know what the type of host is (unix/windows)?
> > > 
> > > 
> > > -- 
> > > Petr Viktorin
> Please review the attached patch.
> 
> 
> 
> > -- 
> > Manage your subscription for the Freeipa-devel mailing list:
> > https://www.redhat.com/mailman/listinfo/freeipa-devel
> > Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
> 
Could you please review this patch

> From 5b01d7eb1bc3723201b6083a814467f87d865367 Mon Sep 17 00:00:00 2001
> From: Niranjan MR 
> Date: Tue, 12 Apr 2016 17:18:10 +0530
> Subject: [PATCH] modify run_command to execute on Windows
> 
> Add global parameter windows_test_dir to specify test directory
> for Windows
> Add parameter host_type(per host) to specify the type of host
> (host_type:windows)
> move run_command from Host class to BaseHost class
> 
> Signed-off-by: Niranjan MR 
> ---
>  pytest_multihost/config.py |  3 ++
>  pytest_multihost/host.py   | 87 
> +-
>  2 files changed, 50 insertions(+), 40 deletions(-)
> 
> diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
> index 
> 31045c21e8ee67c1793f154f841375f8df7b365f..58a3a5fbc8dbcdaac35e3fd305f23999d5f5b09f
>  100644
> --- a/pytest_multihost/config.py
> +++ b/pytest_multihost/config.py
> @@ -45,6 +45,7 @@ class Config(object):
>  self.ssh_password = kwargs.get('ssh_password')
>  self.ssh_username = kwargs.get('ssh_username', 'root')
>  self.ipv6 = bool(kwargs.get('ipv6', False))
> +self.windows_test_dir = kwargs.get('windows_test_dir', 
> '/home/Administrator')
>  
>  if not self.ssh_password and not self.ssh_key_filename:
>  self.ssh_key_filename = '~/.ssh/id_rsa'
> @@ -80,6 +81,8 @@ class Config(object):
>  dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
>  if 'root_password' in dct:
>  dct['ssh_password'] = dct.pop('root_password')
> +if 'windows_test_dir' in dct:
> +dct['windows_test_dir'] = dct.pop('windows_test_dir')
>  
>  all_init_args = set(init_args) | set(cls.extra_init_args)
>  extra_args = set(dct) - all_init_args
> diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
> index 
> e6c0db50799b2042e699d66ed9ec5f04f6592d31..828ba81279b563e4c5d2735bc6396480f4152304
>  100644
> --- a/pytest_multihost/host.py
> +++ b/pytest_multihost/host.py
> @@ -27,9 +27,13 @@ class BaseHost(object):
>  transport_class = None
>  
>  def __init__(self, domain, hostname, role, ip=None,
> - external_hostname=None, username=None, password=None):
> + external_hostname=None, username=None, 
> + password=None, windows_test_dir=None, 
> + host_type=None):
>  self.domain = domain
>  self.role = str(role)
> +self.host_type = host_type
> +self.command_prelude = 'set -e\n'
>  if username is None:
>  self.ssh_username = self.config.ssh_username
>  else:
> @@ -40,6 +44,8 @@ class BaseHost(object):
>  else:
>  self.ssh_key_filename = None
>  self.ssh_password = password
> +if windows_test_dir is None:
> +self.windows_test_dir = self.config.windows_test_dir
>  
>  shortname, dot, ext_domain = hostname.partition('.')
>  self.shortname = shortname
> @@ -118,11 +124,13 @@ class BaseHost(object):
>  
>  username = dct.pop('username', None)
>  password = dct.pop('password', None)
> +windows_test_dir = dct.pop('windows_test_dir', None)
> +host_type = dct.pop('host_type', None)
>  
>  check_config_dict_empty(dct, 'host %s' % hostname)
>  
>  return cls(domain, 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-13 Thread Niranjan
Niranjan wrote:
> Petr Viktorin wrote:
> > On 04/06/2016 10:55 AM, Niranjan wrote:
> > > Greetings,
> > > 
> > > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > > proposed
> > > a patch, I think this patch is more of a workaround , than a solution. I 
> > > would
> > > like to get more inputs on how to use pytest-multihost to execute 
> > > commands 
> > > on Windows. The method i am using requires cygwin with openssh/bash to be
> > > installed. 
> > 
> > Wow. I'm surprised the only problem on Windows is the "set -e".
> > 
> > Regarding the patch:
> > 
> > - Why is get_winhost_class needed? I don't see it called anywhere.
> > - Similarly, why is host_type needed? Your patch only sets it.
> > 
> > If run_command of WinHost and Unix hosts are this similar, I would put
> > the 'set -e\n' for Unix (and an empty string for Windows) in a class
> > attribute named e.g. "command_prelude", use it in run_command, and move
> > run_command from Host to BaseHost.
> > Would that work, or am I missing something?
> How do we detect the host is windows/unix then , we still need host_type 
> to know what the type of host is (unix/windows)?
> > 
> > 
> > -- 
> > Petr Viktorin
Please review the attached patch.



> -- 
> Manage your subscription for the Freeipa-devel mailing list:
> https://www.redhat.com/mailman/listinfo/freeipa-devel
> Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

From 5b01d7eb1bc3723201b6083a814467f87d865367 Mon Sep 17 00:00:00 2001
From: Niranjan MR 
Date: Tue, 12 Apr 2016 17:18:10 +0530
Subject: [PATCH] modify run_command to execute on Windows

Add global parameter windows_test_dir to specify test directory
for Windows
Add parameter host_type(per host) to specify the type of host
(host_type:windows)
move run_command from Host class to BaseHost class

Signed-off-by: Niranjan MR 
---
 pytest_multihost/config.py |  3 ++
 pytest_multihost/host.py   | 87 +-
 2 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
index 
31045c21e8ee67c1793f154f841375f8df7b365f..58a3a5fbc8dbcdaac35e3fd305f23999d5f5b09f
 100644
--- a/pytest_multihost/config.py
+++ b/pytest_multihost/config.py
@@ -45,6 +45,7 @@ class Config(object):
 self.ssh_password = kwargs.get('ssh_password')
 self.ssh_username = kwargs.get('ssh_username', 'root')
 self.ipv6 = bool(kwargs.get('ipv6', False))
+self.windows_test_dir = kwargs.get('windows_test_dir', 
'/home/Administrator')
 
 if not self.ssh_password and not self.ssh_key_filename:
 self.ssh_key_filename = '~/.ssh/id_rsa'
@@ -80,6 +81,8 @@ class Config(object):
 dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
 if 'root_password' in dct:
 dct['ssh_password'] = dct.pop('root_password')
+if 'windows_test_dir' in dct:
+dct['windows_test_dir'] = dct.pop('windows_test_dir')
 
 all_init_args = set(init_args) | set(cls.extra_init_args)
 extra_args = set(dct) - all_init_args
diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
index 
e6c0db50799b2042e699d66ed9ec5f04f6592d31..828ba81279b563e4c5d2735bc6396480f4152304
 100644
--- a/pytest_multihost/host.py
+++ b/pytest_multihost/host.py
@@ -27,9 +27,13 @@ class BaseHost(object):
 transport_class = None
 
 def __init__(self, domain, hostname, role, ip=None,
- external_hostname=None, username=None, password=None):
+ external_hostname=None, username=None, 
+ password=None, windows_test_dir=None, 
+ host_type=None):
 self.domain = domain
 self.role = str(role)
+self.host_type = host_type
+self.command_prelude = 'set -e\n'
 if username is None:
 self.ssh_username = self.config.ssh_username
 else:
@@ -40,6 +44,8 @@ class BaseHost(object):
 else:
 self.ssh_key_filename = None
 self.ssh_password = password
+if windows_test_dir is None:
+self.windows_test_dir = self.config.windows_test_dir
 
 shortname, dot, ext_domain = hostname.partition('.')
 self.shortname = shortname
@@ -118,11 +124,13 @@ class BaseHost(object):
 
 username = dct.pop('username', None)
 password = dct.pop('password', None)
+windows_test_dir = dct.pop('windows_test_dir', None)
+host_type = dct.pop('host_type', None)
 
 check_config_dict_empty(dct, 'host %s' % hostname)
 
 return cls(domain, hostname, role, ip, external_hostname,
-   username, password)
+   username, password, windows_test_dir, host_type)
 
 def to_dict(self):
 """Export info about this Host to a dict"""
@@ -131,6 +139,8 @@ class BaseHost(object):
 'ip': self.ip,
 

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-12 Thread Niranjan
Petr Viktorin wrote:
> On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> > 
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > proposed
> > a patch, I think this patch is more of a workaround , than a solution. I 
> > would
> > like to get more inputs on how to use pytest-multihost to execute commands 
> > on Windows. The method i am using requires cygwin with openssh/bash to be
> > installed. 
> 
> Wow. I'm surprised the only problem on Windows is the "set -e".
> 
> Regarding the patch:
> 
> - Why is get_winhost_class needed? I don't see it called anywhere.
> - Similarly, why is host_type needed? Your patch only sets it.
> 
> If run_command of WinHost and Unix hosts are this similar, I would put
> the 'set -e\n' for Unix (and an empty string for Windows) in a class
> attribute named e.g. "command_prelude", use it in run_command, and move
> run_command from Host to BaseHost.
> Would that work, or am I missing something?
How do we detect the host is windows/unix then , we still need host_type 
to know what the type of host is (unix/windows)?
> 
> 
> -- 
> Petr Viktorin


pgpvWKGk8kMuR.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-08 Thread Niranjan
Petr Viktorin wrote:
> On 04/07/2016 10:12 PM, Niranjan wrote:
> > Petr Viktorin wrote:
> >> On 04/06/2016 10:55 AM, Niranjan wrote:
> >>> Greetings,
> >>>
> >>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> >>> proposed
> >>> a patch, I think this patch is more of a workaround , than a solution. I 
> >>> would
> >>> like to get more inputs on how to use pytest-multihost to execute 
> >>> commands 
> >>> on Windows. The method i am using requires cygwin with openssh/bash to be
> >>> installed. 
> >>
> >> Wow. I'm surprised the only problem on Windows is the "set -e".
> >>
> >> Regarding the patch:
> >>
> >> - Why is get_winhost_class needed? I don't see it called anywhere.
> >> - Similarly, why is host_type needed? Your patch only sets it.
> >>
> >> If run_command of WinHost and Unix hosts are this similar, I would put
> >> the 'set -e\n' for Unix (and an empty string for Windows) in a class
> >> attribute named e.g. "command_prelude", use it in run_command, and move
> >> run_command from Host to BaseHost.
> >> Would that work, or am I missing something?
> > yes, that would work.
> 
> OK. Can you write a patch?
yes, i will come up with a patch, 
> 
> > But there are few more suggestions, right now
> > test_dir is global and for windows test_dir should be set to
> > ~/$ssh_username/username. So can that also be set ?
> 
> Yes. Add a configuration option to Host (in __init__, from_dict and
> to_dict), and take the global default if not used.
> 
> Then you can let Windows hosts default to either a hard-coded path, or
> to a new global config option like "windows_test_dir".
Okay , thanks for this input. 
> 
> 
> -- 
> Petr Viktorin


pgp5Tgi9za4pc.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-08 Thread Petr Viktorin
On 04/07/2016 10:12 PM, Niranjan wrote:
> Petr Viktorin wrote:
>> On 04/06/2016 10:55 AM, Niranjan wrote:
>>> Greetings,
>>>
>>> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
>>> proposed
>>> a patch, I think this patch is more of a workaround , than a solution. I 
>>> would
>>> like to get more inputs on how to use pytest-multihost to execute commands 
>>> on Windows. The method i am using requires cygwin with openssh/bash to be
>>> installed. 
>>
>> Wow. I'm surprised the only problem on Windows is the "set -e".
>>
>> Regarding the patch:
>>
>> - Why is get_winhost_class needed? I don't see it called anywhere.
>> - Similarly, why is host_type needed? Your patch only sets it.
>>
>> If run_command of WinHost and Unix hosts are this similar, I would put
>> the 'set -e\n' for Unix (and an empty string for Windows) in a class
>> attribute named e.g. "command_prelude", use it in run_command, and move
>> run_command from Host to BaseHost.
>> Would that work, or am I missing something?
> yes, that would work.

OK. Can you write a patch?

> But there are few more suggestions, right now
> test_dir is global and for windows test_dir should be set to
> ~/$ssh_username/username. So can that also be set ?

Yes. Add a configuration option to Host (in __init__, from_dict and
to_dict), and take the global default if not used.

Then you can let Windows hosts default to either a hard-coded path, or
to a new global config option like "windows_test_dir".


-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-07 Thread Niranjan
Petr Viktorin wrote:
> On 04/06/2016 10:55 AM, Niranjan wrote:
> > Greetings,
> > 
> > For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> > proposed
> > a patch, I think this patch is more of a workaround , than a solution. I 
> > would
> > like to get more inputs on how to use pytest-multihost to execute commands 
> > on Windows. The method i am using requires cygwin with openssh/bash to be
> > installed. 
> 
> Wow. I'm surprised the only problem on Windows is the "set -e".
> 
> Regarding the patch:
> 
> - Why is get_winhost_class needed? I don't see it called anywhere.
> - Similarly, why is host_type needed? Your patch only sets it.
> 
> If run_command of WinHost and Unix hosts are this similar, I would put
> the 'set -e\n' for Unix (and an empty string for Windows) in a class
> attribute named e.g. "command_prelude", use it in run_command, and move
> run_command from Host to BaseHost.
> Would that work, or am I missing something?
yes, that would work. But there are few more suggestions, right now
test_dir is global and for windows test_dir should be set to
~/$ssh_username/username. So can that also be set ?

> 
> 
> -- 
> Petr Viktorin

Regards,
yiranjan


pgp5F277IIbPC.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [python-pytest-multihost]-Ticket-6 run_command produces exit code 1 on windows

2016-04-06 Thread Petr Viktorin
On 04/06/2016 10:55 AM, Niranjan wrote:
> Greetings,
> 
> For https://fedorahosted.org/python-pytest-multihost/ticket/6 , i have 
> proposed
> a patch, I think this patch is more of a workaround , than a solution. I would
> like to get more inputs on how to use pytest-multihost to execute commands 
> on Windows. The method i am using requires cygwin with openssh/bash to be
> installed. 

Wow. I'm surprised the only problem on Windows is the "set -e".

Regarding the patch:

- Why is get_winhost_class needed? I don't see it called anywhere.
- Similarly, why is host_type needed? Your patch only sets it.

If run_command of WinHost and Unix hosts are this similar, I would put
the 'set -e\n' for Unix (and an empty string for Windows) in a class
attribute named e.g. "command_prelude", use it in run_command, and move
run_command from Host to BaseHost.
Would that work, or am I missing something?


-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code