async def login(self): if self.authenticated: return cred = CredentialManager.get_credential(self.cloud, self.cloud_type, self.credential) self.client = VSphereClient(cred, self.endpoint) try: await app.loop.run_in_executor(None, self.client.login) self.authenticated = True except VSphereInvalidLogin: raise
async def configure_tools(self): """ Configure AWS CLI. """ cred = CredentialManager.get_credential(self.cloud, self.cloud_type, self.credential) try: ret, _, _ = await arun( ['aws', 'configure', 'list', '--profile', self.credential], check=False) if ret != 0: await arun(['aws', 'configure', '--profile', self.credential], input='{}\n{}\n\n\n'.format(cred.access_key, cred.secret_key), check=True) except CalledProcessError as e: app.log.error('Failed to configure AWS CLI profile: {}'.format( e.stderr)) raise