當前位置: 首頁>>代碼示例>>Python>>正文


Python auth.PlainTextAuthProvider方法代碼示例

本文整理匯總了Python中cassandra.auth.PlainTextAuthProvider方法的典型用法代碼示例。如果您正苦於以下問題:Python auth.PlainTextAuthProvider方法的具體用法?Python auth.PlainTextAuthProvider怎麽用?Python auth.PlainTextAuthProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cassandra.auth的用法示例。


在下文中一共展示了auth.PlainTextAuthProvider方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self, ip_addresses, cassandra_config):
        self._ip_addresses = ip_addresses
        self._auth_provider = None
        self._ssl_context = None
        self._cassandra_config = cassandra_config

        if cassandra_config.cql_username is not None and cassandra_config.cql_password is not None:
            auth_provider = PlainTextAuthProvider(username=cassandra_config.cql_username,
                                                  password=cassandra_config.cql_password)
            self._auth_provider = auth_provider

        if cassandra_config.certfile is not None and cassandra_config.usercert is not None and \
           cassandra_config.userkey is not None:
            ssl_context = SSLContext(PROTOCOL_TLSv1)
            ssl_context.load_verify_locations(cassandra_config.certfile)
            ssl_context.verify_mode = CERT_REQUIRED
            ssl_context.load_cert_chain(
                certfile=cassandra_config.usercert,
                keyfile=cassandra_config.userkey)
            self._ssl_context = ssl_context

        load_balancing_policy = WhiteListRoundRobinPolicy(ip_addresses)
        self._execution_profiles = {
            'local': ExecutionProfile(load_balancing_policy=load_balancing_policy)
        } 
開發者ID:thelastpickle,項目名稱:cassandra-medusa,代碼行數:27,代碼來源:cassandra_utils.py

示例2: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):
        self.MORPHL_SERVER_IP_ADDRESS = getenv('MORPHL_SERVER_IP_ADDRESS')
        self.MORPHL_CASSANDRA_USERNAME = getenv('MORPHL_CASSANDRA_USERNAME')
        self.MORPHL_CASSANDRA_PASSWORD = getenv('MORPHL_CASSANDRA_PASSWORD')
        self.MORPHL_CASSANDRA_KEYSPACE = getenv('MORPHL_CASSANDRA_KEYSPACE')

        self.prep_stmt = {}

        template_for_prediction = 'INSERT INTO ga_chp_bq_predictions (client_id,prediction) VALUES (?,?)'
        template_for_predictions_by_date = 'INSERT INTO ga_chp_bq_predictions_by_prediction_date (prediction_date, client_id, prediction) VALUES (?,?,?)'
        template_for_predictions_statistics = 'UPDATE ga_chp_bq_predictions_statistics SET loyal=loyal+?, neutral=neutral+?, churning=churning+?, lost=lost+? WHERE prediction_date=?'


        self.CASS_REQ_TIMEOUT = 3600.0

        self.auth_provider = PlainTextAuthProvider(
            username=self.MORPHL_CASSANDRA_USERNAME,
            password=self.MORPHL_CASSANDRA_PASSWORD)
        self.cluster = Cluster(
            [self.MORPHL_SERVER_IP_ADDRESS], auth_provider=self.auth_provider)
        self.session = self.cluster.connect(self.MORPHL_CASSANDRA_KEYSPACE)

        self.prep_stmt['prediction'] = self.session.prepare(template_for_prediction)
        self.prep_stmt['predictions_by_date'] = self.session.prepare(template_for_predictions_by_date)
        self.prep_stmt['predictions_statistics'] = self.session.prepare(template_for_predictions_statistics) 
開發者ID:Morphl-AI,項目名稱:MorphL-Community-Edition,代碼行數:27,代碼來源:ga_chp_bq_batch_inference.py

