[PATCH] [TEST] Fixing the run() fn of vxml.py

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237383510 25200 # Node ID a06ef66126e2c8636f0b2ae0d978d38192471e9d # Parent daccd46e12ccf2afce3295a41510d7e94ff48d7b [TEST] Fixing the run() fn of vxml.py. Fixing run() fn of vxml.py to be able to run virsh commands on the remote machine. We need this for successful execution of the ssh remote commands like net-createa via virsh, otherwise the remote execution of the command fails when the file is not locally present on the remote machine. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r daccd46e12cc -r a06ef66126e2 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri Mar 13 10:31:02 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Mar 18 06:38:30 2009 -0700 @@ -164,12 +164,29 @@ else: name = param + # We need to copy the xml files to remote machine for + # successful execution of the ssh remote commands like net-createa via virsh, + # otherwise the remote execution of the command fails when the + # file is not locally present on the remote machine. + if vcmd == 'define' or vcmd == 'create' or vcmd == 'net-create' or \ + vcmd == 'pool-create': + s, o = utils.copy_remote(ip, name, remote=name) + if s != 0: + logger.error("Failed to copy the tempxml file to execute '%s'"\ + " cmd on '%s'", vcmd, ip) + return 0 + cmd = 'virsh -c %s %s %s' % (self.vuri, vcmd, name) s, o = utils.run_remote(ip, cmd) - if vcmd == 'define' or vcmd == 'create': + if vcmd == 'define' or vcmd == 'create' or vcmd == 'net-create' \ + or vcmd == 'pool-create': # don't wait till gc does the ntf.close() ntf.close() + # Remove the tmp file copied to the remote machine + cmd = 'rm -rf %s' % name + utils.run_remote(ip, cmd) + return s == 0 class NetXML(Virsh, XMLClass):

@@ -164,12 +164,29 @@ else: name = param
+ # We need to copy the xml files to remote machine for + # successful execution of the ssh remote commands like net-createa via virsh, + # otherwise the remote execution of the command fails when the + # file is not locally present on the remote machine. + if vcmd == 'define' or vcmd == 'create' or vcmd == 'net-create' or \ + vcmd == 'pool-create': + s, o = utils.copy_remote(ip, name, remote=name) + if s != 0: + logger.error("Failed to copy the tempxml file to execute '%s'"\ + " cmd on '%s'", vcmd, ip) + return 0 +
You're doing this copy every time run() is called, which isn't necessary for actions that are taking place on the local system. Instead, it would be better to copy the key once. In main.py, if the user specifies --target_url, then call copy_remote(). However, the problem with copy_remote() is that it doesn't do any checking to see if the id_rsa file exists on the remote system. So if a file exists, it is replaced by the testsuite. Also, we don't really need to copy the private key itself, we need to write the public key to the target's authorized_keys file. I think something like setup_ssh_keys() is needed to do a proper key exchange between the source and target systems. Also, there's a long standing bug that needs to be fixed here.. I'll follow up with a patch. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

@@ -164,12 +164,29 @@ else: name = param
+ # We need to copy the xml files to remote machine for + # successful execution of the ssh remote commands like net-createa via virsh, + # otherwise the remote execution of the command fails when the + # file is not locally present on the remote machine. + if vcmd == 'define' or vcmd == 'create' or vcmd == 'net-create' or \ + vcmd == 'pool-create': + s, o = utils.copy_remote(ip, name, remote=name) + if s != 0: + logger.error("Failed to copy the tempxml file to execute '%s'"\ + " cmd on '%s'", vcmd, ip) + return 0 +
You're doing this copy every time run() is called, which isn't necessary for actions that are taking place on the local system.
Instead, it would be better to copy the key once. In main.py, if the user specifies --target_url, then call copy_remote(). Copying the files is required when we are planning to initiate the test execution on the remote machine from the local machine. target_url is used for remote migration as of now. But otherwise also for cases like the following to run commands like define/net-create via *ssh* we would need the temp files to be present on the remote machines. This is what I realized when I executed some ssh commands manually like
Kaitlin Rupert wrote: the one below: From Machine ABC: ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa root@machinexyz "virsh -c qemu:///system net-create /tmp/tmpPnWJnU" CIM_NS=root/virt CIM_USER=root CIM_PASS=<xyzpasswd> ./runtests libvirt-cim -i <xyzhost> -c -v KVM -g ElementConforms
However, the problem with copy_remote() is that it doesn't do anyCopying the files is required when we are planning to run the tests checking to see if the id_rsa file exists on the remote system. So if a file exists, it is replaced by the testsuite. Also, we don't really need to copy the private key itself, we need to write the public key to the target's authorized_keys file.
Do you mean that copying the ssh_ids.pub key to authorized file will solve the problem ? If yes, then we already have copied the ssh_ids.pub manually to authorized file on the remote machine. Also, the changes are wrt to executing the commands like virsh define , virsh net-create , virsh pool-create and are conditionally executed only for these cases. Please let me know if I am missing something ?
I think something like setup_ssh_keys() is needed to do a proper key exchange between the source and target systems.
Also, there's a long standing bug that needs to be fixed here.. I'll follow up with a patch.
I have not yet verified your patch yet if it will solve the issue which I mentioned above. -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

Deepti B Kalakeri wrote:
@@ -164,12 +164,29 @@ else: name = param
+ # We need to copy the xml files to remote machine for + # successful execution of the ssh remote commands like net-createa via virsh, + # otherwise the remote execution of the command fails when the + # file is not locally present on the remote machine. + if vcmd == 'define' or vcmd == 'create' or vcmd == 'net-create' or \ + vcmd == 'pool-create': + s, o = utils.copy_remote(ip, name, remote=name) + if s != 0: + logger.error("Failed to copy the tempxml file to execute '%s'"\ + " cmd on '%s'", vcmd, ip) + return 0 +
You're doing this copy every time run() is called, which isn't necessary for actions that are taking place on the local system.
Instead, it would be better to copy the key once. In main.py, if the user specifies --target_url, then call copy_remote(). Copying the files is required when we are planning to initiate the test execution on the remote machine from the local machine. target_url is used for remote migration as of now. But otherwise also for cases like the following to run commands like define/net-create via *ssh* we would need the temp files to be present on the remote machines. This is what I realized when I executed some ssh commands manually like
Kaitlin Rupert wrote: the one below:
From Machine ABC:
ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa root@machinexyz "virsh -c qemu:///system net-create /tmp/tmpPnWJnU"
CIM_NS=root/virt CIM_USER=root CIM_PASS=<xyzpasswd> ./runtests libvirt-cim -i <xyzhost> -c -v KVM -g ElementConforms
However, the problem with copy_remote() is that it doesn't do anyCopying the files is required when we are planning to run the tests checking to see if the id_rsa file exists on the remote system. So if a file exists, it is replaced by the testsuite. Also, we don't really need to copy the private key itself, we need to write the public key to the target's authorized_keys file.
Do you mean that copying the ssh_ids.pub key to authorized file will solve the problem ? If yes, then we already have copied the ssh_ids.pub manually to authorized file on the remote machine. Also, the changes are wrt to executing the commands like virsh define , virsh net-create , virsh pool-create and are conditionally executed only for these cases.
Please let me know if I am missing something ?
This is my mistake Deepti. When I read the patch, I thought you were copying the ssh key of the source to the target. I wasn't reading carefully enough. Although, I'm not sure that calling copy_remote() each time is a good idea. Since most of the calls will take place on the source system, the files should already be present there. Ideally, you would have a way of specifying whether a net-create call is happening on a source or target (and copy only when necessary), but the structure of vxml isn't well suited for handling this. I think this is a reasonable approach for now. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert