Class: CloudInteractor::Volume
- Inherits:
-
Object
- Object
- CloudInteractor::Volume
- Defined in:
- lib/cloud_interactor/volume.rb,
lib/cloud_interactor/volume/list.rb,
lib/cloud_interactor/volume/read.rb,
lib/cloud_interactor/volume/create.rb,
lib/cloud_interactor/volume/destroy.rb
Overview
Constant Summary collapse
- IDENTITY =
'volumes'
- RESOURCE =
'volume'
Instance Method Summary collapse
- #create(args) ⇒ Object
- #destroy(args) ⇒ Object
-
#initialize(main_obj, classes, options = {}) ⇒ Volume
constructor
A new instance of Volume.
- #list(args = {}, output = true) ⇒ Object
- #read(args, output = true, mode = "display_name") ⇒ Object
- #run(method, args, mode = "name") ⇒ Object
Constructor Details
#initialize(main_obj, classes, options = {}) ⇒ Volume
Returns a new instance of Volume.
7 8 9 10 11 |
# File 'lib/cloud_interactor/volume.rb', line 7 def initialize main_obj, classes, ={} @main_obj = main_obj @options = @classes = classes end |
Instance Method Details
#create(args) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/cloud_interactor/volume/create.rb', line 3 def create args puts "(#{ IDENTITY }) Creating #{ args['display_name'] } in #{ IDENTITY }..." puts("Creating #{ IDENTITY.singularize } with args #{ ap(args) }") if @options['verbose'] args['volume_type'] = 'SSD' unless args['volume_type'] @main_obj["#{ IDENTITY }_create_request"] = JSON.parse(@classes['auth'].auth_service(RESOURCE).instance_eval(IDENTITY).create(args).to_json) end |
#destroy(args) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/cloud_interactor/volume/destroy.rb', line 3 def destroy args read args, false #TODO strict checking on volumes to ensure a volume can't be destroyed when it is still attached @classes['helper'].generic_destroy_parse args, IDENTITY, RESOURCE, 'display_name' end |
#list(args = {}, output = true) ⇒ Object
3 4 5 |
# File 'lib/cloud_interactor/volume/list.rb', line 3 def list args={}, output=true @classes['helper'].generic_list_call IDENTITY, RESOURCE, output end |
#read(args, output = true, mode = "display_name") ⇒ Object
3 4 5 6 7 |
# File 'lib/cloud_interactor/volume/read.rb', line 3 def read args, output=true, mode="display_name" list([], false) if @main_obj["specific_#{ IDENTITY }"].nil? @classes['helper'].generic_read_parse args, IDENTITY, output, mode end |
#run(method, args, mode = "name") ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cloud_interactor/volume.rb', line 13 def run method, args, mode="name" case method when "read" then self.send(method, args, mode) else self.send(method, args) end end |