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
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 141 def get_context return "" unless context if context.is_a? String return %Q|CONTEXT= [ #{context} ]\n| elsif context.is_a? Hash ret = "" context.each do |key, value| ret << %Q|"#{key}"="#{value}",| end ret.chop! if ret.end_with?(',') return %Q|CONTEXT=[ #{ret} ]\n| else return "" end end |
#get_cpu ⇒ Object
47 48 49 50 51 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 47 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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 72 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.gsub!(/\{/, '[') ret.gsub!(/\}/, ']') ret.gsub!(/>/,'') ret end |
#get_graphics ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 97 def get_graphics return "" unless graphics ret = "GRAPHICS=#{graphics}\n" ret.gsub!(/\{/, '[') ret.gsub!(/\}/, ']') ret.gsub!(/>/,'') ret end |
#get_memory ⇒ Object
58 59 60 61 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 58 def get_memory self.memory = 128 unless memory "MEMORY=#{memory}\n" end |
#get_nic ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 106 def get_nic # NIC=[MODEL="virtio",NETWORK="vlan17",NETWORK_UNAME="oneadmin"] return "" if nic.nil? ret = "" if nic.is_a? Array nic.each do |n| ret += %Q|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
88 89 90 91 92 93 94 95 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 88 def get_os return "" unless os ret = "OS=#{os}\n" ret.gsub!(/\{/, '[') ret.gsub!(/\}/, ']') ret.gsub!(/>/,'') ret end |
#get_raw ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 63 def get_raw return "" unless raw ret = "RAW=#{raw}\n" ret.gsub!(/\{/, '[') ret.gsub!(/\}/, ']') ret.gsub!(/>/,'') ret end |
#get_sched_ds_rank ⇒ Object
126 127 128 129 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 126 def get_sched_ds_rank return "" unless sched_ds_rank %Q|SCHED_DS_RANK="#{sched_ds_rank.gsub(/"/){ %q(\") }}"\n| end |
#get_sched_ds_requirements ⇒ Object
121 122 123 124 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 121 def get_sched_ds_requirements return "" unless sched_ds_requirements %Q|SCHED_DS_REQUIREMENTS="#{sched_ds_requirements.gsub(/"/){ %q(\") }}"\n| end |
#get_sched_rank ⇒ Object
136 137 138 139 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 136 def get_sched_rank return "" unless sched_rank %Q|SCHED_RANK="#{sched_rank.gsub(/"/){ %q(\") }}"\n| end |
#get_sched_requirements ⇒ Object
131 132 133 134 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 131 def get_sched_requirements return "" unless sched_requirements %Q|SCHED_REQUIREMENTS="#{sched_requirements.gsub(/"/){ %q(\") }}"\n| end |
#get_user_variables ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 157 def get_user_variables return "" unless user_variables if user_variables.is_a? String return %Q|#{user_variables}\n| elsif user_variables.is_a? Hash ret = "" user_variables.each do |key, value| ret << %Q|#{key}="#{value}"\n| end return ret else return "" end end |
#get_vcpu ⇒ Object
53 54 55 56 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 53 def get_vcpu self.vcpu = 1 unless vcpu "VCPU=#{vcpu}\n" end |
#to_label ⇒ Object
26 27 28 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 26 def to_label "#{name} -- #{vcpu} VCPU - #{memory}MB Mem" end |
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 30 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 |