You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/how-to-use-dscc-api-and-ansible-to-collect-the-storage-configuration.md
+76-3Lines changed: 76 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,9 @@ Now in order to be independent of any python library (or the lack of updates to
26
26
27
27
## Retrieving a DSCC access token
28
28
29
-
The steps to first generate the client Id and the client secret used to access the DSCC REST API was already described in a blog on the HPE Developer Portal: <!--StartFragment-->[Using HPE GreenLake Console's API Gateway for Data Services Cloud Console ](https://developer.hpe.com/blog/api-console-for-data-services-cloud-console/)<!--EndFragment-->.
29
+
The steps to first generate the client id and the client secret used to access the DSCC REST API was already described in a blog on the HPE Developer Portal: <!--StartFragment-->[Using HPE GreenLake Console's API Gateway for Data Services Cloud Console ](https://developer.hpe.com/blog/api-console-for-data-services-cloud-console/)<!--EndFragment-->.
30
30
31
-
Once you do have your client id and client secret, you can generate an access token that is valid for two hours.
31
+
Once you do have your client id and client secret, you can generate an access token, that is valid for two hours. This access token will allow you to issue REST API calls to the Data Services Cloud Console - you will have the empowerment on the REST API as the user that is linked with the client id and secret used to create the access token. Hence, it is best practice to store the client id and secret in a secure place. The below code example had the client credentials stored in the credentials.yml file, that was encrypted using ansible-vault. The current Ansible playbook stores the access token in a file that grants access only to the current user (hence, the access mode 600 for this file) to avoid misuse of the retrieved access token.
32
32
33
33
```
34
34
- name: Include encrypted vars
@@ -53,11 +53,15 @@ Once you do have your client id and client secret, you can generate an access to
53
53
ansible.builtin.copy:
54
54
content: "{{ token }}"
55
55
dest: 'vars/token.txt'
56
-
mode: "0644"
56
+
mode: "0600"
57
57
```
58
58
59
59
## DSCC REST API call
60
60
61
+
62
+
63
+
64
+
61
65
```
62
66
- name: Include encrypted vars
63
67
include_vars: vars/credentials.yml
@@ -125,6 +129,75 @@ Once you do have your client id and client secret, you can generate an access to
125
129
when: status not in ['200', '201', '202','401']
126
130
```
127
131
132
+
133
+
134
+
135
+
136
+
# System Configuration capture
137
+
138
+
```
139
+
hosts: localhost
140
+
vars:
141
+
method: "GET"
142
+
143
+
tasks:
144
+
- name: DSCC API Call GET storage systems
145
+
vars:
146
+
request_uri: "/api/v1/storage-systems"
147
+
ansible.builtin.include_tasks:
148
+
file: DSCC-API-Call.yaml
149
+
150
+
- name: Retry the command if status 401
151
+
vars:
152
+
request_uri: "/api/v1/storage-systems"
153
+
ansible.builtin.include_tasks:
154
+
file: DSCC-API-401.yaml
155
+
when: status == '401'
156
+
157
+
- name: Set Systems
158
+
ansible.builtin.set_fact:
159
+
systems: "{{ response.json['items'] }}"
160
+
when: status in ['200', '201']
161
+
162
+
- name: Initialize Storage system dictionary if not defined
0 commit comments