driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 15s
driver / test (3.12) (pull_request) Failing after 14s
driver / types (pull_request) Failing after 23s
driver / test (3.13) (pull_request) Failing after 13s
driver / lowest (pull_request) Failing after 14s
driver / security (pull_request) Failing after 32s
driver / build (pull_request) Successful in 25s
CI / driver (pull_request) Failing after 1m21s
driver / publish (pull_request) Skipped
netOrk shows and controls every scheduled job of a host; on Windows that is the Task Scheduler. The driver now implements napalm-device-types' ScheduledJobsMixin over PowerShell Remoting, one script per call as every getter does. get_scheduled_jobs reads every task with its run info in one script (Get-ScheduledTask, Get-ScheduledTaskInfo) as task:<path><name>, its triggers summarised. Tasks under \Microsoft\ are the platform's, others the admin's: Windows does not record which software installed a task. The time zone is mapped to IANA for the common Windows zones, else None. A reading cut short, or holding fewer tasks than it counted, raises. manage_scheduled_job switches the task's own flag or starts it; Start-ScheduledTask returns once the task has started, so the result says that and no more. A disabled task, or one that refuses a start on demand, is not offered run. put_scheduled_job registers an application's task \<name> in the root folder from XML, so a create and a change write the whole definition the same way: the command runs in cmd.exe /d /s /c, the principal is SYSTEM or a local user without a stored password (S4U), and the cron expression becomes triggers only where Task Scheduler can say it exactly; any other shape is refused, naming why. The description keeps the job's name and cron expression, so the reading gives back what was written, and the digest also covers the triggers, so a change by hand is seen. delete_scheduled_job unregisters such a task and no other. Every write reads the task again first, and every value goes into PowerShell single-quoted with its quotes doubled. Requires napalm-device-types 4.26.0. Closes #8
116 lines
5.1 KiB
Python
116 lines
5.1 KiB
Python
"""Windows time zone ids as IANA names, for the scheduled-jobs reading (#8).
|
|
|
|
Windows names its zones by their standard-time name (``W. Europe Standard Time``);
|
|
the contract wants an IANA name. The table holds the common zones, each mapped to
|
|
the zone CLDR names for its territory ``001`` (``windowsZones.xml``); a zone not in
|
|
it is ``None`` -- the reading says it does not know rather than guess.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
WINDOWS_TO_IANA: dict[str, str] = {
|
|
# UTC and fixed offsets
|
|
"UTC": "Etc/UTC",
|
|
"Dateline Standard Time": "Etc/GMT+12",
|
|
"UTC-11": "Etc/GMT+11",
|
|
"UTC-09": "Etc/GMT+9",
|
|
"UTC-08": "Etc/GMT+8",
|
|
"UTC-02": "Etc/GMT+2",
|
|
"UTC+12": "Etc/GMT-12",
|
|
"UTC+13": "Etc/GMT-13",
|
|
# Europe
|
|
"GMT Standard Time": "Europe/London",
|
|
"Greenwich Standard Time": "Atlantic/Reykjavik",
|
|
"W. Europe Standard Time": "Europe/Berlin",
|
|
"Central Europe Standard Time": "Europe/Budapest",
|
|
"Romance Standard Time": "Europe/Paris",
|
|
"Central European Standard Time": "Europe/Warsaw",
|
|
"GTB Standard Time": "Europe/Bucharest",
|
|
"E. Europe Standard Time": "Europe/Chisinau",
|
|
"FLE Standard Time": "Europe/Kyiv",
|
|
"Turkey Standard Time": "Europe/Istanbul",
|
|
"Kaliningrad Standard Time": "Europe/Kaliningrad",
|
|
"Russian Standard Time": "Europe/Moscow",
|
|
"Belarus Standard Time": "Europe/Minsk",
|
|
"Azores Standard Time": "Atlantic/Azores",
|
|
"Cape Verde Standard Time": "Atlantic/Cape_Verde",
|
|
# Africa and the Middle East
|
|
"Morocco Standard Time": "Africa/Casablanca",
|
|
"W. Central Africa Standard Time": "Africa/Lagos",
|
|
"Egypt Standard Time": "Africa/Cairo",
|
|
"South Africa Standard Time": "Africa/Johannesburg",
|
|
"E. Africa Standard Time": "Africa/Nairobi",
|
|
"Namibia Standard Time": "Africa/Windhoek",
|
|
"Israel Standard Time": "Asia/Jerusalem",
|
|
"Jordan Standard Time": "Asia/Amman",
|
|
"Middle East Standard Time": "Asia/Beirut",
|
|
"Arabic Standard Time": "Asia/Baghdad",
|
|
"Arab Standard Time": "Asia/Riyadh",
|
|
"Iran Standard Time": "Asia/Tehran",
|
|
"Arabian Standard Time": "Asia/Dubai",
|
|
# Asia and the Pacific
|
|
"Georgian Standard Time": "Asia/Tbilisi",
|
|
"Azerbaijan Standard Time": "Asia/Baku",
|
|
"Caucasus Standard Time": "Asia/Yerevan",
|
|
"Afghanistan Standard Time": "Asia/Kabul",
|
|
"Pakistan Standard Time": "Asia/Karachi",
|
|
"West Asia Standard Time": "Asia/Tashkent",
|
|
"Ekaterinburg Standard Time": "Asia/Yekaterinburg",
|
|
"India Standard Time": "Asia/Kolkata",
|
|
"Sri Lanka Standard Time": "Asia/Colombo",
|
|
"Nepal Standard Time": "Asia/Kathmandu",
|
|
"Bangladesh Standard Time": "Asia/Dhaka",
|
|
"Myanmar Standard Time": "Asia/Yangon",
|
|
"SE Asia Standard Time": "Asia/Bangkok",
|
|
"N. Central Asia Standard Time": "Asia/Novosibirsk",
|
|
"North Asia Standard Time": "Asia/Krasnoyarsk",
|
|
"China Standard Time": "Asia/Shanghai",
|
|
"Singapore Standard Time": "Asia/Singapore",
|
|
"Taipei Standard Time": "Asia/Taipei",
|
|
"W. Australia Standard Time": "Australia/Perth",
|
|
"Tokyo Standard Time": "Asia/Tokyo",
|
|
"Korea Standard Time": "Asia/Seoul",
|
|
"Cen. Australia Standard Time": "Australia/Adelaide",
|
|
"AUS Central Standard Time": "Australia/Darwin",
|
|
"E. Australia Standard Time": "Australia/Brisbane",
|
|
"AUS Eastern Standard Time": "Australia/Sydney",
|
|
"Tasmania Standard Time": "Australia/Hobart",
|
|
"Vladivostok Standard Time": "Asia/Vladivostok",
|
|
"New Zealand Standard Time": "Pacific/Auckland",
|
|
"Fiji Standard Time": "Pacific/Fiji",
|
|
"Tonga Standard Time": "Pacific/Tongatapu",
|
|
"Samoa Standard Time": "Pacific/Apia",
|
|
# The Americas
|
|
"Hawaiian Standard Time": "Pacific/Honolulu",
|
|
"Aleutian Standard Time": "America/Adak",
|
|
"Alaskan Standard Time": "America/Anchorage",
|
|
"Pacific Standard Time": "America/Los_Angeles",
|
|
"Pacific Standard Time (Mexico)": "America/Tijuana",
|
|
"US Mountain Standard Time": "America/Phoenix",
|
|
"Mountain Standard Time": "America/Denver",
|
|
"Central America Standard Time": "America/Guatemala",
|
|
"Central Standard Time": "America/Chicago",
|
|
"Central Standard Time (Mexico)": "America/Mexico_City",
|
|
"Canada Central Standard Time": "America/Regina",
|
|
"SA Pacific Standard Time": "America/Bogota",
|
|
"Eastern Standard Time": "America/New_York",
|
|
"US Eastern Standard Time": "America/Indiana/Indianapolis",
|
|
"Cuba Standard Time": "America/Havana",
|
|
"Venezuela Standard Time": "America/Caracas",
|
|
"Atlantic Standard Time": "America/Halifax",
|
|
"SA Western Standard Time": "America/La_Paz",
|
|
"Pacific SA Standard Time": "America/Santiago",
|
|
"Paraguay Standard Time": "America/Asuncion",
|
|
"Newfoundland Standard Time": "America/St_Johns",
|
|
"E. South America Standard Time": "America/Sao_Paulo",
|
|
"Argentina Standard Time": "America/Argentina/Buenos_Aires",
|
|
"SA Eastern Standard Time": "America/Cayenne",
|
|
"Montevideo Standard Time": "America/Montevideo",
|
|
"Greenland Standard Time": "America/Nuuk",
|
|
}
|
|
|
|
|
|
def iana_time_zone(windows_id: str | None) -> str | None:
|
|
"""The IANA name of the Windows zone *windows_id*; None for one the table lacks."""
|
|
return WINDOWS_TO_IANA.get(windows_id or "")
|