Détails du package

smp-config-veyon

retour Revenir à la liste des packages

smp-config-veyon

Fichier control :

package           : smp-config-veyon
version           : 5
architecture      : all
section           : base
priority          : optional
name              : 
categories        : 
maintainer        : Simon Fonteneau
description       : Configuration Veyon with wapt groups
depends           : 
conflicts         : 
maturity          : 
locale            : 
target_os         : windows
min_os_version    : 
max_os_version    : 
min_wapt_version  : 1.5
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 6008b5d3-4d62-4fca-9fbf-0fd79109b117
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature         : AsGlNkRCRQ+HaawIcm1nD142HLfzqYN2s443tHI76h7fU3DdT8ruLEcIWMwu4Tm1lqQ3RjFrU3YsIJF95NDZbD80Jh40CwFldalhADyVoGO5sNSilHUyjsa37b1aNL6s+PkH88rq3lXNNC15dMG4g2L96Mb8uyfUECHnC/P2UScADSUcAZT0/+Bue8CvDWhqFIeH6d7K2J4jGetuBiOwISF2hu1zzxghgx2uq7BA7mdqSRLfacAr7NBYpRcvRlEyOnh0Bz/++PEks5Pb9pHPcLuf5POz0y9ygDWQwLuKXh6Fj05o5HBd2Ek93s5UAoEVpN0rTTFXegTTzsECHG4gSg==
signature_date    : 2020-07-04T01:18:38.675106
signed_attributes : package,version,architecture,section,priority,name,categories,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,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,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()