Class: Fog::Compute::OpenNebula::Flavor
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::OpenNebula::Flavor
- Defined in:
- lib/fog/opennebula/models/compute/flavor.rb
Instance Method Summary collapse
- #get_context ⇒ Object
- #get_cpu ⇒ Object
- #get_disk ⇒ Object
- #get_graphics ⇒ Object
- #get_memory ⇒ Object
- #get_nic ⇒ Object
- #get_os ⇒ Object
- #get_raw ⇒ Object
- #get_sched_ds_rank ⇒ Object
- #get_sched_ds_requirements ⇒ Object
- #get_sched_rank ⇒ Object
- #get_sched_requirements ⇒ Object
- #get_user_variables ⇒ Object
- #get_vcpu ⇒ Object
- #to_label ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#get_context ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 153 def get_context return '' unless context if context.is_a? String return %(CONTEXT= [ #{context} ]\n) elsif context.is_a? Hash ret = '' context.each do |key, value| ret << %("#{key}"="#{value}",) end ret.chop! if ret.end_with?(',') return %(CONTEXT=[ #{ret} ]\n) else return '' end end |
#get_cpu ⇒ Object
50 51 52 53 54 55 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 50 def get_cpu return "CPU=#{vcpu.to_f / 10}\n" unless cpu return "CPU=#{vcpu}\n" if cpu.to_i > vcpu.to_i "CPU=#{cpu}\n" end |
#get_disk ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 77 def get_disk return '' unless disk ret = '' if disk.is_a? Array disk.each do |d| ret += "DISK=#{d}\n" end else ret = "DISK=#{disk}\n" end ret.tr!('{', '[') ret.tr!('}', ']') ret.delete!('>') ret end |
#get_graphics ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 104 def get_graphics return '' unless graphics ret = "GRAPHICS=#{graphics}\n" ret.tr!('{', '[') ret.tr!('}', ']') ret.delete!('>') ret end |
#get_memory ⇒ Object
62 63 64 65 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 62 def get_memory self.memory = 128 unless memory "MEMORY=#{memory}\n" end |
#get_nic ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 114 def get_nic return '' if nic.nil? ret = '' if nic.is_a? Array nic.each do |n| ret += %(NIC=[MODEL="#{n.model}",NETWORK_ID="#{n.vnet.id}"]\n) unless n.vnet.nil? end end # ret.gsub!(/\{/, '[') # ret.gsub!(/\}/, ']') # ret.gsub!(/>/,'') ret end |
#get_os ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 94 def get_os return '' unless os ret = "OS=#{os}\n" ret.tr!('{', '[') ret.tr!('}', ']') ret.delete!('>') ret end |
#get_raw ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 67 def get_raw return '' unless raw ret = "RAW=#{raw}\n" ret.tr!('{', '[') ret.tr!('}', ']') ret.tr!(/=>/, '=') ret end |
#get_sched_ds_rank ⇒ Object
135 136 137 138 139 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 135 def get_sched_ds_rank return '' unless sched_ds_rank %(SCHED_DS_RANK="#{sched_ds_rank.gsub(/"/) { %q(\") }}"\n) end |
#get_sched_ds_requirements ⇒ Object
129 130 131 132 133 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 129 def get_sched_ds_requirements return '' unless sched_ds_requirements %(SCHED_DS_REQUIREMENTS="#{sched_ds_requirements.gsub(/"/) { %q(\") }}"\n) end |
#get_sched_rank ⇒ Object
147 148 149 150 151 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 147 def get_sched_rank return '' unless sched_rank %(SCHED_RANK="#{sched_rank.gsub(/"/) { %q(\") }}"\n) end |
#get_sched_requirements ⇒ Object
141 142 143 144 145 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 141 def get_sched_requirements return '' unless sched_requirements %(SCHED_REQUIREMENTS="#{sched_requirements.gsub(/"/) { %q(\") }}"\n) end |
#get_user_variables ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 169 def get_user_variables return '' unless user_variables if user_variables.is_a? String return %(#{user_variables}\n) elsif user_variables.is_a? Hash ret = '' user_variables.each do |key, value| ret << %(#{key}="#{value}"\n) end return ret else return '' end end |
#get_vcpu ⇒ Object
57 58 59 60 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 57 def get_vcpu self.vcpu = 1 unless vcpu "VCPU=#{vcpu}\n" end |
#to_label ⇒ Object
29 30 31 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 29 def to_label "#{name} -- #{vcpu} VCPU - #{memory}MB Mem" end |
#to_s ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 33 def to_s '' + get_cpu \ + get_vcpu \ + get_memory \ + get_disk \ + get_nic \ + get_os \ + get_graphics \ + get_raw \ + get_sched_requirements \ + get_sched_ds_requirements \ + get_sched_rank \ + get_sched_ds_rank \ + get_context \ + get_user_variables end |