當前位置: 首頁>>代碼示例>>Python>>正文


Python DataLayer.DataLayer類代碼示例

本文整理匯總了Python中enarksh.DataLayer.DataLayer的典型用法代碼示例。如果您正苦於以下問題:Python DataLayer類的具體用法?Python DataLayer怎麽用?Python DataLayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DataLayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle

    def handle(_event, message, controller):
        """
        Handles a PossibleNodeActionsWebMessage received event.

        :param * _event: Not used.
        :param enarksh.controller.message.PossibleNodeActionsWebMessage.PossibleNodeActionsWebMessage message:
               The message.
        :param enarksh.controller.Controller.Controller controller: The controller.
        """
        del _event

        log = logging.getLogger('enarksh')

        try:
            schedule = controller.get_schedule_by_sch_id(message.sch_id)
            if schedule:
                response = schedule.request_possible_node_actions(message.rnd_id)
            else:
                response = Schedule.get_response_template()

            DataLayer.commit()
        except Exception:
            log.exception('Error')

            response = dict()
            response['ret'] = -1
            response['message'] = 'Internal error'

            DataLayer.rollback()

        # Send the message to the web interface.
        controller.message_controller.send_message('lockstep', response, True)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:32,代碼來源:PossibleNodeActionsWebMessageEventHandler.py

示例2: handle

    def handle(_event, message, controller):
        """
        Handles a NodeActionWebMessage received event.

        :param * _event: Not used.
        :param enarksh.controller.message.NodeActionWebMessage.NodeActionWebMessage message: The message.
        :param enarksh.controller.Controller.Controller controller: The controller.
        """
        del _event

        log = logging.getLogger('enarksh')

        # Compose a response message for the web interface.
        response = {'ret':     0,
                    'new_run': 0,
                    'message': 'OK'}

        try:
            NodeActionMessageBaseEventHandler.base_handle(controller,
                                                          response,
                                                          message.sch_id,
                                                          message.rnd_id,
                                                          message.act_id)

            DataLayer.commit()
        except Exception:
            log.exception('Error')

            response['ret'] = -1
            response['message'] = 'Internal error'

            DataLayer.rollback()

        # Send the message to the web interface.
        controller.message_controller.send_message('lockstep', response, True)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:35,代碼來源:NodeActionMessageWebEventHandler.py

示例3: sync_state

    def sync_state(self):
        if self._read_write_lock_count:
            rws_id = enarksh.ENK_RWS_ID_WRITE
        elif self._read_lock_count:
            rws_id = enarksh.ENK_RWS_ID_READ
        else:
            rws_id = enarksh.ENK_RWS_ID_NONE

        DataLayer.enk_back_read_write_lock_resource_update_consumpted(self._rsc_id, rws_id)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:9,代碼來源:ReadWriteLockResource.py

示例4: sync_state

 def sync_state(self):
     """
     Updates the state of this node into the database.
     """
     DataLayer.enk_back_run_node_update_status(self.rnd_id,
                                               self.rst_id,
                                               self._rnd_datetime_start,
                                               self._rnd_datetime_stop,
                                               self._exit_status)
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:9,代碼來源:Node.py

示例5: store

    def store(self, nod_id):
        """
        Stores the definition of this port into the database.

        :param int nod_id: The ID of the node to which this node belongs
        """
        uri_id = DataLayer.enk_misc_insert_uri(self.get_uri())
        self._prt_id = DataLayer.enk_reader_port_store_input_port(nod_id,
                                                                  uri_id,
                                                                  self._port_name)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:10,代碼來源:InputPort.py

示例6: store

    def store(self, port, node):
        """
        Stores this dependency into the database.

        :param enarksh.xml_reader.port.Port.Port port: The port of the dependency.
        :param enarksh.xml_reader.node.Node.Node node: The node of the dependency.
        """
        prt_id_dependant = port.prt_id
        prt_id_predecessor = node.get_port_by_name(self._node_name, self._port_name).prt_id

        DataLayer.enk_reader_dependency_store_dependency(prt_id_dependant, prt_id_predecessor)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:11,代碼來源:Dependency.py

示例7: store

    def store(self, hst_id, nod_id):
        """
        :param int hst_id:
        :param int nod_id:
        """
        uri_id = DataLayer.enk_misc_insert_uri(self.get_uri())

        self._rsc_id = DataLayer.enk_reader_resource_store_read_write_lock_resource(hst_id,
                                                                                    nod_id,
                                                                                    uri_id,
                                                                                    self._resource_name)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:11,代碼來源:ReadWriteLockResource.py

示例8: _drop_views

 def _drop_views():
     """
     Drops all views form the databases.
     """
     rows = DataLayer.execute_rows('SELECT TABLE_NAME table_name '
                                   'FROM   information_schema.TABLES '
                                   'WHERE  TABLE_SCHEMA = database() '
                                   'AND    TABLE_TYPE   = "VIEW" '
                                   'ORDER BY table_name')
     for row in rows:
         print('Dropping view %s' % row['table_name'])
         DataLayer.execute_none('drop view %s' % row['table_name'])
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:12,代碼來源:Bootsrap.py

示例9: _drop_routines

 def _drop_routines():
     """
     Drops all stored routines form the databases.
     """
     rows = DataLayer.execute_rows('select ROUTINE_TYPE routine_type '
                                   ',      ROUTINE_NAME routine_name '
                                   'from   information_schema.ROUTINES '
                                   'where  ROUTINE_SCHEMA = database() '
                                   'and    ROUTINE_TYPE   = "PROCEDURE" '
                                   'order by ROUTINE_NAME')
     for row in rows:
         print('Dropping %s %s' % (row['routine_type'], row['routine_name']))
         DataLayer.execute_none('drop %s %s' % (row['routine_type'], row['routine_name']))
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:13,代碼來源:Bootsrap.py

示例10: __startup

    def __startup(self):
        """
        Performs the necessary actions for starting the controller daemon.
        """
        self.__log.info('Starting controller')

        credentials = Credentials.get()

        # Set database configuration options.
        DataLayer.config['host'] = credentials.get_host()
        DataLayer.config['user'] = credentials.get_user()
        DataLayer.config['password'] = credentials.get_password()
        DataLayer.config['database'] = credentials.get_database()
        DataLayer.config['port'] = credentials.get_port()
        DataLayer.config['autocommit'] = False

        # Connect to the MySQL.
        DataLayer.connect()
        DataLayer.start_transaction()

        # Sanitise the data in the database.
        DataLayer.enk_back_controller_init()

        # Create resources defined at host level.
        self.__create_host_resources()

        # Set the effective user and group to an unprivileged user and group.
        self.__set_unprivileged_user()

        # Commit transaction and close connection to MySQL.
        DataLayer.commit()
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:31,代碼來源:Controller.py

示例11: store

    def store(self, nod_id):
        """
        Stores the definition of this consumption into the database.

        :param int nod_id: The ID of the node to which this consumption belongs.
        """
        resource = self._node.get_resource_by_name(self._resource_name)
        rsc_id = resource.rsc_id
        uri_id = DataLayer.enk_misc_insert_uri(self.get_uri())

        self._cns_id = DataLayer.enk_reader_consumption_store_counting_consumption(nod_id,
                                                                                   rsc_id,
                                                                                   uri_id,
                                                                                   self._amount)
開發者ID:OlegKlimenko,項目名稱:py-enarksh,代碼行數:14,代碼來源:CountingConsumption.py

示例12: load_db

    def load_db(self, hostname):
        """
        Loads the definition of this host from the database.

        :param str hostname: The name of the host that must be loaded.
        """
        self._hostname = hostname

        host = DataLayer.enk_reader_host_load_host(hostname)
        self._hst_id = host['hst_id']

        resources_data = DataLayer.enk_back_get_host_resources()
        for resource_data in resources_data:
            resource = create_resource(resource_data['rtp_id'], resource_data['rsc_id'], None)
            self._resources[resource.name] = resource
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:15,代碼來源:Host.py

示例13: __create_host_resources

 def __create_host_resources(self):
     """
     Creates resources defined at host level.
     """
     resources_data = DataLayer.enk_back_get_host_resources()
     for resource_data in resources_data:
         self.host_resources[resource_data['rsc_id']] = resource.create_resource(resource_data)
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:7,代碼來源:Controller.py

示例14: _store_self

    def _store_self(self, uri_id):
        """
        Stores the definition of this host into the database.

        :param int uri_id: The ID of the URI of this node.
        """
        details = DataLayer.enk_reader_host_load_host(self._hostname)
        self._hst_id = details['hst_id']
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:8,代碼來源:Host.py

示例15: _renew

 def _renew(self):
     """
     If required renews this node, i.e. creates a new row in ENK_RUN_NODE.
     """
     if self._rst_id in (C.ENK_RST_ID_ERROR, C.ENK_RST_ID_COMPLETED):
         self._rnd_id = DataLayer.enk_back_run_node_renew(self.rnd_id)
         self._rst_id = C.ENK_RST_ID_WAITING
         self._rnd_datetime_start = None
         self._rnd_datetime_stop = None
         self._exit_status = None
開發者ID:SetBased,項目名稱:py-enarksh,代碼行數:10,代碼來源:Node.py


注:本文中的enarksh.DataLayer.DataLayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。