当前位置: 首页 > 工具软件 > oVirt > 使用案例 >

ovirt-engine4.3源码

苗学民
2023-12-01

VdsDynamic

含义:虚拟独立服务器系统(动态信息对象),一个系统就是一个虚拟服务器节点,三个形成集群

查这个类是因为进入管理页面控制台报错:

GET http://192.168.100.225:8888/ovirt-engine/services/files/spice/SpiceVersion.txt 404 (Not Found)

说没找到 SpiceVersion.txt文件,查找官方源码发现源码也是没有这个文件的,猜测应该是编译生成的而我们部署编译的时候遗漏了什么步骤导致没有生成这个文件?

查找数据库发现 spice 版本为 0.14.0 - 9.el7

对应表字段:

CREATE TABLE "public"."vds_dynamic" (
  "vds_id" uuid NOT NULL,  
  "status" int4 NOT NULL,
  "cpu_cores" int4,
  "cpu_model" varchar(255) COLLATE "pg_catalog"."default",
  "cpu_speed_mh" numeric(18),
  "if_total_speed" varchar(40) COLLATE "pg_catalog"."default",
  "kvm_enabled" bool,
  "physical_mem_mb" int4,
  "mem_commited" int4 DEFAULT 0,
  "vm_active" int4 DEFAULT 0,
  "vm_count" int4 NOT NULL DEFAULT 0,
  "vm_migrating" int4 DEFAULT 0,
  "reserved_mem" int4,
  "guest_overhead" int4,
  "software_version" varchar(40) COLLATE "pg_catalog"."default",
  "version_name" varchar(40) COLLATE "pg_catalog"."default",
  "build_name" varchar(40) COLLATE "pg_catalog"."default",
  "previous_status" int4,
  "cpu_flags" varchar(4000) COLLATE "pg_catalog"."default",
  "vms_cores_count" int4,
  "pending_vcpus_count" int4,
  "cpu_sockets" int4,
  "net_config_dirty" bool,
  "supported_cluster_levels" varchar(40) COLLATE "pg_catalog"."default",
  "host_os" varchar(4000) COLLATE "pg_catalog"."default",
  "kvm_version" varchar(4000) COLLATE "pg_catalog"."default",
  "spice_version" varchar(4000) COLLATE "pg_catalog"."default",
  "kernel_version" varchar(4000) COLLATE "pg_catalog"."default",
  "iscsi_initiator_name" varchar(4000) COLLATE "pg_catalog"."default",
  "transparent_hugepages_state" int4 NOT NULL DEFAULT 0,
  "hooks" text COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "_update_date" timestamptz(6),
  "non_operational_reason" int4 NOT NULL DEFAULT 0,
  "pending_vmem_size" int4 NOT NULL DEFAULT 0,
  "rpm_version" varchar(256) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "supported_engines" varchar(40) COLLATE "pg_catalog"."default",
  "libvirt_version" varchar(256) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
  "cpu_threads" int4,
  "hw_manufacturer" varchar(255) COLLATE "pg_catalog"."default",
  "hw_product_name" varchar(255) COLLATE "pg_catalog"."default",
  "hw_version" varchar(255) COLLATE "pg_catalog"."default",
  "hw_serial_number" varchar(255) COLLATE "pg_catalog"."default",
  "hw_uuid" varchar(255) COLLATE "pg_catalog"."default",
  "hw_family" varchar(255) COLLATE "pg_catalog"."default",
  "hbas" text COLLATE "pg_catalog"."default",
  "supported_emulated_machines" text COLLATE "pg_catalog"."default",
  "gluster_version" varchar(4000) COLLATE "pg_catalog"."default",
  "controlled_by_pm_policy" bool DEFAULT false,
  "kdump_status" int2 NOT NULL DEFAULT '-1'::integer,
  "selinux_enforce_mode" int4,
  "auto_numa_balancing" int2,
  "is_numa_supported" bool,
  "supported_rng_sources" varchar(255) COLLATE "pg_catalog"."default",
  "online_cpus" text COLLATE "pg_catalog"."default",
  "maintenance_reason" text COLLATE "pg_catalog"."default",
  "incoming_migrations" int4 NOT NULL DEFAULT 0,
  "outgoing_migrations" int4 NOT NULL DEFAULT 0,
  "is_update_available" bool NOT NULL DEFAULT false,
  "external_status" int4 NOT NULL DEFAULT 0,
  "is_hostdev_enabled" bool NOT NULL DEFAULT false,
  "librbd1_version" varchar(4000) COLLATE "pg_catalog"."default",
  "glusterfs_cli_version" varchar(4000) COLLATE "pg_catalog"."default",
  "kernel_args" text COLLATE "pg_catalog"."default",
  "pretty_name" varchar(255) COLLATE "pg_catalog"."default",
  "hosted_engine_configured" bool NOT NULL DEFAULT false,
  "in_fence_flow" bool NOT NULL DEFAULT false,
  "kernel_features" jsonb,
  "openvswitch_version" varchar(4000) COLLATE "pg_catalog"."default",
  "vnc_encryption_enabled" bool DEFAULT false,
  "connector_info" jsonb,
  "supported_domain_versions" varchar(256) COLLATE "pg_catalog"."default",
  "supported_block_size" jsonb,
  CONSTRAINT "pk_vds_dynamic" PRIMARY KEY ("vds_id"),
  CONSTRAINT "vds_static_vds_dynamic" FOREIGN KEY ("vds_id") REFERENCES "public"."vds_static" ("vds_id") ON DELETE NO ACTION ON UPDATE NO ACTION
)

