foreman_fog_proxmox 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +32 -6
- data/app/helpers/proxmox_compute_resources_vms_helper.rb +6 -1
- data/app/helpers/proxmox_vm_cloudinit_helper.rb +100 -0
- data/app/helpers/proxmox_vm_config_helper.rb +9 -4
- data/app/helpers/proxmox_vm_interfaces_helper.rb +3 -3
- data/app/models/concerns/fog_extensions/proxmox/server.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox.rb +9 -3
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox_console.rb +3 -1
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +5 -8
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +0 -2
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +19 -8
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +7 -5
- data/app/views/compute_resources/form/_proxmox.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +4 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb +1 -11
- data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +19 -12
- data/app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb +1 -9
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +23 -16
- data/app/views/compute_resources_vms/index/_proxmox.html.erb +1 -0
- data/lib/foreman_fog_proxmox/engine.rb +3 -1
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/locale/en/foreman_fog_proxmox.po +13 -4
- data/locale/foreman_fog_proxmox.pot +22 -9
- data/locale/fr/foreman_fog_proxmox.po +16 -7
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +2 -2
- data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +2 -5
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +8 -2
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +8 -2
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +3 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +9 -3
- metadata +21 -21
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b41c2a927bcce7383e1fd55c588247e935e0c6e11ba967fe6628db72a80730df
         | 
| 4 | 
            +
              data.tar.gz: ce7634ce750c8317bc28906e4394888d50b66931b9c77586f3af90c339ca07c2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 65a3b9ac47bb382cc0c2b30430151a9db92bf64dcc9c64ed6c9fffb1fbb5dc525316d3475a7c5d88c21d30e3ffb8ad8eaf6ef5d6676cff53cfbd43dd5a086378
         | 
| 7 | 
            +
              data.tar.gz: e210dad89239964322d0dc1b5f3a326a11f449ada2ad61d23f87f2047d421454020aa4b14ffed1efc173f31fd7cb0c68d92a76a9df0757133c810993a49a5a85
         | 
| @@ -15,6 +15,8 @@ | |
| 15 15 | 
             
            // You should have received a copy of the GNU General Public License
         | 
| 16 16 | 
             
            // along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
         | 
| 17 17 |  | 
| 18 | 
            +
            //= require jquery-ui/widgets/accordion
         | 
| 19 | 
            +
             | 
| 18 20 | 
             
            $(document).ready(vmTypeSelected);
         | 
| 19 21 |  | 
| 20 22 | 
             
            function vmTypeSelected() {
         | 
| @@ -27,13 +29,8 @@ function vmTypeSelected() { | |
| 27 29 | 
             
              fieldsets.push({id: 'config_ext', toggle: true, new_vm: new_vm, selected: selected});
         | 
| 28 30 | 
             
              fieldsets.push({id: 'volume', toggle: true, new_vm: new_vm, selected: selected});
         | 
| 29 31 | 
             
              fieldsets.push({id: 'network', toggle: true, new_vm: true, selected: selected});
         | 
| 30 | 
            -
              fieldsets.push({id: 'config_options', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 31 | 
            -
              fieldsets.push({id: 'config_cpu', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 32 | 
            -
              fieldsets.push({id: 'config_memory', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 33 | 
            -
              fieldsets.push({id: 'config_cdrom', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 34 | 
            -
              fieldsets.push({id: 'config_os', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 35 | 
            -
              fieldsets.push({id: 'config_dns', toggle: false, new_vm: new_vm, selected: selected});
         | 
| 36 32 | 
             
              fieldsets.forEach(toggleFieldsets);
         | 
| 33 | 
            +
              toggleAccordion(selected);
         | 
| 37 34 | 
             
              toggleVolumes(selected);
         | 
| 38 35 | 
             
              return false;
         | 
| 39 36 | 
             
            }
         | 
| @@ -142,6 +139,35 @@ function disableFieldset(fieldsetId, fieldset) { | |
| 142 139 | 
             
              input_hidden_id(fieldsetId).attr('disabled','disabled');
         | 
| 143 140 | 
             
            }
         | 
| 144 141 |  | 
| 142 | 
            +
            function enableConfigOptions(fieldsetId) {
         | 
| 143 | 
            +
              var field = $("#" + fieldsetId + "_advanced_options");
         | 
| 144 | 
            +
              field.accordion({collapsible : true, heightStyle: "content"});
         | 
| 145 | 
            +
              field.removeClass('disabled').find("*").prop("disabled", false);
         | 
| 146 | 
            +
              field.removeClass('hide');
         | 
| 147 | 
            +
            }
         | 
| 148 | 
            +
             | 
| 149 | 
            +
            function disableConfigOptions(fieldsetId) {
         | 
| 150 | 
            +
              var field = $("#" + fieldsetId + "_advanced_options");
         | 
| 151 | 
            +
              field.addClass('disabled').find("*").prop("disabled", true);
         | 
| 152 | 
            +
              field.addClass('hide');
         | 
| 153 | 
            +
            }
         | 
| 154 | 
            +
             | 
| 155 | 
            +
            function toggleConfigOptions(fieldsetId, type1, type2) {
         | 
| 156 | 
            +
              if (type1 === type2) {
         | 
| 157 | 
            +
                enableConfigOptions(fieldsetId);
         | 
| 158 | 
            +
              } else {
         | 
| 159 | 
            +
                disableConfigOptions(fieldsetId);
         | 
| 160 | 
            +
              }
         | 
| 161 | 
            +
            }
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            function toggleAccordion(selected){
         | 
| 164 | 
            +
              ['qemu', 'lxc'].forEach(function(type){
         | 
| 165 | 
            +
                fieldsets(type).forEach(function(fieldsetId){
         | 
| 166 | 
            +
                  toggleConfigOptions(fieldsetId, selected, type);
         | 
| 167 | 
            +
                });
         | 
| 168 | 
            +
              });
         | 
| 169 | 
            +
            }
         | 
| 170 | 
            +
             | 
| 145 171 | 
             
            function toggleFieldset(fieldsetId, fieldset, type1, type2) {  
         | 
| 146 172 | 
             
              type1 === type2 ? enableFieldset(fieldsetId, fieldset) : disableFieldset(fieldsetId, fieldset);
         | 
| 147 173 | 
             
            }
         | 
| @@ -41,6 +41,11 @@ module ProxmoxComputeResourcesVmsHelper | |
| 41 41 | 
             
              end
         | 
| 42 42 |  | 
| 43 43 | 
             
              def vm_associate_action(vm)
         | 
| 44 | 
            +
                vm_associate_link(vm, link_class: "btn btn-default")
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              def vm_associate_link(vm, link_class: "")
         | 
| 48 | 
            +
                return unless @compute_resource.supports_host_association?
         | 
| 44 49 | 
             
                display_link_if_authorized(
         | 
| 45 50 | 
             
                  _('Associate VM'),
         | 
| 46 51 | 
             
                  hash_for_associate_compute_resource_vm_path(
         | 
| @@ -52,7 +57,7 @@ module ProxmoxComputeResourcesVmsHelper | |
| 52 57 | 
             
                  ),
         | 
| 53 58 | 
             
                  :title => _('Associate VM to a Foreman host'),
         | 
| 54 59 | 
             
                  :method => :put,
         | 
| 55 | 
            -
                  :class =>  | 
| 60 | 
            +
                  :class => link_class
         | 
| 56 61 | 
             
                )
         | 
| 57 62 | 
             
              end
         | 
| 58 63 |  | 
| @@ -37,7 +37,107 @@ module ProxmoxVmCloudinitHelper | |
| 37 37 | 
             
                  id = "#{controller}#{device}" if controller && device
         | 
| 38 38 | 
             
                  cloudinit_h.store(:id, id.to_sym) if id
         | 
| 39 39 | 
             
                  cloudinit_h.store(:volid, cloudinit_volid) if cloudinit_volid
         | 
| 40 | 
            +
                  cloudinit_h.store(:media, 'cdrom')
         | 
| 40 41 | 
             
                end
         | 
| 41 42 | 
             
                cloudinit_h
         | 
| 42 43 | 
             
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def create_cloudinit_iso(vm_name, configs, ssh)
         | 
| 46 | 
            +
                iso = File.join(default_iso_path, "#{vm_name.tr('.', '_')}_cloudinit.iso")
         | 
| 47 | 
            +
                files = []
         | 
| 48 | 
            +
                wd = create_temp_directory(ssh)
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                configs.each do |config|
         | 
| 51 | 
            +
                  config_file = ssh.run(%(echo "#{config[1]}" >> "#{wd}/#{config[0]}"))
         | 
| 52 | 
            +
                  unless config_file.first.status.zero?
         | 
| 53 | 
            +
                    delete_temp_dir(ssh, wd)
         | 
| 54 | 
            +
                    raise ::Foreman::Exception, "Failed to create file #{config[0]}: #{config_file.first.stdout}"
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  files.append(File.join(wd, config[0]))
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
                generated_iso = ssh.run(generate_iso_command(iso, files))
         | 
| 59 | 
            +
                unless generated_iso.first.status.zero?
         | 
| 60 | 
            +
                  delete_temp_dir(ssh, wd)
         | 
| 61 | 
            +
                  raise Foreman::Exception, N_("ISO build failed: #{generated_iso.first.stdout}")
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
                delete_temp_dir(ssh, wd)
         | 
| 64 | 
            +
                iso
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              def generate_iso_command(iso_file, config_files)
         | 
| 68 | 
            +
                arguments = ["genisoimage", "-output #{iso_file}", '-volid', 'cidata', '-joliet', '-rock']
         | 
| 69 | 
            +
                iso_command = arguments.concat(config_files).join(' ')
         | 
| 70 | 
            +
                logger.debug("iso image generation args: #{iso_command}")
         | 
| 71 | 
            +
                iso_command
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              def create_temp_directory(ssh)
         | 
| 75 | 
            +
                res = ssh.run("mktemp -d")
         | 
| 76 | 
            +
                raise ::Foreman::Exception, "Could not create working directory to store cloudinit config data: #{res.first.stdout}." unless res.first.status.zero?
         | 
| 77 | 
            +
                res.first.stdout.chomp
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              def delete_temp_dir(ssh, working_dir)
         | 
| 81 | 
            +
                ssh.run("rm -rf #{working_dir}")
         | 
| 82 | 
            +
              rescue Foreman::Exception => e
         | 
| 83 | 
            +
                logger.warn("Could not delete directory for config files: #{e}. Please delete it manually at #{working_dir}")
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              def parse_cloudinit_config(args)
         | 
| 87 | 
            +
                filenames = ["meta-data"]
         | 
| 88 | 
            +
                config_data = ["instance-id: #{args[:name]}"]
         | 
| 89 | 
            +
                user_data = args.delete(:user_data)
         | 
| 90 | 
            +
                return args if user_data == ''
         | 
| 91 | 
            +
                check_template_format(user_data)
         | 
| 92 | 
            +
                ssh = vm_ssh
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                if user_data.include?('#network-config') && user_data.include?('#cloud-config')
         | 
| 95 | 
            +
                  config_data.concat(user_data.split('#network-config'))
         | 
| 96 | 
            +
                  filenames.concat(['user-data', 'network-config'])
         | 
| 97 | 
            +
                elsif user_data.include?('#network-config') && !user_data.include?('#cloud-config')
         | 
| 98 | 
            +
                  config_data.append(user_data.split('#network-config')[1])
         | 
| 99 | 
            +
                  filenames.append("network-config")
         | 
| 100 | 
            +
                elsif !user_data.include?('#network-config') && user_data.include?('#cloud-config')
         | 
| 101 | 
            +
                  config_data.append(user_data)
         | 
| 102 | 
            +
                  filenames.append("user-data")
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                return args if config_data.length == 1
         | 
| 106 | 
            +
                configs = filenames.zip(config_data).to_h
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                iso = create_cloudinit_iso(args[:name], configs, ssh)
         | 
| 109 | 
            +
                args[:config_attributes]&.merge!(update_boot_order(args[:image_id]))
         | 
| 110 | 
            +
                args.merge!(attach_cloudinit_iso(args[:node_id], iso))
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              def attach_cloudinit_iso(node, iso)
         | 
| 114 | 
            +
                storage = storages(node, 'iso')[0]
         | 
| 115 | 
            +
                volume = storage.volumes.detect { |v| v.volid.include? File.basename(iso) }
         | 
| 116 | 
            +
                { ide2: "#{volume.volid},media=cdrom" }
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              def default_iso_path
         | 
| 120 | 
            +
                "/var/lib/vz/template/iso"
         | 
| 121 | 
            +
              end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
              def update_boot_order(image_id)
         | 
| 124 | 
            +
                vm = find_vm_by_uuid(image_id)
         | 
| 125 | 
            +
                return if vm.disks.nil?
         | 
| 126 | 
            +
                disks = vm.disks.map { |disk| disk.split(":")[0] }.join(";")
         | 
| 127 | 
            +
                { boot: "order=" + disks }
         | 
| 128 | 
            +
              end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
              def vm_ssh
         | 
| 131 | 
            +
                ssh = Fog::SSH.new(URI.parse(fog_credentials[:proxmox_url]).host, fog_credentials[:proxmox_username].split('@')[0], { password: fog_credentials[:proxmox_password] })
         | 
| 132 | 
            +
                ssh.run('ls') # test if ssh is successful
         | 
| 133 | 
            +
                ssh
         | 
| 134 | 
            +
              rescue StandardError => e
         | 
| 135 | 
            +
                raise ::Foreman::Exception, "Unable to ssh into proxmox server: #{e}"
         | 
| 136 | 
            +
              end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
              def check_template_format(user_data)
         | 
| 139 | 
            +
                YAML.safe_load(user_data)
         | 
| 140 | 
            +
              rescue StandardError => e
         | 
| 141 | 
            +
                raise ::Foreman::Exception, "'User data kind' template provided could not be loaded, please check the format: #{e}"
         | 
| 142 | 
            +
              end
         | 
| 43 143 | 
             
            end
         | 
| @@ -27,11 +27,11 @@ require 'foreman_fog_proxmox/hash_collection' | |
| 27 27 | 
             
            module ProxmoxVmConfigHelper
         | 
| 28 28 | 
             
              def object_to_config_hash(vm, type)
         | 
| 29 29 | 
             
                vm_h = ActiveSupport::HashWithIndifferentAccess.new
         | 
| 30 | 
            -
                main_a = ['vmid']
         | 
| 31 | 
            -
                main = vm.attributes.select { |key, _value| main_a.include? key }
         | 
| 30 | 
            +
                main_a = ['vmid', 'type']
         | 
| 31 | 
            +
                main = vm.attributes.select { |key, _value| main_a.include? key.to_s }
         | 
| 32 32 | 
             
                main_a += ['templated']
         | 
| 33 33 | 
             
                config = vm.config.attributes.reject do |key, _value|
         | 
| 34 | 
            -
                  main_a.include?(key) || Fog::Proxmox::DiskHelper.disk?(key) || Fog::Proxmox::NicHelper.nic?(key)
         | 
| 34 | 
            +
                  main_a.include?(key.to_s) || Fog::Proxmox::DiskHelper.disk?(key) || Fog::Proxmox::NicHelper.nic?(key)
         | 
| 35 35 | 
             
                end
         | 
| 36 36 | 
             
                vm_h = vm_h.merge(main)
         | 
| 37 37 | 
             
                vm_h = vm_h.merge('config_attributes': config)
         | 
| @@ -40,7 +40,7 @@ module ProxmoxVmConfigHelper | |
| 40 40 | 
             
              end
         | 
| 41 41 |  | 
| 42 42 | 
             
              def general_a(type)
         | 
| 43 | 
            -
                general_a = ['node_id', 'type', 'config_attributes', 'volumes_attributes', 'interfaces_attributes']
         | 
| 43 | 
            +
                general_a = ['node_id', 'type', 'config_attributes', 'volumes_attributes', 'interfaces_attributes', 'image_id']
         | 
| 44 44 | 
             
                general_a += ['firmware_type', 'provision_method', 'container_volumes', 'server_volumes', 'start_after_create']
         | 
| 45 45 | 
             
                general_a += ['name'] if type == 'lxc'
         | 
| 46 46 | 
             
                general_a
         | 
| @@ -126,6 +126,11 @@ module ProxmoxVmConfigHelper | |
| 126 126 | 
             
              def parse_typed_memory(args, type)
         | 
| 127 127 | 
             
                ForemanFogProxmox::HashCollection.remove_empty_values(args)
         | 
| 128 128 | 
             
                logger.debug("parse_typed_memory(#{type}): args=#{args}")
         | 
| 129 | 
            +
                # Convert balloon value from bytes to expected MiB if its not already
         | 
| 130 | 
            +
                if args.key?('balloon')
         | 
| 131 | 
            +
                  mb = (args['balloon'].to_i / 1024**2).to_s
         | 
| 132 | 
            +
                  args['balloon'] = (mb == '0') ? args['balloon'] : mb
         | 
| 133 | 
            +
                end
         | 
| 129 134 | 
             
                args
         | 
| 130 135 | 
             
              end
         | 
| 131 136 |  | 
| @@ -56,7 +56,7 @@ module ProxmoxVmInterfacesHelper | |
| 56 56 | 
             
              end
         | 
| 57 57 |  | 
| 58 58 | 
             
              def interface_common_typed_keys(type)
         | 
| 59 | 
            -
                [ | 
| 59 | 
            +
                ['id', type == 'qemu' ? 'macaddr' : 'hwaddr']
         | 
| 60 60 | 
             
              end
         | 
| 61 61 |  | 
| 62 62 | 
             
              def compute_dhcps(interface_attributes_h)
         | 
| @@ -80,8 +80,8 @@ module ProxmoxVmInterfacesHelper | |
| 80 80 | 
             
                  interfaces_to_delete.push(id.to_s)
         | 
| 81 81 | 
             
                else
         | 
| 82 82 | 
             
                  interface_common_typed_keys(type).each do |key|
         | 
| 83 | 
            -
                    ForemanFogProxmox::HashCollection.add_and_format_element(nic, key | 
| 84 | 
            -
                      key | 
| 83 | 
            +
                    ForemanFogProxmox::HashCollection.add_and_format_element(nic, key.to_sym, interface_attributes,
         | 
| 84 | 
            +
                      key)
         | 
| 85 85 | 
             
                  end
         | 
| 86 86 | 
             
                  interface_attributes_h = interface_attributes['compute_attributes']
         | 
| 87 87 | 
             
                  if ForemanFogProxmox::Value.empty?(interface_attributes['compute_attributes'])
         | 
| @@ -154,7 +154,7 @@ module ForemanFogProxmox | |
| 154 154 | 
             
                  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
         | 
| 155 155 | 
             
                rescue StandardError => e
         | 
| 156 156 | 
             
                  logger.warn("failed to create compute client: #{e}")
         | 
| 157 | 
            -
                  raise e
         | 
| 157 | 
            +
                  raise ::Foreman::Exception, error_message(e)
         | 
| 158 158 | 
             
                end
         | 
| 159 159 |  | 
| 160 160 | 
             
                def identity_client
         | 
| @@ -163,7 +163,7 @@ module ForemanFogProxmox | |
| 163 163 | 
             
                  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
         | 
| 164 164 | 
             
                rescue StandardError => e
         | 
| 165 165 | 
             
                  logger.warn("failed to create identity client: #{e}")
         | 
| 166 | 
            -
                  raise e
         | 
| 166 | 
            +
                  raise ::Foreman::Exception, error_message(e)
         | 
| 167 167 | 
             
                end
         | 
| 168 168 |  | 
| 169 169 | 
             
                def network_client
         | 
| @@ -172,7 +172,13 @@ module ForemanFogProxmox | |
| 172 172 | 
             
                  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
         | 
| 173 173 | 
             
                rescue StandardError => e
         | 
| 174 174 | 
             
                  logger.warn("failed to create network client: #{e}")
         | 
| 175 | 
            -
                  raise e
         | 
| 175 | 
            +
                  raise ::Foreman::Exception, error_message(e)
         | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                def error_message(e)
         | 
| 179 | 
            +
                  "Failed to create Proxmox compute resource: #{e.message}.
         | 
| 180 | 
            +
                   Either provided credentials or FQDN is wrong or
         | 
| 181 | 
            +
                   your server cannot connect to Proxmox due to network issues."
         | 
| 176 182 | 
             
                end
         | 
| 177 183 |  | 
| 178 184 | 
             
                def host
         | 
| @@ -41,7 +41,7 @@ ostype: ostype) | |
| 41 41 | 
             
                end
         | 
| 42 42 |  | 
| 43 43 | 
             
                def interface_compute_attributes(interface_attributes)
         | 
| 44 | 
            -
                  vm_attrs = ForemanFogProxmox::HashCollection.new_hash_reject_keys(interface_attributes, [:identifier, : | 
| 44 | 
            +
                  vm_attrs = ForemanFogProxmox::HashCollection.new_hash_reject_keys(interface_attributes, [:identifier, :macaddr, :hwaddr])
         | 
| 45 45 | 
             
                  vm_attrs[:dhcp] = interface_attributes[:ip] == 'dhcp' ? '1' : '0'
         | 
| 46 46 | 
             
                  vm_attrs[:dhcp6] = interface_attributes[:ip6] == 'dhcp' ? '1' : '0'
         | 
| 47 47 | 
             
                  vm_attrs
         | 
| @@ -31,7 +31,9 @@ module ForemanFogProxmox | |
| 31 31 | 
             
                  options.store(:websocket, 1) if type_console == 'vnc'
         | 
| 32 32 | 
             
                  begin
         | 
| 33 33 | 
             
                    vnc_console = vm.start_console(options)
         | 
| 34 | 
            -
                     | 
| 34 | 
            +
                    vmid = extract_vmid(uuid).to_i
         | 
| 35 | 
            +
                    vnc_host_port = vnc_console['port'].to_i + vmid
         | 
| 36 | 
            +
                    WsProxy.start(:host => host, :host_port => vnc_host_port, :password => vnc_console['ticket']).merge(
         | 
| 35 37 | 
             
                      :name => vm.name, :type => type_console
         | 
| 36 38 | 
             
                    )
         | 
| 37 39 | 
             
                  rescue StandardError => e
         | 
| @@ -47,8 +47,9 @@ module ForemanFogProxmox | |
| 47 47 | 
             
                def templates
         | 
| 48 48 | 
             
                  volumes = []
         | 
| 49 49 | 
             
                  nodes.each do |node|
         | 
| 50 | 
            -
                     | 
| 51 | 
            -
             | 
| 50 | 
            +
                    storages(node.node).each do |storage|
         | 
| 51 | 
            +
                      volumes += storage.volumes.list_by_content_type('images')
         | 
| 52 | 
            +
                    end
         | 
| 52 53 | 
             
                  end
         | 
| 53 54 | 
             
                  volumes.select(&:template?)
         | 
| 54 55 | 
             
                end
         | 
| @@ -57,15 +58,11 @@ module ForemanFogProxmox | |
| 57 58 | 
             
                  find_vm_by_uuid(uuid)
         | 
| 58 59 | 
             
                end
         | 
| 59 60 |  | 
| 60 | 
            -
                def clone_from_image(image_id,  | 
| 61 | 
            +
                def clone_from_image(image_id, vmid)
         | 
| 61 62 | 
             
                  logger.debug("create_vm(): clone #{image_id} in #{vmid}")
         | 
| 62 63 | 
             
                  image = find_vm_by_uuid(image_id)
         | 
| 63 64 | 
             
                  image.clone(vmid)
         | 
| 64 | 
            -
                   | 
| 65 | 
            -
                  options = {}
         | 
| 66 | 
            -
                  options.store(:name, args[:name]) unless clone.container?
         | 
| 67 | 
            -
                  options.store(:hostname, args[:name]) if clone.container?
         | 
| 68 | 
            -
                  clone.update(options)
         | 
| 65 | 
            +
                  find_vm_by_uuid(id.to_s + '_' + vmid.to_s)
         | 
| 69 66 | 
             
                end
         | 
| 70 67 | 
             
              end
         | 
| 71 68 | 
             
            end
         | 
| @@ -39,26 +39,37 @@ module ForemanFogProxmox | |
| 39 39 | 
             
                  raise ::Foreman::Exception, format(N_('invalid vmid=%<vmid>s'), vmid: vmid) unless node.servers.id_valid?(vmid)
         | 
| 40 40 |  | 
| 41 41 | 
             
                  image_id = args[:image_id]
         | 
| 42 | 
            +
                  remove_volume_keys(args)
         | 
| 42 43 | 
             
                  if image_id
         | 
| 43 | 
            -
                    clone_from_image(image_id,  | 
| 44 | 
            +
                    vm = clone_from_image(image_id, vmid)
         | 
| 45 | 
            +
                    vm.update(compute_clone_attributes(args, vm.container?, type))
         | 
| 46 | 
            +
                    update_pool(vm, args[:pool]) if args[:pool]
         | 
| 44 47 | 
             
                  else
         | 
| 45 | 
            -
                    remove_volume_keys(args)
         | 
| 46 48 | 
             
                    logger.warn("create vm: args=#{args}")
         | 
| 47 49 | 
             
                    vm = node.send(vm_collection(type)).create(parse_typed_vm(args, type))
         | 
| 48 | 
            -
                    start_on_boot(vm, args)
         | 
| 49 50 | 
             
                  end
         | 
| 51 | 
            +
                  start_on_boot(vm, args)
         | 
| 50 52 | 
             
                rescue StandardError => e
         | 
| 51 53 | 
             
                  logger.warn("failed to create vm: #{e}")
         | 
| 52 | 
            -
                  destroy_vm  | 
| 54 | 
            +
                  destroy_vm id.to_s + '_' + vm.vmid.to_s if vm
         | 
| 53 55 | 
             
                  raise e
         | 
| 54 56 | 
             
                end
         | 
| 55 57 |  | 
| 58 | 
            +
                def compute_clone_attributes(args, container, type)
         | 
| 59 | 
            +
                  args = parse_cloudinit_config(args) if args[:user_data]
         | 
| 60 | 
            +
                  parsed_args = parse_typed_vm(args, type)
         | 
| 61 | 
            +
                  if container
         | 
| 62 | 
            +
                    options = { :hostname => args[:name] }
         | 
| 63 | 
            +
                    parsed_args.merge(options)
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                  parsed_args.reject { |k| k == 'pool' }
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 56 68 | 
             
                def destroy_vm(uuid)
         | 
| 57 69 | 
             
                  vm = find_vm_by_uuid(uuid)
         | 
| 58 | 
            -
                   | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
                  end
         | 
| 70 | 
            +
                  return true if vm.nil?
         | 
| 71 | 
            +
                  vm.stop if vm.ready?
         | 
| 72 | 
            +
                  vm.destroy
         | 
| 62 73 | 
             
                rescue ActiveRecord::RecordNotFound
         | 
| 63 74 | 
             
                  # if the VM does not exists, we don't really care.
         | 
| 64 75 | 
             
                  true
         | 
| @@ -104,12 +104,14 @@ module ForemanFogProxmox | |
| 104 104 |  | 
| 105 105 | 
             
                def volume_exists?(vm, volume_attributes)
         | 
| 106 106 | 
             
                  disk = vm.config.disks.get(volume_attributes['id'])
         | 
| 107 | 
            -
                   | 
| 108 | 
            -
                  return exists unless disk
         | 
| 107 | 
            +
                  return false unless disk
         | 
| 109 108 |  | 
| 110 | 
            -
                   | 
| 111 | 
            -
                   | 
| 112 | 
            -
             | 
| 109 | 
            +
                  # Return boolean if disk of type hard_disk, cloud_init, cdrom or rootfs(LXC container) exists
         | 
| 110 | 
            +
                  if disk.hard_disk? || disk.cloud_init? || disk.rootfs?
         | 
| 111 | 
            +
                    volume_attributes['volid'].present?
         | 
| 112 | 
            +
                  elsif disk.cdrom?
         | 
| 113 | 
            +
                    volume_attributes['cdrom'].present?
         | 
| 114 | 
            +
                  end
         | 
| 113 115 | 
             
                end
         | 
| 114 116 |  | 
| 115 117 | 
             
                def volume_to_delete?(volume_attributes)
         | 
| @@ -38,5 +38,5 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 38 38 | 
             
                :placeholder => _("Optionally provide a CA, or a correctly ordered CA chain. If left blank, disable ssl_verify_peer.") %>
         | 
| 39 39 | 
             
            <% end %>
         | 
| 40 40 | 
             
            <div class="col-md-offset-2">
         | 
| 41 | 
            -
              <%= test_connection_button_f(f, (f.object.nodes rescue  | 
| 41 | 
            +
              <%= test_connection_button_f(f, (f.object.nodes rescue true)) %>
         | 
| 42 42 | 
             
            </div>
         | 
| @@ -21,7 +21,10 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 21 21 | 
             
              <%= checkbox_f f, :templated, :label => _('Create image?'), :disabled => untemplatable, :class => ('hide' if untemplatable), :no_label => untemplatable %>
         | 
| 22 22 | 
             
              <%= counter_f f, :vmid, :label => _('VM ID'), :label_size => "col-md-2", :required => true, :disabled => (!new_vm || from_profile) %>
         | 
| 23 23 | 
             
              <%= select_f f, :node_id, compute_resource.nodes, :node, :node, { }, :label => _('Node'), :label_size => "col-md-2", :required => true, :onchange => 'nodeSelected(this)' %>
         | 
| 24 | 
            -
               | 
| 24 | 
            +
              <% unless !new_vm || from_profile %>
         | 
| 25 | 
            +
                <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start_after_create] || '1' %>
         | 
| 26 | 
            +
                <%= checkbox_f f, :start_after_create, {:checked => (checked == '1'), :label => _('Start after creation?')} %>
         | 
| 27 | 
            +
              <% end %>
         | 
| 25 28 | 
             
              <% unless local_assigns[:hide_image] && !new_vm %>
         | 
| 26 29 | 
             
                <%
         | 
| 27 30 | 
             
                  arch ||= nil ; os ||= nil
         | 
| @@ -18,14 +18,4 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 18 18 | 
             
            <% container = f.object.type == 'lxc' %>  
         | 
| 19 19 |  | 
| 20 20 | 
             
            <%= field_set_tag _("Advanced"), :id => "container_config_advanced_options", :class => ('hide' unless container) do %>
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              <%= check_box_tag 'show_container_config_options', '1', false, :onclick => "$('#container_config_options').toggle()" %>
         | 
| 23 | 
            -
              <%= label_tag 'show_container_config_cpu', _("CPU") %>
         | 
| 24 | 
            -
              <%= check_box_tag 'show_container_config_cpu', '1', false, :onclick => "$('#container_config_cpu').toggle()" %>
         | 
| 25 | 
            -
              <%= label_tag 'show_container_config_memory', _("Memory") %>
         | 
| 26 | 
            -
              <%= check_box_tag 'show_container_config_memory', '1', false, :onclick => "$('#container_config_memory').toggle()" %>
         | 
| 27 | 
            -
              <%= label_tag 'show_container_config_dns', _("DNS") %>
         | 
| 28 | 
            -
              <%= check_box_tag 'show_container_config_dns', '1', false, :onclick => "$('#container_config_dns').toggle()" %>
         | 
| 29 | 
            -
              <%= label_tag 'show_container_config_os', _("OS") %>
         | 
| 30 | 
            -
              <%= check_box_tag 'show_container_config_os', '1', false, :onclick => "$('#container_config_os').toggle()" %>
         | 
| 31 | 
            -
            <% end %>
         | 
| 21 | 
            +
            <% end %>
         | 
| @@ -17,25 +17,32 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 17 17 |  | 
| 18 18 | 
             
            <%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm_container', "data-turbolinks-track" => true %>
         | 
| 19 19 | 
             
            <% container = type == 'lxc' %>
         | 
| 20 | 
            -
            <%=  | 
| 21 | 
            -
              <%=  | 
| 22 | 
            -
               | 
| 23 | 
            -
             | 
| 24 | 
            -
            <%=  | 
| 20 | 
            +
            <%= content_tag :div, :id => "container_advanced_options" do %>
         | 
| 21 | 
            +
              <%= content_tag :h3, "Main Options"%>
         | 
| 22 | 
            +
              <div>
         | 
| 23 | 
            +
                <%= textarea_f f, :description, :label => _('Description'), :label_size => "col-md-2" %>
         | 
| 24 | 
            +
                <%= checkbox_f f, :onboot, :label => _('Start at boot') %>
         | 
| 25 | 
            +
              </div>
         | 
| 26 | 
            +
              <%= content_tag :h3, "CPUs"%>
         | 
| 27 | 
            +
              <div>
         | 
| 25 28 | 
             
              <%= select_f f, :arch, proxmox_archs_map, :id, :name, { }, :label => _('Architecture'), :label_size => "col-md-2" %>
         | 
| 26 29 | 
             
              <%= counter_f f, :cores, :class => "input-mini", :label => _('Cores'), :label_size => "col-md-2" %>
         | 
| 27 30 | 
             
              <%= counter_f f, :cpulimit, :class => "input-mini", :label => _('CPU limit'), :label_size => "col-md-2" %>
         | 
| 28 31 | 
             
              <%= counter_f f, :cpuunits, :class => "input-mini", :label => _('CPU units'), :label_size => "col-md-2" %>
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            <%=  | 
| 32 | 
            +
              </div>
         | 
| 33 | 
            +
              <%= content_tag :h3, "Memory"%>
         | 
| 34 | 
            +
              <div>
         | 
| 31 35 | 
             
              <%= text_f f, :memory, :class => "input-mini", :label => _('Memory (MB)'), :label_size => "col-md-2" %>
         | 
| 32 36 | 
             
              <%= text_f f, :swap, :class => "input-mini", :label => _('Swap (MB)'), :label_size => "col-md-2" %>
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            <%=  | 
| 37 | 
            +
              </div>
         | 
| 38 | 
            +
              <%= content_tag :h3, "DNS"%>
         | 
| 39 | 
            +
              <div>
         | 
| 35 40 | 
             
              <%= text_f f, :hostname, :label => _('Hostname'), :label_size => "col-md-2", :disabled => true %>
         | 
| 36 41 | 
             
              <%= text_f f, :nameserver, :label => _('DNS server'), :label_size => "col-md-2" %>
         | 
| 37 42 | 
             
              <%= text_f f, :searchdomain, :label => _('Search domain'), :label_size => "col-md-2" %>
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            <%=  | 
| 43 | 
            +
              </div>
         | 
| 44 | 
            +
              <%= content_tag :h3, "Operating System"%>
         | 
| 45 | 
            +
              <div>
         | 
| 40 46 | 
             
              <%= select_f f, :ostype, proxmox_ostypes_map, :id, :name, { }, :label => _('OS type'), :label_size => "col-md-2" %>
         | 
| 41 | 
            -
             | 
| 47 | 
            +
              </div>
         | 
| 48 | 
            +
            <% end %>
         | 
| @@ -18,12 +18,4 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 18 18 | 
             
            <% server = f.object.type == 'qemu' %>
         | 
| 19 19 |  | 
| 20 20 | 
             
            <%= field_set_tag _("Advanced"), :id => "server_config_advanced_options", :class => ('hide' unless server) do %>
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              <%= check_box_tag 'show_server_config_options', '1', false, :onclick => "$('#server_config_options').toggle()" %>
         | 
| 23 | 
            -
              <%= label_tag 'show_server_config_cpu', _("CPU") %>
         | 
| 24 | 
            -
              <%= check_box_tag 'show_server_config_cpu', '1', false, :onclick => "$('#server_config_cpu').toggle()" %>
         | 
| 25 | 
            -
              <%= label_tag 'show_server_config_memory', _("Memory") %>
         | 
| 26 | 
            -
              <%= check_box_tag 'show_server_config_memory', '1', false, :onclick => "$('#server_config_memory').toggle()" %>
         | 
| 27 | 
            -
              <%= label_tag 'show_server_config_os', _("OS") %>
         | 
| 28 | 
            -
              <%= check_box_tag 'show_server_config_os', '1', false, :onclick => "$('#server_config_os').toggle()" %>
         | 
| 29 | 
            -
            <% end %>
         | 
| 21 | 
            +
            <% end %>
         | 
| @@ -20,17 +20,21 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 20 20 | 
             
            <% server = type == 'qemu' %>
         | 
| 21 21 | 
             
            <% logger.debug("_config.html.erb server_config=#{f.object.inspect}") %>
         | 
| 22 22 |  | 
| 23 | 
            -
            <%=  | 
| 24 | 
            -
              <%=  | 
| 25 | 
            -
               | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
            <%=  | 
| 23 | 
            +
            <%= content_tag :div, :id => "server_advanced_options" do %>
         | 
| 24 | 
            +
              <%= content_tag :h3, "Main Options" %>
         | 
| 25 | 
            +
              <div>
         | 
| 26 | 
            +
                <%= textarea_f f, :description, :label => _('Description'), :label_size => "col-md-2" %>
         | 
| 27 | 
            +
                <%= text_f f, :boot, :label => _('Boot device order'), :label_size => "col-md-2", :label_help => _('Order your devices, e.g. order=net0;ide2;scsi0. Default empty (any)')  %>
         | 
| 28 | 
            +
                <%= checkbox_f f, :onboot, :label => _('Start at boot') %>
         | 
| 29 | 
            +
                <%= checkbox_f f, :agent, :label => _('Qemu Agent') %>
         | 
| 30 | 
            +
                <%= checkbox_f f, :kvm, :label => _('KVM'), :label_help => _('Enable/disable KVM hardware virtualization') %>
         | 
| 31 | 
            +
                <%= select_f f, :vga, proxmox_vgas_map, :id, :name, { :include_blank => true }, :label => _('VGA'), :label_size => "col-md-2" %>
         | 
| 32 | 
            +
                <%= select_f f, :scsihw, proxmox_scsi_controllers_map, :id, :name, { }, :label => _('SCSI Controller'), :label_size => "col-md-2" %>
         | 
| 33 | 
            +
                <%= select_f f, :bios, proxmox_bios_map, :id, :name, { }, :label => _('BIOS'), :label_size => "col-md-2" %>
         | 
| 34 | 
            +
              </div>
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              <%= content_tag :h3, "CPUs" %>
         | 
| 37 | 
            +
              <div>
         | 
| 34 38 | 
             
              <%= select_f f, :cpu_type, proxmox_cpus_map, :id, :name, { }, :label => _('Type'), :label_size => "col-md-2" %>
         | 
| 35 39 | 
             
              <%= counter_f f, :sockets, :class => "input-mini", :label => _('Sockets'), :label_size => "col-md-2" %>
         | 
| 36 40 | 
             
              <%= counter_f f, :cores, :class => "input-mini", :label => _('Cores'), :label_size => "col-md-2" %>
         | 
| @@ -43,14 +47,17 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 43 47 | 
             
                  <%= select_f f, flag_key, proxmox_cpu_flags_map, :id, :name, { }, :label => _(flag_value) %>
         | 
| 44 48 | 
             
                <% end %>
         | 
| 45 49 | 
             
              <% end %>
         | 
| 46 | 
            -
             | 
| 47 | 
            -
            <%=  | 
| 50 | 
            +
              </div>
         | 
| 51 | 
            +
              <%= content_tag :h3, "Memory" %>
         | 
| 52 | 
            +
              <div>
         | 
| 48 53 | 
             
              <%= text_f f, :memory, :class => "input-mini", :label => _('Memory (MB)'), :label_size => "col-md-2" %>
         | 
| 49 54 | 
             
              <%= text_f f, :balloon, :class => "input-mini", :label => _('Minimum memory (MB)'), :label_size => "col-md-2" %>
         | 
| 50 55 | 
             
              <%= text_f f, :shares, :class => "input-mini", :label => _('Shares (MB)'), :label_size => "col-md-2" %>
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            <%=  | 
| 56 | 
            +
              </div>
         | 
| 57 | 
            +
              <%= content_tag :h3, "Operating System" %>
         | 
| 58 | 
            +
              <div>
         | 
| 53 59 | 
             
              <%= select_f f, :ostype, proxmox_operating_systems_map, :id, :name, { :include_blank => true }, :label => _('OS type'), :label_size => "col-md-2" %>
         | 
| 60 | 
            +
              </div>
         | 
| 54 61 | 
             
            <% end %>
         | 
| 55 62 | 
             
            <%= field_set_tag _("Cloud-init"), :id => "server_config_cloud_init", :class => ('hide' unless cloudinit), :disabled => (!cloudinit) do %>
         | 
| 56 63 | 
             
              <%= text_f f, :ciuser, :label => _('User'), :label_size => "col-md-2" %>
         | 
| @@ -58,4 +65,4 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 58 65 | 
             
              <%= text_f f, :searchdomain, :label => _('DNS domain'), :label_size => "col-md-2" %>
         | 
| 59 66 | 
             
              <%= text_f f, :nameserver, :label => _('DNS servers'), :label_size => "col-md-2" %>
         | 
| 60 67 | 
             
              <%= textarea_f f, :sshkeys, :label => _("SSH public key"), :size => "col-md-4" %>
         | 
| 61 | 
            -
            <% end %>
         | 
| 68 | 
            +
            <% end %>
         | 
| @@ -41,6 +41,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |
| 41 41 | 
             
                    <td>
         | 
| 42 42 | 
             
                    <%= action_buttons(
         | 
| 43 43 | 
             
                            vm_power_action(vm, authorizer),
         | 
| 44 | 
            +
            		vm_associate_link(vm),
         | 
| 44 45 | 
             
                            display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.unique_cluster_identity(@compute_resource)).merge(:auth_object => @compute_resource, :authorizer => authorizer))) %>
         | 
| 45 46 | 
             
                    </td>
         | 
| 46 47 | 
             
                  </tr>
         | 
| @@ -40,13 +40,15 @@ module ForemanFogProxmox | |
| 40 40 | 
             
                initializer 'foreman_fog_proxmox.register_plugin', :before => :finisher_hook do |_app|
         | 
| 41 41 | 
             
                  Foreman::Plugin.register :foreman_fog_proxmox do
         | 
| 42 42 | 
             
                    requires_foreman '>= 1.22.0'
         | 
| 43 | 
            +
                    # Add Global files for extending foreman-core components and routes
         | 
| 44 | 
            +
                    register_global_js_file 'global'
         | 
| 43 45 | 
             
                    # Register Proxmox VE compute resource in foreman
         | 
| 44 46 | 
             
                    compute_resource ForemanFogProxmox::Proxmox
         | 
| 45 47 | 
             
                    parameter_filter(ComputeResource, :uuid)
         | 
| 46 48 | 
             
                    # add dashboard widget
         | 
| 47 49 | 
             
                    widget 'foreman_fog_proxmox_widget', name: N_('Foreman Fog Proxmox widget'), sizex: 8, sizey: 1
         | 
| 48 50 | 
             
                    security_block :foreman_fog_proxmox do
         | 
| 49 | 
            -
                      permission : | 
| 51 | 
            +
                      permission :view_compute_resources, { :'foreman_fog_proxmox/compute_resources' =>
         | 
| 50 52 | 
             
                        [:ostemplates_by_id_and_node_and_storage,
         | 
| 51 53 | 
             
                         :isos_by_id_and_node_and_storage,
         | 
| 52 54 | 
             
                         :ostemplates_by_id_and_node,
         | 
| @@ -244,7 +244,10 @@ msgstr "" | |
| 244 244 | 
             
            msgid "Memory"
         | 
| 245 245 | 
             
            msgstr ""
         | 
| 246 246 |  | 
| 247 | 
            -
            msgid " | 
| 247 | 
            +
            msgid "Memory (MB)"
         | 
| 248 | 
            +
            msgstr ""
         | 
| 249 | 
            +
             | 
| 250 | 
            +
            msgid "Minimum memory (MB)"
         | 
| 248 251 | 
             
            msgstr ""
         | 
| 249 252 |  | 
| 250 253 | 
             
            msgid "Mount point"
         | 
| @@ -340,10 +343,10 @@ msgstr "" | |
| 340 343 | 
             
            msgid "Search domain"
         | 
| 341 344 | 
             
            msgstr ""
         | 
| 342 345 |  | 
| 343 | 
            -
            msgid "Shares"
         | 
| 346 | 
            +
            msgid "Shares (MB)"
         | 
| 344 347 | 
             
            msgstr ""
         | 
| 345 348 |  | 
| 346 | 
            -
            msgid "Size"
         | 
| 349 | 
            +
            msgid "Size (GB)"
         | 
| 347 350 | 
             
            msgstr ""
         | 
| 348 351 |  | 
| 349 352 | 
             
            msgid "Sockets"
         | 
| @@ -358,7 +361,7 @@ msgstr "" | |
| 358 361 | 
             
            msgid "Storage"
         | 
| 359 362 | 
             
            msgstr ""
         | 
| 360 363 |  | 
| 361 | 
            -
            msgid "Swap"
         | 
| 364 | 
            +
            msgid "Swap (MB)"
         | 
| 362 365 | 
             
            msgstr ""
         | 
| 363 366 |  | 
| 364 367 | 
             
            msgid "Template storage"
         | 
| @@ -472,6 +475,12 @@ msgstr "" | |
| 472 475 | 
             
            msgid "net[n] with n integer >= 0, e.g. net0"
         | 
| 473 476 | 
             
            msgstr ""
         | 
| 474 477 |  | 
| 478 | 
            +
            msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
         | 
| 479 | 
            +
            msgstr ""
         | 
| 480 | 
            +
             | 
| 481 | 
            +
            msgid "parse_hard_disk_volume(): args=%<args>s"
         | 
| 482 | 
            +
            msgstr ""
         | 
| 483 | 
            +
             | 
| 475 484 | 
             
            msgid "remove CDROM"
         | 
| 476 485 | 
             
            msgstr ""
         | 
| 477 486 |  | 
| @@ -8,8 +8,8 @@ msgid "" | |
| 8 8 | 
             
            msgstr ""
         | 
| 9 9 | 
             
            "Project-Id-Version: foreman_fog_proxmox 1.0.0\n"
         | 
| 10 10 | 
             
            "Report-Msgid-Bugs-To: \n"
         | 
| 11 | 
            -
            "POT-Creation-Date: 2022-12- | 
| 12 | 
            -
            "PO-Revision-Date: 2022-12- | 
| 11 | 
            +
            "POT-Creation-Date: 2022-12-16 17:29+0100\n"
         | 
| 12 | 
            +
            "PO-Revision-Date: 2022-12-16 17:29+0100\n"
         | 
| 13 13 | 
             
            "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
         | 
| 14 14 | 
             
            "Language-Team: LANGUAGE <LL@li.org>\n"
         | 
| 15 15 | 
             
            "Language: \n"
         | 
| @@ -89,6 +89,10 @@ msgstr "" | |
| 89 89 | 
             
            msgid "Change the password"
         | 
| 90 90 | 
             
            msgstr ""
         | 
| 91 91 |  | 
| 92 | 
            +
            #: ../app/helpers/proxmox_vm_volumes_helper.rb:52
         | 
| 93 | 
            +
            msgid "parse_hard_disk_volume(): args=%<args>s"
         | 
| 94 | 
            +
            msgstr ""
         | 
| 95 | 
            +
             | 
| 92 96 | 
             
            #: ../app/models/concerns/fog_extensions/proxmox/server.rb:62
         | 
| 93 97 | 
             
            msgid "Type %<type>s, node %<node>s, %<cpus>s CPUs and %<memory>s MB memory"
         | 
| 94 98 | 
             
            msgstr ""
         | 
| @@ -129,10 +133,15 @@ msgstr "" | |
| 129 133 | 
             
            msgid "invalid vmid=%<vmid>s"
         | 
| 130 134 | 
             
            msgstr ""
         | 
| 131 135 |  | 
| 132 | 
            -
            #: ../app/models/foreman_fog_proxmox/ | 
| 136 | 
            +
            #: ../app/models/foreman_fog_proxmox/proxmox_vm_new.rb:199
         | 
| 137 | 
            +
            msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
         | 
| 138 | 
            +
            msgstr ""
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            #: ../app/models/foreman_fog_proxmox/proxmox_vm_queries.rb:78
         | 
| 133 141 | 
             
            msgid "Failed retrieving proxmox server vm by vmid=%<vmid>s"
         | 
| 134 142 | 
             
            msgstr ""
         | 
| 135 143 |  | 
| 144 | 
            +
            #: ../app/models/foreman_fog_proxmox/proxmox_volumes.rb:88
         | 
| 136 145 | 
             
            #: ../app/models/foreman_fog_proxmox/proxmox_volumes.rb:91
         | 
| 137 146 | 
             
            msgid "Unable to shrink %<id>s size. Proxmox allows only increasing size."
         | 
| 138 147 | 
             
            msgstr ""
         | 
| @@ -365,10 +374,8 @@ msgstr "" | |
| 365 374 | 
             
            #:
         | 
| 366 375 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb:10
         | 
| 367 376 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:15
         | 
| 368 | 
            -
            #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:16
         | 
| 369 377 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb:10
         | 
| 370 378 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:32
         | 
| 371 | 
            -
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:33
         | 
| 372 379 | 
             
            #: ../app/views/compute_resources_vms/index/_proxmox.html.erb:10
         | 
| 373 380 | 
             
            msgid "Memory"
         | 
| 374 381 | 
             
            msgstr ""
         | 
| @@ -418,9 +425,15 @@ msgstr "" | |
| 418 425 | 
             
            msgid "CPU units"
         | 
| 419 426 | 
             
            msgstr ""
         | 
| 420 427 |  | 
| 428 | 
            +
            #:
         | 
| 429 | 
            +
            #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:16
         | 
| 430 | 
            +
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:33
         | 
| 431 | 
            +
            msgid "Memory (MB)"
         | 
| 432 | 
            +
            msgstr ""
         | 
| 433 | 
            +
             | 
| 421 434 | 
             
            #:
         | 
| 422 435 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:17
         | 
| 423 | 
            -
            msgid "Swap"
         | 
| 436 | 
            +
            msgid "Swap (MB)"
         | 
| 424 437 | 
             
            msgstr ""
         | 
| 425 438 |  | 
| 426 439 | 
             
            #:
         | 
| @@ -598,7 +611,7 @@ msgstr "" | |
| 598 611 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb:11
         | 
| 599 612 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb:8
         | 
| 600 613 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb:16
         | 
| 601 | 
            -
            msgid "Size"
         | 
| 614 | 
            +
            msgid "Size (GB)"
         | 
| 602 615 | 
             
            msgstr ""
         | 
| 603 616 |  | 
| 604 617 | 
             
            #:
         | 
| @@ -660,11 +673,11 @@ msgid "CPU Flags" | |
| 660 673 | 
             
            msgstr ""
         | 
| 661 674 |  | 
| 662 675 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:34
         | 
| 663 | 
            -
            msgid "Minimum memory"
         | 
| 676 | 
            +
            msgid "Minimum memory (MB)"
         | 
| 664 677 | 
             
            msgstr ""
         | 
| 665 678 |  | 
| 666 679 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:35
         | 
| 667 | 
            -
            msgid "Shares"
         | 
| 680 | 
            +
            msgid "Shares (MB)"
         | 
| 668 681 | 
             
            msgstr ""
         | 
| 669 682 |  | 
| 670 683 | 
             
            #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:40
         | 
| @@ -244,8 +244,11 @@ msgstr "" | |
| 244 244 | 
             
            msgid "Memory"
         | 
| 245 245 | 
             
            msgstr "Mémoire"
         | 
| 246 246 |  | 
| 247 | 
            -
            msgid " | 
| 248 | 
            -
            msgstr " | 
| 247 | 
            +
            msgid "Memory (MB)"
         | 
| 248 | 
            +
            msgstr ""
         | 
| 249 | 
            +
             | 
| 250 | 
            +
            msgid "Minimum memory (MB)"
         | 
| 251 | 
            +
            msgstr ""
         | 
| 249 252 |  | 
| 250 253 | 
             
            msgid "Mount point"
         | 
| 251 254 | 
             
            msgstr "Point de montage"
         | 
| @@ -340,11 +343,11 @@ msgstr "" | |
| 340 343 | 
             
            msgid "Search domain"
         | 
| 341 344 | 
             
            msgstr "Domaine de recherche"
         | 
| 342 345 |  | 
| 343 | 
            -
            msgid "Shares"
         | 
| 344 | 
            -
            msgstr " | 
| 346 | 
            +
            msgid "Shares (MB)"
         | 
| 347 | 
            +
            msgstr ""
         | 
| 345 348 |  | 
| 346 | 
            -
            msgid "Size"
         | 
| 347 | 
            -
            msgstr " | 
| 349 | 
            +
            msgid "Size (GB)"
         | 
| 350 | 
            +
            msgstr ""
         | 
| 348 351 |  | 
| 349 352 | 
             
            msgid "Sockets"
         | 
| 350 353 | 
             
            msgstr ""
         | 
| @@ -358,7 +361,7 @@ msgstr "Démarrer au boot" | |
| 358 361 | 
             
            msgid "Storage"
         | 
| 359 362 | 
             
            msgstr "Stockage"
         | 
| 360 363 |  | 
| 361 | 
            -
            msgid "Swap"
         | 
| 364 | 
            +
            msgid "Swap (MB)"
         | 
| 362 365 | 
             
            msgstr ""
         | 
| 363 366 |  | 
| 364 367 | 
             
            msgid "Template storage"
         | 
| @@ -472,6 +475,12 @@ msgstr "vmid=%<vmid>s incorrect" | |
| 472 475 | 
             
            msgid "net[n] with n integer >= 0, e.g. net0"
         | 
| 473 476 | 
             
            msgstr ""
         | 
| 474 477 |  | 
| 478 | 
            +
            msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
         | 
| 479 | 
            +
            msgstr ""
         | 
| 480 | 
            +
             | 
| 481 | 
            +
            msgid "parse_hard_disk_volume(): args=%<args>s"
         | 
| 482 | 
            +
            msgstr ""
         | 
| 483 | 
            +
             | 
| 475 484 | 
             
            msgid "remove CDROM"
         | 
| 476 485 | 
             
            msgstr ""
         | 
| 477 486 |  | 
| @@ -140,8 +140,8 @@ module ForemanFogProxmox | |
| 140 140 | 
             
                describe 'object_to_config_hash' do
         | 
| 141 141 | 
             
                  setup { Fog.mock! }
         | 
| 142 142 | 
             
                  teardown { Fog.unmock! }
         | 
| 143 | 
            -
                  excluded_qemu_keys = ['templated', 'ide2', 'scsi0', 'net0', 'net1']
         | 
| 144 | 
            -
                  excluded_lxc_keys = ['templated', 'rootfs', 'mp0', 'net0', 'net1']
         | 
| 143 | 
            +
                  excluded_qemu_keys = ['vmid', 'type', 'templated', 'ide2', 'scsi0', 'net0', 'net1']
         | 
| 144 | 
            +
                  excluded_lxc_keys = ['vmid', 'type', 'templated', 'rootfs', 'mp0', 'net0', 'net1']
         | 
| 145 145 |  | 
| 146 146 | 
             
                  it '#server qemu' do
         | 
| 147 147 | 
             
                    config_hash = object_to_config_hash(server, 'qemu')
         | 
| @@ -27,7 +27,6 @@ module ForemanFogProxmox | |
| 27 27 | 
             
                describe 'clone_from_image' do
         | 
| 28 28 | 
             
                  before do
         | 
| 29 29 | 
             
                    @cr = FactoryBot.build_stubbed(:proxmox_cr)
         | 
| 30 | 
            -
                    @args = { :name => 'name' }
         | 
| 31 30 | 
             
                    @image_id = @cr.id.to_s + '_' + 100.to_s
         | 
| 32 31 | 
             
                    @vmid = 101
         | 
| 33 32 | 
             
                    @image = mock('vm')
         | 
| @@ -36,16 +35,14 @@ module ForemanFogProxmox | |
| 36 35 | 
             
                    @clone = mock('vm')
         | 
| 37 36 | 
             
                  end
         | 
| 38 37 | 
             
                  it 'clones server from image' do
         | 
| 39 | 
            -
                    @clone.expects(:update).with(:name => 'name')
         | 
| 40 38 | 
             
                    @clone.stubs(:container?).returns(false)
         | 
| 41 39 | 
             
                    @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
         | 
| 42 | 
            -
                    @cr.clone_from_image(@image_id, @ | 
| 40 | 
            +
                    @cr.clone_from_image(@image_id, @vmid)
         | 
| 43 41 | 
             
                  end
         | 
| 44 42 | 
             
                  it 'clones container from image' do
         | 
| 45 43 | 
             
                    @clone.stubs(:container?).returns(true)
         | 
| 46 | 
            -
                    @clone.expects(:update).with(:hostname => 'name')
         | 
| 47 44 | 
             
                    @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
         | 
| 48 | 
            -
                    @cr.clone_from_image(@image_id, @ | 
| 45 | 
            +
                    @cr.clone_from_image(@image_id, @vmid)
         | 
| 49 46 | 
             
                  end
         | 
| 50 47 | 
             
                end
         | 
| 51 48 | 
             
              end
         | 
| @@ -291,8 +291,14 @@ module ForemanFogProxmox | |
| 291 291 | 
             
                    args = { vmid: '100', type: 'lxc', image_id: '999', name: 'name' }
         | 
| 292 292 | 
             
                    servers = mock('servers')
         | 
| 293 293 | 
             
                    servers.stubs(:id_valid?).returns(true)
         | 
| 294 | 
            -
                     | 
| 295 | 
            -
                    cr | 
| 294 | 
            +
                    containers = mock('containers')
         | 
| 295 | 
            +
                    cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
         | 
| 296 | 
            +
                    vm = mock('vm')
         | 
| 297 | 
            +
                    cr.expects(:clone_from_image).with('999', 100).returns(vm)
         | 
| 298 | 
            +
                    vm.expects(:container?).returns(true)
         | 
| 299 | 
            +
                    expected_args = { :vmid => "100", :type => "lxc" }
         | 
| 300 | 
            +
                    cr.stubs(:parse_typed_vm).with(args, 'lxc').returns(expected_args)
         | 
| 301 | 
            +
                    vm.expects(:update).with(expected_args)
         | 
| 296 302 | 
             
                    cr.create_vm(args)
         | 
| 297 303 | 
             
                  end
         | 
| 298 304 | 
             
                end
         | 
| @@ -96,9 +96,15 @@ module ForemanFogProxmox | |
| 96 96 | 
             
                  it 'clones server' do
         | 
| 97 97 | 
             
                    args = { vmid: '100', type: 'qemu', image_id: '999', name: 'name' }
         | 
| 98 98 | 
             
                    servers = mock('servers')
         | 
| 99 | 
            +
                    containers = mock('containers')
         | 
| 99 100 | 
             
                    servers.stubs(:id_valid?).returns(true)
         | 
| 100 | 
            -
                    cr =  | 
| 101 | 
            -
                     | 
| 101 | 
            +
                    cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
         | 
| 102 | 
            +
                    vm = mock('vm')
         | 
| 103 | 
            +
                    cr.expects(:clone_from_image).with('999', 100).returns(vm)
         | 
| 104 | 
            +
                    vm.expects(:container?).returns(false)
         | 
| 105 | 
            +
                    expected_args = { :vmid => "100", :type => "qemu", :name => "name" }
         | 
| 106 | 
            +
                    cr.stubs(:parse_typed_vm).with(args, 'qemu').returns(expected_args)
         | 
| 107 | 
            +
                    vm.expects(:update).with(expected_args)
         | 
| 102 108 | 
             
                    cr.create_vm(args)
         | 
| 103 109 | 
             
                  end
         | 
| 104 110 | 
             
                end
         | 
| @@ -44,6 +44,7 @@ module ForemanFogProxmox | |
| 44 44 | 
             
                    disk.stubs(:id).returns('ide2')
         | 
| 45 45 | 
             
                    disk.stubs(:hard_disk?).returns(false)
         | 
| 46 46 | 
             
                    disk.stubs(:cdrom?).returns(true)
         | 
| 47 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 47 48 | 
             
                    disks.stubs(:get).returns
         | 
| 48 49 | 
             
                    config.stubs(:disks).returns(disks)
         | 
| 49 50 | 
             
                    config.stubs(:attributes).returns(:cores => '')
         | 
| @@ -93,6 +94,7 @@ module ForemanFogProxmox | |
| 93 94 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 94 95 | 
             
                    disk.stubs(:hard_disk?).returns(false)
         | 
| 95 96 | 
             
                    disk.stubs(:cdrom?).returns(true)
         | 
| 97 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 96 98 | 
             
                    disk.stubs(:cloud_init?).returns(false)
         | 
| 97 99 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 98 100 | 
             
                    disk.stubs(:volid).returns('local-lvm:iso/ubuntu-20_4.iso')
         | 
| @@ -145,6 +147,7 @@ module ForemanFogProxmox | |
| 145 147 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 146 148 | 
             
                    disk.stubs(:hard_disk?).returns(false)
         | 
| 147 149 | 
             
                    disk.stubs(:cdrom?).returns(true)
         | 
| 150 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 148 151 | 
             
                    disk.stubs(:cloud_init?).returns(false)
         | 
| 149 152 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 150 153 | 
             
                    disk.stubs(:volid).returns('local-lvm:iso/ubuntu-20_4.iso')
         | 
| @@ -24,12 +24,13 @@ require 'factories/foreman_fog_proxmox/proxmox_server_mock_factory' | |
| 24 24 | 
             
            require 'active_support/core_ext/hash/indifferent_access'
         | 
| 25 25 |  | 
| 26 26 | 
             
            module ForemanFogProxmox
         | 
| 27 | 
            -
              class ProxmoxVmCommandsServerUpdateHardDiskTest < ActiveSupport::TestCase
         | 
| 27 | 
            +
              class ProxmoxVmCommandsServerUpdateHardDiskTest < ActiveSupport::TestCase # rubocop:disable Metrics/ClassLength
         | 
| 28 28 | 
             
                include ComputeResourceTestHelpers
         | 
| 29 29 | 
             
                include ProxmoxNodeMockFactory
         | 
| 30 30 | 
             
                include ProxmoxServerMockFactory
         | 
| 31 31 | 
             
                include ProxmoxVmHelper
         | 
| 32 32 |  | 
| 33 | 
            +
                # rubocop:disable Metrics/BlockLength
         | 
| 33 34 | 
             
                describe 'save_vm' do
         | 
| 34 35 | 
             
                  before do
         | 
| 35 36 | 
             
                    @cr = FactoryBot.build_stubbed(:proxmox_cr)
         | 
| @@ -43,6 +44,7 @@ module ForemanFogProxmox | |
| 43 44 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 44 45 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 45 46 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 47 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 46 48 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 47 49 | 
             
                    disk.stubs(:id).returns('scsi0')
         | 
| 48 50 | 
             
                    disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1')
         | 
| @@ -94,6 +96,7 @@ module ForemanFogProxmox | |
| 94 96 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 95 97 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 96 98 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 99 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 97 100 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 98 101 | 
             
                    disk.stubs(:id).returns('virtio0')
         | 
| 99 102 | 
             
                    disks.stubs(:get).returns(disk)
         | 
| @@ -147,6 +150,7 @@ module ForemanFogProxmox | |
| 147 150 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 148 151 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 149 152 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 153 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 150 154 | 
             
                    disk.stubs(:storage).returns('scsi0')
         | 
| 151 155 | 
             
                    disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
         | 
| 152 156 | 
             
                    disk.stubs(:id).returns('local-lvm')
         | 
| @@ -202,6 +206,7 @@ module ForemanFogProxmox | |
| 202 206 | 
             
                    disk.stubs(:size).returns('2')
         | 
| 203 207 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 204 208 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 209 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 205 210 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 206 211 | 
             
                    disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
         | 
| 207 212 | 
             
                    disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '2')
         | 
| @@ -254,8 +259,7 @@ module ForemanFogProxmox | |
| 254 259 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 255 260 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 256 261 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 257 | 
            -
                    disk.stubs(: | 
| 258 | 
            -
                    disk.stubs(:cdrom?).returns(false)
         | 
| 262 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 259 263 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 260 264 | 
             
                    disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1', volid: 'local-lvm:vm-100-disk-0')
         | 
| 261 265 | 
             
                    disks.stubs(:get).returns(disk)
         | 
| @@ -307,6 +311,7 @@ module ForemanFogProxmox | |
| 307 311 | 
             
                    disk.stubs(:size).returns('1')
         | 
| 308 312 | 
             
                    disk.stubs(:hard_disk?).returns(true)
         | 
| 309 313 | 
             
                    disk.stubs(:cdrom?).returns(false)
         | 
| 314 | 
            +
                    disk.stubs(:rootfs?).returns(false)
         | 
| 310 315 | 
             
                    disk.stubs(:storage).returns('local-lvm')
         | 
| 311 316 | 
             
                    disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
         | 
| 312 317 | 
             
                    disk.stubs(:id).returns('scsi0')
         | 
| @@ -352,5 +357,6 @@ module ForemanFogProxmox | |
| 352 357 | 
             
                    @cr.save_vm(uuid, new_attributes)
         | 
| 353 358 | 
             
                  end
         | 
| 354 359 | 
             
                end
         | 
| 360 | 
            +
                # rubocop:enable Metrics/BlockLength
         | 
| 355 361 | 
             
              end
         | 
| 356 362 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: foreman_fog_proxmox
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.15.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tristan Robert
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2023-11-15 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: deface
         | 
| @@ -262,29 +262,29 @@ signing_key: | |
| 262 262 | 
             
            specification_version: 4
         | 
| 263 263 | 
             
            summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
         | 
| 264 264 | 
             
            test_files:
         | 
| 265 | 
            -
            - test/test_plugin_helper.rb
         | 
| 266 | 
            -
            - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
         | 
| 267 | 
            -
            - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
         | 
| 268 | 
            -
            - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
         | 
| 269 265 | 
             
            - test/factories/proxmox_factory.rb
         | 
| 266 | 
            +
            - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
         | 
| 267 | 
            +
            - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
         | 
| 268 | 
            +
            - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
         | 
| 269 | 
            +
            - test/test_plugin_helper.rb
         | 
| 270 | 
            +
            - test/functional/compute_resources_controller_test.rb
         | 
| 270 271 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
         | 
| 271 | 
            -
            - test/unit/foreman_fog_proxmox/ | 
| 272 | 
            -
            - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
         | 
| 273 | 
            -
            - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
         | 
| 274 | 
            -
            - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
         | 
| 275 | 
            -
            - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
         | 
| 276 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
         | 
| 277 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
         | 
| 272 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_test.rb
         | 
| 278 273 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
         | 
| 279 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
         | 
| 280 | 
            -
            - test/unit/foreman_fog_proxmox/semver_test.rb
         | 
| 281 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
         | 
| 282 274 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
         | 
| 275 | 
            +
            - test/unit/foreman_fog_proxmox/semver_test.rb
         | 
| 283 276 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
         | 
| 284 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
         | 
| 285 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
         | 
| 286 | 
            -
            - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
         | 
| 287 277 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
         | 
| 288 | 
            -
            - test/unit/foreman_fog_proxmox/ | 
| 278 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
         | 
| 289 279 | 
             
            - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
         | 
| 290 | 
            -
            - test/ | 
| 280 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
         | 
| 281 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
         | 
| 282 | 
            +
            - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
         | 
| 283 | 
            +
            - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
         | 
| 284 | 
            +
            - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
         | 
| 285 | 
            +
            - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
         | 
| 286 | 
            +
            - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
         | 
| 287 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
         | 
| 288 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
         | 
| 289 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
         | 
| 290 | 
            +
            - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
         |