[libvirt] [jenkins-ci PATCH v2 10/12] lcitool: Add projects information handling

Katerina Koukiou kkoukiou at redhat.com
Tue Jul 17 17:55:00 UTC 2018


On Tue, Jul 17, 2018 at 04:44:24PM +0200, Andrea Bolognani wrote:
> On Tue, 2018-07-17 at 15:04 +0200, Katerina Koukiou wrote:
> > On Thu, Jul 12, 2018 at 05:19:27PM +0200, Andrea Bolognani wrote:
> > > +class Projects:
> > > +
> > > +    def __init__(self):
> > > +        try:
> > > +            with open("./vars/mappings.yml", "r") as f:
> > 
> > There is clear information where how to run the lcitool in the docs
> > in some patches befor so the relative paths that are used everywhere in
> > the code are not causing a problem.
> > Though IMO, I think it's clearer to have a variable (config
> > option, hardcoded, env variable or whatever you decide), storing the path of
> > these files so that this code is not dependent on relative paths. WDYT?
> 
> Some of the paths, like vars/mappings.yml, are pretty much entirely
> arbitrary but others, like group_vars/all/main.yml, can't be changed
> because that's what Ansible expects.
> 
> Additionally, none of the paths is repeated more than once in the
> script so using something like
> 
>   mappings_path = "./vars/mappings.yml"
>   open(mappings_path, "r")
> 
> instead of
> 
>   open("./vars/mappings.yml", "r")
> 
> wouldn't IMHO buy us much.

I meant only having a variable for the playbook location.

playbook_path = os.getenv('PLAYBOOK_PATH', './'))

And then use os.path.join for all the others relative paths to the
playbook path.
So that you can actually run the lcitool script from wherever you want.

Anyway, since this script usage is not wide, feel free to keep
everything hardcoded.

> 
> -- 
> Andrea Bolognani / Red Hat / Virtualization
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180717/e05f2460/attachment-0001.sig>


More information about the libvir-list mailing list