示例3: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):
        self.MORPHL_SERVER_IP_ADDRESS = getenv('MORPHL_SERVER_IP_ADDRESS')
        self.MORPHL_CASSANDRA_USERNAME = getenv('MORPHL_CASSANDRA_USERNAME')
        self.MORPHL_CASSANDRA_PASSWORD = getenv('MORPHL_CASSANDRA_PASSWORD')
        self.MORPHL_CASSANDRA_KEYSPACE = getenv('MORPHL_CASSANDRA_KEYSPACE')

        self.QUERY = 'SELECT * FROM ga_chp_bq_predictions WHERE client_id = ? LIMIT 1'
        self.CASS_REQ_TIMEOUT = 3600.0

        self.auth_provider = PlainTextAuthProvider(
            username=self.MORPHL_CASSANDRA_USERNAME,
            password=self.MORPHL_CASSANDRA_PASSWORD)
        self.cluster = Cluster(
            [self.MORPHL_SERVER_IP_ADDRESS], auth_provider=self.auth_provider)

        self.session = self.cluster.connect(self.MORPHL_CASSANDRA_KEYSPACE)
        self.session.row_factory = dict_factory
        self.session.default_fetch_size = 100

        self.prepare_statements() 
開發者ID:Morphl-AI,項目名稱:MorphL-Community-Edition,代碼行數:22,代碼來源:model_serving_endpoint.py

示例4: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):
        self.MORPHL_SERVER_IP_ADDRESS = getenv('MORPHL_SERVER_IP_ADDRESS')
        self.MORPHL_CASSANDRA_USERNAME = getenv('MORPHL_CASSANDRA_USERNAME')
        self.MORPHL_CASSANDRA_PASSWORD = getenv('MORPHL_CASSANDRA_PASSWORD')
        self.MORPHL_CASSANDRA_KEYSPACE = getenv('MORPHL_CASSANDRA_KEYSPACE')

        self.CASS_REQ_TIMEOUT = 3600.0

        self.auth_provider = PlainTextAuthProvider(
            username=self.MORPHL_CASSANDRA_USERNAME,
            password=self.MORPHL_CASSANDRA_PASSWORD)
        self.cluster = Cluster(
            [self.MORPHL_SERVER_IP_ADDRESS], auth_provider=self.auth_provider)

        self.session = self.cluster.connect(self.MORPHL_CASSANDRA_KEYSPACE)
        self.session.row_factory = dict_factory
        self.session.default_fetch_size = 100

        self.prepare_statements() 
開發者ID:Morphl-AI,項目名稱:MorphL-Community-Edition,代碼行數:21,代碼來源:model_serving_endpoint.py

示例5: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self, config, profile='dev', hosts=['127.0.0.1'], port=9042,
                 user=None, password=None, host_cert_path=None,
                 client_key_path=None, client_cert_path=None):
        self.config = config

        try:
            self.current_profile = self.config.profiles[profile]
        except KeyError:
            raise ValueError("Invalid profile name '{}'".format(profile))

        if user:
            auth_provider = PlainTextAuthProvider(user, password)
        else:
            auth_provider = None

        if host_cert_path:
            ssl_options = self._build_ssl_options(
                host_cert_path,
                client_key_path,
                client_cert_path)
        else:
            ssl_options = None

        self.cluster = Cluster(
            contact_points=hosts,
            port=port,
            auth_provider=auth_provider,
            max_schema_agreement_wait=300,
            control_connection_timeout=10,
            connect_timeout=30,
            ssl_options=ssl_options)

        self._session = None 
開發者ID:Cobliteam,項目名稱:cassandra-migrate,代碼行數:35,代碼來源:migrator.py

示例6: get_auth_provider

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def get_auth_provider(user, password):
    return PlainTextAuthProvider(username=user, password=password) 
開發者ID:apache,項目名稱:cassandra-dtest,代碼行數:4,代碼來源:dtest.py

示例7: setup_connection

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def setup_connection(self):
        assert isinstance(self.settings, CassandraSettings), self.settings

        # Optionally construct an "auth provider" object.
        if self.settings.username and self.settings.password:
            auth_provider = PlainTextAuthProvider(
                username=self.settings.username, password=self.settings.password
            )
        else:
            auth_provider = None

        # Resolve the consistency level to a driver object.
        try:
            consistency_level_name = self.settings.consistency.upper()
            consistency_level = ConsistencyLevel.name_to_value[consistency_level_name]
        except KeyError:
            msg = "Cassandra consistency level name '{}' not found." "".format(
                self.settings.consistency
            )
            raise DatasourceSettingsError(msg)

        # Use the other self.settings directly.
        cassandra.cqlengine.connection.setup(
            hosts=self.settings.hosts,
            consistency=consistency_level,
            default_keyspace=self.settings.default_keyspace,
            port=self.settings.port,
            auth_provider=auth_provider,
            protocol_version=self.settings.protocol_version,
            lazy_connect=True,
            retry_connect=True,
        ) 
