def _leaseBlob(self, storageAccount, mediaLink): primary = self._getStorageAccountKey(storageAccount) # BlobServiceオブジェクトを作成 blobService = BlobService(storageAccount, primary) (container, blob) = self._getBlobFromMediaLink(blobService, mediaLink) prop = blob.properties # Lease StatusがlockedだったらBlobのリース解放を試みる if prop.lease_status == 'locked': # unlockedの時に実行すると、 azure.WindowsAzureConflictError res = blobService.lease_blob(container_name=container.name, blob_name=blob.name, x_ms_lease_action='break') # (成功すると?){}が返ってくる updatedBlob = blobService.get_blob_properties(container_name=container.name, blob_name=blob.name)
def _leaseBlob(self, storageAccount, mediaLink): primary = self._getStorageAccountKey(storageAccount) # BlobServiceオブジェクトを作成 blobService = BlobService(storageAccount, primary) (container, blob) = self._getBlobFromMediaLink(blobService, mediaLink) prop = blob.properties # Lease StatusがlockedだったらBlobのリース解放を試みる if prop.lease_status == 'locked': # unlockedの時に実行すると、 azure.WindowsAzureConflictError res = blobService.lease_blob(container_name=container.name, blob_name=blob.name, x_ms_lease_action='break') # (成功すると?){}が返ってくる updatedBlob = blobService.get_blob_properties( container_name=container.name, blob_name=blob.name)
# # 見つからなければエラー終了 if (targetBlob is None): logger.error('deleteOSandDataDisk.py: target blob(%s) is not found.' % mediaLink.split('://')[1]) sys.exit() #----------------- # lease開始 logger.debug("deleteOSandDataDisk.py: Blob mediaLink of OS or Data Disk leasing...(%s-->%s)" % (targetContainer.name, targetBlob.name)) prop = targetBlob.properties # Lease StatusがlockedだったらBlobのリース解放を試みる if prop.lease_status == 'locked': # unlockedの時に実行すると、 azure.WindowsAzureConflictError res = blobService.lease_blob(container_name=targetContainer.name, blob_name=targetBlob.name, x_ms_lease_action='break') # (成功すると?){}が返ってくる updatedBlob = blobService.get_blob_properties(container_name=targetContainer.name, blob_name=targetBlob.name) logger.debug("deleteOSandDataDisk.py: Blob mediaLink of OS or Data Disk leased.(%s-->%s)" % (targetContainer.name, targetBlob.name)) logger.debug("sleeping... 120sec") time.sleep(120) #----------------- # osHardDiskをOSディスクリストから削除 # if ( osHardDiskName is not None ): logger.debug("deleteOSandDataDisk.py: OS Disk deleting...(%s)" % osHardDiskName) try: systemProperty = sms.delete_disk(osHardDiskName, True)