Détails du package smp-config-veyon_5_all.wapt
retour Revenir à la liste des packages

smp-config-veyon

ATTENTION CE DÉPÔT n'est plus compatible 1.3 vous devez migrer en 1.5.1.21 !

Fichier control :

package           : smp-config-veyon
version           : 5
architecture      : all
section           : base
priority          : optional
maintainer        : Simon Fonteneau
description       : Configuration Veyon with wapt groups
depends           : 
conflicts         : 
maturity          : 
locale            : 
target_os         : 
min_os_version    : 
max_os_version    : 
min_wapt_version  : 1.5
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : a15e9c0f-58b3-4c4e-acfc-02fbbda51dd2
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 8da83ebdac1a25e820b186510d049f47407b11835b0664fdc5bacd3595b1671d
signature         : DdTegZDk1XhNPLcHfQX/E54coYThS1EVzFsXHrHfXGc2kgPgsj03G6M5eJtoJ7OcQkSxeJ14sfOaqcerw/Sl11eBzAHK144DQKUXi/QUJWs8uqQ4/kx++a55/6kp8o3/W7rUU8Ffurdq3OZWSGqgaTohqEt0pJ3ohzCy/WeF1n30L6sqGV1jDQkUV7L75qMz+N9ECm6aWu+JcM+3p8SaJ5DoY8VCXy22S+v6o/Gh3ikSmdR/xb+GsPG1icZRZ556CfCBuRQyKcdpmDYN26L7myDRQxLz3FER5yswnsJtFbGjfF2HTaG+9ob8rhDVenJnFpicxIV9Bj63XBSqVJlCNw==
signature_date    : 2019-05-03T17:34:52.520000
signed_attributes : package,version,architecture,section,priority,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,audit_schedule,editor,keywords,licence,homepage,package_uuid,signer,signer_fingerprint,signature_date,signed_attributes






Fichier setup.py :

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import waptguihelper

uninstallkey = []


def install():


    pathveyon = installed_softwares('veyon')[0]['uninstall_string'].rsplit('\\',1)[0]
    veyonctl = makepath(pathveyon,'veyon-cli.exe')

    #Import configuration Veyon with config.json
    run(r'"%s" config import "%s"' % (veyonctl,makepath(basedir,'config.json')) )

    # List all mac address
    listmac =[]
    for m in networking():
        listmac.append(m['mac'])

    # Clear all networkobjects
    run(r'"%s" networkobjects clear"' % (veyonctl))

    # Add a room  csv if mac address host is in this csv
    for m in listmac:
        for csv in glob.glob('*.csv'):
            inside = open( csv, "r").read()
            if m in inside:
                grpname = csv.split('.csv')[0]
                run(r'"%s" networkobjects import "%s" format ' % (veyonctl,makepath(basedir,csv)) + '"%location%,%name%,%host%,%mac%" ' )


def update_package():
    from waptpackage import PackageEntry
    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())

    #Delete all csv
    for csv in glob.glob('*.csv'):
        remove_file(csv)

    urlserver = inifile_readstring(makepath(install_location('WAPT_is1'),'wapt-get.ini'),'global','wapt_server').replace('https://','')
    credentials_url = waptguihelper.login_password_dialog('Credentials for wapt server',urlserver,'admin','')

    # Give all package
    apigroup = json.loads(wgets('https://%s:%s@%s/api/v1/groups' % (credentials_url['user'],credentials_url['password'],urlserver)))['result']

    # Create csv file for all group wapt
    prefix = pe.package.split('-')[0]
    listgroup = []
    for grp in apigroup:
        if not grp['package'].startswith(prefix):
            listgroup.append(grp['package'])

    for grp in listgroup:
        sallecsv = ""
        for pc in json.loads(wgets('https://%s:%s@%s/api/v1/hosts?groups=%s&columns=connected_ips,mac_addresses&limit=10000' % (credentials_url['user'],credentials_url['password'],urlserver,grp)))['result']:
            sallecsv = sallecsv + """%s,%s,%s,%s\n""" % (grp,pc['computer_name'],pc['connected_ips'][0],pc['mac_addresses'][0])

        print('Generate room "%s"' % grp)
        fichier = open('%s.csv' % grp, "w")
        fichier.write(sallecsv)
        fichier.close()

    print('Please delete csv useless in c:\\waptdev\\%s : ' % pe.package)

if __name__ == '__main__':
    update_package()