Skip to content

Commit

Permalink
[AutoPR compute/resource-manager] Set location for the final state op…
Browse files Browse the repository at this point in the history
…tion 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)
  • Loading branch information
AutorestCI authored Sep 25, 2018
1 parent b191e1b commit 356476f
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_long_running_output(response):
lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
interactions:
- request:
body: '{"location": "westus", "properties": {"creationData": {"createOption":
"Empty"}, "diskSizeGB": 20}}'
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['99']
Content-Type: [application/json; charset=utf-8]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
accept-language: [en-US]
method: PUT
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
response:
body: {string: "{\r\n \"sku\": {\r\n \"name\": \"Standard_LRS\",\r\n \"\
tier\": \"Standard\"\r\n },\r\n \"properties\": {\r\n \"creationData\"\
: {\r\n \"createOption\": \"Empty\"\r\n },\r\n \"diskSizeGB\":\
\ 20,\r\n \"provisioningState\": \"Updating\",\r\n \"isArmResource\"\
: true,\r\n \"faultDomain\": 0\r\n },\r\n \"location\": \"westus\",\r\
\n \"name\": \"my_disk_name\"\r\n}"}
headers:
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']
cache-control: [no-cache]
content-length: ['324']
content-type: [application/json; charset=utf-8]
date: ['Tue, 25 Sep 2018 18:27:19 GMT']
expires: ['-1']
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']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/CreateUpdateDisks3Min;999,Microsoft.Compute/CreateUpdateDisks30Min;3998']
x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 202, message: Accepted}
- request:
body: null
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
method: GET
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
response:
body: {string: "{\r\n \"startTime\": \"2018-09-25T18:27:19.9691669+00:00\",\r\
\n \"endTime\": \"2018-09-25T18:27:20.1254636+00:00\",\r\n \"status\": \"\
Succeeded\",\r\n \"properties\": {\r\n \"output\": {\"sku\":{\"name\"\
:\"Standard_LRS\",\"tier\":\"Standard\"},\"properties\":{\"creationData\"\
:{\"createOption\":\"Empty\"},\"diskSizeGB\":20,\"timeCreated\":\"2018-09-25T18:23:01.8100645+00:00\"\
,\"provisioningState\":\"Succeeded\",\"diskState\":\"ActiveSAS\"},\"type\"\
:\"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\"\
,\"name\":\"my_disk_name\"}\r\n },\r\n \"name\": \"7db72277-5593-47a1-9052-2abfb61c958d\"\
\r\n}"}
headers:
cache-control: [no-cache]
content-length: ['697']
content-type: [application/json; charset=utf-8]
date: ['Tue, 25 Sep 2018 18:27:50 GMT']
expires: ['-1']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
transfer-encoding: [chunked]
vary: [Accept-Encoding]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49998,Microsoft.Compute/GetOperation30Min;249993']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
method: GET
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
response:
body: {string: "{\r\n \"sku\": {\r\n \"name\": \"Standard_LRS\",\r\n \"\
tier\": \"Standard\"\r\n },\r\n \"properties\": {\r\n \"creationData\"\
: {\r\n \"createOption\": \"Empty\"\r\n },\r\n \"diskSizeGB\":\
\ 20,\r\n \"timeCreated\": \"2018-09-25T18:23:01.8100645+00:00\",\r\n \
\ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"ActiveSAS\"\
\r\n },\r\n \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"\
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\"\
,\r\n \"name\": \"my_disk_name\"\r\n}"}
headers:
cache-control: [no-cache]
content-length: ['576']
content-type: [application/json; charset=utf-8]
date: ['Tue, 25 Sep 2018 18:27:51 GMT']
expires: ['-1']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
transfer-encoding: [chunked]
vary: [Accept-Encoding]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/LowCostGet3Min;4997,Microsoft.Compute/LowCostGet30Min;19994']
status: {code: 200, message: OK}
- request:
body: '{"access": "Read", "durationInSeconds": 1}'
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['42']
Content-Type: [application/json; charset=utf-8]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
accept-language: [en-US]
method: POST
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
response:
body: {string: ''}
headers:
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']
cache-control: [no-cache]
content-length: ['0']
date: ['Tue, 25 Sep 2018 18:27:51 GMT']
expires: ['-1']
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']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/HighCostDiskHydrate3Min;999,Microsoft.Compute/HighCostDiskHydrate30Min;4998']
x-ms-ratelimit-remaining-subscription-writes: ['1199']
status: {code: 202, message: Accepted}
- request:
body: null
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
method: GET
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
response:
body: {string: "{\r\n \"startTime\": \"2018-09-25T18:27:51.654499+00:00\",\r\n\
\ \"endTime\": \"2018-09-25T18:27:51.8264577+00:00\",\r\n \"status\": \"\
Succeeded\",\r\n \"properties\": {\r\n \"output\": {\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\"\
\r\n}\r\n },\r\n \"name\": \"993880d3-35d5-4d69-95a1-e41256ac1613\"\r\n}"}
headers:
cache-control: [no-cache]
content-length: ['424']
content-type: [application/json; charset=utf-8]
date: ['Tue, 25 Sep 2018 18:28:22 GMT']
expires: ['-1']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
transfer-encoding: [chunked]
vary: [Accept-Encoding]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49996,Microsoft.Compute/GetOperation30Min;249991']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: [application/json]
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.5
msrest_azure/0.4.34 computemanagementclient/4.1.0 Azure-SDK-For-Python]
method: GET
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
response:
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\"\
\r\n}"}
headers:
cache-control: [no-cache]
content-length: ['200']
content-type: [application/json; charset=utf-8]
date: ['Tue, 25 Sep 2018 18:28:22 GMT']
expires: ['-1']
pragma: [no-cache]
server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
strict-transport-security: [max-age=31536000; includeSubDomains]
transfer-encoding: [chunked]
vary: [Accept-Encoding]
x-content-type-options: [nosniff]
x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/GetOperation3Min;49995,Microsoft.Compute/GetOperation30Min;249990']
status: {code: 200, message: OK}
version: 1
29 changes: 28 additions & 1 deletion azure-mgmt-compute/tests/test_mgmt_managed_disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ def test_empty_md(self, resource_group, location):
)
disk_resource = async_creation.result()

@ResourceGroupPreparer()
def test_grant_access(self, resource_group, location):
'''Create an empty Managed Disk.'''
DiskCreateOption = self.compute_client.disks.models.DiskCreateOption

async_creation = self.compute_client.disks.create_or_update(
resource_group.name,
'my_disk_name',
{
'location': location,
'disk_size_gb': 20,
'creation_data': {
'create_option': DiskCreateOption.empty
}
}
)
disk_resource = async_creation.result()

grant_access_poller = self.compute_client.disks.grant_access(
resource_group.name,
'my_disk_name',
'Read',
'1',
)
access_uri = grant_access_poller.result()
assert access_uri.access_sas is not None

@ResourceGroupPreparer()
def test_md_from_storage_blob(self, resource_group, location):
'''Create a Managed Disk from Blob Storage.'''
Expand Down Expand Up @@ -334,7 +361,7 @@ def test_create_virtual_machine_scale_set(self, resource_group, location):
'name': naming_infix + 'ipconfig',
'subnet': {
'id': subnet_id
}
}
}]
}]
}
Expand Down

0 comments on commit 356476f

Please sign in to comment.