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
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 137 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
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 68 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
93 94 95 96 97 98 99 100 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 93 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 return "MEMORY=128\n" unless memory "MEMORY=#{memory}\n" end |
#get_nic ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 102 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
84 85 86 87 88 89 90 91 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 84 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 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 63 def get_raw return "" unless raw "RAW=#{raw}\n" end |
#get_sched_ds_rank ⇒ Object
122 123 124 125 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 122 def get_sched_ds_rank return "" unless sched_ds_rank %Q|SCHED_DS_RANK="#{sched_ds_rank}"\n| end |
#get_sched_ds_requirements ⇒ Object
117 118 119 120 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 117 def get_sched_ds_requirements return "" unless sched_ds_requirements %Q|SCHED_DS_REQUIREMENTS="#{sched_ds_requirements}"\n| end |
#get_sched_rank ⇒ Object
132 133 134 135 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 132 def get_sched_rank return "" unless sched_rank %Q|SCHED_RANK="#{sched_rank}"\n| end |
#get_sched_requirements ⇒ Object
127 128 129 130 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 127 def get_sched_requirements return "" unless sched_requirements %Q|SCHED_REQUIREMENTS="#{sched_requirements}"\n| end |
#get_user_variables ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 153 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 return "VCPU=1\n" 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 |