Module: VirtualMaster::Helpers
- Defined in:
- lib/vmaster/helpers.rb
Class Method Summary collapse
- .create_instance(name, image_id, profile, realm) ⇒ Object
- .get_hw_profile(memory, storage) ⇒ Object
- .get_instance(name) ⇒ Object
- .get_instances ⇒ Object
Class Method Details
.create_instance(name, image_id, profile, realm) ⇒ Object
67 68 69 70 71 |
# File 'lib/vmaster/helpers.rb', line 67 def self.create_instance(name, image_id, profile, realm) api = VirtualMaster::CLI.api api.create_instance(image_id, {:name => name, :hwp_id => 'default', :memory => profile[:memory], :storage => profile[:storage], :realm_id => realm}) end |
.get_hw_profile(memory, storage) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/vmaster/helpers.rb', line 59 def self.get_hw_profile(memory, storage) api = VirtualMaster::CLI.api profile_list = api.hardware_profiles.select { |p| p.memory.value.to_i == memory && p.storage.value.to_i == storage } profile_list.first end |
.get_instance(name) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/vmaster/helpers.rb', line 51 def self.get_instance(name) get_instances.each do |instance| return instance if instance.name == name end nil end |
.get_instances ⇒ Object
47 48 49 |
# File 'lib/vmaster/helpers.rb', line 47 def self.get_instances VirtualMaster::CLI.api.instances end |