def invoke(self, data, context): """Invoke this action class. """ self.logger.info('Invoked MySqlSelect Activity: {}'.format(data)) check_input_params(data, self.SELECTQUERY) sql = data[self.SELECTQUERY] target = MySqlTarget(data) user = MySqlUser(data) adapter = MySqlAdapter(data) result = {} try: connection = adapter.connect_to_mysql(user) with connection.cursor() as cursor: cursor.execute(sql) result[self.RETURNQUERY] = cursor.fetchall() result[self.ROWCOUNT] = len(result[self.RETURNQUERY]) self.logger.info( "Returning {} to Result Engine".format(result)) return result except MySqlError as e: self.logger.error("Action failed. Cause=%s, Response=%s", e.__cause__) self.raise_action_error("102", e.__cause__) finally: connection.close()
def invoke(self, data, context): """Invoke this action class. """ self.logger.info('Invoked ActionQuery2') check_input_params(data, self.TEMPLATE_NAME) template_name = data[self.TEMPLATE_NAME] target = TemplateTarget(data) user = TemplateUser(data) params = TemplateLaunchParams(data) template_adapter = TemplateAdapter(target, self.logger) try: token = template_adapter.get_auth_token(user, self.proxies) info = template_adapter.create_template(token, template_name, params, self.proxies) return info except TemplateError as e: self.logger.error("Action failed. Status=%s, Response=%s", e.status_code, e.response) self.raise_action_error(e.status_code, e.message)
def invoke(self, data, context): """Invoke this action class. """ self.logger.info('Invoked ActionQuery1') check_input_params(data, self.input_name) output1 = data[self.input_name] check_input_params(data, self.hello_world) output2 = data[self.hello_world] result = {} try: result[self.output1] = output1 result[self.output2] = output2 + output1 return result except TemplateError as e: self.logger.error("Action failed. Status=%s, Response=%s", e.status_code, e.response) self.raise_action_error(e.status_code, e.message)
def fill_password(self, data): """Set the user password from the given data. """ check_input_params(data, self.PASSWORD) self.password = data[self.PASSWORD]
def fill_username(self, data): """Set the user name from the given data. """ check_input_params(data, self.USERNAME) self.username = data[self.USERNAME]
def fill_host(self, data): """Set the target host. """ check_input_params(data, self.HOST) self.host = data[self.HOST]
def fill_charset(self, data): check_input_params(data, self.DB) self.charset = get_optional_value(data, self.CHARSET, "utf8mb4")
def fill_db(self, data): check_input_params(data, self.DB) self.db = data[self.DB]