예제 #1
0
파일: jms_wmq.py 프로젝트: xbx/zato
    def handle(self):
        input = self.request.input
        with closing(self.odb.session()) as session:
            # Let's see if we already have an object of that name before committing
            # any stuff into the database.
            existing_one = session.query(ConnDefWMQ).\
                filter(ConnDefWMQ.cluster_id==Cluster.id).\
                filter(ConnDefWMQ.name==input.name).\
                first()
            
            if existing_one:
                raise Exception('JMS WebSphere MQ definition [{0}] already exists on this cluster'.format(input.name))
            
            try:
                def_ = ConnDefWMQ(None, input.name, input.host, input.port, input.queue_manager, 
                    input.channel, input.cache_open_send_queues, input.cache_open_receive_queues,
                    input.use_shared_connections, input.ssl, input.ssl_cipher_spec, 
                    input.ssl_key_repository, input.needs_mcd, input.max_chars_printed,
                    input.cluster_id)
                session.add(def_)
                session.commit()

                self.response.payload.id = def_.id
                self.response.payload.name = def_.name

            except Exception, e:
                msg = "Could not create a JMS WebSphere MQ definition, e:[{e}]".format(e=format_exc(e))
                self.logger.error(msg)
                session.rollback()

                raise 
예제 #2
0
파일: jms_wmq.py 프로젝트: emre/zato
    def handle(self):
        input = self.request.input

        with closing(self.odb.session()) as session:

            # Let's see if we already have an object of that name before committing
            # any stuff into the database.
            existing_one = session.query(ConnDefWMQ).\
                filter(ConnDefWMQ.cluster_id==Cluster.id).\
                filter(ConnDefWMQ.name==input.name).\
                first()

            if existing_one:
                raise Exception(
                    'IBM MQ definition `{}` already exists on this cluster'.
                    format(input.name))

            try:
                input.password = uuid4().hex
                input.use_jms = input.use_jms or False

                def_ = ConnDefWMQ(None, input.name, input.host, input.port,
                                  input.queue_manager, input.channel,
                                  input.cache_open_send_queues,
                                  input.cache_open_receive_queues,
                                  input.use_shared_connections, input.ssl,
                                  input.ssl_cipher_spec,
                                  input.ssl_key_repository, input.needs_mcd,
                                  input.max_chars_printed, input.cluster_id,
                                  input.username, input.password, input.use_jms
                                  or False)
                session.add(def_)
                session.commit()

                input.id = def_.id
                input.action = DEFINITION.WMQ_CREATE.value
                self.broker_client.publish(input)

                self.response.payload.id = def_.id
                self.response.payload.name = def_.name

            except Exception:
                self.logger.error(
                    'Could not create an IBM MQ MQ definition, e:`%s`',
                    format_exc())
                session.rollback()

                raise