Skip to content

Commit 356476f

Browse files
authored
[AutoPR compute/resource-manager] Set location for the final state option of the POST long running disk… (#3431)
* Generated from 001427fae9affdb238c7bcb30cf81da5fd96e546 Set location for the final state option of the POST long running disk operations. * GrantAccess test (#3430)
1 parent b191e1b commit 356476f

File tree

6 files changed

+227
-9
lines changed

6 files changed

+227
-9
lines changed

azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/disks_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def get_long_running_output(response):
633633
lro_delay = operation_config.get(
634634
'long_running_operation_timeout',
635635
self.config.long_running_operation_timeout)
636-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
636+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
637637
elif polling is False: polling_method = NoPolling()
638638
else: polling_method = polling
639639
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
@@ -715,7 +715,7 @@ def get_long_running_output(response):
715715
lro_delay = operation_config.get(
716716
'long_running_operation_timeout',
717717
self.config.long_running_operation_timeout)
718-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
718+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
719719
elif polling is False: polling_method = NoPolling()
720720
else: polling_method = polling
721721
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)

azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/snapshots_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def get_long_running_output(response):
633633
lro_delay = operation_config.get(
634634
'long_running_operation_timeout',
635635
self.config.long_running_operation_timeout)
636-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
636+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
637637
elif polling is False: polling_method = NoPolling()
638638
else: polling_method = polling
639639
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
@@ -715,7 +715,7 @@ def get_long_running_output(response):
715715
lro_delay = operation_config.get(
716716
'long_running_operation_timeout',
717717
self.config.long_running_operation_timeout)
718-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
718+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
719719
elif polling is False: polling_method = NoPolling()
720720
else: polling_method = polling
721721
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)

azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/disks_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def get_long_running_output(response):
633633
lro_delay = operation_config.get(
634634
'long_running_operation_timeout',
635635
self.config.long_running_operation_timeout)
636-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
636+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
637637
elif polling is False: polling_method = NoPolling()
638638
else: polling_method = polling
639639
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
@@ -715,7 +715,7 @@ def get_long_running_output(response):
715715
lro_delay = operation_config.get(
716716
'long_running_operation_timeout',
717717
self.config.long_running_operation_timeout)
718-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
718+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
719719
elif polling is False: polling_method = NoPolling()
720720
else: polling_method = polling
721721
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)

azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/snapshots_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def get_long_running_output(response):
633633
lro_delay = operation_config.get(
634634
'long_running_operation_timeout',
635635
self.config.long_running_operation_timeout)
636-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
636+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
637637
elif polling is False: polling_method = NoPolling()
638638
else: polling_method = polling
639639
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
@@ -715,7 +715,7 @@ def get_long_running_output(response):
715715
lro_delay = operation_config.get(
716716
'long_running_operation_timeout',
717717
self.config.long_running_operation_timeout)
718-
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
718+
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
719719
elif polling is False: polling_method = NoPolling()
720720
else: polling_method = polling
721721
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
interactions:
2+
- request:
3+
body: '{"location": "westus", "properties": {"creationData": {"createOption":
4+
"Empty"}, "diskSizeGB": 20}}'
5+
headers:
6+
Accept: [application/json]
7+
Accept-Encoding: ['gzip, deflate']
8+
Connection: [keep-alive]
9+
Content-Length: ['99']
10+
Content-Type: [application/json; charset=utf-8]
11+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
12+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
13+
accept-language: [en-US]
14+
method: PUT
15+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_managed_disks_test_grant_access609310b8/providers/Microsoft.Compute/disks/my_disk_name?api-version=2018-06-01
16+
response:
17+
body: {string: "{\r\n \"sku\": {\r\n \"name\": \"Standard_LRS\",\r\n \"\
18+
tier\": \"Standard\"\r\n },\r\n \"properties\": {\r\n \"creationData\"\
19+
: {\r\n \"createOption\": \"Empty\"\r\n },\r\n \"diskSizeGB\":\
20+
\ 20,\r\n \"provisioningState\": \"Updating\",\r\n \"isArmResource\"\
21+
: true,\r\n \"faultDomain\": 0\r\n },\r\n \"location\": \"westus\",\r\
22+
\n \"name\": \"my_disk_name\"\r\n}"}
23+
headers:
24+
azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/7db72277-5593-47a1-9052-2abfb61c958d?api-version=2018-06-01']
25+
cache-control: [no-cache]
26+
content-length: ['324']
27+
content-type: [application/json; charset=utf-8]
28+
date: ['Tue, 25 Sep 2018 18:27:19 GMT']
29+
expires: ['-1']
30+
location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/7db72277-5593-47a1-9052-2abfb61c958d?monitor=true&api-version=2018-06-01']
31+
pragma: [no-cache]
32+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
33+
strict-transport-security: [max-age=31536000; includeSubDomains]
34+
x-content-type-options: [nosniff]
35+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/CreateUpdateDisks3Min;999,Microsoft.Compute/CreateUpdateDisks30Min;3998']
36+
x-ms-ratelimit-remaining-subscription-writes: ['1199']
37+
status: {code: 202, message: Accepted}
38+
- request:
39+
body: null
40+
headers:
41+
Accept: [application/json]
42+
Accept-Encoding: ['gzip, deflate']
43+
Connection: [keep-alive]
44+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
45+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
46+
method: GET
47+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/7db72277-5593-47a1-9052-2abfb61c958d?api-version=2018-06-01
48+
response:
49+
body: {string: "{\r\n \"startTime\": \"2018-09-25T18:27:19.9691669+00:00\",\r\
50+
\n \"endTime\": \"2018-09-25T18:27:20.1254636+00:00\",\r\n \"status\": \"\
51+
Succeeded\",\r\n \"properties\": {\r\n \"output\": {\"sku\":{\"name\"\
52+
:\"Standard_LRS\",\"tier\":\"Standard\"},\"properties\":{\"creationData\"\
53+
:{\"createOption\":\"Empty\"},\"diskSizeGB\":20,\"timeCreated\":\"2018-09-25T18:23:01.8100645+00:00\"\
54+
,\"provisioningState\":\"Succeeded\",\"diskState\":\"ActiveSAS\"},\"type\"\
55+
:\"Microsoft.Compute/disks\",\"location\":\"westus\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_managed_disks_test_grant_access609310b8/providers/Microsoft.Compute/disks/my_disk_name\"\
56+
,\"name\":\"my_disk_name\"}\r\n },\r\n \"name\": \"7db72277-5593-47a1-9052-2abfb61c958d\"\
57+
\r\n}"}
58+
headers:
59+
cache-control: [no-cache]
60+
content-length: ['697']
61+
content-type: [application/json; charset=utf-8]
62+
date: ['Tue, 25 Sep 2018 18:27:50 GMT']
63+
expires: ['-1']
64+
pragma: [no-cache]
65+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
66+
strict-transport-security: [max-age=31536000; includeSubDomains]
67+
transfer-encoding: [chunked]
68+
vary: [Accept-Encoding]
69+
x-content-type-options: [nosniff]
70+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49998,Microsoft.Compute/GetOperation30Min;249993']
71+
status: {code: 200, message: OK}
72+
- request:
73+
body: null
74+
headers:
75+
Accept: [application/json]
76+
Accept-Encoding: ['gzip, deflate']
77+
Connection: [keep-alive]
78+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
79+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
80+
method: GET
81+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_managed_disks_test_grant_access609310b8/providers/Microsoft.Compute/disks/my_disk_name?api-version=2018-06-01
82+
response:
83+
body: {string: "{\r\n \"sku\": {\r\n \"name\": \"Standard_LRS\",\r\n \"\
84+
tier\": \"Standard\"\r\n },\r\n \"properties\": {\r\n \"creationData\"\
85+
: {\r\n \"createOption\": \"Empty\"\r\n },\r\n \"diskSizeGB\":\
86+
\ 20,\r\n \"timeCreated\": \"2018-09-25T18:23:01.8100645+00:00\",\r\n \
87+
\ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"ActiveSAS\"\
88+
\r\n },\r\n \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"\
89+
westus\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_managed_disks_test_grant_access609310b8/providers/Microsoft.Compute/disks/my_disk_name\"\
90+
,\r\n \"name\": \"my_disk_name\"\r\n}"}
91+
headers:
92+
cache-control: [no-cache]
93+
content-length: ['576']
94+
content-type: [application/json; charset=utf-8]
95+
date: ['Tue, 25 Sep 2018 18:27:51 GMT']
96+
expires: ['-1']
97+
pragma: [no-cache]
98+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
99+
strict-transport-security: [max-age=31536000; includeSubDomains]
100+
transfer-encoding: [chunked]
101+
vary: [Accept-Encoding]
102+
x-content-type-options: [nosniff]
103+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/LowCostGet3Min;4997,Microsoft.Compute/LowCostGet30Min;19994']
104+
status: {code: 200, message: OK}
105+
- request:
106+
body: '{"access": "Read", "durationInSeconds": 1}'
107+
headers:
108+
Accept: [application/json]
109+
Accept-Encoding: ['gzip, deflate']
110+
Connection: [keep-alive]
111+
Content-Length: ['42']
112+
Content-Type: [application/json; charset=utf-8]
113+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
114+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
115+
accept-language: [en-US]
116+
method: POST
117+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_mgmt_managed_disks_test_grant_access609310b8/providers/Microsoft.Compute/disks/my_disk_name/beginGetAccess?api-version=2018-06-01
118+
response:
119+
body: {string: ''}
120+
headers:
121+
azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/993880d3-35d5-4d69-95a1-e41256ac1613?api-version=2018-06-01']
122+
cache-control: [no-cache]
123+
content-length: ['0']
124+
date: ['Tue, 25 Sep 2018 18:27:51 GMT']
125+
expires: ['-1']
126+
location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/993880d3-35d5-4d69-95a1-e41256ac1613?monitor=true&api-version=2018-06-01']
127+
pragma: [no-cache]
128+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
129+
strict-transport-security: [max-age=31536000; includeSubDomains]
130+
x-content-type-options: [nosniff]
131+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/HighCostDiskHydrate3Min;999,Microsoft.Compute/HighCostDiskHydrate30Min;4998']
132+
x-ms-ratelimit-remaining-subscription-writes: ['1199']
133+
status: {code: 202, message: Accepted}
134+
- request:
135+
body: null
136+
headers:
137+
Accept: [application/json]
138+
Accept-Encoding: ['gzip, deflate']
139+
Connection: [keep-alive]
140+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
141+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
142+
method: GET
143+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/993880d3-35d5-4d69-95a1-e41256ac1613?api-version=2018-06-01
144+
response:
145+
body: {string: "{\r\n \"startTime\": \"2018-09-25T18:27:51.654499+00:00\",\r\n\
146+
\ \"endTime\": \"2018-09-25T18:27:51.8264577+00:00\",\r\n \"status\": \"\
147+
Succeeded\",\r\n \"properties\": {\r\n \"output\": {\r\n \"accessSAS\"\
148+
: \"https://md-vdd32wngvswn.blob.core.windows.net/xxggg2fjdrc0/abcd?sv=2017-04-17&sr=b&si=65f2b00c-36ab-4483-928b-cef4b46bbffa&sig=TFnp%2BE69nqvjmIf%2Bpi9dX8cIiHQ9nxeDmIioKslwxvs%3D\"\
149+
\r\n}\r\n },\r\n \"name\": \"993880d3-35d5-4d69-95a1-e41256ac1613\"\r\n}"}
150+
headers:
151+
cache-control: [no-cache]
152+
content-length: ['424']
153+
content-type: [application/json; charset=utf-8]
154+
date: ['Tue, 25 Sep 2018 18:28:22 GMT']
155+
expires: ['-1']
156+
pragma: [no-cache]
157+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
158+
strict-transport-security: [max-age=31536000; includeSubDomains]
159+
transfer-encoding: [chunked]
160+
vary: [Accept-Encoding]
161+
x-content-type-options: [nosniff]
162+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49996,Microsoft.Compute/GetOperation30Min;249991']
163+
status: {code: 200, message: OK}
164+
- request:
165+
body: null
166+
headers:
167+
Accept: [application/json]
168+
Accept-Encoding: ['gzip, deflate']
169+
Connection: [keep-alive]
170+
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
171+
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
172+
method: GET
173+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/993880d3-35d5-4d69-95a1-e41256ac1613?monitor=true&api-version=2018-06-01
174+
response:
175+
body: {string: "{\r\n \"accessSAS\": \"https://md-vdd32wngvswn.blob.core.windows.net/xxggg2fjdrc0/abcd?sv=2017-04-17&sr=b&si=65f2b00c-36ab-4483-928b-cef4b46bbffa&sig=TFnp%2BE69nqvjmIf%2Bpi9dX8cIiHQ9nxeDmIioKslwxvs%3D\"\
176+
\r\n}"}
177+
headers:
178+
cache-control: [no-cache]
179+
content-length: ['200']
180+
content-type: [application/json; charset=utf-8]
181+
date: ['Tue, 25 Sep 2018 18:28:22 GMT']
182+
expires: ['-1']
183+
pragma: [no-cache]
184+
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
185+
strict-transport-security: [max-age=31536000; includeSubDomains]
186+
transfer-encoding: [chunked]
187+
vary: [Accept-Encoding]
188+
x-content-type-options: [nosniff]
189+
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49995,Microsoft.Compute/GetOperation30Min;249990']
190+
status: {code: 200, message: OK}
191+
version: 1

