def add_users_to_system(ssh_host, ssh_username, ssh_password, users):
    '''
    Adds test users to system over SSH connection.
    :param ssh_host: str - SSH server hostname
    :param ssh_username: str - SSH username
    :param ssh_password: str - SSH password
    :param users: dict - user data
    :return: None
    '''
    client = get_client(ssh_host, ssh_username, ssh_password)
    try:
        ssh_user_actions.add_user(client=client,
                                  username=users['user1'][USERNAME],
                                  password=users['user1'][PASSWORD],
                                  group=users['user1']['group'])
        ssh_user_actions.add_user(client=client,
                                  username=users['user2'][USERNAME],
                                  password=users['user2'][PASSWORD],
                                  group=users['user2']['group'])
        ssh_user_actions.add_user(client=client,
                                  username=users['user3'][USERNAME],
                                  password=users['user3'][PASSWORD],
                                  group=users['user3']['group'])
        ssh_user_actions.add_user(client, users['databaseuser'][USERNAME],
                                  users['databaseuser'][PASSWORD])
    finally:
        client.close()
Exemplo n.º 2
0
def add_users_to_system(ssh_host, ssh_username, ssh_password, users):
    '''
    Adds test users to system over SSH connection.
    :param ssh_host: str - SSH server hostname
    :param ssh_username: str - SSH username
    :param ssh_password: str - SSH password
    :param users: dict - user data
    :return: None
    '''
    # Create new SSH connection
    client = ssh_server_actions.get_client(ssh_host, ssh_username,
                                           ssh_password)
    try:
        # Add users
        user = users['user1']
        ssh_user_actions.add_user(client=client,
                                  username=user[USERNAME],
                                  password=user[PASSWORD],
                                  group=user['group'])
        user = users['user2']
        ssh_user_actions.add_user(client=client,
                                  username=user[USERNAME],
                                  password=user[PASSWORD],
                                  group=user['group'])
        user = users['user3']
        ssh_user_actions.add_user(client=client,
                                  username=user[USERNAME],
                                  password=user[PASSWORD],
                                  group=user['group'])
    finally:
        # Close SSH connection
        client.close()
Exemplo n.º 3
0
def add_users_to_system(self, ssh_host, ssh_username, ssh_password):
    '''
    Adds test users to system over SSH connection.
    :param self: MainController object
    :param ssh_host: str - SSH server hostname
    :param ssh_username: str - SSH username
    :param ssh_password: str - SSH password
    :return: None
    '''
    client = get_client(ssh_host, ssh_username, ssh_password)
    try:
        ssh_user_actions.add_user(client=client, username=self.users['user1'][USERNAME],
                                  password=self.users['user1'][PASSWORD],
                                  group=self.users['user1']['group'])
        ssh_user_actions.add_user(client=client, username=self.users['user2'][USERNAME],
                                  password=self.users['user2'][PASSWORD],
                                  group=self.users['user2']['group'])
        ssh_user_actions.add_user(client=client, username=self.users['user3'][USERNAME],
                                  password=self.users['user3'][PASSWORD],
                                  group=self.users['user3']['group'])
        ssh_user_actions.add_user(client, self.users['databaseuser'][USERNAME], self.users['databaseuser'][PASSWORD])
    finally:
        client.close()
Exemplo n.º 4
0
def add_users_to_system(self, ssh_client):
    '''
    Adds test users to system over SSH connection.
    :param self: MainController object
    :param ssh_client: SSHClient object
    :return:
    '''
    user = self.users['user1']
    ssh_user_actions.add_user(client=ssh_client,
                              username=user[USERNAME],
                              password=user[PASSWORD],
                              group=user['group'])
    user = self.users['user2']
    ssh_user_actions.add_user(client=ssh_client,
                              username=user[USERNAME],
                              password=user[PASSWORD],
                              group=user['group'])
    user = self.users['user3']
    ssh_user_actions.add_user(client=ssh_client,
                              username=user[USERNAME],
                              password=user[PASSWORD],
                              group=user['group'])