1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #476: Some formatting and comments

This commit is contained in:
Ruben S. Montero 2011-06-23 16:45:25 +02:00
parent e4d72a3c76
commit 83dc32c53d
3 changed files with 22 additions and 5 deletions

View File

@ -25,11 +25,14 @@ class OpenNebulaHM < OpenNebulaNetwork
process do |nic|
bridge = nic[:bridge]
dev = nic[:phydev]
if dev
vlan = CONF[:start_vlan] + nic[:network_id].to_i
vlan = CONF[:start_vlan] + nic[:network_id].to_i
create_bridge bridge if !bridge_exists? bridge
create_dev_vlan(dev, vlan) if !device_exists?(dev, vlan)
if !attached_bridge_dev?(bridge, dev, vlan)
attach_brigde_dev(bridge, dev, vlan)
end

View File

@ -14,6 +14,7 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
# This class represents the NICS of a VM
class Nics < Array
def initialize(hypervisor)
case hypervisor
@ -77,14 +78,19 @@ class Nics < Array
end
end
# A NIC using KVM. This class implements functions to get the physical interface
# that the NIC is using
class NicKVM < Hash
def initialize
@vm_info = Hash.new
super(nil)
end
def get_info(vm)
@vm_info = Hash.new
deploy_id = vm['DEPLOY_ID']
if deploy_id
@vm_info[:dumpxml] = `#{COMMANDS[:virsh]} dumpxml #{deploy_id} 2>/dev/null`
@vm_info.each_key{|k| @vm_info[k] = nil if @vm_info[k].to_s.strip.empty?}
@ -93,6 +99,7 @@ class NicKVM < Hash
def get_tap
dumpxml = @vm_info[:dumpxml]
if dumpxml
dumpxml_root = REXML::Document.new(dumpxml).root
@ -108,24 +115,31 @@ class NicKVM < Hash
end
end
# A NIC using Xen. This class implements functions to get the physical interface
# that the NIC is using
class NicXen < Hash
def initialize
@vm_info = Hash.new
super(nil)
end
def get_info(vm)
@vm_info = Hash.new
deploy_id = vm['DEPLOY_ID']
if deploy_id
@vm_info[:domid] =`#{COMMANDS[:xm]} domid #{deploy_id}`.strip
@vm_info[:networks] =`#{COMMANDS[:xm]} network-list #{deploy_id}`
@vm_info.each_key{|k| @vm_info[k] = nil if @vm_info[k].to_s.strip.empty?}
end
@vm_info
end
def get_tap
domid = @vm_info[:domid]
if domid
networks = @vm_info[:networks].split("\n")[1..-1]
networks.each do |net|

View File

@ -21,8 +21,8 @@ class OpenvSwitchVLAN < OpenNebulaNetwork
def activate
process do |nic|
cmd = "#{COMMANDS[:ovs_vsctl]} set Port #{nic[:tap]} "
cmd << "tag=#{nic[:network_id].to_i + CONF[:start_vlan]}"
cmd = "#{COMMANDS[:ovs_vsctl]} set Port #{nic[:tap]} "
cmd << "tag=#{nic[:network_id].to_i + CONF[:start_vlan]}"
system(cmd)
end