diff --git a/share/hooks/autostart/host b/share/hooks/autostart/host index 6e15524934..50b37493f9 100755 --- a/share/hooks/autostart/host +++ b/share/hooks/autostart/host @@ -185,7 +185,7 @@ xml_host_template.xpath('HOST/VMS').text.split.each do |vm_id| last_action = vm["#{last_history_xpath}/ACTION"] last_action_str = OpenNebula::VirtualMachine.get_history_action(last_action) - if !%w[none live-migrate].include?(last_action_str) && autostart != 'always' + if !['none', 'live-migrate'].include?(last_action_str) && autostart != 'always' log "vm #{vm_id}: skip: last_action (#{last_action_str}) " \ 'is not none or live-migrate' next diff --git a/share/sudoers/sudoers.rb b/share/sudoers/sudoers.rb index 277794422e..17adaad7b1 100644 --- a/share/sudoers/sudoers.rb +++ b/share/sudoers/sudoers.rb @@ -34,15 +34,15 @@ class Sudoers 'ip route *', 'ip neighbour *' ], - :LVM => %w[ - lvcreate lvremove lvs vgdisplay lvchange lvscan lvextend + :LVM => [ + 'lvcreate', 'lvremove', 'lvs', 'vgdisplay', 'lvchange', 'lvscan', 'lvextend' ], - :OVS => %w[ovs-ofctl ovs-vsctl], - :CEPH => %w[rbd], - :LXD => %w[ - /snap/bin/lxc /usr/bin/catfstab mount umount mkdir lsblk losetup - kpartx qemu-nbd blkid e2fsck resize2fs xfs_growfs rbd-nbd - xfs_admin tune2fs + :OVS => ['ovs-ofctl', 'ovs-vsctl'], + :CEPH => ['rbd'], + :LXD => [ + '/snap/bin/lxc', '/usr/bin/catfstab', 'mount', 'umount', 'mkdir', 'lsblk', + 'losetup', 'kpartx', 'qemu-nbd', 'blkid', 'e2fsck', 'resize2fs', 'xfs_growfs', + 'rbd-nbd', 'xfs_admin', 'tune2fs' ], :HA => [ 'systemctl start opennebula-flow', @@ -62,18 +62,18 @@ class Sudoers 'arping', 'ip address *' ], - :MARKET => %W[#{lib_location}/sh/create_container_image.sh - #{lib_location}/sh/create_docker_image.sh ], - :FIRECRACKER => %w[/usr/bin/jailer - /usr/sbin/one-clean-firecracker-domain - /usr/sbin/one-prepare-firecracker-domain], - :LXC => %w[ - mount umount bindfs losetup qemu-nbd lxc-attach lxc-config - lxc-create lxc-destroy lxc-info lxc-ls lxc-start lxc-stop - lxc-console e2fsck resize2fs xfs_growfs rbd-nbd + :MARKET => ["#{lib_location}/sh/create_container_image.sh", + "#{lib_location}/sh/create_docker_image.sh"], + :FIRECRACKER => ['/usr/bin/jailer', + '/usr/sbin/one-clean-firecracker-domain', + '/usr/sbin/one-prepare-firecracker-domain'], + :LXC => [ + 'mount', 'umount', 'bindfs', 'losetup', 'qemu-nbd', 'lxc-attach', 'lxc-config', + 'lxc-create', 'lxc-destroy', 'lxc-info', 'lxc-ls', 'lxc-start', 'lxc-stop', + 'lxc-console', 'e2fsck', 'resize2fs', 'xfs_growfs', 'rbd-nbd' ], :MEM => ['sysctl vm.drop_caches=3 vm.compact_memory=1'], - :VGPU => %w[sudo /var/tmp/one/vgpu] + :VGPU => ['sudo', '/var/tmp/one/vgpu'] } end diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index c9658023c5..b48b316d1a 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -20,7 +20,7 @@ require 'csv' module CLIHelper # Available operators for filtering operations - FILTER_OPS = %w[= != < <= > >= ~] + FILTER_OPS = ['=', '!=', '<', '<=', '>', '>=', '~'] # CLI general options LIST = { @@ -182,23 +182,23 @@ module CLIHelper ANSI_YELLOW = "\33[33m" # CLI states - OK_STATES = %w[runn rdy on SUCCESS RUNNING] - BAD_STATES = %w[fail - err - error - ERROR - FAILED_DEPLOYING - FAILED_DEPLOYING_NETS - FAILED_UNDEPLOYING - FAILED_UNDEPLOYING_NETS - FAILED_SCALING] - REGULAR_STATES = %w[PENDING - DEPLOYING - DEPLOYING_NETS - UNDEPLOYING - UNDEPLOYING_NETS - CONFIGURING - WARNING] + OK_STATES = ['runn', 'rdy', 'on', 'SUCCESS', 'RUNNING'] + BAD_STATES = ['fail', + 'err', + 'error', + 'ERROR', + 'FAILED_DEPLOYING', + 'FAILED_DEPLOYING_NETS', + 'FAILED_UNDEPLOYING', + 'FAILED_UNDEPLOYING_NETS', + 'FAILED_SCALING'] + REGULAR_STATES = ['PENDING', + 'DEPLOYING', + 'DEPLOYING_NETS', + 'UNDEPLOYING', + 'UNDEPLOYING_NETS', + 'CONFIGURING', + 'WARNING'] # Set state color # diff --git a/src/cli/one_helper/oneflow_helper.rb b/src/cli/one_helper/oneflow_helper.rb index cfd703d702..894d8940c1 100644 --- a/src/cli/one_helper/oneflow_helper.rb +++ b/src/cli/one_helper/oneflow_helper.rb @@ -297,7 +297,7 @@ class OneFlowHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % 'PERMISSIONS', false) - %w[OWNER GROUP OTHER].each do |e| + ['OWNER', 'GROUP', 'OTHER'].each do |e| mask = '---' permissions_hash = document['PERMISSIONS'] mask[0] = 'u' if permissions_hash["#{e}_U"] == '1' diff --git a/src/cli/one_helper/oneflowtemplate_helper.rb b/src/cli/one_helper/oneflowtemplate_helper.rb index 9ba542e596..d0c63ed069 100644 --- a/src/cli/one_helper/oneflowtemplate_helper.rb +++ b/src/cli/one_helper/oneflowtemplate_helper.rb @@ -157,7 +157,7 @@ class OneFlowTemplateHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % 'PERMISSIONS', false) - %w[OWNER GROUP OTHER].each do |e| + ['OWNER', 'GROUP', 'OTHER'].each do |e| mask = '---' permissions_hash = document['PERMISSIONS'] mask[0] = 'u' if permissions_hash["#{e}_U"] == '1' diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 46d5a7860e..578c0a6eca 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -460,10 +460,10 @@ class OneHostHelper < OpenNebulaHelper::OneHelper n_elems = options[:n_elems] || 8 # Different available size units - units = %w[K M G T] + units = ['K', 'M', 'G', 'T'] # Attrs that need units conversion - attrs = %w[FREE_MEMORY USED_MEMORY] + attrs = ['FREE_MEMORY', 'USED_MEMORY'] if unit && !units.include?(unit) STDERR.puts "Invalid unit `#{unit}`" diff --git a/src/cli/one_helper/oneimage_helper.rb b/src/cli/one_helper/oneimage_helper.rb index 7331e17d2a..2ecfc82a4b 100644 --- a/src/cli/one_helper/oneimage_helper.rb +++ b/src/cli/one_helper/oneimage_helper.rb @@ -22,7 +22,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper # This list contains prefixes that should skip adding user home to the path # This must have the same content as the case $FROM in downloader.sh - PREFIXES = %w[http https ssh s3 rbd vcenter lxd docker dockerfile] + PREFIXES = ['http', 'https', 'ssh', 's3', 'rbd', 'vcenter', 'lxd', 'docker', 'dockerfile'] TEMPLATE_OPTIONS=[ { @@ -61,7 +61,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper :format => String, :proc => lambda do |o, _options| prefix=o.strip.downcase - if %w[hd sd xvd vd].include? prefix + if ['hd', 'sd', 'xvd', 'vd'].include? prefix [0, prefix] else [-1, 'The prefix must be hd, sd, xvd or vd'] @@ -322,7 +322,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % 'PERMISSIONS', false) - %w[OWNER GROUP OTHER].each do |e| + ['OWNER', 'GROUP', 'OTHER'].each do |e| mask = '---' mask[0] = 'u' if image["PERMISSIONS/#{e}_U"] == '1' mask[1] = 'm' if image["PERMISSIONS/#{e}_M"] == '1' diff --git a/src/cli/one_helper/onemarketapp_helper.rb b/src/cli/one_helper/onemarketapp_helper.rb index 096634700f..8aba278921 100644 --- a/src/cli/one_helper/onemarketapp_helper.rb +++ b/src/cli/one_helper/onemarketapp_helper.rb @@ -60,7 +60,7 @@ class OneMarketPlaceAppHelper < OpenNebulaHelper::OneHelper } # Available market place mads to import apps on them - MARKETS = %w[http s3] + MARKETS = ['http', 's3'] def self.rname 'MARKETPLACEAPP' @@ -413,7 +413,7 @@ class OneMarketPlaceAppHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % 'PERMISSIONS', false) - %w[OWNER GROUP OTHER].each do |e| + ['OWNER', 'GROUP', 'OTHER'].each do |e| mask = '---' mask[0] = 'u' if app["PERMISSIONS/#{e}_U"] == '1' mask[1] = 'm' if app["PERMISSIONS/#{e}_M"] == '1' diff --git a/src/cli/one_helper/onevcenter_helper.rb b/src/cli/one_helper/onevcenter_helper.rb index 214d9d3bfd..efc1377def 100644 --- a/src/cli/one_helper/onevcenter_helper.rb +++ b/src/cli/one_helper/onevcenter_helper.rb @@ -58,20 +58,20 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper # TABLE = { VOBJECT::DATASTORE => { - :struct => %w[DATASTORE_LIST DATASTORE], + :struct => ['DATASTORE_LIST', 'DATASTORE'], :columns => { :IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10 }, :cli => [:host], :dialogue => ->(arg) {} }, VOBJECT::TEMPLATE => { - :struct => %w[TEMPLATE_LIST TEMPLATE], + :struct => ['TEMPLATE_LIST', 'TEMPLATE'], :columns => { :IMID => 5, :REF => 10, :NAME => 50 }, :cli => [:host], :dialogue => ->(arg) { OneVcenterHelper.template_dialogue(arg) } }, VOBJECT::NETWORK => { - :struct => %w[NETWORK_LIST NETWORK], + :struct => ['NETWORK_LIST', 'NETWORK'], :columns => { :IMID => 5, :REF => 15, @@ -82,13 +82,13 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper :dialogue => ->(arg) { OneVcenterHelper.network_dialogue(arg) } }, VOBJECT::IMAGE => { - :struct => %w[IMAGE_LIST IMAGE], + :struct => ['IMAGE_LIST', 'IMAGE'], :columns => { :IMID => 5, :REF => 35, :PATH => 60 }, :cli => [:host, :datastore], :dialogue => ->(arg) {} }, VOBJECT::HOST => { - :struct => %w[HOST_LIST HOST], + :struct => ['HOST_LIST', 'HOST'], :columns => { :DATACENTER => 10, :NAME => 30, :REF => 35 }, :cli => [], :dialogue => ->(arg) {} @@ -471,7 +471,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper ' do you want to create (IPv[4],IPv[6], [E]thernet)? ' type_answer = ask.call(question, 'ether') - supported_types = %w[4 6 ether e ip4 ip6] + supported_types = ['4', '6', 'ether', 'e', 'ip4', 'ip6'] if !supported_types.include?(type_answer) type_answer = 'e' STDOUT.puts " Type [#{type_answer}] not supported,"\ diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index 9f05061bb3..0f8b5d64a1 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -367,7 +367,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % 'PERMISSIONS', false) - %w[OWNER GROUP OTHER].each do |e| + ['OWNER', 'GROUP', 'OTHER'].each do |e| mask = '---' mask[0] = 'u' if vn["PERMISSIONS/#{e}_U"] == '1' mask[1] = 'm' if vn["PERMISSIONS/#{e}_M"] == '1' diff --git a/src/cli/oneprovision b/src/cli/oneprovision index 42e5c75d3a..ee64f33ab2 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -351,7 +351,7 @@ CommandParser::CmdParser.new(ARGV) do (OneProvision::Provision::RESOURCES + OneProvision::Provision::FULL_CLUSTER - - %w[hosts marketplaceapps flowtemplates]).each do |resource| + ['hosts', 'marketplaceapps', 'flowtemplates']).each do |resource| list_desc = <<-EOT List all available #{resource} EOT @@ -368,7 +368,7 @@ CommandParser::CmdParser.new(ARGV) do (OneProvision::Provision::RESOURCES + OneProvision::Provision::FULL_CLUSTER - - %w[hosts marketplaceapps]).each do |resource| + ['hosts', 'marketplaceapps']).each do |resource| delete_desc = <<-EOT Deletes and unprovisions the given #{resource} EOT diff --git a/src/cli/oneuser b/src/cli/oneuser index d9e0d8896d..c2b1a72193 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -604,7 +604,7 @@ CommandParser::CmdParser.new(ARGV) do command :passwdsearch, passwdsearch_desc, :driver, :password, :options => [CLIHelper::CSV_OPT, OpenNebulaHelper::XML] do - options[:list] = %w[ID NAME AUTH PASSWORD] + options[:list] = ['ID', 'NAME', 'AUTH', 'PASSWORD'] options[:filter] = ["AUTH=#{args[0]}", "PASSWORD=#{args[1]}"] helper.list_pool(options) diff --git a/src/cli/onevm b/src/cli/onevm index 75c1fd1821..f032f37ee0 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -258,7 +258,7 @@ CommandParser::CmdParser.new(ARGV) do } OpenNebulaHelper::TEMPLATE_OPTIONS_VM.delete_if do |v| - %w[as_gid as_uid].include?(v[:name]) + ['as_gid', 'as_uid'].include?(v[:name]) end ######################################################################## diff --git a/src/flow/lib/EventManager.rb b/src/flow/lib/EventManager.rb index bb8d490bae..60c723467a 100644 --- a/src/flow/lib/EventManager.rb +++ b/src/flow/lib/EventManager.rb @@ -40,28 +40,28 @@ class EventManager :wait_release_action ] - FAILURE_STATES = %w[ - BOOT_FAILURE - BOOT_MIGRATE_FAILURE - PROLOG_MIGRATE_FAILURE - PROLOG_FAILURE - EPILOG_FAILURE - EPILOG_STOP_FAILURE - EPILOG_UNDEPLOY_FAILURE - PROLOG_MIGRATE_POWEROFF_FAILURE - PROLOG_MIGRATE_SUSPEND_FAILURE - PROLOG_MIGRATE_UNKNOWN_FAILURE - BOOT_UNDEPLOY_FAILURE - BOOT_STOPPED_FAILURE - PROLOG_RESUME_FAILURE - PROLOG_UNDEPLOY_FAILURE + FAILURE_STATES = [ + 'BOOT_FAILURE', + 'BOOT_MIGRATE_FAILURE', + 'PROLOG_MIGRATE_FAILURE', + 'PROLOG_FAILURE', + 'EPILOG_FAILURE', + 'EPILOG_STOP_FAILURE', + 'EPILOG_UNDEPLOY_FAILURE', + 'PROLOG_MIGRATE_POWEROFF_FAILURE', + 'PROLOG_MIGRATE_SUSPEND_FAILURE', + 'PROLOG_MIGRATE_UNKNOWN_FAILURE', + 'BOOT_UNDEPLOY_FAILURE', + 'BOOT_STOPPED_FAILURE', + 'PROLOG_RESUME_FAILURE', + 'PROLOG_UNDEPLOY_FAILURE' ] - SUBSCRIBE_STATES = %w[ - STOPPED - SUSPENDED - POWEROFF - UNDEPLOYED + SUBSCRIBE_STATES = [ + 'STOPPED', + 'SUSPENDED', + 'POWEROFF', + 'UNDEPLOYED' ] # -------------------------------------------------------------------------- diff --git a/src/flow/lib/ServiceWatchDog.rb b/src/flow/lib/ServiceWatchDog.rb index 5c9dc6e0db..21079871d0 100644 --- a/src/flow/lib/ServiceWatchDog.rb +++ b/src/flow/lib/ServiceWatchDog.rb @@ -36,9 +36,9 @@ class ServiceWD ############################################################################ # WARNING STATES ############################################################################ - WARNING_STATES = %w[ - POWEROFF - UNKNOWN + WARNING_STATES = [ + 'POWEROFF', + 'UNKNOWN' ] + EventManager::FAILURE_STATES # Class constructor diff --git a/src/flow/lib/models/role.rb b/src/flow/lib/models/role.rb index d725c8f20c..181af8b688 100644 --- a/src/flow/lib/models/role.rb +++ b/src/flow/lib/models/role.rb @@ -32,26 +32,26 @@ module OpenNebula attr_reader :service # Actions that can be performed on the VMs of a given Role - SCHEDULE_ACTIONS = %w[ - terminate - terminate-hard - undeploy - undeploy-hard - hold - release - stop - suspend - resume - reboot - reboot-hard - poweroff - poweroff-hard - snapshot-create - snapshot-revert - snapshot-delete - disk-snapshot-create - disk-snapshot-revert - disk-snapshot-delete + SCHEDULE_ACTIONS = [ + 'terminate', + 'terminate-hard', + 'undeploy', + 'undeploy-hard', + 'hold', + 'release', + 'stop', + 'suspend', + 'resume', + 'reboot', + 'reboot-hard', + 'poweroff', + 'poweroff-hard', + 'snapshot-create', + 'snapshot-revert', + 'snapshot-delete', + 'disk-snapshot-create', + 'disk-snapshot-revert', + 'disk-snapshot-delete' ] STATE = { @@ -69,52 +69,52 @@ module OpenNebula 'HOLD' => 11 } - STATE_STR = %w[ - PENDING - DEPLOYING - RUNNING - UNDEPLOYING - WARNING - DONE - FAILED_UNDEPLOYING - FAILED_DEPLOYING - SCALING - FAILED_SCALING - COOLDOWN - HOLD + STATE_STR = [ + 'PENDING', + 'DEPLOYING', + 'RUNNING', + 'UNDEPLOYING', + 'WARNING', + 'DONE', + 'FAILED_UNDEPLOYING', + 'FAILED_DEPLOYING', + 'SCALING', + 'FAILED_SCALING', + 'COOLDOWN', + 'HOLD' ] - RECOVER_DEPLOY_STATES = %w[ - FAILED_DEPLOYING - DEPLOYING - PENDING + RECOVER_DEPLOY_STATES = [ + 'FAILED_DEPLOYING', + 'DEPLOYING', + 'PENDING' ] - RECOVER_UNDEPLOY_STATES = %w[ - FAILED_UNDEPLOYING - UNDEPLOYING + RECOVER_UNDEPLOY_STATES = [ + 'FAILED_UNDEPLOYING', + 'UNDEPLOYING' ] - RECOVER_SCALE_STATES = %w[ - FAILED_SCALING - SCALING + RECOVER_SCALE_STATES = [ + 'FAILED_SCALING', + 'SCALING' ] - VM_FAILURE_STATES = %w[ - BOOT_FAILURE - BOOT_MIGRATE_FAILURE - PROLOG_MIGRATE_FAILURE - PROLOG_FAILURE - EPILOG_FAILURE - EPILOG_STOP_FAILURE - EPILOG_UNDEPLOY_FAILURE - PROLOG_MIGRATE_POWEROFF_FAILURE - PROLOG_MIGRATE_SUSPEND_FAILURE - PROLOG_MIGRATE_UNKNOWN_FAILURE - BOOT_UNDEPLOY_FAILURE - BOOT_STOPPED_FAILURE - PROLOG_RESUME_FAILURE - PROLOG_UNDEPLOY_FAILURE + VM_FAILURE_STATES = [ + 'BOOT_FAILURE', + 'BOOT_MIGRATE_FAILURE', + 'PROLOG_MIGRATE_FAILURE', + 'PROLOG_FAILURE', + 'EPILOG_FAILURE', + 'EPILOG_STOP_FAILURE', + 'EPILOG_UNDEPLOY_FAILURE', + 'PROLOG_MIGRATE_POWEROFF_FAILURE', + 'PROLOG_MIGRATE_SUSPEND_FAILURE', + 'PROLOG_MIGRATE_UNKNOWN_FAILURE', + 'BOOT_UNDEPLOY_FAILURE', + 'BOOT_STOPPED_FAILURE', + 'PROLOG_RESUME_FAILURE', + 'PROLOG_UNDEPLOY_FAILURE' ] SCALE_WAYS = { @@ -129,17 +129,17 @@ module OpenNebula # parents: this has only sense in deploy operation # state: this is internal information managed by OneFlow server # vm_template: this will affect scale operation - IMMUTABLE_ATTRS = %w[ - cardinality - last_vmname - nodes - parents - state - vm_template + IMMUTABLE_ATTRS = [ + 'cardinality', + 'last_vmname', + 'nodes', + 'parents', + 'state', + 'vm_template' ] # VM information to save in document - VM_INFO = %w[ID UID GID UNAME GNAME NAME] + VM_INFO = ['ID', 'UID', 'GID', 'UNAME', 'GNAME', 'NAME'] LOG_COMP = 'ROL' diff --git a/src/flow/lib/models/service.rb b/src/flow/lib/models/service.rb index 298fb4173a..0707fd2581 100644 --- a/src/flow/lib/models/service.rb +++ b/src/flow/lib/models/service.rb @@ -42,64 +42,64 @@ module OpenNebula 'HOLD' => 15 } - STATE_STR = %w[ - PENDING - DEPLOYING - RUNNING - UNDEPLOYING - WARNING - DONE - FAILED_UNDEPLOYING - FAILED_DEPLOYING - SCALING - FAILED_SCALING - COOLDOWN - DEPLOYING_NETS - UNDEPLOYING_NETS - FAILED_DEPLOYING_NETS - FAILED_UNDEPLOYING_NETS - HOLD + STATE_STR = [ + 'PENDING', + 'DEPLOYING', + 'RUNNING', + 'UNDEPLOYING', + 'WARNING', + 'DONE', + 'FAILED_UNDEPLOYING', + 'FAILED_DEPLOYING', + 'SCALING', + 'FAILED_SCALING', + 'COOLDOWN', + 'DEPLOYING_NETS', + 'UNDEPLOYING_NETS', + 'FAILED_DEPLOYING_NETS', + 'FAILED_UNDEPLOYING_NETS', + 'HOLD' ] - TRANSIENT_STATES = %w[ - DEPLOYING - UNDEPLOYING - SCALING - COOLDOWN - DEPLOYING_NETS - UNDEPLOYING_NETS + TRANSIENT_STATES = [ + 'DEPLOYING', + 'UNDEPLOYING', + 'SCALING', + 'COOLDOWN', + 'DEPLOYING_NETS', + 'UNDEPLOYING_NETS' ] - FAILED_STATES = %w[ - FAILED_DEPLOYING - FAILED_UNDEPLOYING - FAILED_SCALING - FAILED_DEPLOYING_NETS - FAILED_UNDEPLOYING_NETS + FAILED_STATES = [ + 'FAILED_DEPLOYING', + 'FAILED_UNDEPLOYING', + 'FAILED_SCALING', + 'FAILED_DEPLOYING_NETS', + 'FAILED_UNDEPLOYING_NETS' ] - RECOVER_DEPLOY_STATES = %w[ - FAILED_DEPLOYING - DEPLOYING - PENDING + RECOVER_DEPLOY_STATES = [ + 'FAILED_DEPLOYING', + 'DEPLOYING', + 'PENDING' ] - RECOVER_UNDEPLOY_STATES = %w[ - FAILED_UNDEPLOYING - UNDEPLOYING - FAILED_UNDEPLOYING_NETS + RECOVER_UNDEPLOY_STATES = [ + 'FAILED_UNDEPLOYING', + 'UNDEPLOYING', + 'FAILED_UNDEPLOYING_NETS' ] - RECOVER_SCALE_STATES = %w[ - FAILED_SCALING - SCALING + RECOVER_SCALE_STATES = [ + 'FAILED_SCALING', + 'SCALING' ] - RECOVER_DEPLOY_NETS_STATES = %w[DEPLOYING_NETS FAILED_DEPLOYING_NETS] + RECOVER_DEPLOY_NETS_STATES = ['DEPLOYING_NETS', 'FAILED_DEPLOYING_NETS'] - RECOVER_UNDEPLOY_NETS_STATES = %w[ - UNDEPLOYING_NETS - FAILED_UNDEPLOYING_NETS + RECOVER_UNDEPLOY_NETS_STATES = [ + 'UNDEPLOYING_NETS', + 'FAILED_UNDEPLOYING_NETS' ] # List of attributes that can't be changed in update operation @@ -114,17 +114,17 @@ module OpenNebula # ready_status_gate: it only has sense when deploying, not in running # state: this is internal information managed by OneFlow server # start_time: this is internal information managed by OneFlow server - IMMUTABLE_ATTRS = %w[ - custom_attrs - custom_attrs_values - deployment - log - name - networks - networks_values - ready_status_gate - state - start_time + IMMUTABLE_ATTRS = [ + 'custom_attrs', + 'custom_attrs_values', + 'deployment', + 'log', + 'name', + 'networks', + 'networks_values', + 'ready_status_gate', + 'state', + 'start_time' ] LOG_COMP = 'SER' @@ -680,7 +680,7 @@ module OpenNebula vnet.each do |_, net| key = net.keys.first - next unless %w[template_id reserve_from].include?(key) + next unless ['template_id', 'reserve_from'].include?(key) rc = OpenNebula::VirtualNetwork.new_with_id( net['id'], diff --git a/src/im_mad/remotes/common.d/monitord-client.rb b/src/im_mad/remotes/common.d/monitord-client.rb index 879c8dd295..1d9c78d3ca 100644 --- a/src/im_mad/remotes/common.d/monitord-client.rb +++ b/src/im_mad/remotes/common.d/monitord-client.rb @@ -149,7 +149,7 @@ end #------------------------------------------------------------------------------- # Script helper functions and gLobals #------------------------------------------------------------------------------- -LOCAL_HYPERVISOR = %w[az ec2 one equinix].freeze +LOCAL_HYPERVISOR = ['az', 'ec2', 'one', 'equinix'].freeze def local?(hypervisor) LOCAL_HYPERVISOR.include?(hypervisor) diff --git a/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb b/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb index 8cca917adb..33252b916d 100755 --- a/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb +++ b/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb @@ -21,7 +21,7 @@ require 'open3' ENV['LANG'] = 'C' ENV['LC_ALL'] = 'C' -GUEST_ARCHS = %w[i686 x86_64] +GUEST_ARCHS = ['i686', 'x86_64'] begin machines = [] diff --git a/src/im_mad/remotes/lib/domain.rb b/src/im_mad/remotes/lib/domain.rb index e40163f07a..45094cf6f5 100644 --- a/src/im_mad/remotes/lib/domain.rb +++ b/src/im_mad/remotes/lib/domain.rb @@ -64,8 +64,8 @@ class BaseDomain Base64.strict_encode64(mon_s) end - MONITOR_KEYS = %w[cpu memory netrx nettx diskrdbytes diskwrbytes diskrdiops - diskwriops] + MONITOR_KEYS = ['cpu', 'memory', 'netrx', 'nettx', 'diskrdbytes', 'diskwrbytes', 'diskrdiops', + 'diskwriops'] end diff --git a/src/im_mad/remotes/lib/monitord_client.rb b/src/im_mad/remotes/lib/monitord_client.rb index a5c9818878..0483de8076 100644 --- a/src/im_mad/remotes/lib/monitord_client.rb +++ b/src/im_mad/remotes/lib/monitord_client.rb @@ -28,8 +28,8 @@ require 'openssl' class MonitorClient # Defined in src/monitor/include/MonitorDriverMessages.h - MESSAGE_TYPES = %w[MONITOR_VM MONITOR_HOST SYSTEM_HOST BEACON_HOST STATE_VM - START_MONITOR STOP_MONITOR].freeze + MESSAGE_TYPES = ['MONITOR_VM', 'MONITOR_HOST', 'SYSTEM_HOST', 'BEACON_HOST', 'STATE_VM', + 'START_MONITOR', 'STOP_MONITOR'].freeze MESSAGE_STATUS = { true =>'SUCCESS', false => 'FAILURE' }.freeze diff --git a/src/im_mad/remotes/lib/numa_common.rb b/src/im_mad/remotes/lib/numa_common.rb index 3b638f1563..ca66718fb7 100644 --- a/src/im_mad/remotes/lib/numa_common.rb +++ b/src/im_mad/remotes/lib/numa_common.rb @@ -75,7 +75,7 @@ module NUMA hp_info = { 'size' => hp_size } begin - %w[free nr surplus].each do |var| + ['free', 'nr', 'surplus'].each do |var| var_path = "#{hpsz_path}/#{var}_hugepages" hp_info[var] = File.read(var_path).chomp end @@ -102,7 +102,7 @@ module NUMA bind = binding - mem_vars = %w[MemTotal MemFree MemUsed] + mem_vars = ['MemTotal', 'MemFree', 'MemUsed'] # rubocop:disable Style/DocumentDynamicEvalDefinition mem_vars.each {|var| bind.eval("#{var.downcase.to_sym} = 0") } diff --git a/src/ipamm_mad/remotes/equinix/register_address_range b/src/ipamm_mad/remotes/equinix/register_address_range index 6b0f73ae3a..dd8f0b9024 100755 --- a/src/ipamm_mad/remotes/equinix/register_address_range +++ b/src/ipamm_mad/remotes/equinix/register_address_range @@ -110,7 +110,7 @@ require 'oneprovision' require 'ipaddr' require 'digest' -IP_TYPE = %w[public_ipv4 global_ipv4] +IP_TYPE = ['public_ipv4', 'global_ipv4'] DEFAULT_PRIVATE_CIDR = '172.16.0.0/12' diff --git a/src/ipamm_mad/remotes/vultr/register_address_range b/src/ipamm_mad/remotes/vultr/register_address_range index afba6e2cef..583e0d1131 100755 --- a/src/ipamm_mad/remotes/vultr/register_address_range +++ b/src/ipamm_mad/remotes/vultr/register_address_range @@ -111,7 +111,7 @@ require 'opennebula' require 'oneprovision' require 'vultr' -IP_TYPE = %w[v4 v6] +IP_TYPE = ['v4', 'v6'] DEFAULT_PRIVATE_CIDR = '172.16.0.0/12' diff --git a/src/market_mad/remotes/linuxcontainers/monitor b/src/market_mad/remotes/linuxcontainers/monitor index 2859eabc82..611848e5c4 100755 --- a/src/market_mad/remotes/linuxcontainers/monitor +++ b/src/market_mad/remotes/linuxcontainers/monitor @@ -49,8 +49,8 @@ class LinuxContainersMarket :fs => 'ext4', :format => 'raw', :agent => 'OpenNebula', - :tested_apps => %w[alpine alt centos rockylinux almalinux oracle debian - ubuntu fedora devuan], + :tested_apps => ['alpine', 'alt', 'centos', 'rockylinux', 'almalinux', 'oracle', 'debian', + 'ubuntu', 'fedora', 'devuan'], :skip_untested => 'yes', :memory => '768', :cpu => 1, diff --git a/src/oca/ruby/opennebula/flow/service_template.rb b/src/oca/ruby/opennebula/flow/service_template.rb index acbc9fa43f..d511b58df6 100644 --- a/src/oca/ruby/opennebula/flow/service_template.rb +++ b/src/oca/ruby/opennebula/flow/service_template.rb @@ -60,11 +60,11 @@ module OpenNebula }, 'shutdown_action' => { :type => :string, - :enum => %w[ - terminate - terminate-hard - shutdown - shutdown-hard + :enum => [ + 'terminate', + 'terminate-hard', + 'shutdown', + 'shutdown-hard' ], :required => false }, @@ -94,10 +94,10 @@ module OpenNebula :properties => { 'type' => { :type => :string, - :enum => %w[ - CHANGE - CARDINALITY - PERCENTAGE_CHANGE + :enum => [ + 'CHANGE', + 'CARDINALITY', + 'PERCENTAGE_CHANGE' ], :required => true }, @@ -143,10 +143,10 @@ module OpenNebula :properties => { 'type' => { :type => :string, - :enum => %w[ - CHANGE - CARDINALITY - PERCENTAGE_CHANGE + :enum => [ + 'CHANGE', + 'CARDINALITY', + 'PERCENTAGE_CHANGE' ], :required => true }, @@ -182,7 +182,7 @@ module OpenNebula }, 'deployment' => { :type => :string, - :enum => %w[none straight], + :enum => ['none', 'straight'], :default => 'none' }, 'description' => { @@ -191,11 +191,11 @@ module OpenNebula }, 'shutdown_action' => { :type => :string, - :enum => %w[ - terminate - terminate-hard - shutdown - shutdown-hard + :enum => [ + 'terminate', + 'terminate-hard', + 'shutdown', + 'shutdown-hard' ], :required => false }, @@ -245,8 +245,8 @@ module OpenNebula # List of attributes that can't be changed in update operation # # registration_time: this is internal info managed by OneFlow server - IMMUTABLE_ATTRS = %w[ - registration_time + IMMUTABLE_ATTRS = [ + 'registration_time' ] def self.init_default_vn_name_template(vn_name_template) diff --git a/src/oca/ruby/opennebula/marketplaceapp_ext.rb b/src/oca/ruby/opennebula/marketplaceapp_ext.rb index 5ba8662ad5..ab16c6fdf0 100644 --- a/src/oca/ruby/opennebula/marketplaceapp_ext.rb +++ b/src/oca/ruby/opennebula/marketplaceapp_ext.rb @@ -314,9 +314,9 @@ module OpenNebula::MarketPlaceAppExt # @param image [OpenNebula::Image] Image information def create_vcenter_template(ds, options, template, image = nil) ret = {} - keys = %w[VCENTER_TEMPLATE_REF - VCENTER_CCR_REF - VCENTER_INSTANCE_ID] + keys = ['VCENTER_TEMPLATE_REF', + 'VCENTER_CCR_REF', + 'VCENTER_INSTANCE_ID'] if ds['//VCENTER_TEMPLATE_REF'] keys.each do |key| diff --git a/src/oca/ruby/opennebula/template_ext.rb b/src/oca/ruby/opennebula/template_ext.rb index 7b8ffeb937..e81d884934 100644 --- a/src/oca/ruby/opennebula/template_ext.rb +++ b/src/oca/ruby/opennebula/template_ext.rb @@ -79,7 +79,7 @@ module OpenNebula::TemplateExt image['STATE'].to_i ] - unless %w[LOCKED READY USED].include?(i_state) + unless ['LOCKED', 'READY', 'USED'].include?(i_state) logger.fatal "Wrong image state #{i_state}" if logger rollback(ids) @@ -204,7 +204,7 @@ module OpenNebula::TemplateExt # @param nic [XMLElement] to delete attributes from #------------------------------------------------------------------- def delete_nic_attributes(nic) - %w[NETWORK NETWORK_ID NETWORK_UNAME SECURITY_GROUPS].each do |a| + ['NETWORK', 'NETWORK_ID', 'NETWORK_UNAME', 'SECURITY_GROUPS'].each do |a| nic.delete_element(a) end end diff --git a/src/oca/ruby/opennebula/virtual_machine_ext.rb b/src/oca/ruby/opennebula/virtual_machine_ext.rb index 8b52122934..b530ed94e3 100644 --- a/src/oca/ruby/opennebula/virtual_machine_ext.rb +++ b/src/oca/ruby/opennebula/virtual_machine_ext.rb @@ -47,17 +47,16 @@ module OpenNebula::VirtualMachineExt # @return [Integer, OpenNebula::Error] the new Template ID in case # of success, error otherwise #------------------------------------------------------------------- - REMOVE_VNET_ATTRS = %w[AR_ID BRIDGE CLUSTER_ID IP MAC TARGET NIC_ID - NETWORK_ID VN_MAD SECURITY_GROUPS VLAN_ID - BRIDGE_TYPE] + REMOVE_VNET_ATTRS = ['AR_ID', 'BRIDGE', 'CLUSTER_ID', 'IP', 'MAC', 'TARGET', 'NIC_ID', + 'NETWORK_ID', 'VN_MAD', 'SECURITY_GROUPS', 'VLAN_ID', + 'BRIDGE_TYPE'] - REMOVE_IMAGE_ATTRS = %w[DEV_PREFIX SOURCE ORIGINAL_SIZE SIZE - DISK_SNAPSHOT_TOTAL_SIZE DRIVER IMAGE_STATE - SAVE CLONE READONLY PERSISTENT TARGET - ALLOW_ORPHANS CLONE_TARGET CLUSTER_ID - DATASTORE DATASTORE_ID DISK_ID DISK_TYPE - IMAGE_ID IMAGE IMAGE_UNAME IMAGE_UID - LN_TARGET TM_MAD TYPE OPENNEBULA_MANAGED] + REMOVE_IMAGE_ATTRS = ['DEV_PREFIX', 'SOURCE', 'ORIGINAL_SIZE', 'SIZE', + 'DISK_SNAPSHOT_TOTAL_SIZE', 'DRIVER', 'IMAGE_STATE', 'SAVE', + 'CLONE', 'READONLY', 'PERSISTENT', 'TARGET', 'ALLOW_ORPHANS', + 'CLONE_TARGET', 'CLUSTER_ID', 'DATASTORE', 'DATASTORE_ID', + 'DISK_ID', 'DISK_TYPE', 'IMAGE_ID', 'IMAGE', 'IMAGE_UNAME', + 'IMAGE_UID', 'LN_TARGET', 'TM_MAD', 'TYPE', 'OPENNEBULA_MANAGED'] def save_as_template(name, desc, opts = {}) opts = { diff --git a/src/onecfg/bin/onecfg b/src/onecfg/bin/onecfg index 62d564a7cb..072930973c 100755 --- a/src/onecfg/bin/onecfg +++ b/src/onecfg/bin/onecfg @@ -151,7 +151,7 @@ CommandParser::CmdParser.new(ARGV) do :format => String } - PATCH_FORMATS = %w[line yaml] + PATCH_FORMATS = ['line', 'yaml'] begin require 'ee' diff --git a/src/onecfg/lib/common/parser.rb b/src/onecfg/lib/common/parser.rb index eecb329215..d064b37109 100644 --- a/src/onecfg/lib/common/parser.rb +++ b/src/onecfg/lib/common/parser.rb @@ -84,7 +84,7 @@ module OneCfg::Common # command parsed[:command].downcase! - if !%w[rm ins set].include?(parsed[:command]) + if !['rm', 'ins', 'set'].include?(parsed[:command]) raise OneCfg::Exception::FileParseError, "Invalid patch action '#{parsed[:command]}'" end diff --git a/src/onecfg/lib/config/files.rb b/src/onecfg/lib/config/files.rb index a3f41f4c9f..d680a3f454 100644 --- a/src/onecfg/lib/config/files.rb +++ b/src/onecfg/lib/config/files.rb @@ -197,7 +197,7 @@ module OneCfg::Config # @return [Hash] Filtered file data def file4desc(data) data.select do |k, _v| - %w[class owner group mode].include?(k) + ['class', 'owner', 'group', 'mode'].include?(k) end end diff --git a/src/onecfg/lib/config/type/augeas/one.rb b/src/onecfg/lib/config/type/augeas/one.rb index 120acae8a3..b9ffe2a800 100644 --- a/src/onecfg/lib/config/type/augeas/one.rb +++ b/src/onecfg/lib/config/type/augeas/one.rb @@ -44,24 +44,22 @@ module OneCfg::Config::Type # Parameters which are expected to be specified MULTIPLE # times in the main section of configuration file. - MULTIPLE = %w[ - VM_RESTRICTED_ATTR - IMAGE_RESTRICTED_ATTR - VNET_RESTRICTED_ATTR - USER_RESTRICTED_ATTR - GROUP_RESTRICTED_ATTR - - DOCUMENT_ENCRYPTED_ATTR - HOST_ENCRYPTED_ATTR - IMAGE_ENCRYPTED_ATTR - VM_ENCRYPTED_ATTR - VNET_ENCRYPTED_ATTR - DATASTORE_ENCRYPTED_ATTR - CLUSTER_ENCRYPTED_ATTR - - INHERIT_DATASTORE_ATTR - INHERIT_IMAGE_ATTR - INHERIT_VNET_ATTR + MULTIPLE = [ + 'VM_RESTRICTED_ATTR', + 'IMAGE_RESTRICTED_ATTR', + 'VNET_RESTRICTED_ATTR', + 'USER_RESTRICTED_ATTR', + 'GROUP_RESTRICTED_ATTR', + 'DOCUMENT_ENCRYPTED_ATTR', + 'HOST_ENCRYPTED_ATTR', + 'IMAGE_ENCRYPTED_ATTR', + 'VM_ENCRYPTED_ATTR', + 'VNET_ENCRYPTED_ATTR', + 'DATASTORE_ENCRYPTED_ATTR', + 'CLUSTER_ENCRYPTED_ATTR', + 'INHERIT_DATASTORE_ATTR', + 'INHERIT_IMAGE_ATTR', + 'INHERIT_VNET_ATTR' ] # Class constructor diff --git a/src/onedb/fsck/history.rb b/src/onedb/fsck/history.rb index 7575baeb99..0c027d6f89 100644 --- a/src/onedb/fsck/history.rb +++ b/src/onedb/fsck/history.rb @@ -67,7 +67,7 @@ module OneDBFsck history_doc = nokogiri_doc(row[:body]) - %w[RETIME ESTIME EETIME ETIME].each do |att| + ['RETIME', 'ESTIME', 'EETIME', 'ETIME'].each do |att| elem = history_doc.root.at_xpath(att) elem.content = etime if elem.text == '0' diff --git a/src/onedb/fsck/network.rb b/src/onedb/fsck/network.rb index 19fb68c684..d7d5d5f64e 100644 --- a/src/onedb/fsck/network.rb +++ b/src/onedb/fsck/network.rb @@ -272,7 +272,7 @@ module OneDBFsck type = address_range.at_xpath('TYPE').text - if %w[IP6 IP4_6].include? type + if ['IP6', 'IP4_6'].include? type ipv6[:link_prefix] = 0xfe80000000000000 end diff --git a/src/onedb/fsck/quotas.rb b/src/onedb/fsck/quotas.rb index 4646513521..86819b1c26 100644 --- a/src/onedb/fsck/quotas.rb +++ b/src/onedb/fsck/quotas.rb @@ -272,7 +272,7 @@ module OneDBFsck size = e.at_xpath('SIZE').text.to_i end - if %w[SWAP FS].include? type + if ['SWAP', 'FS'].include? type sys_used += size next diff --git a/src/oneprovision/lib/provider/provider.rb b/src/oneprovision/lib/provider/provider.rb index 623ef8f9c4..ec54c9ccf2 100644 --- a/src/oneprovision/lib/provider/provider.rb +++ b/src/oneprovision/lib/provider/provider.rb @@ -22,7 +22,7 @@ module OneProvision DOCUMENT_TYPE = 102 # These attributes can not be changed when updating the provider - IMMUTABLE_ATTRS = %w[provider name] + IMMUTABLE_ATTRS = ['provider', 'name'] # These providers get the credentials via some file CREDENTIALS_FILE = { 'google' => 'credentials' } @@ -185,7 +185,7 @@ EOS # @return [JSON] Document information in JSON format def to_json(template) document = {} - skip = %w[provider connection registration_time plain] + skip = ['provider', 'connection', 'registration_time', 'plain'] # Create document JSON document['provider'] = template['provider'] diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index f25cc7bc3e..441e66c3bf 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -35,28 +35,28 @@ module OneProvision 'DELETING' => 5 } - STATE_STR = %w[ - PENDING - DEPLOYING - CONFIGURING - RUNNING - ERROR - DELETING + STATE_STR = [ + 'PENDING', + 'DEPLOYING', + 'CONFIGURING', + 'RUNNING', + 'ERROR', + 'DELETING' ] # Available resources that can be created with the provision # # Note: order is important, some objects depend on others # Objects without dependencies need to be created firstly, then the rest - RESOURCES = %w[images - marketplaceapps - templates - vntemplates - flowtemplates] + RESOURCES = ['images', + 'marketplaceapps', + 'templates', + 'vntemplates', + 'flowtemplates'] - INFRASTRUCTURE_RESOURCES = %w[datastores networks] + INFRASTRUCTURE_RESOURCES = ['datastores', 'networks'] - FULL_CLUSTER = INFRASTRUCTURE_RESOURCES + %w[hosts clusters] + FULL_CLUSTER = INFRASTRUCTURE_RESOURCES + ['hosts', 'clusters'] # Class constructor # @@ -482,7 +482,7 @@ module OneProvision host['connection'] = {} - %w[private_key public_key remote_port remote_user].each do |attr| + ['private_key', 'public_key', 'remote_port', 'remote_user'].each do |attr| host['connection'][attr] = host['provision_connection'][attr] end diff --git a/src/oneprovision/lib/provision/provision_config.rb b/src/oneprovision/lib/provision/provision_config.rb index 9088a91bf9..c56487571b 100644 --- a/src/oneprovision/lib/provision/provision_config.rb +++ b/src/oneprovision/lib/provision/provision_config.rb @@ -87,7 +87,7 @@ module OneProvision ################################################################ if @config['hosts'] - sections = %w[connection provision configuration] + sections = ['connection', 'provision', 'configuration'] @config['hosts'].map! do |host| sections.each do |section| @@ -115,7 +115,7 @@ module OneProvision # Datastores & Networks ################################################################ - %w[datastores networks].each do |r| + ['datastores', 'networks'].each do |r| next unless @config[r] @config[r].map! do |x| @@ -334,26 +334,26 @@ module OneProvision def extra ret = {} - reject = %w[cluster - datastores - defaults - extends - flowtemplates - hosts - images - inputs - marketplaceapps - name - networks - playbook - templates - vntemplates - name - description - state - provider - provision - start_time] + reject = ['cluster', + 'datastores', + 'defaults', + 'extends', + 'flowtemplates', + 'hosts', + 'images', + 'inputs', + 'marketplaceapps', + 'name', + 'networks', + 'playbook', + 'templates', + 'vntemplates', + 'name', + 'description', + 'state', + 'provider', + 'provision', + 'start_time'] @config.each do |key, value| next if reject.include?(key) @@ -423,7 +423,7 @@ module OneProvision end # merge each defaults section separately - %w[connection provision configuration].each do |section| + ['connection', 'provision', 'configuration'].each do |section| base['defaults'][section] ||= {} yaml['defaults'][section] ||= {} defaults = yaml['defaults'][section] @@ -520,7 +520,7 @@ module OneProvision when 'boolean' next unless input['default'] - next if %w[NO YES].include?(input['default']) + next if ['NO', 'YES'].include?(input['default']) return [false, "default #{input['default']} is invalid"] when 'list' @@ -720,7 +720,7 @@ module OneProvision answer = Base64.encode64(answer).strip.delete("\n") end when 'boolean' - until %w[YES NO].include?(answer) + until ['YES', 'NO'].include?(answer) print "Bool `#{input['name']}` " \ "(default=#{input['default']}): " @@ -730,7 +730,7 @@ module OneProvision # Add default in case no default value is given answer = 'NO' if !answer || answer.empty? - unless %w[YES NO].include?(answer) + unless ['YES', 'NO'].include?(answer) puts "Invalid boolean #{answer} " \ 'boolean has to be YES or NO' end diff --git a/src/oneprovision/lib/provision/resources/physical/host.rb b/src/oneprovision/lib/provision/resources/physical/host.rb index d9fd9be9a3..9d8abe6155 100644 --- a/src/oneprovision/lib/provision/resources/physical/host.rb +++ b/src/oneprovision/lib/provision/resources/physical/host.rb @@ -49,7 +49,7 @@ module OneProvision @p_template['configuration'].to_yaml ) if @p_template['configuration'] - reject = %w[im_mad vm_mad provision connection configuration count] + reject = ['im_mad', 'vm_mad', 'provision', 'connection', 'configuration', 'count'] Nokogiri::XML::Builder.new do |xml| xml.HOST do diff --git a/src/oneprovision/lib/provision/resources/resource.rb b/src/oneprovision/lib/provision/resources/resource.rb index 460f5220d8..b85bff4489 100644 --- a/src/oneprovision/lib/provision/resources/resource.rb +++ b/src/oneprovision/lib/provision/resources/resource.rb @@ -20,21 +20,21 @@ module OneProvision class Resource # Keys to remove from template - REJECT_KEYS = %w[meta] + REJECT_KEYS = ['meta'] # Valid keys in template evaluation - EVAL_KEYS = %w[cluster - datastore - host - image - network - template - vntemplate - marketplaceapp] + EVAL_KEYS = ['cluster', + 'datastore', + 'host', + 'image', + 'network', + 'template', + 'vntemplate', + 'marketplaceapp'] - S_EVAL_KEYS = %w[index - provision - provision_id] + S_EVAL_KEYS = ['index', + 'provision', + 'provision_id'] # @one ONE object # @pool ONE pool diff --git a/src/oneprovision/lib/provision/resources/virtual/virtual_sync_resource.rb b/src/oneprovision/lib/provision/resources/virtual/virtual_sync_resource.rb index 453e33ef94..7789cc488f 100644 --- a/src/oneprovision/lib/provision/resources/virtual/virtual_sync_resource.rb +++ b/src/oneprovision/lib/provision/resources/virtual/virtual_sync_resource.rb @@ -25,7 +25,7 @@ module OneProvision DEFAULT_TIMEOUT = 60 # Supported wait modes - SUPPORTED_MODES = %w[true false] + SUPPORTED_MODES = ['true', 'false'] # Delete object def delete(_ = nil, _ = nil, _ = nil) diff --git a/src/oneprovision/lib/terraform/providers/aws.rb b/src/oneprovision/lib/terraform/providers/aws.rb index 594fd976a4..6745c83833 100644 --- a/src/oneprovision/lib/terraform/providers/aws.rb +++ b/src/oneprovision/lib/terraform/providers/aws.rb @@ -32,7 +32,7 @@ module OneProvision :network => 'aws_subnet' } - KEYS = %w[access_key secret_key region] + KEYS = ['access_key', 'secret_key', 'region'] # Class constructor # diff --git a/src/oneprovision/lib/terraform/providers/digitalocean.rb b/src/oneprovision/lib/terraform/providers/digitalocean.rb index fff6d039eb..5e79b5e092 100644 --- a/src/oneprovision/lib/terraform/providers/digitalocean.rb +++ b/src/oneprovision/lib/terraform/providers/digitalocean.rb @@ -32,7 +32,7 @@ module OneProvision :network => '' } - KEYS = %w[token region] + KEYS = ['token', 'region'] # Class constructor # diff --git a/src/oneprovision/lib/terraform/providers/equinix.rb b/src/oneprovision/lib/terraform/providers/equinix.rb index 5399c408c4..9af076f214 100644 --- a/src/oneprovision/lib/terraform/providers/equinix.rb +++ b/src/oneprovision/lib/terraform/providers/equinix.rb @@ -31,7 +31,7 @@ module OneProvision :network => 'packet_reserved_ip_block' } - KEYS = %w[project token facility] + KEYS = ['project', 'token', 'facility'] # Class constructor # diff --git a/src/oneprovision/lib/terraform/providers/google.rb b/src/oneprovision/lib/terraform/providers/google.rb index 0558b397af..efe782f142 100644 --- a/src/oneprovision/lib/terraform/providers/google.rb +++ b/src/oneprovision/lib/terraform/providers/google.rb @@ -32,7 +32,7 @@ module OneProvision :network => '' } - KEYS = %w[credentials project region zone] + KEYS = ['credentials', 'project', 'region', 'zone'] # Class constructor # diff --git a/src/oneprovision/lib/terraform/providers/vultr.rb b/src/oneprovision/lib/terraform/providers/vultr.rb index 9d2deaf393..285716c1f6 100644 --- a/src/oneprovision/lib/terraform/providers/vultr.rb +++ b/src/oneprovision/lib/terraform/providers/vultr.rb @@ -33,7 +33,7 @@ module OneProvision # Vultr Terraform Provider class Vultr < Terraform - KEYS = %w[key region] + KEYS = ['key', 'region'] # Class constructor # diff --git a/src/sunstone/models/sunstone_guac.rb b/src/sunstone/models/sunstone_guac.rb index 96828a3d78..c38a2ce3e4 100644 --- a/src/sunstone/models/sunstone_guac.rb +++ b/src/sunstone/models/sunstone_guac.rb @@ -51,7 +51,7 @@ class SunstoneGuac < SunstoneRemoteConnections return error(400, error_message) end - unless %w[vnc rdp ssh].include?(type_connection.downcase) + unless ['vnc', 'rdp', 'ssh'].include?(type_connection.downcase) return error(400, 'Type connection not supported by Guacamole') end diff --git a/src/tm_mad/lib/backup.rb b/src/tm_mad/lib/backup.rb index b563e1da0b..8dc580424b 100644 --- a/src/tm_mad/lib/backup.rb +++ b/src/tm_mad/lib/backup.rb @@ -131,31 +131,30 @@ module TransferManager #----------------------------------------------------------------------- # Attributes that will be rejected when recovering the new template #----------------------------------------------------------------------- - DISK_LIST = %w[ALLOW_ORPHANS CLONE CLONE_TARGET CLUSTER_ID DATASTORE - DATASTORE_ID DEV_PREFIX DISK_SNAPSHOT_TOTAL_SIZE - DISK_TYPE DRIVER IMAGE IMAGE_ID IMAGE_STATE IMAGE_UID - IMAGE_UNAME LN_TARGET OPENNEBULA_MANAGED ORIGINAL_SIZE - PERSISTENT READONLY SAVE SIZE SOURCE TARGET TM_MAD TYPE - FORMAT] + DISK_LIST = ['ALLOW_ORPHANS', 'CLONE', 'CLONE_TARGET', 'CLUSTER_ID', 'DATASTORE', + 'DATASTORE_ID', 'DEV_PREFIX', 'DISK_SNAPSHOT_TOTAL_SIZE', 'DISK_TYPE', + 'DRIVER', 'IMAGE', 'IMAGE_ID', 'IMAGE_STATE', 'IMAGE_UID', 'IMAGE_UNAME', + 'LN_TARGET', 'OPENNEBULA_MANAGED', 'ORIGINAL_SIZE', 'PERSISTENT', 'READONLY', + 'SAVE', 'SIZE', 'SOURCE', 'TARGET', 'TM_MAD', 'TYPE', 'FORMAT'] - NIC_LIST = %w[AR_ID BRIDGE BRIDGE_TYPE CLUSTER_ID NAME NETWORK_ID - NIC_ID TARGET VLAN_ID VN_MAD MAC VLAN_TAGGED_ID PHYDEV] + NIC_LIST = ['AR_ID', 'BRIDGE', 'BRIDGE_TYPE', 'CLUSTER_ID', 'NAME', 'NETWORK_ID', 'NIC_ID', + 'TARGET', 'VLAN_ID', 'VN_MAD', 'MAC', 'VLAN_TAGGED_ID', 'PHYDEV'] - GRAPHICS_LIST = %w[PORT] + GRAPHICS_LIST = ['PORT'] CONTEXT_LIST = ['DISK_ID', /ETH[0-9]?/, /PCI[0-9]?/] - NUMA_NODE_LIST = %w[CPUS MEMORY_NODE_ID NODE_ID] + NUMA_NODE_LIST = ['CPUS', 'MEMORY_NODE_ID', 'NODE_ID'] - PCI_COMMON = %w[ADDRESS BUS DOMAIN FUNCTION NUMA_NODE PCI_ID SLOT - VM_ADDRESS VM_BUS VM_DOMAIN VM_FUNCTION VM_SLOT] + PCI_COMMON = ['ADDRESS', 'BUS', 'DOMAIN', 'FUNCTION', 'NUMA_NODE', 'PCI_ID', 'SLOT', + 'VM_ADDRESS', 'VM_BUS', 'VM_DOMAIN', 'VM_FUNCTION', 'VM_SLOT'] - PCI_MANUAL_LIST = NIC_LIST + PCI_COMMON + %w[SHORT_ADDRESS] - PCI_AUTO_LIST = NIC_LIST + PCI_COMMON + %w[VENDOR DEVICE CLASS] + PCI_MANUAL_LIST = NIC_LIST + PCI_COMMON + ['SHORT_ADDRESS'] + PCI_AUTO_LIST = NIC_LIST + PCI_COMMON + ['VENDOR', 'DEVICE', 'CLASS'] - ATTR_LIST = %w[AUTOMATIC_DS_REQUIREMENTS AUTOMATIC_NIC_REQUIREMENTS - AUTOMATIC_REQUIREMENTS VMID TEMPLATE_ID TM_MAD_SYSTEM - SECURITY_GROUP_RULE ERROR] + ATTR_LIST = ['AUTOMATIC_DS_REQUIREMENTS', 'AUTOMATIC_NIC_REQUIREMENTS', + 'AUTOMATIC_REQUIREMENTS', 'VMID', 'TEMPLATE_ID', 'TM_MAD_SYSTEM', + 'SECURITY_GROUP_RULE', 'ERROR'] # options = { # :vm_xml64 => XML representation of the VM, base64 encoded diff --git a/src/tm_mad/lib/backup_qcow2.rb b/src/tm_mad/lib/backup_qcow2.rb index 087de61ff4..03b9fa5298 100755 --- a/src/tm_mad/lib/backup_qcow2.rb +++ b/src/tm_mad/lib/backup_qcow2.rb @@ -153,7 +153,7 @@ class QemuImg #--------------------------------------------------------------------------- # qemu-img command methods #--------------------------------------------------------------------------- - QEMU_IMG_COMMANDS = %w[convert create rebase info bitmap] + QEMU_IMG_COMMANDS = ['convert', 'create', 'rebase', 'info', 'bitmap'] QEMU_IMG_COMMANDS.each do |command| define_method(command.to_sym) do |args = '', opts| diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index 81ee0bbbb6..7ca4e0313e 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -179,13 +179,10 @@ class VmmAction # List of xpaths required by the VNM driver actions. TEMPLATE/NIC is # also required but added separately to the driver xml - XPATH_LIST = %w[ - ID DEPLOY_ID TEMPLATE/CONTEXT USER_TEMPLATE - TEMPLATE/SECURITY_GROUP_RULE - HISTORY_RECORDS/HISTORY/HOSTNAME - HISTORY_RECORDS/HISTORY/HID - HISTORY_RECORDS/HISTORY/DS_ID - HISTORY_RECORDS/HISTORY/VM_MAD + XPATH_LIST = [ + 'ID', 'DEPLOY_ID', 'TEMPLATE/CONTEXT', 'USER_TEMPLATE', 'TEMPLATE/SECURITY_GROUP_RULE', + 'HISTORY_RECORDS/HISTORY/HOSTNAME', 'HISTORY_RECORDS/HISTORY/HID', + 'HISTORY_RECORDS/HISTORY/DS_ID', 'HISTORY_RECORDS/HISTORY/VM_MAD' ] DRIVER_NAMES = { @@ -212,7 +209,7 @@ class VmmAction end end - %w[NIC NIC_ALIAS PCI].each do |r| + ['NIC', 'NIC_ALIAS', 'PCI'].each do |r| vm_template_xml.elements.each("TEMPLATE/#{r}") do |element| vn_mad = element.get_text('VN_MAD').to_s diff --git a/src/vmm_mad/remotes/az/az_driver.rb b/src/vmm_mad/remotes/az/az_driver.rb index d97eb32c59..9297eeface 100755 --- a/src/vmm_mad/remotes/az/az_driver.rb +++ b/src/vmm_mad/remotes/az/az_driver.rb @@ -89,10 +89,14 @@ class AzureDriver 'OS Disk Write Operations/Sec' ] - AZ_REQUIRED_PARAMS = %w[ - INSTANCE_TYPE - VM_USER VM_PASSWORD - IMAGE_PUBLISHER IMAGE_OFFER IMAGE_SKU IMAGE_VERSION + AZ_REQUIRED_PARAMS = [ + 'INSTANCE_TYPE', + 'VM_USER', + 'VM_PASSWORD', + 'IMAGE_PUBLISHER', + 'IMAGE_OFFER', + 'IMAGE_SKU', + 'IMAGE_VERSION' ] STATE_MAP = { @@ -225,7 +229,7 @@ class AzureDriver unless @resource_client.resource_groups .check_existence(@rgroup_name) - if %w[BOOT BOOT_FAILURE].include?(lcm_state) + if ['BOOT', 'BOOT_FAILURE'].include?(lcm_state) @defaults = load_default_template_values az_info, context = get_deployment_info(host, xml_text) diff --git a/src/vmm_mad/remotes/lib/kvm/opennebula_vm.rb b/src/vmm_mad/remotes/lib/kvm/opennebula_vm.rb index af44bcd9e5..0faa5d9ea9 100644 --- a/src/vmm_mad/remotes/lib/kvm/opennebula_vm.rb +++ b/src/vmm_mad/remotes/lib/kvm/opennebula_vm.rb @@ -143,10 +143,10 @@ module VirtualMachineManagerKVM dev << '' end - inb_keys = %w[INBOUND_AVG_BW INBOUND_PEAK_BW INBOUND_PEAK_KB] + inb_keys = ['INBOUND_AVG_BW', 'INBOUND_PEAK_BW', 'INBOUND_PEAK_KB'] inbound = inb_keys.any? {|e| exist? e } - outb_keys = %w[OUTBOUND_AVG_BW OUTBOUND_PEAK_BW OUTBOUND_PEAK_KB] + outb_keys = ['OUTBOUND_AVG_BW', 'OUTBOUND_PEAK_BW', 'OUTBOUND_PEAK_KB'] outbound = outb_keys.any? {|e| exist? e } if inbound || outbound @@ -260,7 +260,7 @@ module VirtualMachineManagerKVM # Setting Bus address needs to check that a PCI contoller is # present for Bus 1 - vm_addr = %w[VM_DOMAIN VM_BUS VM_SLOT VM_FUNCTION].all? {|e| exist? e } + vm_addr = ['VM_DOMAIN', 'VM_BUS', 'VM_SLOT', 'VM_FUNCTION'].all? {|e| exist? e } if vm_addr && opts[:pci] dev << '
'sudo -n qemu-nbd --fork -c', diff --git a/src/vmm_mad/remotes/lib/nsx_driver/nsx_constants.rb b/src/vmm_mad/remotes/lib/nsx_driver/nsx_constants.rb index 7967b0ebc6..425da6aebc 100644 --- a/src/vmm_mad/remotes/lib/nsx_driver/nsx_constants.rb +++ b/src/vmm_mad/remotes/lib/nsx_driver/nsx_constants.rb @@ -127,7 +127,7 @@ end } } NSXV_RULE_BASE = 'xxx' - NSX_RULE_IPSEC_PORTS = %w[500 4500] + NSX_RULE_IPSEC_PORTS = ['500', '4500'] # Logical Ports NSXT_LP_BASE = NSXT_BASE + '/logical-ports/' NSXV_LP_BASE = '' diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb index 24022959b0..add12be600 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb @@ -743,9 +743,9 @@ module VCenterDriver image_path = '' # Skip not relevant files - next unless %w[FloppyImageFileInfo - IsoImageFileInfo - VmDiskFileInfo].include? image.class.to_s + next unless ['FloppyImageFileInfo', + 'IsoImageFileInfo', + 'VmDiskFileInfo'].include? image.class.to_s # Get image path and name image_path << folderpath << image.path diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb b/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb index b3d08b38bf..89eaf57e66 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb @@ -109,7 +109,7 @@ module VCenterDriver def self.needs_unpack?(file_path) type = get_type(file_path) type.gsub!(%r{^application/(x-)?}, '') - %w[bzip2 gzip tar].include?(type) + ['bzip2', 'gzip', 'tar'].include?(type) end def self.vcenter_file_info(file_path) diff --git a/src/vnm_mad/remotes/hooks/clean/firecracker b/src/vnm_mad/remotes/hooks/clean/firecracker index 2f57917bce..9edc5a47c9 100755 --- a/src/vnm_mad/remotes/hooks/clean/firecracker +++ b/src/vnm_mad/remotes/hooks/clean/firecracker @@ -44,7 +44,7 @@ vnmad = File.basename(File.expand_path('..', File.dirname(__FILE__))) XPATH_NICS = "//TEMPLATE/NIC[VN_MAD='#{vnmad}']" XPATH_HV = '//HISTORY/VM_MAD' -OVS_VN_MADS = %w[ovswitch ovswitch_vxlan] +OVS_VN_MADS = ['ovswitch', 'ovswitch_vxlan'] #---------------------------------------------------------------------------- diff --git a/src/vnm_mad/remotes/hooks/pre/firecracker b/src/vnm_mad/remotes/hooks/pre/firecracker index f148d42952..fd3fdfc340 100755 --- a/src/vnm_mad/remotes/hooks/pre/firecracker +++ b/src/vnm_mad/remotes/hooks/pre/firecracker @@ -40,7 +40,7 @@ vnmad = File.basename(File.expand_path('..', File.dirname(__FILE__))) XPATH_NICS = "//TEMPLATE/NIC[VN_MAD='#{vnmad}']" XPATH_HV = '//HISTORY/VM_MAD' -OVS_VN_MADS = %w[ovswitch ovswitch_vxlan] +OVS_VN_MADS = ['ovswitch', 'ovswitch_vxlan'] #----------------------------------------------------------------------------