|
32 | 32 | "userName": "administrator", |
33 | 33 | "password": "ecosystem" |
34 | 34 | }, |
35 | | - "api_version": 600 |
| 35 | + "api_version": 500 |
36 | 36 | } |
37 | 37 |
|
38 | 38 | # Try load config from a file (if there is a config file) |
39 | 39 | config = try_load_from_file(config) |
40 | 40 |
|
41 | 41 | oneview_client = OneViewClient(config) |
42 | 42 |
|
| 43 | +# Request body for create operation |
| 44 | +# Supported from API version >= 500 |
43 | 45 | 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" |
51 | 132 | } |
52 | 133 |
|
53 | 134 | oneview_client = OneViewClient(config) |
|
57 | 138 | storage_pools = oneview_client.storage_pools.get_all() |
58 | 139 | storage_pool_added = False |
59 | 140 | storage_system_added = False |
60 | | - |
61 | 141 | if storage_pools: |
62 | 142 | storage_pool = storage_pools[0] |
63 | 143 | print(" Found storage pool '{name}' at uri: '{uri}".format(**storage_pool)) |
|
103 | 183 |
|
104 | 184 | # Create storage volume template |
105 | 185 | print("Create storage volume template") |
106 | | -#options["provisioning"]["storagePoolUri"] = storage_pool["uri"] |
107 | | -print options |
108 | 186 | volume_template = oneview_client.storage_volume_templates.create(options) |
109 | 187 | pprint(volume_template) |
110 | 188 |
|
| 189 | +template_id = volume_template["uri"].split('/')[-1] |
| 190 | + |
111 | 191 | # Update storage volume template |
112 | 192 | print("Update '{name}' at uri: {uri}".format(**volume_template)) |
113 | 193 | volume_template['description'] = "updated description" |
|
120 | 200 | for template in volume_templates: |
121 | 201 | print(" '{name}' at uri: {uri}".format(**template)) |
122 | 202 |
|
123 | | -template_id = volume_template["uri"].split("/")[-1] |
124 | | - |
125 | 203 | # Get storage volume template by id |
126 | 204 | try: |
127 | 205 | print("Get storage volume template by id: '{}'".format(template_id)) |
|
141 | 219 | print(" Found '{name}' at uri: {uri}".format(**volume_template_byname)) |
142 | 220 |
|
143 | 221 | # 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) |
150 | 228 |
|
151 | 229 | # 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) |
155 | 234 |
|
156 | 235 | # Remove storage volume template |
157 | 236 | print("Delete storage volume template") |
|
0 commit comments