diff --git a/src/vmm_mad/dummy/one_vmm_dummy.rb b/src/vmm_mad/dummy/one_vmm_dummy.rb index f8b902cee6..41451da89a 100755 --- a/src/vmm_mad/dummy/one_vmm_dummy.rb +++ b/src/vmm_mad/dummy/one_vmm_dummy.rb @@ -192,10 +192,10 @@ class DummyDriver < VirtualMachineDriver # monitor_info: string in the form "VAR=VAL VAR=VAL ... VAR=VAL" # known VAR are in POLL_ATTRIBUTES. VM states VM_STATES monitor_info = "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]} " \ - "#{POLL_ATTRIBUTE[:nettx]}=#{prev_nettx+(50*rand(3))} " \ - "#{POLL_ATTRIBUTE[:netrx]}=#{prev_netrx+(100*rand(4))} " \ - "#{POLL_ATTRIBUTE[:usedmemory]}=#{max_memory * (rand(80)+20)/100} " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=#{max_cpu * (rand(95)+5)/100} " \ + "#{POLL_ATTRIBUTE[:net_tx]}=#{prev_nettx+(50*rand(3))} " \ + "#{POLL_ATTRIBUTE[:net_rx]}=#{prev_netrx+(100*rand(4))} " \ + "#{POLL_ATTRIBUTE[:memory]}=#{max_memory * (rand(80)+20)/100} " \ + "#{POLL_ATTRIBUTE[:cpu]}=#{max_cpu * (rand(95)+5)/100} " \ "#{POLL_ATTRIBUTE[:disk_actual]}=#{rand(1024)} " \ "#{POLL_ATTRIBUTE[:disk_virtual]}=#{1024}" diff --git a/src/vmm_mad/remotes/az/az_driver.rb b/src/vmm_mad/remotes/az/az_driver.rb index 46685fe44d..f05b69b6e0 100755 --- a/src/vmm_mad/remotes/az/az_driver.rb +++ b/src/vmm_mad/remotes/az/az_driver.rb @@ -149,11 +149,11 @@ class AzureDriver # Sanitize region data if @region['pem_management_cert'].nil? - raise "pem_management_cert not defined for #{host}" + raise "pem_management_cert not defined for #{host}" end if @region['subscription_id'].nil? - raise "subscription_id not defined for #{host}" + raise "subscription_id not defined for #{host}" end # Set default endpoint if not declared @@ -268,10 +268,10 @@ class AzureDriver @azure_vms.list_virtual_machines.each do |vm| poll_data=parse_poll(vm) - if vm.vm_name.start_with?('one-') and - vm.vm_name.match(/([^_]+)_(.+)/) and + if vm.vm_name.start_with?('one-') and + vm.vm_name.match(/([^_]+)_(.+)/) and vm.vm_name.match(/([^_]+)_(.+)/).size > 1 - + one_id = vm.vm_name.match(/([^_]+)_(.+)/)[1].split("-")[1] end @@ -336,7 +336,7 @@ private if !az # If we don't find an Azure location, and ONE just # knows about one Azure location, let's use that - if all_az_elements.size == 1 and + if all_az_elements.size == 1 and all_az_elements[0].elements["TYPE"].text.downcase.eql? "azure" az = all_az_elements[0] else @@ -371,10 +371,10 @@ private # Retrive the vm information from the Azure instance def parse_poll(instance) begin - info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ - "#{POLL_ATTRIBUTE[:nettx]}=0 " \ - "#{POLL_ATTRIBUTE[:netrx]}=0 " + info = "#{POLL_ATTRIBUTE[:memory]}=0 " \ + "#{POLL_ATTRIBUTE[:cpu]}=0 " \ + "#{POLL_ATTRIBUTE[:net_tx]}=0 " \ + "#{POLL_ATTRIBUTE[:net_rx]}=0 " state = "" if !instance @@ -383,7 +383,7 @@ private state = case instance.deployment_status when "Running", "Starting" VM_STATE[:active] - when "Suspended", "Stopping", + when "Suspended", "Stopping", VM_STATE[:paused] else VM_STATE[:unknown] @@ -446,10 +446,10 @@ private :winrm_transport => az_value(az_info, 'WIN_RM'), :cloud_service_name => csn, :tcp_endpoints => az_value(az_info, 'TCP_ENDPOINTS'), - # TODO possibly taking the values from user template + # TODO possibly taking the values from user template # and create temp files # :private_key_file => 'c:/private_key.key', - # :certificate_file => 'c:/certificate.pem', + # :certificate_file => 'c:/certificate.pem', :ssh_port => az_value(az_info, 'SSHPORT'), :vm_size => az_value(az_info, 'INSTANCE_TYPE'), :affinity_group_name => az_value(az_info, 'AFFINITY_GROUP'), @@ -539,9 +539,9 @@ private $stderr.reopen orig_stderr end retval - end + end - # Retrive the instance from Azure. If OpenNebula asks for it, then the + # Retrive the instance from Azure. If OpenNebula asks for it, then the # vm_name must comply with the notation name_csn def get_instance(vm_name) begin diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index a5a7290ad8..258200d329 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -253,7 +253,7 @@ class EC2Driver end tags = generate_options(:tags, ec2_info)['tags'] || {} - + tags['ONE_ID'] = id tags.each{ |key,value| begin @@ -429,10 +429,10 @@ private # Retrieve the vm information from the EC2 instance def parse_poll(instance) begin - info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ - "#{POLL_ATTRIBUTE[:nettx]}=0 " \ - "#{POLL_ATTRIBUTE[:netrx]}=0 " + info = "#{POLL_ATTRIBUTE[:memory]}=0 " \ + "#{POLL_ATTRIBUTE[:cpu]}=0 " \ + "#{POLL_ATTRIBUTE[:net_tx]}=0 " \ + "#{POLL_ATTRIBUTE[:net_rx]}=0 " state = "" if !instance.exists? diff --git a/src/vmm_mad/remotes/poll_xen_kvm.rb b/src/vmm_mad/remotes/poll_xen_kvm.rb index 8001813968..b0ee5f155a 100755 --- a/src/vmm_mad/remotes/poll_xen_kvm.rb +++ b/src/vmm_mad/remotes/poll_xen_kvm.rb @@ -76,9 +76,9 @@ module KVM values=Hash.new - values[:state] = get_state(dominfo['State']) - values[:usedcpu] = cpu[vm[:pid]] if cpu[vm[:pid]] - values[:usedmemory] = [resident_mem, max_mem].max + values[:state] = get_state(dominfo['State']) + values[:cpu] = cpu[vm[:pid]] if cpu[vm[:pid]] + values[:memory] = [resident_mem, max_mem].max xml = dump_xml(vmid) @@ -134,9 +134,9 @@ module KVM values = Hash.new - values[:state] = get_state(dominfo['State']) - values[:usedcpu] = cpu[vm[:pid]] if cpu[vm[:pid]] - values[:usedmemory] = [resident_mem, max_mem].max + values[:state] = get_state(dominfo['State']) + values[:cpu] = cpu[vm[:pid]] if cpu[vm[:pid]] + values[:memory] = [resident_mem, max_mem].max xml = dump_xml(name) @@ -246,7 +246,7 @@ module KVM # Aggregate statics of all VM NICs # @param the ID of the VM as defined in libvirt # @param text [nil, String] dumpxml output or nil to execute dumpxml - # @return [Hash] with network stats, by name [symbol] :netrx, :nettx + # @return [Hash] with network stats, by name [symbol] :net_rx, :net_tx def self.get_interface_statistics(vmid, text = nil) text = dump_xml(vmid) if !text @@ -264,8 +264,8 @@ module KVM values = Hash.new - values[:netrx] = 0 - values[:nettx] = 0 + values[:net_rx] = 0 + values[:net_tx] = 0 interfaces.each do |interface| text=`#{virsh(:domifstat)} #{vmid} #{interface}` @@ -277,9 +277,9 @@ module KVM case columns[1] when 'rx_bytes' - values[:netrx] += columns[2].to_i + values[:net_rx] += columns[2].to_i when 'tx_bytes' - values[:nettx]+=columns[2].to_i + values[:net_tx]+=columns[2].to_i end end end @@ -576,13 +576,13 @@ module XEN dom_hash = Hash.new - dom_hash[:name] = name - dom_hash[:vm_name] = name - dom_hash[:state] = get_state(dom_data[1]) - dom_hash[:usedcpu] = dom_data[3] - dom_hash[:usedmemory] = dom_data[4] - dom_hash[:nettx] = dom_data[10].to_i * 1024 - dom_hash[:netrx] = dom_data[11].to_i * 1024 + dom_hash[:name] = name + dom_hash[:vm_name] = name + dom_hash[:state] = get_state(dom_data[1]) + dom_hash[:cpu] = dom_data[3] + dom_hash[:memory] = dom_data[4] + dom_hash[:net_tx] = dom_data[10].to_i * 1024 + dom_hash[:net_rx] = dom_data[11].to_i * 1024 if !name.match(/^one-\d/) && vm_templates[name] dom_hash[:template] = diff --git a/src/vmm_mad/remotes/sl/sl_driver.rb b/src/vmm_mad/remotes/sl/sl_driver.rb index bfce896620..80fcae667d 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.rb +++ b/src/vmm_mad/remotes/sl/sl_driver.rb @@ -87,7 +87,7 @@ class SLDriver }, "BLOCKDEVICE" => { :opt => 'blockDevices', - :proc => lambda {|str| + :proc => lambda {|str| [{:device=>0, :diskImage=>{:capacity=>str}}]} }, @@ -109,14 +109,14 @@ class SLDriver }, "SSHKEYS" => { :opt => 'sshKeys', # Array of SSH Keys ids - :proc => lambda {|str| + :proc => lambda {|str| sshArray = Array.new str.split(",").each { |id| - sshArray << {:id=> id} + sshArray << {:id=> id} } sshArray } - + }, "POSTSCRIPT" => { :opt => 'postInstallScriptUri' @@ -159,7 +159,7 @@ class SLDriver # SoftLayer constructor, loads credentials and endpoint def initialize(host) @host = host - + public_cloud_sl_conf = YAML::load(File.read(SL_DRIVER_CONF)) @instance_types = public_cloud_sl_conf['instance_types'] @@ -270,7 +270,7 @@ class SLDriver vms = @sl_client['Account'].getVirtualGuests vms_info = "VM_POLL=YES\n" - + usedcpu = 0 usedmemory = 0 @@ -279,7 +279,7 @@ class SLDriver vm = @sl_client['Virtual_Guest'].object_with_id(i['id'].to_i) poll_data = parse_poll(vm) # Retrieve Virtual Guest to consult tags - + tags = vm.getTagReferences # We know that the first one is the ONE identifier one_id=nil @@ -326,7 +326,7 @@ private @instance_types[name]['memory'].to_i * 1024 * 1024 end - # Get the SoftLayer section of the template. If more than one SoftLayer + # Get the SoftLayer section of the template. If more than one SoftLayer # section, the DATACENTER element is used and matched with the host def get_deployment_info(host, xml_text) xml = REXML::Document.new xml_text @@ -334,7 +334,7 @@ private sl = nil all_sl_elements = xml.root.get_elements("//USER_TEMPLATE/PUBLIC_CLOUD") - all_sl_elements = all_sl_elements.select { |element| + all_sl_elements = all_sl_elements.select { |element| element.elements["TYPE"].text.downcase.eql? "softlayer" } @@ -382,10 +382,10 @@ private # Retrieve the VM information from the SoftLayer instance def parse_poll(vm) begin - info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ - "#{POLL_ATTRIBUTE[:nettx]}=0 " \ - "#{POLL_ATTRIBUTE[:netrx]}=0 " + info = "#{POLL_ATTRIBUTE[:memory]}=0 " \ + "#{POLL_ATTRIBUTE[:cpu]}=0 " \ + "#{POLL_ATTRIBUTE[:net_tx]}=0 " \ + "#{POLL_ATTRIBUTE[:net_rx]}=0 " state = "" @@ -518,7 +518,7 @@ private end # Load the default values that will be used to create a new instance, if - # not provided in the template. These values are defined in the + # not provided in the template. These values are defined in the # SL_DRIVER_DEFAULT file def load_default_template_values @defaults = Hash.new @@ -559,4 +559,4 @@ private exit(-1) end end -end \ No newline at end of file +end diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index a85ff1fbc6..4e1fcea8b3 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -161,21 +161,21 @@ class VIClient # if not found # @param rpool [String] the ResourcePool name ######################################################################## - def find_resource_pool(poolName) + def find_resource_pool(poolName) baseEntity = @cluster entityArray = poolName.split('/') entityArray.each do |entityArrItem| if entityArrItem != '' if baseEntity.is_a? RbVmomi::VIM::Folder - baseEntity = baseEntity.childEntity.find { |f| - f.name == entityArrItem + baseEntity = baseEntity.childEntity.find { |f| + f.name == entityArrItem } or return @cluster.resourcePool elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource - baseEntity = baseEntity.resourcePool.resourcePool.find { |f| - f.name == entityArrItem + baseEntity = baseEntity.resourcePool.resourcePool.find { |f| + f.name == entityArrItem } or return @cluster.resourcePool elsif baseEntity.is_a? RbVmomi::VIM::ResourcePool - baseEntity = baseEntity.resourcePool.find { |f| + baseEntity = baseEntity.resourcePool.find { |f| f.name == entityArrItem } or return @cluster.resourcePool else @@ -183,12 +183,12 @@ class VIClient end end end - - if !baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and + + if !baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and baseEntity.respond_to?(:resourcePool) - baseEntity = baseEntity.resourcePool + baseEntity = baseEntity.resourcePool end - + baseEntity end @@ -300,7 +300,7 @@ class VIClient vmpool = OpenNebula::VirtualMachinePool.new( (one_client||@one), OpenNebula::Pool::INFO_ALL) - rc = vmpool.info + rc = vmpool.info hostpool = OpenNebula::HostPool.new((one_client||@one)) rc = hostpool.info @@ -312,10 +312,10 @@ class VIClient vms = get_entities(dc.vmFolder, 'VirtualMachine') ccrs = get_entities(dc.hostFolder, 'ClusterComputeResource') - vm_list = vms.select { |v| + vm_list = vms.select { |v| # Get rid of VM Templates and VMs not in running state v.config && - v.config.template != true && + v.config.template != true && v.summary.runtime.powerState == "poweredOn" } @@ -326,7 +326,7 @@ class VIClient # Do not reimport VMs deployed by OpenNebula # since the core will get confused with the IDs - next if vi_tmp.vm.name.match(/one-\d/) + next if vi_tmp.vm.name.match(/one-\d/) container_hostname = vi_tmp.vm.runtime.host.parent.name @@ -375,7 +375,7 @@ class VIClient end ######################################################################## - # Builds a hash with the Datacenter / CCR (Distributed)Networks + # Builds a hash with the Datacenter / CCR (Distributed)Networks # for this VCenter # @param one_client [OpenNebula::Client] Use this client instead of @one # @return [Hash] in the form @@ -388,7 +388,7 @@ class VIClient (one_client||@one), OpenNebula::Pool::INFO_ALL) rc = vnpool.info # TODO check error - # + # datacenters = get_entities(@root, 'Datacenter') datacenters.each { |dc| @@ -744,7 +744,7 @@ class VCenterVm current_memory = vm.config.hardware.memoryMB if current_cpu != expected_cpu or current_memory != expected_memory - capacity_hash = {:numCPUs => expected_cpu.to_i, + capacity_hash = {:numCPUs => expected_cpu.to_i, :memoryMB => expected_memory } spec = RbVmomi::VIM.VirtualMachineConfigSpec(capacity_hash) vm.ReconfigVM_Task(:spec => spec).wait_for_completion @@ -971,7 +971,7 @@ class VCenterVm spec_hash = calculate_addnic_spec(vm, mac, bridge, model) - spec = RbVmomi::VIM.VirtualMachineConfigSpec({:deviceChange => + spec = RbVmomi::VIM.VirtualMachineConfigSpec({:deviceChange => [spec_hash]}) vm.ReconfigVM_Task(:spec => spec).wait_for_completion @@ -1000,7 +1000,7 @@ class VCenterVm } vm.ReconfigVM_Task(:spec => spec).wait_for_completion - end + end ######################################################################## # Initialize the vm monitor information @@ -1052,10 +1052,10 @@ class VCenterVm str_info << "GUEST_IP=" << @guest_ip.to_s << " " if @guest_ip str_info << "STATE=" << @state << " " - str_info << "USEDCPU=" << @used_cpu.to_s << " " - str_info << "USEDMEMORY=" << @used_memory.to_s << " " - str_info << "NETRX=" << @net_rx.to_s << " " - str_info << "NETTX=" << @net_tx.to_s << " " + str_info << "CPU=" << @used_cpu.to_s << " " + str_info << "MEMORY=" << @used_memory.to_s << " " + str_info << "NET_RX=" << @net_rx.to_s << " " + str_info << "NET_TX=" << @net_tx.to_s << " " str_info << "ESX_HOST=" << @esx_host.to_s << " " str_info << "GUEST_STATE=" << @guest_state.to_s << " " str_info << "VMWARETOOLS_RUNNING_STATUS=" << @vmware_tools.to_s << " " @@ -1091,7 +1091,7 @@ class VCenterVm notes = @vm.config.annotation.gsub("\\", "\\\\").gsub("\"", "\\\"") str << "DESCRIPTION = \"#{notes}\"\n" end - + case @vm.guest.guestFullName when /CentOS/i str << "LOGO=images/logos/centos.png" @@ -1134,7 +1134,7 @@ class VCenterVm vp = @vm.config.extraConfig.select{|v| v[:key]=="remotedisplay.vnc.port"} - keymap = @vm.config.extraConfig.select{|v| + keymap = @vm.config.extraConfig.select{|v| v[:key]=="remotedisplay.vnc.keymap"} if vp.size > 0 @@ -1204,7 +1204,7 @@ private vm.config.hardware.device.each{ |dv| card_num = card_num + 1 if is_nic?(dv) - } + } nic_card = case model when "virtuale1000", "e1000" @@ -1231,17 +1231,17 @@ private :network => network) else port = RbVmomi::VIM::DistributedVirtualSwitchPortConnection( - :switchUuid => + :switchUuid => network.config.distributedVirtualSwitch.uuid, :portgroupKey => network.key) - backing = + backing = RbVmomi::VIM.VirtualEthernetCardDistributedVirtualPortBackingInfo( :port => port) end return {:operation => :add, :device => nic_card.new( - :key => 0, + :key => 0, :deviceInfo => { :label => "net" + card_num.to_s, :summary => bridge @@ -1308,7 +1308,7 @@ private raise "Cannot clone VM Template" if vm.nil? - vm.Destroy_Task.wait_for_completion + vm.Destroy_Task.wait_for_completion vm = vc_template.CloneVM_Task( :folder => vc_template.parent, :name => "one-#{vmid}", @@ -1382,7 +1382,7 @@ private cpu = xml.root.elements["//TEMPLATE/VCPU"].text memory = xml.root.elements["//TEMPLATE/MEMORY"].text - capacity_spec = {:numCPUs => cpu.to_i, + capacity_spec = {:numCPUs => cpu.to_i, :memoryMB => memory } # Perform the VM reconfiguration diff --git a/src/vmm_mad/remotes/vmware/vi_driver.rb b/src/vmm_mad/remotes/vmware/vi_driver.rb index c404cf35a0..470b74df8e 100644 --- a/src/vmm_mad/remotes/vmware/vi_driver.rb +++ b/src/vmm_mad/remotes/vmware/vi_driver.rb @@ -240,7 +240,7 @@ class VIVm ############################################################################ def reset @vm.ResetVM_Task.wait_for_completion - end + end ######################################################################## # Initialize the vm monitor information @@ -297,11 +297,11 @@ class VIVm str_info = "" - str_info << "STATE=" << @state << " " - str_info << "USEDCPU=" << @used_cpu.to_s << " " - str_info << "USEDMEMORY="<< @used_memory.to_s << " " - str_info << "NETRX=" << @net_rx.to_s << " " - str_info << "NETTX=" << @net_tx.to_s + str_info << "STATE=" << @state << " " + str_info << "CPU=" << @used_cpu.to_s << " " + str_info << "MEMORY=" << @used_memory.to_s << " " + str_info << "NET_RX=" << @net_rx.to_s << " " + str_info << "NET_TX=" << @net_tx.to_s end private