hpeOneView.resources.security package

Submodules

hpeOneView.resources.security.certificate_authority module

class hpeOneView.resources.security.certificate_authority.CertificateAuthority(connection, data=None)[source]

Bases: Resource

Certificate Authority API client.

URI = '/rest/certificates/ca'
create(data=None, parent_task='', timeout=-1)[source]

Imports an external CA root certificate or CA certificate chain into the appliance trust store. Same CA certificate will not be allowed to be imported into the appliance trust store.

Parameters
  • data – Fields passed to create the resource.

  • parent_task – The parentTask can be passed only if auth header has either a valid trusted token or a valid combined token consisting of a trusted token.

  • timeout – Timeout in seconds. Wait for task completion by default.

Returns

response body of imported CA Certificate.

Return type

dict

get_all(filter='', cert_details=True)[source]

Retrieves all the CA certificates.

Parameters
  • filter – Filter based on a specific value. Supported filter is filter=certType:INTERNAL

  • cert_details – If this is set to true the api returns all the CA certificates with full certificate details

Returns

List of all CA Certificate.

Return type

list

get_by_aliasname(alias_name)[source]

Returns the collection having CA certificates

Parameters

alias_name – alias name of CA certificate

Returns

The Certificate details by certificate authority alias name

Return type

dict

get_crl()[source]

Retrieves the contents of the CRL file maintained by the internal CA; in Base-64 encoded format, in the form of a string.

Returns

The Certificate Revocation List

Return type

str

get_crl_by_aliasname(alias_name)[source]

Downloads the CRL file associated with the given certificate authority alias name.

Parameters

alias_name – alias name of CA certificate

Returns

The Certificate Revocation List by certificate authority alias name

Return type

str

hpeOneView.resources.security.certificate_rabbitmq module

class hpeOneView.resources.security.certificate_rabbitmq.CertificateRabbitMQ(con)[source]

Bases: object

URI = '/rest/certificates/client/rabbitmq'
generate(information, timeout=-1)[source]

Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients.

Parameters
  • information (dict) – Information to generate the certificate for RabbitMQ clients.

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.

Returns

RabbitMQ certificate generated

Return type

dict

get(alias_name)[source]

Retrieves the base-64 encoded certificate associated with the RabbitMQ user.

Parameters

alias_name – Key pair associated with the RabbitMQ

Returns

RabbitMQ certificate

Return type

dict

get_key_pair(alias_name)[source]

Retrieves the public and private key pair associated with the specified alias name.

Parameters

alias_name – Key pair associated with the RabbitMQ

Returns

RabbitMQ certificate

Return type

dict

get_keys(alias_name, key_format)[source]

Retrieves the contents of PKCS12 file in the format specified. This PKCS12 formatted file contains both the certificate as well as the key file data. Valid key formats are Base64 and PKCS12.

Parameters
  • alias_name – Key pair associated with the RabbitMQ

  • key_format – Valid key formats are Base64 and PKCS12.

Returns

RabbitMQ certificate

Return type

dict

hpeOneView.resources.security.certificates_server module

class hpeOneView.resources.security.certificates_server.CertificatesServer(connection, data=None)[source]

Bases: Resource

The Certificates Servers resource provides REST APIs for configuration of device or server certificates for the appliance to establish SSL communication with other managed network entities.

Import, Update and Delete APIs are asynchronous and GET API is synchronous.

URI = '/rest/certificates'
create(data=None, timeout=-1)[source]

Makes a POST request to create a server certificate resource.

Parameters
  • data – Fields passed to create the resource.

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.

Returns

Created certificate resource.

get_by_alias_name(alias_name)[source]

Retrieves the device or server certificate, already trusted in the appliance, with the specified aliasName.

Parameters

alias_name (str) – Alias name.

Returns

Certificate of trusted appliance

Return type

dict

get_remote(remote_address)[source]

Retrieves the device or server certificate and certificate chain of the specified device or server.

Parameters

remote_address – Address of remote server

Returns

Certificate chain of remote server

Return type

dict

hpeOneView.resources.security.login_details module

class hpeOneView.resources.security.login_details.LoginDetails(con)[source]

Bases: object

list login details.

URI = '/rest/logindetails'
get_login_details()[source]

List the login details

Returns

login details.

Return type

dict

hpeOneView.resources.security.roles module

class hpeOneView.resources.security.roles.Roles(con)[source]

Bases: object

Roles API client.

RESOURCES_PATH = '/resources'
URI = '/rest/roles'
get(name_or_uri)[source]

Get the role by its URI or Name.

Parameters

name_or_uri – Can be either the Name or the URI.

Returns

Role

Return type

dict

get_all(start=0, count=-1, filter='', sort='')[source]

Gets a list of roles based on optional sorting and filtering and is constrained by start and count parameters.

Parameters
  • start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.

  • count – The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items.

  • filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.

  • sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.

Returns

A list of roles.

Return type

list

hpeOneView.resources.security.users module

class hpeOneView.resources.security.users.Users(connection, data=None)[source]

Bases: Resource

Users API client.

URI = '/rest/users'
add_role_to_userName(username, data)[source]

Add roles to a given user name

Parameters
  • username (str) – userName of the user

  • data (list) – roles to be added

Returns

User

Return type

dict object

change_password(resource)[source]

Change one’s own password

Parameters
  • resource (dict) – Object to change password

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView, just stops waiting for its completion.

create_multiple_user(data)[source]

Create a multiple user

Agrs:

data (list): multiple user

Returns

User

Return type

dict object

delete_multiple_user(data)[source]

Delete the multiple users

Parameters

data (list) – List of users to be deleted

Returns

None

get_by_userName(name)[source]

Gets a complete json body for username

Parameters

name (str) – userName of the user

Returns

User

Return type

dict object

get_role_associated_with_userName(userName)[source]

Gets a user by userName.

Parameters

name (str) – userName of the user.

Returns

User

Return type

dict object

get_user_by_role(rolename)[source]

Gets all the users associated with this role

Parameters

rolename (str) – rolename of the user

Returns

User

Return type

list

query_filter(filters)[source]
remove_role_from_username(username, data)[source]

Removes a specified role from the username

Parameters
  • username (str) – username of the user

  • data (str/list) – list role to be removed from user

Returns

boolean

update(data=None, timeout=-1, custom_headers=None, force=False)[source]

Makes a PUT request to update a resource when a request body is required.

Parameters
  • data (dict) – Data to update the resource.

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.

  • custom_headers – Allows to add custom HTTP headers.

  • force – Force the update operation.

Returns

A dict with the updated resource data.

update_role_to_userName(username, data)[source]

Update roles to a given user name

Agrs:

username (str): username of the user data (list): roles to be updated

Returns

User

Return type

dict

validate_full_name(full_name, timeout=-1)[source]

Verifies if a fullName is already in use.

Parameters
  • full_name (str) – The fullName to be verified.

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView, just stops waiting for its completion.

Returns: True if full name is in use, False if it is not.

validate_user_name(user_name, timeout=-1)[source]

Verifies if a userName is already in use.

Parameters
  • user_name (str) – The userName to be verified.

  • timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView, just stops waiting for its completion.

Returns: True if user name is in use, False if it is not.

Module contents