tis-config-veyon

6
Configuration Veyon with wapt groups
1411 downloads
Download
default icon

  Description 

  • package : tis-config-veyon
  • version : 6
  • architecture : all
  • categories :
  • maintainer : Simon Fonteneau
  • description : Configuration Veyon with wapt groups
  • locale :
  • target_os :
  • 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 :
  • editor :
  • licence :
  • signature_date : 2020-02-27T21:29:35.883675

  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()


										

  Changelog 



No changelog.txt.
									
  manifest.sha256