Class: Fog::Brightbox::Compute::Volume
Instance Method Summary
collapse
#lock!, #locked?, #unlock!
#collection_name, #resource_name
Instance Method Details
#attach(server) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 37
def attach(server)
requires :identity
data = service.attach_volume(identity, server: server.id)
merge_attributes(data)
true
end
|
#attached? ⇒ Boolean
44
45
46
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 44
def attached?
state == "attached"
end
|
#copy(options = {}) ⇒ Fog::Compute::Volume
Returns a new model for the copy.
55
56
57
58
59
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 55
def copy(options = {})
requires :identity
data = service.copy_volume(identity, options)
service.volumes.new(data)
end
|
#creating? ⇒ Boolean
61
62
63
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 61
def creating?
state == "creating"
end
|
#deleted? ⇒ Boolean
65
66
67
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 65
def deleted?
state == "deleted"
end
|
#deleting? ⇒ Boolean
69
70
71
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 69
def deleting?
state == "deleting"
end
|
#destroy ⇒ Object
143
144
145
146
147
148
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 143
def destroy
requires :identity
data = service.delete_volume(identity)
merge_attributes(data)
true
end
|
#detach ⇒ Object
73
74
75
76
77
78
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 73
def detach
requires :identity
data = service.detach_volume(identity)
merge_attributes(data)
true
end
|
#detached? ⇒ Boolean
80
81
82
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 80
def detached?
state == "detached"
end
|
#failed? ⇒ Boolean
84
85
86
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 84
def failed?
state == "failed"
end
|
#finished? ⇒ Boolean
88
89
90
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 88
def finished?
deleted? || failed?
end
|
#ready? ⇒ Boolean
92
93
94
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 92
def ready?
attached? || detached?
end
|
#resize(options) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 98
def resize(options)
requires :identity
options.merge!(:from => size)
data = service.resize_volume(identity, options)
merge_attributes(data)
true
end
|
#save ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/fog/brightbox/models/compute/volume.rb', line 110
def save
if persisted?
options = {
:delete_with_server => delete_with_server,
:description => description,
:name => name,
:serial => serial
}.delete_if { |_k, v| v.nil? || v == "" }
data = service.update_volume(identity, options)
else
raise Fog::Errors::Error.new("'image_id' and 'filesystem_type' are mutually exclusive") if image_id && filesystem_type
raise Fog::Errors::Error.new("'image_id' or 'filesystem_type' is required") unless image_id || filesystem_type
options = {
:delete_with_server => delete_with_server,
:description => description,
:filesystem_label => filesystem_label,
:filesystem_type => filesystem_type,
:name => name,
:serial => serial,
:size => size
}.delete_if { |_k, v| v.nil? || v == "" }
options.merge!(:image => image_id) unless image_id.nil? || image_id == ""
data = service.create_volume(options)
end
merge_attributes(data)
true
end
|