create or replace function insert_many_hosts(how_many integer) returns void
as $$
declare
  host_id uuid;
  host_name varchar;
  host_ip varchar;
  cluster_id uuid;
begin
  for i in 0..how_many loop
    select uuid_generate_v1() into host_id;
    select 'host' || i into host_name;
    select '192.168.122.' || i into host_ip;
    select vds_group_id into cluster_id from vds_groups where name = 'Default';

    perform InsertVds(
      host_id,    -- v_vds_id
      host_name,  -- v_host_name
      null,       -- v_free_text_comment
      host_ip,    -- v_ip
      null,       -- v_vds_unique_id
      54321,      -- v_port
      cluster_id, -- v_vds_group_id
      host_name,  -- v_vds_name
      't',        -- v_server_SSL_enabled
      0,          -- v_vds_type
      100,        -- v_vds_strength
      null,       -- v_pm_type
      null,       -- v_pm_user
      null,       -- v_pm_password
      null,       -- v_pm_port
      '',         -- v_pm_options
      'f',        -- v_pm_enabled
      null,       -- v_pm_proxy_preferences
      null,       -- v_pm_secondary_ip
      null,       -- v_pm_secondary_type
      null,       -- v_pm_secondary_user
      null,       -- v_pm_secondary_password
      null,       -- v_pm_secondary_port
      null,       -- v_pm_secondary_options
      null,       -- v_pm_secondary_concurrent
      1,          -- v_vds_spm_priority
      null,       -- v_console_address
      22,         -- v_ssh_port
      'root'      -- v_ssh_username
    );
  end loop;

end; $$
language plpgsql;
