-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelpers.rb
More file actions
73 lines (61 loc) · 1.55 KB
/
Copy pathhelpers.rb
File metadata and controls
73 lines (61 loc) · 1.55 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
module VirtualMaster
CONFIG_FILE = ".virtualmaster"
DEFAULT_URL = "https://www.virtualmaster.com/virtualmaster/services/deltacloud"
DEFAULT_IMAGE = 2664
DEFAULT_PROFILE = "micro"
# pre-defined list of images
IMAGES = {
:ubuntu_precise => 2664,
:ubuntu_lucid => 2818,
:debian_squeeze => 2808,
:centos_6 => 2818,
:centos_5 => 2804,
:archlinux => 2668
}
PROFILES = {
:nano => {
:memory => 256,
:storage => 3840
},
:micro => {
:memory => 512,
:storage => 10240,
},
:milli => {
:memory => 1024,
:storage => 20480,
},
:small => {
:memory => 2048,
:storage => 30720,
},
:medium => {
:memory => 4096,
:storage => 40960,
},
:large => {
:memory => 7000,
:storage => 20480,
}
}
module Helpers
def self.get_instances
VirtualMaster::CLI.api.instances
end
def self.get_instance(name)
get_instances.each do |instance|
return instance if instance.name == name
end
nil
end
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
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
end
end