Skip to content

Conversation

@changlei-li
Copy link
Contributor

@changlei-li changlei-li commented Nov 17, 2025

  • New filed: host.timezone
  • APIs: host.set_timezone, host.get_timezone, host.list_timezones
  • host.timezone dbsync

@changlei-li
Copy link
Contributor Author

changlei-li commented Nov 17, 2025

use examples:

python sdk APIs

    print(session.xenapi.host.get_timezone(host_ref))
    session.xenapi.host.set_timezone(host_ref, 'Europe/London')
    print(session.xenapi.host.get_timezone(host_ref))
    try:
        session.xenapi.host.set_timezone(host_ref, 'Europe/Londom')
    except Exception as e:
        print(e)
    print(session.xenapi.host.list_timezones(host_ref))

output:

UTC
---
Europe/London
---
['INVALID_VALUE', 'timezone', 'Europe/Londom']
---
['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', 'Africa/Asmara', 'Africa/Bamako', 'Africa/Bangui', 'Africa/Banjul', 'Africa/Bissau', 'Africa/Blantyre', 'Africa/Brazzaville', 'Africa/Bujumbura', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Ceuta', 'Africa/Conakry', 'Africa/Dakar', 'Africa/Dar_es_Salaam' ... 'Pacific/Wallis', 'UTC']

xe commands

# xe host-param-get uuid=14d51417-1953-45a3-af9f-c552bd7d9346 param-name=timezone
Europe/London
# xe host-param-set uuid=14d51417-1953-45a3-af9f-c552bd7d9346 timezone=UTC
# xe host-param-get uuid=14d51417-1953-45a3-af9f-c552bd7d9346 param-name=timezone
UTC
# xe host-param-set uuid=14d51417-1953-45a3-af9f-c552bd7d9346 timezone=+8
The value given is invalid
field: timezone
value: +8

@changlei-li changlei-li force-pushed the private/changleli/add-timezone branch from 1064533 to 5e3f968 Compare November 17, 2025 08:58
@changlei-li changlei-li force-pushed the private/changleli/add-timezone branch from 5e3f968 to 4ef9bcc Compare November 18, 2025 01:50
~ssh_enabled_timeout ~ssh_expiry ~console_idle_timeout ~ssh_auto_mode
~max_cstate:"" ~secure_boot ~ntp_mode:`ntp_mode_dhcp ~ntp_custom_servers:[]
~ntp_enabled:false ;
~ntp_enabled:false ~timezone:"UTC" ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not related with this PR)
Just to confirm: the timezone should be reserved when a host joins a pool.

Copy link
Contributor Author

@changlei-li changlei-li Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pool join case, the new-joined host will keep its own timezone. For example, coordinator is 'UTC', host A is 'Asia/Shanghai' before join. Then hostA joins the pool and reboot, the hostA dbsync will set its timezone field to 'Asia/Shanghai' according to the real setting on host.
The test result

# xe host-list params=uuid,timezone
uuid ( RO)        : f910aa46-0e52-4a86-8bdf-634ea894c32a
    timezone ( RW): UTC


uuid ( RO)        : ff2efb83-326a-4842-8b98-8e2efef32d3c
    timezone ( RW): Asia/Shanghai

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pool join, the host will first be added to the pool database using this function, with UTC as timezone. Then xapi will restart and dbsync will update it to the real timezone.

~params:
[
(Ref _host, "self", "The host")
; (String, "value", "The timezone to set, e.g., 'Europe/London'")
Copy link
Member

@minglumlu minglumlu Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to get it clear as:
The time zone identifier as defined in the IANA Time Zone Database.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

New filed: host.timezone
APIs: host.set_timezone, host.get_timezone, host.list_timezones

Signed-off-by: Changlei Li <changlei.li@cloud.com>
@changlei-li changlei-li force-pushed the private/changleli/add-timezone branch from 4ef9bcc to 5f0e5cd Compare November 18, 2025 03:16
Signed-off-by: Changlei Li <changlei.li@cloud.com>
@changlei-li changlei-li force-pushed the private/changleli/add-timezone branch from 5f0e5cd to f677ea7 Compare November 18, 2025 03:26
@changlei-li changlei-li requested a review from robhoes November 18, 2025 04:58
@changlei-li changlei-li merged commit 4a67e13 into xapi-project:feature/config-ntp-timezone-maxcstate Nov 18, 2025
16 checks passed
@changlei-li changlei-li deleted the private/changleli/add-timezone branch November 18, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants