Пример #1
0
    def create_builder(self, name, pgp, ssl=None, ip=None):
        """
        :param str name: name of the builder
        :param str pgp: path to the pgp public keyfile
        :param str ssl: path to the ssl certificate
        :param str ip: ip address of the builder
        """

        if NAMESPACE.session.query(Builder).filter_by(name=name).first():
            raise ValueError("Slave already exists.")

        pgp = import_pgp(self.pgp_keyring, pgp)
        if ssl is not None:
            ssl = import_ssl(self.ssl_keyring, ssl, name)
            b = Builder(name=name, maintainer=NAMESPACE.user, pgp=pgp, ssl=ssl,
                        last_ping=datetime.utcnow())

        elif ip is not None:
            b = Builder(name=name, maintainer=NAMESPACE.user, pgp=pgp, ip=ip,
                        last_ping=datetime.utcnow())

        else:
            raise ValueError("Need either ssl certificate or ip address")

        NAMESPACE.session.add(b)

        emit('create', 'slave', b.debilize())
        return b.debilize()
Пример #2
0
    def update_user_keys(self, email, pgp, ssl):
        user = NAMESPACE.session.query(Person).filter_by(email=email).first()

        if not user:
            raise ValueError("No user with email %s." % email)

        user.pgp = import_pgp(self.pgp_keyring, pgp)
        user.ssl = import_ssl(self.ssl_keyring, ssl, user.name, user.email)

        clean_ssl_keyring(self.ssl_keyring, NAMESPACE.session)

        return user.debilize()
Пример #3
0
    def create_user(self, name, email, pgp, ssl):
        if NAMESPACE.session.query(Person).filter_by(email=email).first():
            raise ValueError("User already exists.")

        pgp = import_pgp(self.pgp_keyring, pgp)
        ssl = import_ssl(self.ssl_keyring, ssl, name, email)

        p = Person(name=name, email=email, pgp=pgp, ssl=ssl)
        NAMESPACE.session.add(p)

        emit('create', 'user', p.debilize())
        return p.debilize()
Пример #4
0
    def update_builder_keys(self, name, pgp, ssl):
        builder = NAMESPACE.session.query(Builder).filter_by(name=name).first()

        if not builder:
            raise ValueError("No builder with name %s." % name)

        builder.pgp = import_pgp(self.pgp_keyring, pgp)
        builder.ssl = import_ssl(self.ssl_keyring, ssl, builder.name)

        clean_ssl_keyring(self.ssl_keyring, NAMESPACE.session)

        return builder.debilize()
Пример #5
0
    def create_builder(self, name, pgp, ssl):
        if NAMESPACE.session.query(Builder).filter_by(name=name).first():
            raise ValueError("Slave already exists.")

        pgp = import_pgp(self.pgp_keyring, pgp)
        ssl = import_ssl(self.ssl_keyring, ssl, name)

        b = Builder(name=name, maintainer=NAMESPACE.user, pgp=pgp, ssl=ssl,
                    last_ping=datetime.utcnow())
        NAMESPACE.session.add(b)

        emit('create', 'slave', b.debilize())
        return b.debilize()
Пример #6
0
    def create_user(self, name, email, pgp, ssl=None, ip=None):
        if NAMESPACE.session.query(Person).filter_by(email=email).first():
            raise ValueError("User already exists.")

        pgp = import_pgp(self.pgp_keyring, pgp)

        if ssl is not None:
            ssl = import_ssl(self.ssl_keyring, ssl, name, email)

        p = Person(name=name, email=email, pgp=pgp, ssl=ssl, ip=ip)
        NAMESPACE.session.add(p)

        emit('create', 'user', p.debilize())
        return p.debilize()
Пример #7
0
    def update_user_keys(self, email, pgp, ssl):
        if self.ssl_keyring is None:
            # TODO
            raise Exception
        user = NAMESPACE.session.query(Person).filter_by(email=email).first()

        if not user:
            raise ValueError("No user with email %s." % email)

        user.pgp = import_pgp(self.pgp_keyring, pgp)
        user.ssl = import_ssl(self.ssl_keyring, ssl, user.name, user.email)

        clean_ssl_keyring(self.ssl_keyring, NAMESPACE.session)

        return user.debilize()
Пример #8
0
    def update_builder_keys(self, name, pgp, ssl):
        if self.ssl_keyring is None:
            # TODO
            raise Exception
        builder = NAMESPACE.session.query(Builder).filter_by(name=name).first()

        if not builder:
            raise ValueError("No builder with name %s." % name)

        builder.pgp = import_pgp(self.pgp_keyring, pgp)
        builder.ssl = import_ssl(self.ssl_keyring, ssl, builder.name)

        clean_ssl_keyring(self.ssl_keyring, NAMESPACE.session)

        return builder.debilize()
Пример #9
0
    def test_import_pgp_successful(self, mock):
        fingerprint = import_pgp('keyring', 'data')

        self.assertEquals(fingerprint, '000XXX000')
Пример #10
0
    def test_import_pgp_successful(self, mock):
        fingerprint = import_pgp('keyring', 'data')

        self.assertEquals(fingerprint, '000XXX000')