Class: Fog::Compute::OpenNebula::Flavor

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/opennebula/models/compute/flavor.rb

Instance Method Summary collapse

Instance Method Details

#get_cpuObject



43
44
45
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 43

def get_cpu
  "CPU=#{vcpu.to_f/10}\n"
end

#get_diskObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 62

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_graphicsObject



87
88
89
90
91
92
93
94
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 87

def get_graphics
  return "" unless graphics 
  ret = "GRAPHICS=#{graphics}\n"
  ret.gsub!(/\{/, '[')
  ret.gsub!(/\}/, ']')
  ret.gsub!(/>/,'')
  ret 
end

#get_memoryObject



52
53
54
55
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 52

def get_memory
  memory = 128 unless memory
  "MEMORY=#{memory}\n"
end

#get_nicObject



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 96

def get_nic
  # NIC=[MODEL="virtio",NETWORK="vlan17",NETWORK_UNAME="oneadmin"]
  return "" if( nic.nil? || !(nic.is_a? Array))
  ret = ""

  nic.each do |n|
    ret += %Q|NIC=[MODEL="#{n.model}",NETWORK_ID="#{n.vnet.id}"]\n|
  end
  #ret.gsub!(/\{/, '[')
  #ret.gsub!(/\}/, ']')
  #ret.gsub!(/>/,'')
  ret 
end

#get_osObject



78
79
80
81
82
83
84
85
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 78

def get_os
  return "" unless os
  ret = "OS=#{os}\n"
  ret.gsub!(/\{/, '[')
  ret.gsub!(/\}/, ']')
  ret.gsub!(/>/,'')
  ret 
end

#get_rawObject



57
58
59
60
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 57

def get_raw
  return "" unless raw
  "RAW=#{raw}\n"
end

#get_sched_ds_rankObject



115
116
117
118
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 115

def get_sched_ds_rank
  return "" unless sched_ds_rank 
  %Q|SCHED_DS_RANK="#{sched_ds_rank}"\n|
end

#get_sched_ds_requirementsObject



110
111
112
113
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 110

def get_sched_ds_requirements
  return "" unless sched_ds_requirements 
  %Q|SCHED_DS_REQUIREMENTS="#{sched_ds_requirements}"\n|
end

#get_sched_rankObject



125
126
127
128
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 125

def get_sched_rank
  return "" unless sched_rank 
  %Q|SCHED_RANK="#{sched_rank}"\n|
end

#get_sched_requirementsObject



120
121
122
123
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 120

def get_sched_requirements
  return "" unless sched_requirements 
  %Q|SCHED_REQUIREMENTS="#{sched_requirements}"\n|
end

#get_vcpuObject



47
48
49
50
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 47

def get_vcpu
  vcpu = 1 unless vcpu
  "VCPU=#{vcpu}\n"
end

#to_labelObject



24
25
26
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 24

def to_label
  "#{name} -- #{vcpu} VCPU - #{memory}MB Mem"
end

#to_sObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/opennebula/models/compute/flavor.rb', line 28

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
end