Ejemplo n.º 1
0
    def migrate(self, tenant_id=None):
        cmd = [self.path, 'migrate']

        if tenant_id is not None:
            cmd.extend(['--tenant', tenant_id])

        docker.execute(self.cid, cmd)
Ejemplo n.º 2
0
    def migrate(self, tenant_id=None):
        cmd = ['usr/bin/deviceauth', 'migrate']

        if tenant_id is not None:
            cmd.extend(['--tenant', tenant_id])

        docker.execute(self.cid, cmd)
Ejemplo n.º 3
0
    def create_org(self, name, username, password):
        cmd = [
            '/usr/bin/tenantadm', 'create-org', '--name', name, '--username',
            username, '--password', password
        ]

        tid = docker.execute(self.cid, cmd)
        return tid
Ejemplo n.º 4
0
    def __init__(self, docker_prefix=None):
        filt = ['mender-useradm']
        if docker_prefix is not None:
            filt.append(docker_prefix)

        self.cid = docker.getid(filt)

        # is it an open useradm, or useradm-enterprise?
        for path in ['/usr/bin/useradm', '/usr/bin/useradm-enterprise']:
            try:
                docker.execute(self.cid, [path, '--version'])
                self.path = path
            except:
                continue

        if self.path is None:
            raise RuntimeError('no runnable binary found in mender-useradm')
Ejemplo n.º 5
0
    def add_default_tenant_token(self, tenant_token):
        """
        Stops the container, adds the default_tenant_token to the config file
        at '/etc/deviceauth/config.yaml, and starts the container back up.

        :param tenant_token - 'the default tenant token to set'
        """

        # Append the default_tenant_token in the config ('/etc/deviceauth/config.yaml')
        cmd = [
            '/bin/sed', '-i',
            '$adefault_tenant_token: {}'.format(tenant_token),
            '/etc/deviceauth/config.yaml'
        ]
        docker.execute(self.cid, cmd)

        # Restart the container, so that it is picked up by the device-auth service on startup
        docker.cmd(self.cid, 'stop')
        docker.cmd(self.cid, 'start')
Ejemplo n.º 6
0
    def create_user(self, username, password, tenant_id=''):
        cmd = [
            self.path, 'create-user', '--username', username, '--password',
            password
        ]

        if tenant_id != '':
            cmd += ['--tenant-id', tenant_id]

        uid = docker.execute(self.cid, cmd)
        return uid
Ejemplo n.º 7
0
    def migrate(self):
        cmd = ['usr/bin/tenantadm', 'migrate']

        docker.execute(self.cid, cmd)
Ejemplo n.º 8
0
    def get_tenant(self, tid):
        cmd = ['/usr/bin/tenantadm', 'get-tenant', '--id', tid]

        tenant = docker.execute(self.cid, cmd)
        return tenant
Ejemplo n.º 9
0
    def create_tenant(self, name):
        cmd = ['/usr/bin/tenantadm', 'create-tenant', '--name', name]

        tid = docker.execute(self.cid, cmd)
        return tid