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

Commit 736e5ce

Browse files
Merge pull request #368 from HewlettPackard/upgrade/600/storage-volume-temlates
Upgrade/600/storage volume temlates
2 parents 5ea7690 + b5bf6ea commit 736e5ce

File tree

5 files changed

+123
-27
lines changed

5 files changed

+123
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Extends support of the SDK to OneView Rest API version 600 (OneView v4.0).
2626
- Server hardware
2727
- Server profile
2828
- Server profile template
29+
- Storage volume template
2930
- Switch
3031
- Switch type
3132
- Tasks

endpoints-support.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,14 @@
491491
|<sub>/rest/storage-volume-attachments/{attachmentId}/paths</sub> | GET | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |
492492
|<sub>/rest/storage-volume-attachments/{attachmentId)/paths/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |
493493
| **Storage Volume Templates** |
494-
|<sub>/rest/storage-volume-templates</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
495-
|<sub>/rest/storage-volume-templates</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
496-
|<sub>/rest/storage-volume-templates/connectable-volume-templates</sub> | GET | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |
497-
|<sub>/rest/storage-volume-templates/reachable-volume-templates</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
498-
|<sub>/rest/storage-volume-templates/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
499-
|<sub>/rest/storage-volume-templates/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
500-
|<sub>/rest/storage-volume-templates/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
501-
|<sub>/rest/storage-volume-templates/{id}/compatible-systems</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
494+
|<sub>/rest/storage-volume-templates</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
495+
|<sub>/rest/storage-volume-templates</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
496+
|<sub>/rest/storage-volume-templates/connectable-volume-templates</sub> | GET | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: | :heavy_minus_sign:
497+
|<sub>/rest/storage-volume-templates/reachable-volume-templates</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark:
498+
|<sub>/rest/storage-volume-templates/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
499+
|<sub>/rest/storage-volume-templates/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
500+
|<sub>/rest/storage-volume-templates/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
501+
|<sub>/rest/storage-volume-templates/{id}/compatible-systems</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark:
502502
| **Switch Types** |
503503
|<sub>/rest/switch-types</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
504504
|<sub>/rest/switch-types/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

examples/storage_volume_templates.py

Lines changed: 105 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,98 @@
3939

4040
oneview_client = OneViewClient(config)
4141

