Esempio n. 1
0
    def post(self, member):
        """Create a new member."""
        LOG.info("Create member [member_name=%s]" % member.name)

        if not (member.name and member.protocol_port
                and member.address and member.listener_name):
            raise exceptions.InputException(
                'You must provide at least name, protocol_port, '
                'listener_name and address of the member.'
            )

        pecan.response.status = 201

        values = member.to_dict()
        listener_name = values.pop('listener_name')
        lb_driver = driver.LB_DRIVER()

        with db_api.transaction():
            listener = db_api.get_listener(listener_name)

            values['listener_id'] = listener.id

            member = db_api.create_member(values)
            db_model = lb_driver.create_member(member)

            lb_driver.apply_changes()

        return Member.from_dict(db_model.to_dict())
Esempio n. 2
0
    def get(self, name):
        """Return the named listener."""
        LOG.info("Fetch listener [name=%s]" % name)

        db_model = db_api.get_listener(name)

        return Listener.from_dict(db_model.to_dict())
Esempio n. 3
0
    def get(self, name):
        """Return the named listener."""
        LOG.info("Fetch listener [name=%s]" % name)

        db_model = db_api.get_listener(name)

        return Listener.from_dict(db_model.to_dict())
    def post(self, member):
        """Create a new member."""
        LOG.info("Create member [member_name=%s]" % member.name)

        if not (member.name and member.protocol_port and member.address
                and member.listener_name):
            raise exceptions.InputException(
                'You must provide at least name, protocol_port, '
                'listener_name and address of the member.')

        pecan.response.status = 201

        values = member.to_dict()
        listener_name = values.pop('listener_name')
        lb_driver = driver.LB_DRIVER()

        with db_api.transaction():
            listener = db_api.get_listener(listener_name)

            values['listener_id'] = listener.id

            member = db_api.create_member(values)
            db_model = lb_driver.create_member(member)

            lb_driver.apply_changes()

        return Member.from_dict(db_model.to_dict())
Esempio n. 5
0
    def delete(self, name):
        """Delete the named listener."""
        LOG.info("Delete listener [name=%s]" % name)

        lb_driver = driver.LB_DRIVER()

        with db_api.transaction():
            listener = db_api.get_listener(name)
            lb_driver.delete_listener(listener)
            db_api.delete_listener(name)

            lb_driver.apply_changes()
Esempio n. 6
0
    def delete(self, name):
        """Delete the named listener."""
        LOG.info("Delete listener [name=%s]" % name)

        lb_driver = driver.LB_DRIVER()

        with db_api.transaction():
            listener = db_api.get_listener(name)
            lb_driver.delete_listener(listener)
            db_api.delete_listener(name)

            lb_driver.apply_changes()