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()
def test_get_env_values(self, monkeypatch): monkeypatch.setattr(neo.libs.login, "load_env_file", self.fake_load_env_file) monkeypatch.setattr(neo.libs.login, "check_env", self.fake_check_env) monkeypatch.setenv("OS_USERNAME", "jhon") monkeypatch.setenv("OS_PROJECT_ID", "g7ia30trlk") assert login.get_env_values() == { "username": "******", "password": None, "auth_url": None, "project_id": "g7ia30trlk", "user_domain_name": None, }
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"])
def test_get_env_values(self, monkeypatch): monkeypatch.setattr(neo.libs.login, "load_env_file", self.dummy_config_toml) monkeypatch.setattr(neo.libs.login, "check_env", self.fake_check_env) assert login.get_env_values()