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

Commit ed209f2

Browse files
committed
Updated example file
1 parent e5c8713 commit ed209f2

File tree

1 file changed

+101
-22
lines changed

1 file changed

+101
-22
lines changed

examples/storage_volume_templates.py

Lines changed: 101 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,103 @@
3232
"userName": "administrator",
3333
"password": "ecosystem"
3434
},
35-
"api_version": 600
35+
"api_version": 500
3636
}
3737

3838
# Try load config from a file (if there is a config file)
3939
config = try_load_from_file(config)
4040

4141
oneview_client = OneViewClient(config)
4242

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

53134
oneview_client = OneViewClient(config)
@@ -57,7 +138,6 @@
57138
storage_pools = oneview_client.storage_pools.get_all()
58139
storage_pool_added = False
59140
storage_system_added = False
60-
61141
if storage_pools:
62142
storage_pool = storage_pools[0]
63143
print(" Found storage pool '{name}' at uri: '{uri}".format(**storage_pool))
@@ -103,11 +183,11 @@
103183

104184
# Create storage volume template
105185
print("Create storage volume template")
106-
#options["provisioning"]["storagePoolUri"] = storage_pool["uri"]
107-
print options
108186
volume_template = oneview_client.storage_volume_templates.create(options)
109187
pprint(volume_template)
110188

189+
template_id = volume_template["uri"].split('/')[-1]
190+
111191
# Update storage volume template
112192
print("Update '{name}' at uri: {uri}".format(**volume_template))
113193
volume_template['description'] = "updated description"
@@ -120,8 +200,6 @@
120200
for template in volume_templates:
121201
print(" '{name}' at uri: {uri}".format(**template))
122202

123-
template_id = volume_template["uri"].split("/")[-1]
124-
125203
# Get storage volume template by id
126204
try:
127205
print("Get storage volume template by id: '{}'".format(template_id))
@@ -141,17 +219,18 @@
141219
print(" Found '{name}' at uri: {uri}".format(**volume_template_byname))
142220

143221
# Gets the storage templates that are connected on the specified networks
144-
#print("Storage templates that are connected on the specified networks")
145-
#storage_templates=oneview_client.storage_volume_templates.get_reachable_volume_templates(
146-
# networks='/rest/fcoe-networks/7f0f74a0-4957-47ac-81c1-f573aa6d83de',
147-
# scope_uris='/rest/scopes/63d1ca81-95b3-41f1-a1ee-f9e1bc2d635f',
148-
# private_allowed_only=False)
149-
#print(storage_templates)
222+
print("Get torage templates that are connected on the specified networks")
223+
storage_templates=oneview_client.storage_volume_templates.get_reachable_volume_templates(
224+
networks="/rest/fcoe-networks/7f0f74a0-4957-47ac-81c1-f573aa6d83de,",
225+
scope_uris="/rest/scopes/63d1ca81-95b3-41f1-a1ee-f9e1bc2d635f",
226+
private_allowed_only=False)
227+
print(storage_templates)
150228

151229
# Retrieves all storage systems that is applicable to the storage volume template.
152-
#print("Storage systems that is applicable to the storage volume template")
153-
#storage_systems = oneview_client.storage_volume_templates.get_compatible_systems(id_or_uri=template_id)
154-
#print(storage_systems)
230+
print("Get storage systems that is applicable to the storage volume template")
231+
storage_systems = oneview_client.storage_volume_templates.get_compatible_systems(
232+
id_or_uri=template_id)
233+
print(storage_systems)
155234

156235
# Remove storage volume template
157236
print("Delete storage volume template")

0 commit comments

Comments
 (0)