Exemplo n.º 1
0
    def __init__(self, conf={}, daoClass=Dao):
        if any(conf) == False:
            self._openclosProperty = OpenClosProperty(appName=moduleName)
            self._conf = self._openclosProperty.getProperties()

            global webServerRoot
            webServerRoot = self._conf['outputDir']
        else:
            self._conf = conf

        self.__daoClass = daoClass
        self.__dao = daoClass.getInstance()
        self.openclosDbSessionPlugin = OpenclosDbSessionPlugin(daoClass)

        if 'httpServer' in self._conf and 'ipAddr' in self._conf[
                'httpServer'] and self._conf['httpServer'][
                    'ipAddr'] is not None:
            self.host = self._conf['httpServer']['ipAddr']
        else:
            self.host = 'localhost'

        if 'httpServer' in self._conf and 'port' in self._conf['httpServer']:
            self.port = self._conf['httpServer']['port']
        else:
            self.port = 8080
        self.baseUrl = 'http://%s:%d' % (self.host, self.port)

        self.report = ResourceAllocationReport(self._conf, daoClass)
        # Create a single instance of l2Report as it holds thread-pool
        # for device connection. Don't create l2Report multiple times
        self.l2Report = L2Report(self._conf, daoClass)
        # Create a single instance of l3Report as it holds thread-pool
        # for device connection. Don't create l3Report multiple times
        self.l3Report = L3Report(self._conf, daoClass)
        self.deviceSku = DeviceSku()
Exemplo n.º 2
0
    def __init__(self, conf={}, daoClass=Dao):
        if any(conf) == False:
            self._conf = OpenClosProperty(appName=moduleName).getProperties()
        else:
            self._conf = conf

        self._dao = daoClass.getInstance()
Exemplo n.º 3
0
    def __init__(self, deviceId, conf={}, daoClass=Dao):
        if any(conf) == False:
            self._conf = OpenClosProperty(appName=moduleName).getProperties()
        else:
            self._conf = conf

        self.daoClass = daoClass
        self.pod = None
        self.deviceId = deviceId
        self.deviceConnectionHandle = None
        self.deviceSku = DeviceSku()
Exemplo n.º 4
0
    def __init__(self, conf={}, templateEnv=None, daoClass=Dao):
        if any(conf) == False:
            self.__conf = OpenClosProperty(appName=moduleName).getProperties()
        else:
            self.__conf = conf

        self._dao = daoClass.getInstance()

        if templateEnv is None:
            self.templateEnv = Environment(
                loader=PackageLoader('jnpr.openclos', ztpTemplateLocation))
            self.templateEnv.lstrip_blocks = True
            self.templateEnv.trim_blocks = True
Exemplo n.º 5
0
    def __init__(self, conf={}):
        if conf is None or any(conf) == False:
            self.__conf = OpenClosProperty(appName=moduleName).getProperties()
        else:
            self.__conf = conf

        # default value
        self.target = DEFAULT_HOST
        self.port = DEFAULT_PORT

        # validate required parameter
        if 'snmpTrap' in self.__conf and 'openclos_trap_group' in self.__conf[
                'snmpTrap'] and 'target' in self.__conf['snmpTrap'][
                    'openclos_trap_group']:
            self.target = self.__conf['snmpTrap']['openclos_trap_group'][
                'target']
        else:
            logger.info(
                "snmpTrap:openclos_trap_group:target is missing from configuration. using %s"
                % (self.target))

        if 'snmpTrap' in self.__conf and 'openclos_trap_group' in self.__conf[
                'snmpTrap'] and 'port' in self.__conf['snmpTrap'][
                    'openclos_trap_group']:
            self.port = int(
                self.__conf['snmpTrap']['openclos_trap_group']['port'])
        else:
            logger.info(
                "snmpTrap:openclos_trap_group:port is missing from configuration. using %d"
                % (self.port))

        if 'snmpTrap' in self.__conf and 'threadCount' in self.__conf[
                'snmpTrap']:
            self.executor = concurrent.futures.ThreadPoolExecutor(
                max_workers=self.__conf['snmpTrap']['threadCount'])
        else:
            self.executor = concurrent.futures.ThreadPoolExecutor(
                max_workers=DEFAULT_MAX_THREADS)

        # event to stop from sleep
        self.stopEvent = Event()

        self.twoStageConfigurationCallback = util.getTwoStageConfigurationCallback(
            self.__conf)
Exemplo n.º 6
0
 def _getDbUrl(self):
     from propLoader import OpenClosProperty
     return OpenClosProperty().getDbUrl()