Page 1 of 1

User and password as argument to wapt-get

Published: October 12, 2015 - 10:53 AM
by lduriez
Good morning,

I am looking to automate, to a greater or lesser extent, the addition of host packages to my WAPT server.

I would like to know if it is possible to directly pass the username and password as arguments with the "wapt-get build-upload" command.<chemin_paquet_host> "? Or at least not have to manually enter the username and password.

If that's not possible, does anyone have any ideas on how to do it?

Personally, I tried something like this:

Code: Select all

wapt-get build-upload [chemin_paquet_host] < saisie.txt 
The following data is contained in the saisie.txt file:

Code: Select all

admin
pswd
admin being the WAPT Server user and pswd the WAPT Server password (NB -> This password is an example).

Unfortunately, it only works halfway because the user is correctly registered automatically (without me needing to enter it manually), however, the password is not registered, I am forced to enter it manually.

Thank you in advance for your answers, ideas, etc.

Re: User and password as arguments to wapt-get

Published: October 12, 2015 - 3:03 PM
by htouvet
We can patch wapt-get.py to allow this information to be passed via the command line...
Add 2 options to the parser.

Code: Select all

    parser.add_option("--wapt-server-user", dest="wapt_server_user", default=None, help="User to upload packages to waptserver. (default: %default)")
    parser.add_option("--wapt-server-passwd", dest="wapt_server_passwd", default=None, help="Password to upload packages to waptserver. (default: %default)")
    

Add the values ​​to the call to build_upload:

Code: Select all

   res = mywapt.upload_package(cmd_dict,wapt_server_user = options.wapt_server_user,wapt_server_passwd=options.wapt_server_passwd)
                             print('Status : %s, %s' % (

Code: Select all

@@ -134,6 +134,8 @@ parser.add_option("-U","--user", dest="user", default=None, help="Interactive us
 parser.add_option("-g","--usergroups", dest="usergroups", default='[]', help="Groups of the final user as a JSon array for checking install permission (default: %default)")
 parser.add_option("-t","--maxttl", type='int',  dest="max_ttl", default=60, help="Max run time in minutes of wapt-get process before being killed by subsequent wapt-get (default: %default minutes)")
 parser.add_option("-L","--language",    dest="language",    default=setuphelpers.get_language(), help="Override language for install (example : fr) (default: %default)")
+parser.add_option("--wapt-server-user", dest="wapt_server_user", default=None, help="User to upload packages to waptserver. (default: %default)")
+parser.add_option("--wapt-server-passwd", dest="wapt_server_passwd", default=None, help="Password to upload packages to waptserver. (default: %default)")
 
 (options,args) = parser.parse_args()
 
@@ -742,7 +744,7 @@ def main():
                                 'waptfile': files_list,
                                 'waptdir':package_group[0],
                             }
-                            res = mywapt.upload_package(cmd_dict)
+                            res = mywapt.upload_package(cmd_dict,wapt_server_user = options.wapt_server_user,wapt_server_passwd=options.wapt_server_passwd)
                             print('Status : %s, %s' % (
                                 res['status'], res['message']))
                                 

Re: User and password as arguments to wapt-get

Published: October 12, 2015 - 3:36 PM
by lduriez
Thank you very much for your reply.

I'll look into it, but I think it will help me a lot.

Re: User and password as arguments to wapt-get

Published: October 14, 2015 - 2:12 PM
by lduriez
Hello,

just to let you know that I made the change to wapt-get.py and it works perfectly.

Thanks anyway, and I hope this can help someone else.

PS: I think you should include this in future versions of WAPT as it could be useful for some people.

Re: User and password as arguments to wapt-get

Published: October 14, 2015 - 2:14 PM
by htouvet