diff --git a/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb b/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb index 8287cb81f..a00d811b3 100644 --- a/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +++ b/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb @@ -31,11 +31,12 @@ def start_on_boot(vm, args) vm end + # rubocop:disable Metrics/AbcSize def create_vm(args = {}) - vmid = args[:vmid].to_i type = args[:type] node = client.nodes.get(args[:node_id]) - vmid = node.servers.next_id.to_i if vmid < 1 + vmid = node.servers.next_id.to_i if args[:vmid].to_i < 1 || args[:vmid].nil? + args[:vmid] = vmid if args[:vmid].nil? raise ::Foreman::Exception, format(N_('invalid vmid=%s'), vmid: vmid) unless node.servers.id_valid?(vmid) image_id = args[:image_id] @@ -54,6 +55,7 @@ def create_vm(args = {}) destroy_vm id.to_s + '_' + vm.vmid.to_s if vm raise e end + # rubocop:enable Metrics/AbcSize def compute_clone_attributes(args, container, type) args = parse_cloudinit_config(args) if args[:user_data]