Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit e2ac671

Browse files
authored
Merge pull request #382 from HewlettPackard/upgrade/600/os_volumes
Upgrade/600/os volumes
2 parents 5ed378d + d45832e commit e2ac671

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Updated support for HPE Synergy Image Streamer REST API 500/600.
99
- Interconnect
1010
- Network set
1111
- OS deployment plan
12+
- OS volume
1213
- Plan script
1314
- Storage pool
1415
- Storage system

endpoints-support.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@
611611
|<sub> /rest/build-plans/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
612612
|<sub> /rest/build-plans/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
613613
| **OS Volumes** |
614-
|<sub> /rest/os-volumes</sub> | GET | :white_check_mark: |
615-
|<sub> /rest/os-volumes/{id}</sub> | GET | :white_check_mark: |
616-
|<sub> /rest/os-volumes/archive/{id}</sub> | GET | :white_check_mark: |
614+
|<sub> /rest/os-volumes</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
615+
|<sub> /rest/os-volumes/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
616+
|<sub> /rest/os-volumes/archive/{name}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
617+
|<sub> /rest/os-volumes/{id}/storage</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
617618
| **Plan Scripts** |
618619
|<sub> /rest/plan-scripts</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
619620
|<sub> /rest/plan-scripts/differences/{id}</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |

examples/image_streamer/os_volumes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@
5555
os_volume = image_streamer_client.os_volumes.get_by_name(os_volumes_information['name'])
5656
pprint(os_volume)
5757

58+
# Get storage details (available only with API version 600 and above)
59+
print("Get storage details")
60+
storage = image_streamer_client.os_volumes.get_storage(os_volumes_information['id'])
61+
pprint(storage)
5862

5963
# Retrieve archived logs of the OS Volume
6064
print("Retrieve archived logs of the OS Volume")
61-
if image_streamer_client.os_volumes.download_archive(os_volume['uri'], destination_archive_path):
65+
if image_streamer_client.os_volumes.download_archive(os_volume['name'], destination_archive_path):
6266
print(" File downloaded successfully.")
6367
else:
6468
print(" Error downloading the file.")

hpOneView/image_streamer/resources/os_volumes.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,29 @@ def get_by_name(self, name):
107107
"""
108108
return self._client.get_by_name(name)
109109

110-
def download_archive(self, id_or_uri, file_path):
110+
def download_archive(self, name, file_path):
111111
"""
112-
Download the details of the archived OS Volume.
112+
Download archived logs of the OS Volume.
113113
114114
Args:
115-
id_or_uri: ID or URI of the OS Volume.
115+
name: Name of the OS Volume.
116116
file_path (str): Destination file path.
117117
118118
Returns:
119119
bool: Indicates if the resource was successfully downloaded.
120120
"""
121-
uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
121+
uri = self.URI + "/archive/" + name
122122
return self._client.download(uri, file_path)
123+
124+
def get_storage(self, id_or_uri):
125+
"""
126+
Get storage details of an OS Volume.
127+
128+
Args:
129+
id_or_uri: ID or URI of the OS Volume.
130+
131+
Returns:
132+
dict: Storage details
133+
"""
134+
uri = self.URI + "/{}/storage".format(extract_id_from_uri(id_or_uri))
135+
return self._client.get(uri)

tests/unit/image_streamer/resources/test_os_volumes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,14 @@ def test_download_archive_called_once_with_id(self, mock_download):
8282

8383
@mock.patch.object(ResourceClient, 'download')
8484
def test_download_archive_called_once_with_uri(self, mock_download):
85-
uri = '/rest/os-volumes/archive/3518be0e-17c1-4189-8f81-83f3724f6155'
85+
name = "fake"
86+
uri = '/rest/os-volumes/archive/fake'
8687

87-
self._client.download_archive(uri, "~/archive.log")
88+
self._client.download_archive(name, "~/archive.log")
89+
mock_download.assert_called_once_with(uri, '~/archive.log')
8890

89-
mock_download.assert_called_once_with('/rest/os-volumes/archive/3518be0e-17c1-4189-8f81-83f3724f6155',
90-
'~/archive.log')
91+
@mock.patch.object(ResourceClient, 'get')
92+
def test_get_storage(self, mock_get):
93+
volume_id = '3518be0e-17c1-4189-8f81-83f3724f6155'
94+
self._client.get_storage(volume_id)
95+
mock_get.assert_called_once_with('/rest/os-volumes/3518be0e-17c1-4189-8f81-83f3724f6155/storage')

0 commit comments

Comments
 (0)