Credentials¶
Manage cluster credentials, e.g. ssh keys, Cloud Files account information.
When creating a cluster, you will need to provide a ssh key with which you can
log in to the cluster (since we do not generate passwords). In the lava
script, if you have not created any ssh key credentials before creating a
cluster, you will be asked to create one using $HOME/.ssh/id_rsa.pub,
assuming that public key file exists. However, when using
Lava
, you will have to create your ssh credentials
manually:
>>> ssh_key = lava.credentials.create_ssh_key('my_key',
... '/path/to/id_rsa.pub')
>>> lava.clusters.create(
... 'my_cluster',
... 'HADOOP_HDP2_2',
... username='scott',
... ssh_keys=[ssh_key.id],
... node_groups={'slave': {'count': 3, 'flavor_id': 'hadoop1-7'}})
Warning
Some credentials, such as Ambari read-only users, can not be added to existing clusters via the API, and therefore must be specified at cluster creation time. However, some credentials may be updated on existing clusters; for example, while you can’t create a new Ambari user on an existing cluster, changing an existing user’s password will be reflected on all clusters that include that user.
Similarly, you can add credentials to access other services from your clusters, e.g. Cloud Files, which you can enable using the credentials argument when creating a cluster:
>>> cloudfiles = lava.credentials.create_cloud_files('cloudfiles_user',
... 'cloudfiles_apikey')
>>> lava.clusters.create(
... 'my_cluster',
... 'HADOOP_HDP2_2',
... username='scott',
... ssh_keys=[ssh_key.id],
... credentials=[{'cloud_files': cloudfiles.id}],
... node_groups={'slave': {'count': 3, 'flavor_id': 'hadoop1-7'}})
Note
The connectors argument has been replaced by credentials, which shares the same format.
Note
You do not need to remember which attribute to use for each credential type; instead, you can always use the id attribute. For example, when specifying ssh keys, you can use ssh_key.id instead of ssh_key.name.
Note
The currently supported credential types are SSH, Cloud Files, Ambari, and Amazon S3.
API Reference¶
-
class
lavaclient.api.credentials.
Resource
¶ Credentials API methods
-
create_ambari
(username, password)¶ Create credentials for Ambari access
Parameters: - username – Ambari username
- password – Password
Returns: AmbariCredential
-
create_cloud_files
(username, api_key)¶ Create credentials for Cloud Files access
Parameters: - username – Cloud Files username
- api_key – Cloud Files API Key
Returns: CloudFilesCredential
-
create_s3
(access_key_id, access_secret_key)¶ Create credentials for Amazon S3 access
Parameters: - access_key_id – S3 access key id
- access_secret_key – S3 access secret key
Returns: S3Credential
-
create_ssh_key
(name, public_key)¶ Upload an SSH public key for cluster logins
Parameters: - name – The name to associate to the public key
- public_key – SSH public key in plaintext or path to key file
Returns: SSHKey
-
delete_ambari
(username)¶ Delete Ambari credential
Parameters: username – Ambari username
-
delete_cloud_files
(username)¶ Delete Cloud Files credential
Parameters: username – Cloud Files username
-
delete_s3
(access_key_id)¶ Delete Amazon s3 credential
Parameters: access_key_id – S3 access key id
-
delete_ssh_key
(name)¶ Delete SSH key
Parameters: name – Name that identifies the SSH key
-
list
()¶ List all credentials belonging to the tenant
Returns: List of Credentials
objects
-
list_ambari
()¶ List all Ambari credentials
Returns: List of AmbariCredential
objects
-
list_cloud_files
()¶ List all Cloud Files credentials
Returns: List of CloudFilesCredential
objects
-
list_s3
()¶ List all Amazon S3 credentials
Returns: List of S3Credential
objects
-
list_ssh_keys
()¶ List all SSH keys
Returns: List of SSHKey
objects
-
list_types
()¶ List all credential types
Returns: List of CredentialType objects
-
update_ambari
(username, password)¶ Update credentials for Ambari access
Parameters: - username – Ambari username
- password – Password
Returns: AmbariCredential
-
update_cloud_files
(username, api_key)¶ Update credentials for Cloud Files access
Parameters: - username – Cloud Files username
- api_key – Cloud Files API Key
Returns: CloudFilesCredential
-
update_s3
(access_key_id, access_secret_key)¶ Update credentials for Amazon S3 access
Parameters: - access_key_id – S3 access key id
- access_secret_key – S3 access secret Key
Returns: S3Credential
-
update_ssh_key
(name, public_key)¶ Upload an SSH public key for cluster logins
Parameters: - name – The name of an existing SSH key
- public_key – SSH public key in plaintext or path to key file
Returns: SSHKey
-
-
class
lavaclient.api.response.
Credentials
¶ -
describe
()¶ Return a pretty-formatted string that describes the format of the data
-
to_dict
()¶ Convert the config to a plain python dictionary
-
ambari
¶
-
cloud_files
¶
-
s3
¶
-
ssh_keys
¶
-
-
class
lavaclient.api.response.
SSHKey
¶ -
delete
()¶ Delete this key
-
describe
()¶ Return a pretty-formatted string that describes the format of the data
-
to_dict
()¶ Convert the config to a plain python dictionary
-
name
¶
-
-
class
lavaclient.api.response.
CloudFilesCredential
¶ -
delete
()¶ Delete this credential
-
describe
()¶ Return a pretty-formatted string that describes the format of the data
-
to_dict
()¶ Convert the config to a plain python dictionary
-
username
¶
-