Class: Fog::Compute::Hyperv::Vhd
Instance Method Summary
collapse
#initialize
#lazy_attributes
#cluster, #computer, #dirty?, #lazy_attributes, #parent, #vm
Instance Method Details
#destroy ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 91
def destroy
requires :path, :disk_identifier
service.remove_item(
path: unc_path
)
end
|
#host ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 41
def host
requires :computer_name
@host ||= begin
ret = parent
ret = service.hosts.get computer_name unless ret
ret = ret.parent unless ret.is_a?(Host)
ret
end
end
|
#real_path ⇒ Object
def identity_name
:disk_identifier unless disk_identifier
:disk_number if disk
:path
end
28
29
30
31
32
33
34
35
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 28
def real_path
requires :path, :computer_name
ret = path
ret += '.vhdx' unless ret.downcase.end_with? '.vhdx'
ret = host.virtual_hard_disk_path + '\\' + ret unless ret.downcase.start_with? host.virtual_hard_disk_path.downcase
ret
end
|
#reload ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 77
def reload
requires :computer_name
requires_one :path, :disk
data = service.get_vhd(
computer_name: computer_name,
path: path,
disk_number: disk
)
merge_attributes(data.attributes)
@old = data
self
end
|
#save ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 52
def save
requires :path, :computer_name, :size
data = \
if persisted?
attributes
else
service.new_vhd(
computer_name: computer_name,
path: real_path,
block_size_bytes: block_size,
size_bytes: size,
_return_fields: self.class.attributes,
_json_depth: 1
)
end
merge_attributes(data)
@old = dup
self
end
|
#unc_path ⇒ Object
37
38
39
|
# File 'lib/fog/hyperv/models/compute/vhd.rb', line 37
def unc_path
"\\\\#{computer_name || '.'}\\#{real_path.tr ':', '$'}"
end
|