def create_authinfo(computer, store=False): """Allow the current user to use the given computer.""" from aiida.orm import AuthInfo authinfo = AuthInfo(computer=computer, user=get_current_user()) if store: authinfo.store() return authinfo
def _configure_computer(self): """create AuthInfo""" print("Configuring '{}'".format(self.name)) sshcfg = parse_sshconfig(self.hostname) authparams = { 'compress': True, 'gss_auth': False, 'gss_deleg_creds': False, 'gss_host': self.hostname, 'gss_kex': False, 'key_policy': 'WarningPolicy', 'load_system_host_keys': True, 'port': 22, 'timeout': 60, } if 'user' in sshcfg: authparams['username'] = sshcfg['user'] else: print( "SSH username is not provided, please run `verdi computer configure {}` " "from the command line".format(self.name)) return if 'proxycommand' in sshcfg: authparams['proxy_command'] = sshcfg['proxycommand'] aiidauser = User.objects.get_default() from aiida.orm import AuthInfo authinfo = AuthInfo(computer=Computer.objects.get(name=self.name), user=aiidauser) authinfo.set_auth_params(authparams) authinfo.store() print( check_output(['verdi', 'computer', 'show', self.name]).decode('utf-8'))
def get_authinfo(computer): """Get existing authinfo or create one if not in place""" try: authinfo = computer.get_authinfo(get_current_user()) except NotExistent: authinfo = AuthInfo(computer=computer, user=get_current_user()) authinfo.store() return authinfo
def _configure_computer(self): """Create AuthInfo.""" print("Configuring '{}'".format(self.label)) sshcfg = parse_sshconfig(self.hostname) authparams = { 'compress': True, 'key_filename': os.path.expanduser( sshcfg.get('identityfile', ['~/.ssh/id_rsa'])[0]), 'gss_auth': False, 'gss_deleg_creds': False, 'gss_host': self.hostname, 'gss_kex': False, 'key_policy': 'WarningPolicy', 'load_system_host_keys': True, 'port': sshcfg.get('port', 22), 'timeout': 60, 'use_login_shell': self._use_login_shell.value, } if 'user' in sshcfg: authparams['username'] = sshcfg['user'] else: print( f"SSH username is not provided, please run `verdi computer configure {self.label}` " "from the command line.") return if 'proxycommand' in sshcfg: authparams['proxy_command'] = sshcfg['proxycommand'] aiidauser = User.objects.get_default() from aiida.orm import AuthInfo authinfo = AuthInfo(computer=Computer.objects.get(name=self.label), user=aiidauser) authinfo.set_auth_params(authparams) authinfo.store() print( check_output(['verdi', 'computer', 'show', self.label]).decode('utf-8'))
def _configure_computer(self): """Create AuthInfo.""" print(f"Configuring '{self.label}'") sshcfg = parse_sshconfig(self.hostname) authparams = { "compress": True, "key_filename": os.path.expanduser( sshcfg.get("identityfile", ["~/.ssh/id_rsa"])[0] ), "gss_auth": False, "gss_deleg_creds": False, "gss_host": self.hostname, "gss_kex": False, "key_policy": "WarningPolicy", "load_system_host_keys": True, "port": sshcfg.get("port", 22), "timeout": 60, "use_login_shell": self._use_login_shell.value, "safe_interval": self.safe_interval, } if "user" in sshcfg: authparams["username"] = sshcfg["user"] else: print( f"SSH username is not provided, please run `verdi computer configure {self.label}` " "from the command line." ) return if "proxycommand" in sshcfg: authparams["proxy_command"] = sshcfg["proxycommand"] aiidauser = User.objects.get_default() from aiida.orm import AuthInfo authinfo = AuthInfo( computer=Computer.objects.get(label=self.label), user=aiidauser ) authinfo.set_auth_params(authparams) authinfo.store() print(check_output(["verdi", "computer", "show", self.label]).decode("utf-8"))
def setUpClass(cls): super(TestRemoteData, cls).setUpClass() user = User.objects.get_default() authinfo = AuthInfo(cls.computer, user) authinfo.store()
def setUpClass(cls): # pylint: disable=arguments-differ super().setUpClass() user = User.objects.get_default() authinfo = AuthInfo(cls.computer, user) authinfo.store()