ovirt-engine-4.3\packaging\playbooks\roles\ovirt-host-deploy-spice-encryption\tasks\main.yml中发现会在服务器生成 /etc/pki/tls/spice.cnf 配置文件,应该是设置服务器spice协议连接的相关参数

---
- name: Create SPICE config file with the right permissions
  file:
    dest: '/etc/pki/tls/spice.cnf'
    state: touch
    mode: 0644
    owner: root
    group: root

- name: Put cipher string to SPICE config file
  copy:
    dest: '/etc/pki/tls/spice.cnf'
    backup: yes
    mode: 0644
    content: |
      CipherString = {{ host_deploy_spice_cipher_string }}
      Protocol = {{ host_deploy_spice_protocol }}

src/main/java/org/ovirt/engine/ui/uicommonweb/Configurator.java中发现engine会检索外部spice相关资源然后根据操作系统做相应的更新动作,检索资源名为SpiceVersion.txt、SpiceVersion_x64.txt,检索路径为 服务基础路径/services/files/spice/

    protected void updateSpiceVersion() {
        // Update spice version from the text files which are located on the server.
        // If can't update spice version - leave the default value from the Configurator.
        if (clientPlatformType().equalsIgnoreCase("win32")) { //$NON-NLS-1$
            updateSpice32Version();
        } else if (clientPlatformType().equalsIgnoreCase("win64")) { //$NON-NLS-1$
            updateSpice64Version();
        }
    }

    public void updateSpice32Version() {
        fetchFile(getSpiceBaseURL() + "SpiceVersion.txt", getSpiceVersionFileFetchedEvent()); //$NON-NLS-1$
    }

    public void updateSpice64Version() {
        fetchFile(getSpiceBaseURL() + "SpiceVersion_x64.txt", getSpiceVersionFileFetchedEvent()); //$NON-NLS-1$
    }
    /**
     * Returns the base URL for retrieving Spice-related resources.
     */
    public static String getSpiceBaseURL() {
        return FrontendUrlUtils.getRootURL() + BaseContextPathData.getRelativePath()
                + "services/files/spice/"; //$NON-NLS-1$
    }

查看运行日志:

2022-08-31 10:30:30,382+08 INFO  [org.ovirt.engine.core.utils.servlet.ServletUtils] (default task-24) [] Can't read file '/home/ovirt/ovirt-engine/share/ovirt-engine/files/spice/SpiceVersion.txt' for request '/ovirt-engine/services/files/spice/SpiceVersion.txt' -- 404

其检索的目录是 /home/ovirt/ovirt-engine/share/ovirt-engine/files/spice/SpiceVersion.txt
尝试创建一个空文件SpiceVersion.txt,里面没有写任何内容。
重新访问,没报错了。

总结:
这个 SpiceVersion.txt 作用主要是用于更新 Spice 版本,就是说没有也是可以正常运行的,用的是默认的 spice 版本。但是因为每次刷新主页都会去检索这个文件,而我们的编译步骤有一段代码是报错的,应该没有生成这个 SpiceVersion.txt 文件就是在其中。后续需要留意这个问题。

 类似资料: