Commit 22e7e40c authored by Daniel STAN's avatar Daniel STAN
Browse files

hptools: secrets_new et débarras de ldap_crans

parent 7c95f97b
#!/usr/bin/env python
#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
"""
......@@ -14,23 +14,23 @@ TODO réécrire ce script (la moitié des fonctions ne marchent plus,
from time import sleep
from sys import stderr, path
from commands import getstatusoutput
from annuaires_pg import chbre_prises, all_switchs
from os.path import exists
from os import system
import os
import sys
from re import findall
import re
from config import vlans
import netsnmp
path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
cl = crans_ldap()
if '/usr/scripts' not in sys.path:
path.append('/usr/scripts')
import gestion.secrets_new as secrets
from gestion.config import vlans
from gestion.annuaires_pg import chbre_prises, all_switchs
try:
path.append('/usr/scripts/gestion/secrets')
from secrets import config_snmp_secrete, reconf_snmp
config_snmp_secrete = secrets.get('config_snmp_secrete')
reconf_snmp = secrets.get('reconf_snmp')
except:
# Si a pas le droit de lire config_snmp_secrete
# on va tenter de tout faire en snmpv1 et communauté public
......@@ -140,15 +140,13 @@ class snmp :
else :
raise ValueError('Version incorrecte')
def getBaseMac(self):
''' retourne la Base Mac du switch concerné. C'est elle qui est
utilisée pour l'engineid.'''
switch = cl.search("host=%s" % self.host)["machineCrans"][0]
baseMac = switch.mac().replace(':', '')[0:11] + '0'
return baseMac
def fetch_engineid(self):
self._engineid = '0000000b0000%s' % self.getBaseMac()
short_host = self.host.split('.', 1)[0]
try:
self._engineid = secrets.get('engineid').get(short_host, None)
except:
self._engineid = None
def __exec(self,cmd) :
status, response = getstatusoutput(cmd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment