[SOLVED] Encrypting your Wapt passwords
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
You need to place your script in the wapt installation folder.
-
louisinger
- Messages: 27
- Registration: June 26, 2018 - 09:40
Okay, it's a .pyd file, my bad, thanks
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
Feel free to post your script once it's finished.
It contributes to the Wapt community!
It contributes to the Wapt community!
-
louisinger
- Messages: 27
- Registration: June 26, 2018 - 09:40
Here's my code, anonymized and commented as much as possible. Hopefully it helps.
PS: That definitely deserves some Tranquil IT stickers, don't you think?
Code: Select all
def isGroup(myPackage):
"""
Renvoie True si le paquet est un paquet groupe de l'AD.
:param myPackage: nom du paquet à tester.
:return boolean: True si myPackage appartient à groupPackages, False si non.
:exemple:
> isGroup('lot1')
True
> isGroup('tis-java8')
False
"""
groupPackages = {'lot1','lot2','lot3','lot4'}
for group in groupPackages:
if group == myPackage:
return True
return False
def haveGroup(depends):
"""
Renvoie true si la ligne de dépendance en paramètre contient un des groupes.
:param depends: ligne de dépendance au format "dependance1,dependance2,..."
:return boolean: True si il y a un groupe False si non.
:exemple:
> haveGroup('tis-chrome, tis-microsoft-office, lot1')
True
> haveGroup('tis-chrome')
False
"""
if not depends :
return False
else :
packages = depends.split(',')
for p in packages:
if isGroup(p):
return True
return False
def main(get_group):
"""
Repartie les clients WAPT dans différents groupes (groupes AD).
:param get_group: fonction qui renvoie le nom du package group
"""
# const
USER = 'admin'
URL_SERVER = '**********'
RESULT_LIMIT = 1500
TEMP_DIR_ROOT = 'c:/temp/*******'
PATH_TO_CONFIGFILE = r'C:/Users/administrateur/AppData/Local/waptconsole/waptconsole.ini'
FORCE = False
remove_tree(TEMP_DIR_ROOT)
myWapt = Wapt(config_filename = PATH_TO_CONFIGFILE)
mycrt = r"****************"
credentials_url = waptguihelper.login_password_dialog('admin loggin', URL_SERVER, USER, '')
passwd_private_key = waptguihelper.key_password_dialog('Password for private key',mycrt, '')
USER = credentials_url['user']
PASSWORD = credentials_url['password']
PASSWORD_KEY = passwd_private_key['keypassword']
data = json.loads(wgets('https://%s:%s@%s/api/v1/hosts?limit=%s' % (USER, PASSWORD, URL_SERVER, RESULT_LIMIT)))
uuid, depends, fqdn, tmpdir = '','','',''
if FORCE:
print("Force : True")
for value in data['result']:
uuid = value.get('uuid')
depends = value.get('depends')
fqdn = value.get('computer_fqdn')
if not haveGroup(depends) or FORCE:
group_name = get_group(fqdn)
tmpdir = makepath(TEMP_DIR_ROOT, uuid)
myWapt.edit_host(uuid, target_directory = tmpdir, append_depends = group_name)
myWapt.build_upload(r'%s'%tmpdir, private_key_passwd = PASSWORD_KEY, wapt_server_user = USER, wapt_server_passwd = PASSWORD)
print("%s (%s) ---> %s"%(uuid,fqdn,group_name))
if __name__ == "__main__":
main(get_group = mafonctiongetGroup)PS: That definitely deserves some Tranquil IT stickers, don't you think?
- sfonteneau
- WAPT Expert
- Messages: 2318
- Registered: July 10, 2014 - 11:52 PM
- Contact :
You don't want to provide the anonymized version of the function mafonctiongetGroup? 
-
louisinger
- Messages: 27
- Registration: June 26, 2018 - 09:40
It's a function specific to each organization, and even anonymized, I doubt it makes sense to provide it. But I'll see what I can do 
-
louisinger
- Messages: 27
- Registration: June 26, 2018 - 09:40
Here is getGroup:
assuming that the job titles are in the format: X000Y100.organisation.fr
where X000 is the site reference.
Alias_groupe is of the form:
and the switcher that allows switching between sites and groups:
There you go, it's simple and simplistic, but it saves a huge amount of time when sorting the machines.
assuming that the job titles are in the format: X000Y100.organisation.fr
where X000 is the site reference.
Code: Select all
def toSiteName(computer_fqdn):
"""
Renvoie le nom du site en fonction du host name.
:param computer_fqdn: full hostname d'un poste client.
:return string: nom du site en majuscule
"""
host = computer_fqdn.split('.')[0][0:4]
return host.upper()
def getGroup(fqdn):
"""
Renvoie le groupe en fonction du nom de l'hote
"""
site_name = toSiteName(fqdn)
group_name = alias_groupe.get(switcher.get(site_name, 0), 'hors-lot')
return group_name
Code: Select all
alias_groupe = {
0:'hors-lot'
1:'lot1',
2:'lot2',
3:'lot3'
}
Code: Select all
switcher = {
'X000':1
'X001':2
'X002':1
'Y010':3
}