開發者ID:johnbywater,項目名稱:eventsourcing,代碼行數:34,代碼來源:datastore.py

示例8: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self, cassandra_conn_id: str = 'cassandra_default'):
        super().__init__()
        conn = self.get_connection(cassandra_conn_id)

        conn_config = {}
        if conn.host:
            conn_config['contact_points'] = conn.host.split(',')

        if conn.port:
            conn_config['port'] = int(conn.port)

        if conn.login:
            conn_config['auth_provider'] = PlainTextAuthProvider(
                username=conn.login, password=conn.password)

        policy_name = conn.extra_dejson.get('load_balancing_policy', None)
        policy_args = conn.extra_dejson.get('load_balancing_policy_args', {})
        lb_policy = self.get_lb_policy(policy_name, policy_args)
        if lb_policy:
            conn_config['load_balancing_policy'] = lb_policy

        cql_version = conn.extra_dejson.get('cql_version', None)
        if cql_version:
            conn_config['cql_version'] = cql_version

        ssl_options = conn.extra_dejson.get('ssl_options', None)
        if ssl_options:
            conn_config['ssl_options'] = ssl_options

        self.cluster = Cluster(**conn_config)
        self.keyspace = conn.schema
        self.session = None 
開發者ID:apache,項目名稱:airflow,代碼行數:34,代碼來源:cassandra.py

示例9: auth_provider_if_configured

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def auth_provider_if_configured(config):
    if config.has_option('server', 'cassandra_user') and config.has_option('server', 'cassandra_password'):
        from cassandra.auth import PlainTextAuthProvider
        return PlainTextAuthProvider(username=config.get('server', 'cassandra_user'), password=config.get('server', 'cassandra_password'))
    return None 
開發者ID:datastax,項目名稱:cstar_perf,代碼行數:7,代碼來源:util.py

示例10: test_init

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def test_init(self, cassandra_connect_mock):
        repo = cassandra_repo.MetricsRepository()
        self.assertIsNone(
            repo.cluster.auth_provider,
            'cassandra cluster auth provider is expected to None'
        )

        repo.conf.cassandra.user = 'cassandra'
        repo.conf.cassandra.password = 'cassandra'
        repo = cassandra_repo.MetricsRepository()
        self.assertIsInstance(
            repo.cluster.auth_provider,
            PlainTextAuthProvider,
            'cassandra cluster auth provider is expected to be PlainTextAuthProvider'
        ) 
開發者ID:openstack,項目名稱:monasca-api,代碼行數:17,代碼來源:test_repositories.py

示例11: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):
        self.DAY_OF_DATA_CAPTURE = getenv('DAY_OF_DATA_CAPTURE')
        self.MORPHL_SERVER_IP_ADDRESS = getenv('MORPHL_SERVER_IP_ADDRESS')
        self.MORPHL_CASSANDRA_USERNAME = getenv('MORPHL_CASSANDRA_USERNAME')
        self.MORPHL_CASSANDRA_PASSWORD = getenv('MORPHL_CASSANDRA_PASSWORD')
        self.MORPHL_CASSANDRA_KEYSPACE = getenv('MORPHL_CASSANDRA_KEYSPACE')
        self.CASS_REQ_TIMEOUT = 3600.0

        self.auth_provider = PlainTextAuthProvider(
            username=self.MORPHL_CASSANDRA_USERNAME, password=self.MORPHL_CASSANDRA_PASSWORD)
        self.cluster = Cluster(
            contact_points=[self.MORPHL_SERVER_IP_ADDRESS], auth_provider=self.auth_provider)
        self.session = self.cluster.connect(self.MORPHL_CASSANDRA_KEYSPACE)

        self.prepare_statements() 
開發者ID:Morphl-AI,項目名稱:MorphL-Community-Edition,代碼行數:17,代碼來源:ga_chp_connector.py

