forked from ManageIQ/manageiq-smartstate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzureManagedDisk.rb
55 lines (46 loc) · 1.23 KB
/
AzureManagedDisk.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "disk/modules/AzureDiskCommon"
require_relative "../MiqDisk"
require 'ostruct'
module AzureManagedDisk
include AzureDiskCommon
def self.new(svc, disk_name, dInfo = nil)
d_info = dInfo || OpenStruct.new
d_info.storage_disk_svc = svc
d_info.disk_name = disk_name
d_info.fileName = disk_name
MiqDisk.new(self, d_info, 0)
end
def d_init
@diskType = "azure-managed"
@blockSize = SECTOR_LENGTH
@disk_name = @dInfo.disk_name
@storage_disk_svc = @dInfo.storage_disk_svc
@resource_group = @dInfo.resource_group
d_init_common(@dInfo)
end
def d_close
d_close_common
end
def d_read(pos, len)
$log.debug("AzureManagedDisk#d_read(#{pos}, #{len})")
d_read_common(pos, len)
end
def d_size
@d_size ||= blob_headers[:content_range].split("/")[1].to_i
end
def d_write(_pos, _buf, _len)
raise "Write operation not supported."
end
private
def blob_headers
$log.debug("AzureManagedDisk#blob_headers")
@blob_headers ||= begin
options = {
:start_byte => 0,
:length => 1
}
data = @storage_disk_svc.get_blob_raw(@disk_name, @resource_group, options)
data.headers
end
end
end