42+
networks = "/rest/fcoe-networks/7f0f74a0-4957-47ac-81c1-f573aa6d83de"
43+
scope_uris = "/rest/scopes/63d1ca81-95b3-41f1-a1ee-f9e1bc2d635f"
44+
45+
# Request body for create operation
46+
# Supported from API version >= 500
4247
options = {
43-
"name": "OneView Test Volume Template",
44-
"provisioning":
45-
{
46-
"capacity": "235834383322",
47-
"provisionType": "Thin",
48-
"storagePoolUri": ""
48+
"rootTemplateUri": "/rest/storage-volume-templates/5dbaf127-053b-4988-82fe-a80800eef1f3",
49+
"properties": {
50+
"name": {
51+
"title": "Volume name",
52+
"description": "A volume name between 1 and 100 characters",
53+
"meta": {"locked": "false"},
54+
"type": "string",
55+
"required": "true",
56+
"maxLength": 100,
57+
"minLength": 1},
58+
59+
"size": {
60+
"meta": {
61+
"locked": "false",
62+
"semanticType": "capacity"
63+
},
64+
"type": "integer",
65+
"title": "Capacity",
66+
"default": 1073741824,
67+
"maximum": 17592186044416,
68+
"minimum": 268435456,
69+
"required": "true",
70+
"description": "The capacity of the volume in bytes"
71+
},
72+
"description": {
73+
"meta": {
74+
"locked": "false"
75+
},
76+
"type": "string",
77+
"title": "Description",
78+
"default": "",
79+
"maxLength": 2000,
80+
"minLength": 0,
81+
"description": "A description for the volume"
82+
},
83+
"isShareable": {
84+
"meta": {
85+
"locked": "false"
86+
},
87+
"type": "boolean",
88+
"title": "Is Shareable",
89+
"default": "false",
90+
"description": "The shareability of the volume"
91+
},
92+
"storagePool": {
93+
"meta": {
94+
"locked": "false",
95+
"createOnly": "true",
96+
"semanticType": "device-storage-pool"
97+
},
98+
"type": "string",
99+
"title": "Storage Pool",
100+
"format": "x-uri-reference",
101+
"required": "true",
102+
"description": "A common provisioning group URI reference",
103+
"default": "/rest/storage-pools/0DB2A6C7-04D3-4830-9229-A80800EEF1F1"
104+
},
105+
"snapshotPool": {
106+
"meta": {
107+
"locked": "true",
108+
"semanticType": "device-snapshot-storage-pool"
109+
},
110+
"type": "string",
111+
"title": "Snapshot Pool",
112+
"format": "x-uri-reference",
113+
"default": "/rest/storage-pools/0DB2A6C7-04D3-4830-9229-A80800EEF1F1",
114+
"description": "A URI reference to the common provisioning group used to create snapshots"
115+
},
116+
"provisioningType": {
117+
"enum": [
118+
"Thin",
119+
"Full",
120+
"Thin Deduplication"
121+
],
122+
"meta": {
123+
"locked": "true",
124+
"createOnly": "true"
125+
},
126+
"type": "string",
127+
"title": "Provisioning Type",
128+
"default": "Thin",
129+
"description": "The provisioning type for the volume"
49130
}
131+
},
132+
"name": "test_02",
133+
"description": "desc"
50134
}
51135

52136
oneview_client = OneViewClient(config)
@@ -101,10 +185,11 @@
101185

102186
# Create storage volume template
103187
print("Create storage volume template")
104-
options['provisioning']['storagePoolUri'] = storage_pool['uri']
105188
volume_template = oneview_client.storage_volume_templates.create(options)
106189
pprint(volume_template)
107190

191+
template_id = volume_template["uri"].split('/')[-1]
192+
108193
# Update storage volume template
109194
print("Update '{name}' at uri: {uri}".format(**volume_template))
110195
volume_template['description'] = "updated description"
@@ -119,7 +204,6 @@
119204

120205
# Get storage volume template by id
121206
try:
122-
template_id = "71e74304-0697-4fd7-997b-2385fe98b5b4"
123207
print("Get storage volume template by id: '{}'".format(template_id))
124208
volume_template_byid = oneview_client.storage_volume_templates.get(template_id)
125209
print(" Found '{name}' at uri: {uri}".format(**volume_template_byid))
@@ -136,6 +220,19 @@
136220
volume_template_byname = oneview_client.storage_volume_templates.get_by('name', volume_template['name'])[0]
137221
print(" Found '{name}' at uri: {uri}".format(**volume_template_byname))
138222

223+
# Gets the storage templates that are connected on the specified networks
224+
# scoper_uris and private_allowed_only parameters supported only with API version >= 600
225+
print("Get torage templates that are connected on the specified networks")
226+
storage_templates = oneview_client.storage_volume_templates.get_reachable_volume_templates(
227+
networks=networks, scope_uris=scope_uris, private_allowed_only=False)
228+
print(storage_templates)
229+
230+
# Retrieves all storage systems that is applicable to the storage volume template.
231+
print("Get storage systems that is applicable to the storage volume template")
232+
storage_systems = oneview_client.storage_volume_templates.get_compatible_systems(
233+
id_or_uri=template_id)
234+
print(storage_systems)
235+
139236
# Remove storage volume template
140237
print("Delete storage volume template")
141238
oneview_client.storage_volume_templates.delete(volume_template)

hpOneView/resources/storage/storage_volume_templates.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ def get_connectable_volume_templates(self, start=0, count=-1, filter='', query='
115115
"""
116116
uri = self.URI + "/connectable-volume-templates"
117117

118-
get_uri = self._client.build_query_uri(start=start, count=count, filter=filter, query=query, sort=sort, uri=uri)
118+
get_uri = self._client.build_query_uri(start=start, count=count, filter=filter,
119+
query=query, sort=sort, uri=uri)
119120
return self._client.get(get_uri)
120121

121-
def get_reachable_volume_templates(self, start=0, count=-1, filter='', query='', sort='', networks=[]):
122+
def get_reachable_volume_templates(self, start=0, count=-1, filter='', query='', sort='',
123+
networks=None, scope_uris='', private_allowed_only=False):
122124
"""
123125
Gets the storage templates that are connected on the specified networks based on the storage system
124126
port's expected network connectivity.
@@ -128,14 +130,10 @@ def get_reachable_volume_templates(self, start=0, count=-1, filter='', query='',
128130
"""
129131
uri = self.URI + "/reachable-volume-templates"
130132

131-
if networks:
132-
elements = "\'"
133-
for n in networks:
134-
elements += n + ','
135-
elements = elements[:-1] + "\'"
136-
uri = uri + "?networks=" + elements
133+
uri += "?networks={}&privateAllowedOnly={}".format(networks, private_allowed_only)
137134

138-
get_uri = self._client.build_query_uri(start=start, count=count, filter=filter, query=query, sort=sort, uri=uri)
135+
get_uri = self._client.build_query_uri(start=start, count=count, filter=filter,
136+
query=query, sort=sort, uri=uri, scope_uris=scope_uris)
139137
return self._client.get(get_uri)
140138

141139
def get_compatible_systems(self, id_or_uri):

tests/unit/resources/storage/test_storage_volume_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def test_get_connectable_volume_templates_called_once(self, mock_get):
102102

103103
@mock.patch.object(ResourceClient, 'get')
104104
def test_get_reachable_volume_templates_called_once(self, mock_get):
105-
uri = '/rest/storage-volume-templates/reachable-volume-templates?networks=\'/rest/fake\'&start=0&count=-1'
106-
self._storage_volume_templates.get_reachable_volume_templates(networks=['/rest/fake'])
105+
uri = '/rest/storage-volume-templates/reachable-volume-templates?networks=/rest/fake&privateAllowedOnly=False&start=0&count=-1'
106+
self._storage_volume_templates.get_reachable_volume_templates(networks='/rest/fake')
107107
mock_get.assert_called_once_with(uri)
108108

109109
@mock.patch.object(ResourceClient, 'get')

0 commit comments

Comments
 (0)