def connect_ravello(trial_name): """Return a new Ravello connection.""" client = RavelloClient() client.connect() kwargs = cfgdict(app.config, '{0}_ravello'.format(trial_name), 'ravello') client.login(**kwargs) return client
class IntegrationTest(UnitTest): """Base class for integration tests. Integration tests run with a connected client to the API, which is available under the "client" property. """ pubkey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDi3GUFtZA4WxysevYPPrp3G4' \ 'W3sehLJOyEp4vf5G/rLfoKwz1JXd3gqq8snoSwYefQSAW0PKPff6lxyaraFqq4' \ '+vzNg4rAHJSdBhAHLWlcNWSh8UZOGD11vgGdOLrDBPZ8/jKJIZgcFiXjzulMzU' \ 'RKLGx0ZFbUZDfHYIqEpCscnlfG6kenrtWAdCrTkl4CP56xcOY91qx4s9Ll0Yvz' \ 'hyF2GiqgCe0eJqNflJkqX+d9e0A3BdIzM//UfYplzmUGimWgGN4vFFa4sspUzq' \ 'gwHV7yZYI7W+Ey5oOOiSpTt1PpkPHIBaUEmg37/7Pq6PuQxfs18QLPK1DuJz6g' \ 'UsCjFRFl testkey' def setUp(self): url = self.config.get('integration', 'url') or None username = self.config.get('integration', 'username') password = self.config.get('integration', 'password') self.client = RavelloClient() self.client.connect(url) self.client.login(username, password) def tearDown(self): self.client.logout() self.client.close()
def create_client(args): """Connect to the Ravello API and return a connection.""" client = RavelloClient() if args["password"] is None: args["password"] = getpass("Enter password for {0}: ".format(args["username"])) client.connect() try: client.login(args["username"], args["password"]) except RavelloError: raise RavelloError("could not login with provided credentials") return client
def create_client(args): """Connect to the Ravello API and return a connection.""" client = RavelloClient() if args['password'] is None: args['password'] = getpass('Enter password for {0}: '.format( args['username'])) client.connect() try: client.login(args['username'], args['password']) except RavelloError: raise RavelloError('could not login with provided credentials') return client
def _validate_config(): """Validate the configuration options.""" if not CONF.ravello.username: raise exception.InvalidParameterValue(_( "RavelloDriver requires 'username' config option.")) if not CONF.ravello.password: raise exception.InvalidParameterValue(_( "RavelloDriver requires 'password' config option.")) conn = RavelloClient() try: conn.connect(CONF.ravello.endpoint) except socket.error as e: raise exception.InvalidParameterValue(_( "RavelloDriver could not connect to: %s." % CONF.ravello.endpoint)) try: conn.login(CONF.ravello.username, CONF.ravello.password) except RavelloError as e: raise exception.InvalidParameterValue(_( "RavelloDriver could not login with supplied credentials.")) finally: conn.close()
def _get_ravello_client(): """Return a Ravello API client.""" client = RavelloClient() client.connect(CONF.ravello.endpoint) client.login(CONF.ravello.username, CONF.ravello.password) return client