示例12: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):
        self.MORPHL_SERVER_IP_ADDRESS = getenv('MORPHL_SERVER_IP_ADDRESS')
        self.MORPHL_CASSANDRA_USERNAME = getenv('MORPHL_CASSANDRA_USERNAME')
        self.MORPHL_CASSANDRA_PASSWORD = getenv('MORPHL_CASSANDRA_PASSWORD')
        self.MORPHL_CASSANDRA_KEYSPACE = getenv('MORPHL_CASSANDRA_KEYSPACE')

        self.prep_stmt = {}

        template_for_prediction = 'INSERT INTO ga_chp_predictions (client_id,prediction) VALUES (?,?)'
        template_for_predictions_by_date = 'INSERT INTO ga_chp_predictions_by_prediction_date (prediction_date, client_id, prediction) VALUES (?,?,?)'
        template_for_predictions_statistics = 'UPDATE ga_chp_predictions_statistics SET loyal=loyal+?, neutral=neutral+?, churning=churning+?, lost=lost+? WHERE prediction_date=?'

        self.CASS_REQ_TIMEOUT = 3600.0

        self.auth_provider = PlainTextAuthProvider(
            username=self.MORPHL_CASSANDRA_USERNAME,
            password=self.MORPHL_CASSANDRA_PASSWORD)
        self.cluster = Cluster(
            [self.MORPHL_SERVER_IP_ADDRESS], auth_provider=self.auth_provider)
        self.session = self.cluster.connect(self.MORPHL_CASSANDRA_KEYSPACE)

        self.prep_stmt['prediction'] = self.session.prepare(
            template_for_prediction)
        self.prep_stmt['predictions_by_date'] = self.session.prepare(
            template_for_predictions_by_date)
        self.prep_stmt['predictions_statistics'] = self.session.prepare(
            template_for_predictions_statistics) 
開發者ID:Morphl-AI,項目名稱:MorphL-Community-Edition,代碼行數:29,代碼來源:ga_chp_batch_inference.py

示例13: __init__

# 需要導入模塊: from cassandra import auth [as 別名]
# 或者: from cassandra.auth import PlainTextAuthProvider [as 別名]
def __init__(self):

        try:
            self.conf = cfg.CONF

            if self.conf.cassandra.user:
                auth_provider = PlainTextAuthProvider(username=self.conf.cassandra.user,
                                                      password=self.conf.cassandra.password)
            else:
                auth_provider = None

            self.cluster = Cluster(self.conf.cassandra.contact_points,
                                   port=self.conf.cassandra.port,
                                   auth_provider=auth_provider,
                                   connect_timeout=self.conf.cassandra.connection_timeout,
                                   load_balancing_policy=TokenAwarePolicy(
                                       DCAwareRoundRobinPolicy(
                                           local_dc=self.conf.cassandra.local_data_center))
                                   )
            self.session = self.cluster.connect(self.conf.cassandra.keyspace)

            self.dim_val_by_metric_stmt = self.session.prepare(DIMENSION_VALUE_BY_METRIC_CQL)

            self.dim_val_stmt = self.session.prepare(DIMENSION_VALUE_CQL)

            self.dim_name_by_metric_stmt = self.session.prepare(DIMENSION_NAME_BY_METRIC_CQL)

            self.dim_name_stmt = self.session.prepare(DIMENSION_NAME_CQL)

            self.metric_name_by_dimension_stmt = self.session.prepare(METRIC_NAME_BY_DIMENSION_CQL)

            self.metric_name_by_dimension_offset_stmt = self.session.prepare(
                METRIC_NAME_BY_DIMENSION_OFFSET_CQL)

            self.metric_name_stmt = self.session.prepare(METRIC_NAME_CQL)

            self.metric_name_offset_stmt = self.session.prepare(METRIC_NAME_OFFSET_CQL)

            self.metric_by_id_stmt = self.session.prepare(METRIC_BY_ID_CQL)

        except Exception as ex:
            LOG.exception(ex)
            raise exceptions.RepositoryException(ex)

        self.epoch = datetime.utcfromtimestamp(0) 
開發者ID:openstack,項目名稱:monasca-api,代碼行數:47,代碼來源:metrics_repository.py


注:本文中的cassandra.auth.PlainTextAuthProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。