예제 #1
0
def _connect( connection_paramaters ):
  logging.debug( 'azure: connecting with client_id "{0}", tenant_id: "{1}"'.format( connection_paramaters[ 'client_id' ], connection_paramaters[ 'tenant_id' ] ) )
  password = getCredentials( connection_paramaters[ 'password' ] )

  credentials = ServicePrincipalCredentials( client_id=connection_paramaters[ 'client_id' ], secret=password, tenant=connection_paramaters[ 'tenant_id' ] )

  return AzureClient( credentials, connection_paramaters[ 'subscription_id' ] )
예제 #2
0
def _connect(connection_paramaters):
    # work arround invalid SSL
    _create_unverified_https_context = ssl._create_unverified_context
    ssl._create_default_https_context = _create_unverified_https_context
    # TODO: flag for trusting SSL of connection, also there is a paramater to Connect for verified SSL

    creds = connection_paramaters['credentials']
    if isinstance(creds, str):
        creds = getCredentials(creds)

    # TODO: saninity check on creds

    if 'username' in creds:
        logging.debug('vcenter: connecting to "{0}" with user "{1}"'.format(
            connection_paramaters['host'], creds['username']))
        return connect.SmartConnect(host=connection_paramaters['host'],
                                    user=creds['username'],
                                    pwd=creds['password'],
                                    mechanism='userpass')

    else:
        logging.debug('vcenter: connecting to "{0}" with token "{1}"'.format(
            connection_paramaters['host'], creds['token']))
        return connect.SmartConnect(host=connection_paramaters['host'],
                                    b64token=creds['token'],
                                    mechanism='sspi')
예제 #3
0
  def __init__( self, connection_paramaters ):
    super().__init__()
    self.ip_address = connection_paramaters[ 'ip_address' ]
    creds = connection_paramaters[ 'credentials' ]
    if isinstance( creds, str ):
      creds = getCredentials( creds )

    self.username = creds[ 'username' ]
    self.password = creds[ 'password' ]
예제 #4
0
def _connect(connection_paramaters):
    creds = connection_paramaters['credentials']
    if isinstance(creds, str):
        creds = getCredentials(creds)

    logging.debug('virtualbox: connecting to "{0}" with user "{1}"'.format(
        connection_paramaters['host'], creds['username']))

    return VirtualBox(
        'http://{0}:18083/'.format(connection_paramaters['host']),
        creds['username'], creds['password'])
예제 #5
0
def _connect(connection_paramaters):
    creds = connection_paramaters['credentials']
    if isinstance(creds, str):
        creds = getCredentials(creds)

    logging.debug('proxmox: connecting to "{0}" with user "{1}"'.format(
        connection_paramaters['host'], creds['username']))

    return ProxmoxAPI(connection_paramaters['host'],
                      user=creds['username'],
                      password=creds['password'],
                      verify_ssl=False)  # TODO: flag to toggle verify_ssl
예제 #6
0
def _connect():
    logging.debug('aws: connecting to EC2')
    token = None
    token = getCredentials(token)
    return boto3.resource(
        service_name='ec2',
        # region_name='us-west-2',
        # aws_access_key_id=ACCESS_KEY,
        # aws_secret_access_key=SECRET_KEY,
        aws_session_token=token,
        use_ssl=True,
        verify=True)
예제 #7
0
def _connect(paramaters):
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    password = getCredentials(paramaters.get('password', None))
    kwargs = {
        'hostname': paramaters['host'],
        'username': paramaters.get('username', None),
        'password': password,
    }

    client.connect(**kwargs)

    return client