Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #9
0
    def test_import_ssl_successful(self, mock):
        fingerprint = import_ssl('tests/resources/keyring', 'certdata')
        os.remove('tests/resources/keyring')

        self.assertEquals(fingerprint, '00XX00')
Exemple #10
0
    def test_import_ssl_successful(self, mock):
        fingerprint = import_ssl('tests/resources/keyring', 'certdata')
        os.remove('tests/resources/keyring')

        self.assertEquals(fingerprint, '00XX00')