Exemple #1
0
    def __init__(self, router=None, locale=None, interface=None, hint=None,
                 service_type=None, preference=100,poolid=0, spares=0, product=None, status="SPARE", blocksize=None, debug=0):
 
	self.reduced=0			# if 1, pool reduction has been run
        self.router=router
        self.status=status
        self.locale=locale
        self.interface=interface
        self.service_type=service_type
        self.preference=int(preference)
        self.pools=None
        self.poollist=[]		# Collection of IPPool objects
        self.poolcount=0
        self.poolid=int(poolid)
        self.product=product
	self.rules=None
	self.hint=hint
	self.debug=debug

	if self.debug>2: print "In AutoIP, product:", self.product

	if self.product:
	    
            self.db = dbconnect.dbConnect(dbc=DBHANDLE)

	    # Apply a ruleset to given product
	    try:
	        self.rules=IPRules.ProductRules(self.product)
	    except:
		raise IPPoolError, (20, "Rules Violation, Unknown product")

	    # Check if have required criteria for current ruleset
#	    if self.rules.PR_locale and not self.locale:
#		raise IPPoolError, (13, "Rules Violation, Must supply a locale")
#	    if self.rules.PR_router and not self.router:
#		raise IPPoolError, (13, "Rules Violation, Must supply a router")
#	    if self.rules.PR_service_type and not self.service_type:
#		raise IPPoolError, (13, "Rules Violation, Must supply a service_type")
#	    if self.rules.PR_interface and not self.interface:
#		raise IPPoolError, (13, "Rules Violation, Must supply a interface")

            self.getpools(poolid=self.poolid, spares=spares, status=status)
Exemple #2
0
# 

import sys, string,time, getopt

sys.path.append('/opt/bta4/lib')
sys.path.append('/import/bta4/lib')
import dbconnect

d=time.localtime(time.time())
mon=d[1]
year=d[0]
months=[]

#db = dbconnect.dbConnect("bta4/bta498@lbta4_ochre")
#snmpdb = dbconnect.dbConnect("bta4_py/bta4_py98@bta4")
snmpdb = dbconnect.dbConnect("bta4_hist/krakenbta4@traf2_orin")
btadb = dbconnect.dbConnect("bta4_hist/krakenbta4@traf2_orin")
btalinkdb = dbconnect.dbConnect("bta4_www/bta4_www98@bta4")

False=0
True=1
simple=False

def flatten(object):
    """" turn any object into list """
    if type(object) == type([]):
        if len(object)>1:
            links = map(flatten,object)
        else:
            links = object[0]
    elif type(object) == type({}):
Exemple #3
0
import configparser
from fixerio import fixerIOCollector
from dbconnect import dbConnect

fixeriocollector = fixerIOCollector()
dbconnect = dbConnect()

fixeriocollector.connect_fixerio_api()
dbconnect.db_store_data()
Exemple #4
0
#

import sys, string, time, getopt

sys.path.append('/opt/bta4/lib')
sys.path.append('/import/bta4/lib')
import dbconnect

d = time.localtime(time.time())
mon = d[1]
year = d[0]
months = []

#db = dbconnect.dbConnect("bta4/bta498@lbta4_ochre")
#snmpdb = dbconnect.dbConnect("bta4_py/bta4_py98@bta4")
snmpdb = dbconnect.dbConnect("bta4_hist/krakenbta4@traf2_orin")
btadb = dbconnect.dbConnect("bta4_hist/krakenbta4@traf2_orin")
btalinkdb = dbconnect.dbConnect("bta4_www/bta4_www98@bta4")

False = 0
True = 1
simple = False


def flatten(object):
    """" turn any object into list """
    if type(object) == type([]):
        if len(object) > 1:
            links = map(flatten, object)
        else:
            links = object[0]
Exemple #5
0
from dbconnect import dbConnect
import psycopg2
con = dbConnect()
# def create_tables(emp_list):
#     try:
#         if con:
#             cur = con.cursor()
#             query = "CREATE TABLE Employee(Id INTEGER PRIMARY KEY,Name VARCHAR(25) NOT NULL,City VARCHAR(20) NOT NULL)"
#             cur.execute(query)
#             cur.close()
#             con.commit()
#         else:
#             print("Connection object is None")
#     except(Exception,psycopg2.DatabaseError) as error:
#         print("Error while connnecting to database{0}".format(error))
#
# if __name__ == "__main__":
#     create_tables([(1,"Sirajunnisa","Vijayawada"),(2,"Jani","Hyderabad"),(3,"Sona","Gujarath")])

#
# def insert_tb_data(param_list):
#     try:
#         if con:
#             #if id is auto increament
#             select = "insert into Employee VALUES(%s,%s,%s)"
#             cur = con.cursor()
#             cur.executemany(select,param_list)
#             # result = cur.rowcount()
#             # print(result)
#             cur.close()
#             con.commit()