Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this automates 9 commands of virsh iface #681

Closed
wants to merge 44 commits into from

Conversation

sanjeevpatro
Copy link

It automates 9 command by their respective file
File - virsh_iface_list.py
virsh iface-list

File - virsh_iface_start_destroy.py
virsh iface-destroy
virsh iface-start

File - virsh_iface_define_undefine.py
virsh iface-define
virsh iface-undefine

File - virsh_iface_mac_name.py
virsh iface-mac
virsh iface-name

File- virsh_iface_bridge_unbridge.py
virsh iface-bridge
virsh iface-unbridge

Library file-iface.py

virsh command file - virsh.py

@leonstack
Copy link
Member

Wa oh...You have done so many test cases about virsh iface-*...I was thinking about it. Ok, I will share my ideas with you if I think it's helpful for your test.Thanks!

@leonstack
Copy link
Member

I just saw some codes..maybe you have to do some work on their format :)
Check with pep8, or reformat with autopep8.
https://pypi.python.org/pypi/pep8
https://pypi.python.org/pypi/autopep8

if os.path.exists("%s%s"%(net_scr(),opt)):
return 'yes'
else:
return 'no'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one line is enough, Return a bool value is better than string..

return os.path.exists("%s%s"%(net_scr(),opt))

Then you can use it like:

if is_scr_avail(opt):
    pass
else:
    pass

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed this in my latest patches. Please have a look

return False
else:
return True
#print avail_vir_dbl_ifaces('br0','eth0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found there are some #print , maybe you used them for debugging and forgot to remove them

@leonstack
Copy link
Member

@sanjeevpatro You need to run tools/reindent.py xxx.py and tools/run_pylint.py xxx.py to check your source.
reindent.py is to fix some problem, then use git diff xxx.py you will find where has been changed.
run_pylint.py is to check your source, you need to fix the problems manually.

@param: to_file: capture the output to a optional file
@return: CmdResult object
"""
cmd = ('iface-dumpxml %s %s %s' %(ifc_name,to_file,extra))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there is no need to add to_file into cmd.

@yangdongsheng
Copy link
Member

Well, the virsh part looks much better, and I only found a little issue which I believe only takes you 1 min to fix.

good job. And I will take a look at your code for test module.

Thanx.

elif options_ref == '--inactive':
return check_virsh_list_inactive()
else:
return check_virsh_list_active()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man ,maybe you misunderstant autotest :(
your codes will always pass, because they just return True or False.
Actually when test failed, you'd better raise an exception, you can see other test files

@sanjeevpatro
Copy link
Author

I tried to incorporate all the feedback, whatever I got it from liyangfnst and yangdongsheng
1> removed unwanted classpath from Import definition
2> Used Raise expectation for all the failed cases
3> Removed all the print messages which were used for debug
4> Above commits are having all the all configuration and script files like
5> removed to_file from iface-dumpxml definition

@sanjeevpatro
Copy link
Author

If required I ll post some snippets of logging debug of any one command

#!/usr/bin/python
import os,logging, fileinput, re
from autotest.client.shared import utils,error
from virttest import virsh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanjeevpatro
I found you add a new module named iface to manager the all interafces.
But I am afraid it is not the correct location.

There is a dir virttest/libvirt_xml/. Maybe you can take a look at this module and do this work in it.

Thanx for your update.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean shall i move the iface module from virttest to virttest/libvirt_xml/ and update path in all other runner scripts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not need a new module for iface. Lots of the functions are getting or setting info in xml. I believe they should be
virttest/libvirt_xml and the others need be added into another module such as utils_net, virsh or utils_misc. (I am not clear about
every function in your patch.)

In addition, I sugguest you to read some modules in virttest/libvirt_xml. There are some specific coding style you need to follow.

Hmmm, it seems there are lots of work we need to do before apply this large patchset. My suggestion is splite this patch into
some small pull-requests. We can discuss the all problem in first patchset and then the others will be easy.

e.g:
we can focus on virsh_iface_define_undefine test. Add the apis this test will use in the correct module. Then I believe the other
tests is very similar work with it.

@leonstack
Copy link
Member

@sanjeevpatro @yangdongsheng Hmmm. I have a suggestion. Since there is no relationship between these commands, I suggest you close this pullreq and send these patches one by one, for example, you can send iface_bridge_unbridge.cfg and iface_bridge_unbridge.py and its virsh function in virsh.py and other relational files, then if it's pushed you can send the second, and I think because of the first pullreq's experience you can do much better in second pullreq, I think it will save a lot of time for you and reviewers, do you agree with me?
Just a suggestion, you can ignore it if you think it's not a good idea:)

@leonstack
Copy link
Member

@yangdongsheng Wooo... almost same time to give @sanjeevpatro a same idea, hehe

@sanjeevpatro
Copy link
Author

The main reason is I wanted to segregate all the function required by virsh_iface module, other than virsh commands, in single file. At the same time I could not get much idea where to add on those functions in existing modules, but i tried to see if it is available or not but did not get any satisfactory result. I felt it is the easy path.

I am Ok with start up new pull request with, virsh_iface_list first, where I tried to touch up on virsh iface-list commands and tried to store the output in a list base dictionary. All my scripts would traverse through this. And let us go by the iface module, where I will try to explain more about each and every module and see where we can accommodate.

Instead of cancelling pull request is it possible to push this, later as work goes by we will replace those scripts with newer ones. As of I know bare minimal things are working fine. Understand change of the coding standard essential, any how I will work upon that and try to give you the best results

The last one is just a suggestion, ignore if it not relevant

@sanjeevpatro
Copy link
Author

We can close this pull request, I will open another new pull request with "virsh iface-list" with only 4 files virsh iface-list.py, virsh iface-list.cfg, virsh.py and iface.py(optional) from next week. Thanks for all the feedback I will try to improve more on this, specifically the coding standard. Need your cooperation. Let me any write up required to understand the logical flow?

@leonstack
Copy link
Member

Thanks for your response, fair enough to send a new pullreq, and I'm also interesting in these virsh iface-* commands' test, I will cooperate with you closely:)

@yangdongsheng
Copy link
Member

@sanjeevpatro
Glad to got this message from you. let's begin with virsh iface-list!!
and thanx @liyangfnst for your persistent help on this branch.

Closing it and watching a new pull request.

Thanx
:)

@leonstack
Copy link
Member

Hi, @sanjeevpatro , I saw you have did some work on some virsh iface-* command, and I want to know did you have begin some test on virsh iface-dumpxml and iface-edit, hope your response :)

@yumingfei
Copy link
Member

Hey @sanjeevpatro , what's interface commands going on?

@sanjeevpatro
Copy link
Author

On 01/22/2014 02:52 PM, Fergus Yu wrote:

Hey @sanjeevpatro https://github.com/sanjeevpatro , what's interface
commands going on?


Reply to this email directly or view it on GitHub
#681 (comment).

Sorry for delayed response. I have not done much. I was completIy out of
touch with those work as i was involved in some other projects.Now I am
ready work on those patches unless anybody else had not started those.

Thanks
Sanjeev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants