|
39 | 39 |
|
40 | 40 | oneview_client = OneViewClient(config) |
41 | 41 |
|
| 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 |
42 | 47 | 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" |
49 | 130 | } |
| 131 | + }, |
| 132 | + "name": "test_02", |
| 133 | + "description": "desc" |
50 | 134 | } |
51 | 135 |
|
52 | 136 | oneview_client = OneViewClient(config) |
|
101 | 185 |
|
102 | 186 | # Create storage volume template |
103 | 187 | print("Create storage volume template") |
104 | | -options['provisioning']['storagePoolUri'] = storage_pool['uri'] |
105 | 188 | volume_template = oneview_client.storage_volume_templates.create(options) |
106 | 189 | pprint(volume_template) |
107 | 190 |
|
| 191 | +template_id = volume_template["uri"].split('/')[-1] |
| 192 | + |
108 | 193 | # Update storage volume template |
109 | 194 | print("Update '{name}' at uri: {uri}".format(**volume_template)) |
110 | 195 | volume_template['description'] = "updated description" |
|
119 | 204 |
|
120 | 205 | # Get storage volume template by id |
121 | 206 | try: |
122 | | - template_id = "71e74304-0697-4fd7-997b-2385fe98b5b4" |
123 | 207 | print("Get storage volume template by id: '{}'".format(template_id)) |
124 | 208 | volume_template_byid = oneview_client.storage_volume_templates.get(template_id) |
125 | 209 | print(" Found '{name}' at uri: {uri}".format(**volume_template_byid)) |
|
136 | 220 | volume_template_byname = oneview_client.storage_volume_templates.get_by('name', volume_template['name'])[0] |
137 | 221 | print(" Found '{name}' at uri: {uri}".format(**volume_template_byname)) |
138 | 222 |
|
| 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 | + |
139 | 236 | # Remove storage volume template |
140 | 237 | print("Delete storage volume template") |
141 | 238 | oneview_client.storage_volume_templates.delete(volume_template) |
|
0 commit comments