本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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'])
示例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']))
示例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()
示例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)
示例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
示例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)
示例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']
示例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