Add CLI Examples so tests will pass (#39035)

* Add CLI Examples so tests will pass

* Add CLI Examples so tests will pass
This commit is contained in:
C. R. Oldham 2017-01-30 17:04:30 -07:00 committed by Nicole Thomas
parent 0943872fab
commit 92a542fa21
3 changed files with 58 additions and 1 deletions

View file

@ -295,6 +295,11 @@ def cql_query(query, contact_points=None, port=None, cql_user=None, cql_pass=Non
:type params: str
:return: A dictionary from the return values of the query
:rtype: list[dict]
.. code-block:: bash
# CLI Example: Simple CQL query
salt '*' cql_query "SELECT * FROM users_by_name WHERE first_name = 'jane'"
'''
try:
cluster, session = _connect(contact_points=contact_points, port=port, cql_user=cql_user, cql_pass=cql_pass)
@ -363,6 +368,19 @@ def cql_query_with_prepare(query, statement_name, statement_arguments, async=Fal
:type params: str
:return: A dictionary from the return values of the query
:rtype: list[dict]
CLI Example:
.. code-block:: bash
# Insert data asynchronously
salt this-node cassandra_cql.cql_query_with_prepare "name_insert" "INSERT INTO USERS (first_name, last_name) VALUES (?, ?)" \
statement_arguments=['John','Doe'], async=True
# Select data, should not be asynchronous because there is not currently a facility to return data from a future
salt this-node cassandra_cql.cql_query_with_prepare "name_select" "SELECT * FROM USERS WHERE first_name=?" \
statement_arguments=['John']
'''
try:
cluster, session = _connect(contact_points=contact_points, port=port,
@ -663,6 +681,7 @@ def create_keyspace(keyspace, replication_strategy='SimpleStrategy', replication
.. code-block:: bash
# CLI Example:
salt 'minion1' cassandra_cql.create_keyspace keyspace=newkeyspace
salt 'minion1' cassandra_cql.create_keyspace keyspace=newkeyspace replication_strategy=NetworkTopologyStrategy \
@ -757,6 +776,8 @@ def list_users(contact_points=None, port=None, cql_user=None, cql_pass=None):
:return: The list of existing users.
:rtype: dict
CLI Example:
.. code-block:: bash
salt 'minion1' cassandra_cql.list_users
@ -800,6 +821,8 @@ def create_user(username, password, superuser=False, contact_points=None, port=N
:return:
:rtype:
CLI Example:
.. code-block:: bash
salt 'minion1' cassandra_cql.create_user username=joe password=secret
@ -850,6 +873,8 @@ def list_permissions(username=None, resource=None, resource_type='keyspace', per
:return: Dictionary of permissions.
:rtype: dict
CLI Example:
.. code-block:: bash
salt 'minion1' cassandra_cql.list_permissions
@ -857,7 +882,7 @@ def list_permissions(username=None, resource=None, resource_type='keyspace', per
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
permission=select contact_points=minion1
'''
keyspace_cql = "{0} {1}".format(resource_type, resource) if resource else "all keyspaces"
permission_cql = "{0} permission".format(permission) if permission else "all permissions"
@ -906,6 +931,8 @@ def grant_permission(username, resource=None, resource_type='keyspace', permissi
:return:
:rtype:
CLI Example:
.. code-block:: bash
salt 'minion1' cassandra_cql.grant_permission

View file

@ -381,6 +381,13 @@ def upgrade_available(pkg, refresh=True):
def refresh_db():
'''
Update ports with ``port selfupdate``
CLI Example:
.. code-block:: bash
salt mac pkg.refresh_db
'''
cmd = ['port', 'selfupdate']
return salt.utils.mac_utils.execute_return_success(cmd)

View file

@ -1702,6 +1702,7 @@ def list_datacenters(host, username, password, protocol=None, port=None):
.. code-block:: bash
salt '*' vsphere.list_datacenters 1.2.3.4 root bad-password
'''
service_instance = salt.utils.vmware.get_service_instance(host=host,
username=username,
@ -1732,9 +1733,12 @@ def list_clusters(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_clusters 1.2.3.4 root bad-password
'''
service_instance = salt.utils.vmware.get_service_instance(host=host,
username=username,
@ -1765,6 +1769,8 @@ def list_datastore_clusters(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_datastore_clusters 1.2.3.4 root bad-password
@ -1798,6 +1804,8 @@ def list_datastores(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_datastores 1.2.3.4 root bad-password
@ -1831,6 +1839,8 @@ def list_hosts(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_hosts 1.2.3.4 root bad-password
@ -1864,6 +1874,8 @@ def list_resourcepools(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_resourcepools 1.2.3.4 root bad-password
@ -1897,6 +1909,8 @@ def list_networks(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_networks 1.2.3.4 root bad-password
@ -1930,6 +1944,8 @@ def list_vms(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_vms 1.2.3.4 root bad-password
@ -1963,6 +1979,8 @@ def list_folders(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_folders 1.2.3.4 root bad-password
@ -1996,6 +2014,8 @@ def list_dvs(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
salt '*' vsphere.list_dvs 1.2.3.4 root bad-password
@ -2029,8 +2049,11 @@ def list_vapps(host, username, password, protocol=None, port=None):
Optionally set to alternate port if the host is not using the default
port. Default port is ``443``.
CLI Example:
.. code-block:: bash
# List vapps from all minions
salt '*' vsphere.list_vapps 1.2.3.4 root bad-password
'''
service_instance = salt.utils.vmware.get_service_instance(host=host,