Exemplo n.º 1
0
    def execute(self):
        if self.args["--describe"]:
            envs = login_lib.get_env_values()
            env_data = [[
                envs['username'], envs['auth_url'], envs['project_id'],
                envs['user_domain_name']
            ]]
            if len(env_data) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()
            print(
                tabulate(env_data,
                         headers=[
                             "Username", "Auth URL", "Project ID",
                             "Domain Name"
                         ],
                         tablefmt="grid"))
            exit()

        if (self.args["--domain"] and self.args["--keystone-url"]):
            try:
                username = self.args['--username']
                auth_url = self.args['--keystone-url']
                user_domain_name = self.args['--domain']
                login_lib.do_login(auth_url=auth_url,
                                   user_domain_name=user_domain_name,
                                   username=username)
            except Exception as e:
                utils.log_err(e)

        if (not self.args["--domain"] and not self.args["--keystone-url"]):
            login_lib.do_login()
Exemplo n.º 2
0
    def execute(self):
        if self.args["--describe"]:
            envs = login_lib.get_env_values()
            try:
                env_data = []
                for env in envs:
                    data = [
                        env["username"],
                        env["region"],
                        env["name"],
                        env["auth_url"],
                        env["project_id"],
                        env["user_domain_name"],
                        env["status"],
                    ]
                    env_data.append(data)
            except:
                exit()

            if len(env_data) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()

            print(
                tabulate(
                    env_data,
                    headers=[
                        "Username",
                        "Region",
                        "Name",
                        "Auth URL",
                        "Project ID",
                        "Domain Name",
                        "Status",
                    ],
                    tablefmt="grid",
                ))
            exit()

        if not self.args["--region"] and not self.args["--username"]:
            login_lib.do_login()
        else:
            login_lib.do_login(username=self.args["--username"],
                               region=self.args["--region"])
Exemplo n.º 3
0
 def test_do_login(self, monkeypatch):
     login.load_env_file()
     username = os.environ.get('OS_USERNAME')
     passwd = os.environ.get('OS_PASSWORD')
     # give value to input() prompt
     monkeypatch.setattr('builtins.input', lambda x: username)
     monkeypatch.setattr('getpass.getpass', lambda x: passwd)
     # return True is login succeed
     output = login.do_login()
     assert output == True
Exemplo n.º 4
0
 def test_do_login(self, monkeypatch):
     login.load_env_file()
     username = os.environ.get('OS_USERNAME')
     passwd = os.environ.get('OS_PASSWORD')
     # give value to input() prompt
     monkeypatch.setattr('builtins.input', lambda x: username)
     monkeypatch.setattr('getpass.getpass', lambda x: passwd)
     # return True is login succeed
     output = login.do_login()
     assert output == True
Exemplo n.º 5
0
 def execute(self):
     login_lib.do_login()
Exemplo n.º 6
0
 def test_do_login(self):
     output = login.do_login()
     self.assertTrue(output)
Exemplo n.º 7
0
    def execute(self):

        return login_lib.do_login()