Last active
October 23, 2020 16:32
-
-
Save lmazuel/b8e6e5db007a3a3c3b5cb113e6029bab to your computer and use it in GitHub Desktop.
VM PATCH behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format="%(asctime)s:%(levelname)s:%(name)s:%(message)s" | |
) | |
from devtools_testutils import mgmt_settings_real | |
sub_id = mgmt_settings_real.SUBSCRIPTION_ID | |
cred = mgmt_settings_real.get_azure_core_credentials() | |
from azure.mgmt.compute import ComputeManagementClient | |
client = ComputeManagementClient(cred, sub_id, logging_enable=True) | |
vm_rg = "lmazuel-vm" | |
vm_name = "LmazuelVMTest" | |
from azure.mgmt.core.polling.arm_polling import ARMPolling | |
class FastARMPolling(ARMPolling): | |
def initialize(self, client, initial_response, deserialization_callback): | |
super(FastARMPolling, self).initialize(client, initial_response, deserialization_callback) | |
# Force the initial response to mark "start to poll one second after the initial call" | |
initial_response.http_response.headers['retry-after'] = 1 | |
def request_status(self, status_link): | |
response = super(FastARMPolling, self).request_status(status_link) | |
# Force the intermediate response to mark "continue to poll one second after the previous call" | |
response.http_response.headers['retry-after'] = 1 | |
return response | |
vm_parameters = {'storage_profile' : {'data_disks' : []}} | |
vm_op = client.virtual_machines.begin_update(vm_rg, vm_name, vm_parameters, polling=FastARMPolling()) | |
vm_op.wait() | |
print("I went through") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format="%(asctime)s:%(levelname)s:%(name)s:%(message)s" | |
) | |
from devtools_testutils import mgmt_settings_real | |
sub_id = mgmt_settings_real.SUBSCRIPTION_ID | |
cred = mgmt_settings_real.get_azure_core_credentials() | |
from azure.mgmt.compute import ComputeManagementClient | |
client = ComputeManagementClient(cred, sub_id, logging_enable=True) | |
vm_rg = "lmazuel-vm" | |
vm_name = "LmazuelVMTest" | |
from azure.mgmt.core.polling.arm_polling import ARMPolling | |
vm_parameters = {'storage_profile' : {'data_disks' : []}} | |
vm_op = client.virtual_machines.begin_update(vm_rg, vm_name, vm_parameters, polling=ARMPolling(timeout=1)) | |
vm_op.wait() | |
print("I went through") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment