1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

L #-: Linting for rubocop 1.17.0

This commit is contained in:
Tino Vazquez 2021-06-22 18:11:42 +02:00
parent a4cb02a79f
commit 05295f1ef4
14 changed files with 25 additions and 29 deletions

View File

@ -560,6 +560,9 @@ Layout/MultilineOperationIndentation:
# STYLE
#######
Style/QuotedSymbols:
Enabled: false
Style/OptionalBooleanParameter:
Enabled: false

View File

@ -104,7 +104,9 @@ if VCenterDriver::FileHelper.remote_or_needs_unpack?(img_path)
temp_folder = File.join(VAR_LOCATION, "vcenter/#{target_path}")
temp_file = File.join(temp_folder, File.basename(img_path))
# if the original file doesnt have the vmdk extension, add it
if !temp_file.match(/\.vmdk$/) && !temp_file.match(/\.iso$/) && !VCenterDriver::FileHelper.from_s3?(img_path)
if !temp_file.match(/\.vmdk$/) &&
!temp_file.match(/\.iso$/) &&
!VCenterDriver::FileHelper.from_s3?(img_path)
temp_file += '.vmdk'
end

View File

@ -576,7 +576,7 @@ module OpenNebula
time_offset = offset * period.to_i
end
tmp_str = "SCHED_ACTION = ["
tmp_str = 'SCHED_ACTION = ['
tmp_str << "ACTION = #{action},"
tmp_str << "ARGS = \"#{args}\"," if args
tmp_str << "TIME = #{now + time_offset}]"

View File

@ -134,7 +134,7 @@ module NUMA
distance_h = {}
distance_a.each_with_index {|d, i| distance_h[d.to_i] = i }
distance_h = Hash[distance_h.sort]
distance_h = distance_h.sort.to_h
closer = ''
distance_h.each {|_, v| closer << v.to_s << ' ' }

View File

@ -249,7 +249,7 @@ class InstanceCache
def select_vms
vms = []
execute_retry('SELECT * from vms').each do |vm|
vm = Hash[[:uuid, :id, :name, :state, :type].zip(vm)]
vm = [:uuid, :id, :name, :state, :type].zip(vm).to_h
vm[:deploy_id] = vm[:uuid]
vms << vm
end

View File

@ -484,7 +484,7 @@ module OneCfg::Config::Type
elsif value.is_a?(Array)
value.collect {|v| unsymbolize(v) }
elsif value.is_a?(Hash)
Hash[value.collect {|k, v| [unsymbolize(k), unsymbolize(v)] }]
value.collect {|k, v| [unsymbolize(k), unsymbolize(v)] }.to_h
else
value
end
@ -505,7 +505,7 @@ module OneCfg::Config::Type
elsif value.is_a?(Array)
value.collect {|v| symbolize(v) }
elsif value.is_a?(Hash)
Hash[value.collect {|k, v| [symbolize(k), symbolize(v)] }]
value.collect {|k, v| [symbolize(k), symbolize(v)] }.to_h
else
value
end

View File

@ -62,7 +62,8 @@ module OneProvision
user_data << "chmod 644 ~/.ssh/authorized_keys\n"
# Rename last NIC to eth_one
user_data << "NIC=$(ip --brief link show | tail -1 | awk '{print $1}')\n"
user_data << 'NIC=$(ip --brief link show | '\
"tail -1 | awk '{print $1}')\n"
user_data << "ip link set down $NIC\n"
user_data << "ip link set $NIC name eth_one\n"
user_data << 'ip link set up $NIC'

View File

@ -67,7 +67,6 @@ module OneProvision
i['internal_ip']
end
end
end

View File

@ -209,7 +209,8 @@ class SunstoneGuac < SunstoneRemoteConnections
private_key = user['TEMPLATE/SSH_PRIVATE_KEY']
if private_key.nil?
error_message = "SSH_PRIVATE_KEY not present in the USER:#{OpenNebula::User::SELF} TEMPLATE"
error_message = 'SSH_PRIVATE_KEY not present in the USER:'\
"#{OpenNebula::User::SELF} TEMPLATE"
return { :error => error(400, error_message) }
end

View File

@ -976,7 +976,6 @@ class ExecDriver < VirtualMachineDriver
target_device = target_device.text if target_device
nic_alias = false
external = false
if xml_data.elements["VM/TEMPLATE/NIC[ATTACH='YES']"]
base_tmpl = "VM/TEMPLATE/NIC[ATTACH='YES']"
@ -991,14 +990,10 @@ class ExecDriver < VirtualMachineDriver
target = xml_data.elements["#{base_tmpl}/TARGET"]
vn_mad = xml_data.elements["#{base_tmpl}/VN_MAD"]
external = xml_data.elements["#{base_tmpl}/EXTERNAL"]
source = source.text.strip
mac = mac.text.strip
target = target.text.strip
vn_mad = vn_mad.text.strip
external = !external.nil? || vn_mad == 'elastic'
rescue StandardError
send_message(action, RESULT[:failure], id,
'Missing VN_MAD, BRIDGE, TARGET or MAC in VM NIC')
@ -1099,7 +1094,6 @@ class ExecDriver < VirtualMachineDriver
target_device = target_device.text if target_device
nic_alias = false
external = false
if xml_data.elements["VM/TEMPLATE/NIC[ATTACH='YES']"]
base_tmpl = "VM/TEMPLATE/NIC[ATTACH='YES']"
@ -1111,11 +1105,6 @@ class ExecDriver < VirtualMachineDriver
begin
mac = xml_data.elements["#{base_tmpl}/MAC"]
mac = mac.text.strip
external = xml_data.elements["#{base_tmpl}/EXTERNAL"]
vn_mad = xml_data.elements["#{base_tmpl}/VN_MAD"].text.strip
external = !external.nil? || vn_mad == 'elastic'
rescue StandardError
send_message(action, RESULT[:failure], id,
"Error in #{ACTION[:detach_nic]}, MAC needed in NIC")

View File

@ -1145,14 +1145,14 @@ module VCenterDriver
vswitchspec =
RbVmomi::VIM::HostVirtualSwitchSpec(
:bridge => hostbridge,
:mtu => mtu,
:numPorts => num_ports
:mtu => mtu,
:numPorts => num_ports
)
begin
nws
.UpdateVirtualSwitch(
:vswitchName => name,
:spec => vswitchspec
:spec => vswitchspec
)
rescue StandardError => e
raise "The standard switch with name #{name} \
@ -1463,7 +1463,7 @@ module VCenterDriver
nws
.UpdatePortGroup(
:pgName => nr[:name],
:portgrp => nr[:spec]
:portgrp => nr[:spec]
)
rescue StandardError => e
raise "A rollback operation for standard \

View File

@ -3070,7 +3070,8 @@ end
# Create a snapshot for the VM
def create_snapshot(snap_id, snap_name)
memory_dumps = true
memory_dumps = CONFIG[:memory_dumps] unless CONFIG[:memory_dumps].nil?
memory_dumps = CONFIG[:memory_dumps] \
unless CONFIG[:memory_dumps].nil?
snapshot_hash = {
:name => snap_id,

View File

@ -175,8 +175,6 @@ module VirtualMachineMonitor
@monitor[:diskwrbytes] = previous_diskwrbytes +
(write_kbpersec * 1024 * refresh_rate).to_i
end
# rubocop:enable Naming/VariableName
# rubocop:enable Style/FormatStringToken
# Generates a OpenNebula IM Driver valid string with the monitor info
def info

View File

@ -69,7 +69,8 @@ drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VM')
deploy_id = drv_action['DEPLOY_ID']
host_id = drv_action['HISTORY_RECORDS/HISTORY[last()]/HID']
deploy = {}
deploy[:boot] = drv_action['TEMPLATE/OS/BOOT'] unless drv_action['TEMPLATE/OS/BOOT'].nil?
deploy[:boot] = drv_action['TEMPLATE/OS/BOOT'] \
unless drv_action['TEMPLATE/OS/BOOT'].nil?
begin
retries ||= 0
@ -111,7 +112,8 @@ begin
spec_hash = {}
spec_hash[:cpuHotAddEnabled] = vm.cpu_hot_add_enabled?
spec_hash[:memoryHotAddEnabled] = vm.memory_hot_add_enabled?
spec_hash[:uuid] = drv_action['TEMPLATE/OS/UUID'] unless drv_action['TEMPLATE/OS/UUID'].nil?
spec_hash[:uuid] = drv_action['TEMPLATE/OS/UUID'] \
unless drv_action['TEMPLATE/OS/UUID'].nil?
spec = RbVmomi::VIM.VirtualMachineConfigSpec(
spec_hash