Skip to content

Commit c27c30c

Browse files
authored
Rubrik Python SDK v2.0.9
2 parents 29e94de + 96365be commit c27c30c

21 files changed

Lines changed: 1037 additions & 82 deletions

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
## Types of changes
9+
10+
- **Added** for new features.
11+
- **Changed** for changes in existing functionality.
12+
- **Deprecated** for soon-to-be removed features.
13+
- **Removed** for now removed features.
14+
- **Fixed** for any bug fixes.
15+
- **Security** in case of vulnerabilities.
16+
17+
## Unreleased
18+
19+
## v2.0.9
20+
21+
### Added
22+
23+
- get_all_hosts()
24+
- get_all_vcenters()
25+
- Added a new `logging_level` argument to the Connect function that lets users choose which logging level they would like to show in their logs. Note -- this change has limited functionality as all log messages are categorized as `debug` still. Additional enhancements will be added in the next release. ([Issue 222](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/222))
26+
27+
### Changed
28+
29+
- `object_id()` search for vCenter objects now filters based on `primary_cluster_id=local` ([Issue 214](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/214))
30+
31+
### Fixed
32+
33+
- `object_id` will return the ID for all cases using the database name and the database hosts for the `oracle_db` object type ([Issue 199](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/199))
34+
- Fixed case-sensitivity for `object_id` ([Issue 216](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/216))
35+
- Incorrect string join on `get_vsphere_vm` & `get_sql_db` trailing & in query ([Issue 221](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/221))
36+
- Better encode special characteres in `GET` requests. ([Issue 227](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/227))

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Rubrik
3+
Copyright (c) 2020 Rubrik
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,25 @@ rubrik = rubrik_cdm.Connect(node_ip, api_token=api_token)
6262
```
6363

6464

65-
## Debug
65+
## Logging
6666

67-
To enable debuging set the `Connect()` `enable_logging` keyword argument to `True`.
67+
To enable logging, set the `Connect()` `enable_logging` keyword argument to `True`.
68+
69+
The `logging_level` argument can then be used to set the specific logging level you wish to use. The following levels are valid choices:
70+
71+
* `debug` (default value)
72+
* `critical`
73+
* `error`
74+
* `warning`
75+
* `info`
6876

6977
### Example
7078

7179
Script:
7280

7381
```py
7482
import rubrik_cdm
75-
rubrik = rubrik_cdm.Connect(enable_logging=True)
83+
rubrik = rubrik_cdm.Connect(enable_logging=True, logging_level="info)
7684

7785
cluster_version = rubrik.cluster_version()
7886
print(cluster_version)
@@ -81,13 +89,13 @@ print(cluster_version)
8189
Output:
8290

8391
```
84-
[2018-08-08 09:18:59,687] [DEBUG] -- Node IP: 172.21.8.53
85-
[2018-08-08 09:18:59,687] [DEBUG] -- Username: demo
86-
[2018-08-08 09:18:59,687] [DEBUG] -- Password: *******
92+
[2018-08-08 09:18:59,687] [INFO] -- Node IP: 172.21.8.53
93+
[2018-08-08 09:18:59,687] [INFO] -- Username: demo
94+
[2018-08-08 09:18:59,687] [INFO] -- Password: *******
8795

88-
[2018-08-08 09:19:00,062] [DEBUG] -- cluster_version: Getting the software version of the Rubrik Cluster.
89-
[2018-08-08 09:19:00,062] [DEBUG] -- GET https://172.21.8.54/api/v1/cluster/me/version
90-
[2018-08-08 09:19:00,443] [DEBUG] -- <Response [200]>
96+
[2018-08-08 09:19:00,062] [INFO] -- cluster_version: Getting the software version of the Rubrik Cluster.
97+
[2018-08-08 09:19:00,062] [INFO] -- GET https://172.21.8.54/api/v1/cluster/me/version
98+
[2018-08-08 09:19:00,443] [INFO] -- <Response [200]>
9199

92100
4.1.2-2366
93101
```

docs/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* [delete_guest_credential](delete_guest_credential.md)
4545
* [delete_proxy](delete_proxy.md)
4646
* [end_user_authorization](end_user_authorization.md)
47+
* [get_all_vcenters](get_all_vcenters.md)
4748
* [get_floating_ips](get_floating_ips.md)
4849
* [minimum_installed_cdm_version](minimum_installed_cdm_version.md)
4950
* [read_only_authorization](read_only_authorization.md)
@@ -68,6 +69,7 @@
6869
* [create_sla](create_sla.md)
6970
* [delete_sla](delete_sla.md)
7071
* [end_managed_volume_snapshot](end_managed_volume_snapshot.md)
72+
* [get_all_hosts](get_all_hosts.md)
7173
* [get_esxi_subnets](get_esxi_subnets.md)
7274
* [get_sla_objects](get_sla_objects.md)
7375
* [get_sql_db](get_sql_db.md)
@@ -82,6 +84,7 @@
8284
* [object_id](object_id.md)
8385
* [on_demand_snapshot](on_demand_snapshot.md)
8486
* [pause_snapshots](pause_snapshots.md)
87+
* [register_vm](register_vm.md)
8588
* [resume_snapshots](resume_snapshots.md)
8689
* [set_esxi_subnets](set_esxi_subnets.md)
8790
* [sql_db_export](sql_db_export.md)

docs/create_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Rubrik, Inc.
1+
# Copyright 2020 Rubrik, Inc.
22
#
33
# Permission is hereby granted, free of charge, to any person obtaining a copy
44
# of this software and associated documentation files (the "Software"), to

docs/get_all_hosts.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# get_all_hosts
2+
3+
Retrieve information for each host connected to the Rubrik cluster.
4+
5+
```py
6+
def get_all_hosts(self, timeout=15)
7+
```
8+
9+
10+
## Keyword Arguments
11+
| Name | Type | Description | Choices | Default |
12+
|---------|------|-----------------------------------------------------------------------------|---------|---------|
13+
| timeout | int | The number of seconds to wait to establish a connection the Rubrik cluster. | | 15 |
14+
15+
## Returns
16+
| Type | Return Value |
17+
|------|-------------------------------------------|
18+
| dict | The result of the API call `GET /v1/host` |
19+
20+
## Example
21+
```py
22+
import rubrik_cdm
23+
rubrik = rubrik_cdm.Connect()
24+
host_details = rubrik.get_all_hosts()
25+
```

docs/get_all_vcenters.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# get_all_vcenters
2+
3+
Retrieve information for each vCenter connected to the Rubrik cluster.
4+
5+
```py
6+
def get_all_vcenters(self, timeout=15)
7+
```
8+
9+
10+
## Keyword Arguments
11+
| Name | Type | Description | Choices | Default |
12+
|---------|------|-----------------------------------------------------------------------------|---------|---------|
13+
| timeout | int | The number of seconds to wait to establish a connection the Rubrik cluster. | | 15 |
14+
15+
## Returns
16+
| Type | Return Value |
17+
|------|-----------------------------------------------------|
18+
| dict | The full API response for `GET /v1/vmware/vcenter`. |
19+
20+
## Example
21+
```py
22+
import rubrik_cdm
23+
rubrik = rubrik_cdm.Connect()
24+
vcenter_details = rubrik.get_all_vcenters())
25+
```

docs/quick-start.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,24 +422,36 @@ Rubrik prides itself upon its API-first architecture, ensuring everything availa
422422

423423
The Rubrik SDK for Python contains built-in functions and configurations to help assist with troubleshooting any errors that may arise.
424424

425-
### Enabling Debug Mode
425+
### Enabling Logging
426426

427427
The `rubrik_cdm.Connect()` function contains a built-in, verbose logging mechanism which is disabled by default. To enable the logging mechanism, set the `enable_logging` argument to true when connecting to the Rubrik cluster as follows:
428428

429429
```
430430
rubrik = rubrik_cdm.Connect(enable_logging=True)
431431
```
432432

433+
The `logging_level` argument can then be used to set the specific logging level you wish to use. The following levels are valid choices:
434+
435+
* `debug` (default value)
436+
* `critical`
437+
* `error`
438+
* `warning`
439+
* `info`
440+
441+
```
442+
rubrik = rubrik_cdm.Connect(enable_logging=True, logging_level="info")
443+
```
444+
433445
When doing so, more verbose debug messages will be displayed on the console when executing various commands and functions within the Rubrik SDK for Python. For example, the `Connect()` function itself displays no information by default, however running the same function specifying enable_logging=True outputs the following:
434446

435447
```
436-
[2018-08-08 09:18:59,687] [DEBUG] -- User Provided Node IP: 172.21.8.53
437-
[2018-08-08 09:18:59,687] [DEBUG] -- Username: demo
438-
[2018-08-08 09:18:59,687] [DEBUG] -- Password: *******
448+
[2018-08-08 09:18:59,687] [INFO] -- User Provided Node IP: 172.21.8.53
449+
[2018-08-08 09:18:59,687] [INFO] -- Username: demo
450+
[2018-08-08 09:18:59,687] [INFO] -- Password: *******
439451
440-
[2018-08-08 09:18:59,687] [DEBUG] -- cluster_node_ip: Generating a list of all Cluster Node IPs.
441-
[2018-08-08 09:18:59,687] [DEBUG] -- GET https://172.21.8.53/api/internal/cluster/me/node
442-
[2018-08-08 09:19:00,062] [DEBUG] -- <Response [200]>
452+
[2018-08-08 09:18:59,687] [INFO] -- cluster_node_ip: Generating a list of all Cluster Node IPs.
453+
[2018-08-08 09:18:59,687] [INFO] -- GET https://172.21.8.53/api/internal/cluster/me/node
454+
[2018-08-08 09:19:00,062] [INFO] -- <Response [200]>
443455
444456
```
445457

docs/register_vm.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# register_vm
2+
3+
Register the Rubrik Backup Service on a vSphere VM.
4+
5+
```py
6+
def register_vm(self, name, timeout=15):
7+
```
8+
9+
## Arguments
10+
| Name | Type | Description | Choices |
11+
|------|------|-----------------------------|---------|
12+
| name | str | The name of the vSphere VM. | |
13+
14+
## Keyword Arguments
15+
| Name | Type | Description | Choices | Default |
16+
|---------|------|-----------------------------------------------------------------------------|---------|---------|
17+
| timeout | int | The number of seconds to wait to establish a connection the Rubrik cluster. | | 15 |
18+
19+
## Returns
20+
| Type | Return Value |
21+
|------|----------------------------------------------------------------------|
22+
| str | No change required. The VM `name` is already registered. |
23+
| dict | The result of the call for `POST /v1/vmware/vm/{id}/register_agent`. |
24+
25+
## Example
26+
```py
27+
import rubrik_cdm
28+
rubrik = rubrik_cdm.Connect()
29+
vm_name = "Python SDK"
30+
register_vbs_on_bm = rubrik.register_vm(vm_name)
31+
```

rubrik_cdm/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Rubrik, Inc.
1+
# Copyright 2020 Rubrik, Inc.
22
#
33
# Permission is hereby granted, free of charge, to any person obtaining a copy
44
# of this software and associated documentation files (the "Software"), to
@@ -72,9 +72,8 @@ def _common_api(self, call_type, api_version, api_endpoint, config=None, job_sta
7272
if call_type == 'GET':
7373
request_url = "https://{}/api/{}{}".format(self.node_ip, api_version, api_endpoint)
7474
if params is not None:
75-
request_url = request_url + "?" + '&'.join("{}={}".format(key, val)
75+
request_url = request_url + "?" + '&'.join("{}={}".format(key, quote(val))
7676
for (key, val) in params.items())
77-
request_url = quote(request_url, '://?=&[]')
7877
self.log('GET {}'.format(request_url))
7978
api_request = requests.get(
8079
request_url, verify=False, headers=header, timeout=timeout)

0 commit comments

Comments
 (0)