azure-mgmt-compute/tests/test_mgmt_managed_disks.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,33 @@ def test_empty_md(self, resource_group, location):
5454
)
5555
disk_resource = async_creation.result()
5656

57+
@ResourceGroupPreparer()
58+
def test_grant_access(self, resource_group, location):
59+
'''Create an empty Managed Disk.'''
60+
DiskCreateOption = self.compute_client.disks.models.DiskCreateOption
61+
62+
async_creation = self.compute_client.disks.create_or_update(
63+
resource_group.name,
64+
'my_disk_name',
65+
{
66+
'location': location,
67+
'disk_size_gb': 20,
68+
'creation_data': {
69+
'create_option': DiskCreateOption.empty
70+
}
71+
}
72+
)
73+
disk_resource = async_creation.result()
74+
75+
grant_access_poller = self.compute_client.disks.grant_access(
76+
resource_group.name,
77+
'my_disk_name',
78+
'Read',
79+
'1',
80+
)
81+
access_uri = grant_access_poller.result()
82+
assert access_uri.access_sas is not None
83+
5784
@ResourceGroupPreparer()
5885
def test_md_from_storage_blob(self, resource_group, location):
5986
'''Create a Managed Disk from Blob Storage.'''
@@ -334,7 +361,7 @@ def test_create_virtual_machine_scale_set(self, resource_group, location):
334361
'name': naming_infix + 'ipconfig',
335362
'subnet': {
336363
'id': subnet_id
337-
}
364+
}
338365
}]
339366
}]
340367
}

0 commit comments

Comments
 (0)