Cassandra Database Module
2015.5.0 新版功能.
depends: | DataStax Python Driver for Apache Cassandra https://github.com/datastax/python-driver pip install cassandra-driver |
---|---|
referenced by: | Salt's cassandra_cql returner |
configuration: | The Cassandra cluster members and connection port can either be specified in the master or minion config, the minion's pillar or be passed to the module. Example configuration in the config for a single node: cassandra:
cluster: 192.168.50.10
port: 9000
Example configuration in the config for a cluster: cassandra:
cluster:
- 192.168.50.10
- 192.168.50.11
- 192.168.50.12
port: 9000
username: cas_admin
|
salt.modules.cassandra_cql.
cql_query
(query, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Run a query on a Cassandra cluster and return a dictionary.
参数: |
|
---|---|
返回: | A dictionary from the return values of the query |
返回类型: | list[dict] |
salt.modules.cassandra_cql.
create_keyspace
(keyspace, replication_strategy='SimpleStrategy', replication_factor=1, replication_datacenters=None, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Create a new keyspace in Cassandra.
参数: |
|
---|---|
返回: | The info for the keyspace or False if it does not exist. |
返回类型: |
salt 'minion1' cassandra_cql.create_keyspace keyspace=newkeyspace
salt 'minion1' cassandra_cql.create_keyspace keyspace=newkeyspace replication_strategy=NetworkTopologyStrategy replication_datacenters='{"datacenter_1": 3, "datacenter_2": 2}'
salt.modules.cassandra_cql.
create_user
(username, password, superuser=False, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Create a new cassandra user with credentials and superuser status.
参数: |
|
---|---|
返回: | |
返回类型: |
salt 'minion1' cassandra_cql.create_user username=joe password=secret
salt 'minion1' cassandra_cql.create_user username=joe password=secret superuser=True
salt 'minion1' cassandra_cql.create_user username=joe password=secret superuser=True contact_points=minion1
salt.modules.cassandra_cql.
drop_keyspace
(keyspace, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Drop a keyspace if it exists in a Cassandra cluster.
参数: |
|
---|---|
返回: | The info for the keyspace or False if it does not exist. |
返回类型: |
CLI Example:
salt 'minion1' cassandra_cql.drop_keyspace keyspace=test
salt 'minion1' cassandra_cql.drop_keyspace keyspace=test contact_points=minion1
salt.modules.cassandra_cql.
grant_permission
(username, resource=None, resource_type='keyspace', permission=None, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Grant permissions to a user.
参数: |
|
---|---|
返回: | |
返回类型: |
salt 'minion1' cassandra_cql.grant_permission
salt 'minion1' cassandra_cql.grant_permission username=joe resource=test_keyspace permission=select
salt 'minion1' cassandra_cql.grant_permission username=joe resource=test_table resource_type=table permission=select contact_points=minion1
salt.modules.cassandra_cql.
info
(contact_points=None, port=None, cql_user=None, cql_pass=None)¶Show the Cassandra information for this cluster.
参数: |
|
---|---|
返回: | The information for this Cassandra cluster. |
返回类型: |
CLI Example:
salt 'minion1' cassandra_cql.info
salt 'minion1' cassandra_cql.info contact_points=minion1
salt.modules.cassandra_cql.
keyspace_exists
(keyspace, contact_points=None, port=None, cql_user=None, cql_pass=None)¶Check if a keyspace exists in a Cassandra cluster.
:param keyspace The keyspace name to check for. :type keyspace: str :param contact_points: The Cassandra cluster addresses, can either be a string or a list of IPs. :type contact_points: str | list[str] :param cql_user: The Cassandra user if authentication is turned on. :type cql_user: str :param cql_pass: The Cassandra user password if authentication is turned on. :type cql_pass: str :param port: The Cassandra cluster port, defaults to None. :type port: int :return: The info for the keyspace or False if it does not exist. :rtype: dict
CLI Example:
salt 'minion1' cassandra_cql.keyspace_exists keyspace=system
salt 'minion1' cassandra_cql.list_keyspaces keyspace=system contact_points=minion1
salt.modules.cassandra_cql.
list_column_families
(keyspace=None, contact_points=None, port=None, cql_user=None, cql_pass=None)¶List column families in a Cassandra cluster for all keyspaces or just the provided one.
参数: |
|
---|---|
返回: | The column families in this Cassandra cluster. |
返回类型: | list[dict] |
CLI Example:
salt 'minion1' cassandra_cql.list_column_families
salt 'minion1' cassandra_cql.list_column_families contact_points=minion1
salt 'minion1' cassandra_cql.list_column_families keyspace=system
salt.modules.cassandra_cql.
list_keyspaces
(contact_points=None, port=None, cql_user=None, cql_pass=None)¶List keyspaces in a Cassandra cluster.
参数: |
|
---|---|
返回: | The keyspaces in this Cassandra cluster. |
返回类型: | list[dict] |
CLI Example:
salt 'minion1' cassandra_cql.list_keyspaces
salt 'minion1' cassandra_cql.list_keyspaces contact_points=minion1 port=9000
salt.modules.cassandra_cql.
list_permissions
(username=None, resource=None, resource_type='keyspace', permission=None, contact_points=None, port=None, cql_user=None, cql_pass=None)¶List permissions.
参数: |
|
---|---|
返回: | Dictionary of permissions. |
返回类型: |
salt 'minion1' cassandra_cql.list_permissions
salt 'minion1' cassandra_cql.list_permissions username=joe resource=test_keyspace permission=select
salt 'minion1' cassandra_cql.list_permissions username=joe resource=test_table resource_type=table permission=select contact_points=minion1
salt.modules.cassandra_cql.
list_users
(contact_points=None, port=None, cql_user=None, cql_pass=None)¶List existing users in this Cassandra cluster.
参数: |
|
---|---|
返回: | The list of existing users. |
返回类型: |
salt 'minion1' cassandra_cql.list_users
salt 'minion1' cassandra_cql.list_users contact_points=minion1
salt.modules.cassandra_cql.
version
(contact_points=None, port=None, cql_user=None, cql_pass=None)¶Show the Cassandra version.
参数: |
|
---|---|
返回: | The version for this Cassandra cluster. |
返回类型: |
CLI Example:
salt 'minion1' cassandra_cql.version
salt 'minion1' cassandra_cql.version contact_points=minion1