2 use serde
::{Deserialize, Serialize}
;
4 use proxmox
::api
::{api, schema::*}
;
5 use proxmox
::const_regex
;
6 use proxmox
::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32}
;
8 use crate::backup
::CryptMode
;
9 use crate::server
::UPID
;
16 pub use userid
::{Realm, RealmRef}
;
17 pub use userid
::{Username, UsernameRef}
;
18 pub use userid
::Userid
;
19 pub use userid
::PROXMOX_GROUP_ID_SCHEMA
;
21 // File names: may not contain slashes, may not start with "."
22 pub const FILENAME_FORMAT
: ApiStringFormat
= ApiStringFormat
::VerifyFn(|name
| {
23 if name
.starts_with('
.'
) {
24 bail
!("file names may not start with '.'");
26 if name
.contains('
/'
) {
27 bail
!("file names may not contain slashes");
32 macro_rules
! DNS_LABEL { () => (r"(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)") }
33 macro_rules
! DNS_NAME { () => (concat!(r"(?:", DNS_LABEL!() , r"\.)*", DNS_LABEL!())) }
35 macro_rules
! CIDR_V4_REGEX_STR { () => (concat!(r"(?:", IPV4RE!(), r"/\d{1,2}
)$
")) }
36 macro_rules! CIDR_V6_REGEX_STR { () => (concat!(r"(?:", IPV6RE!(), r"/\d{1,3})$")) }
39 pub IP_V4_REGEX
= concat
!(r
"^", IPV4RE
!(), r
"$");
40 pub IP_V6_REGEX
= concat
!(r
"^", IPV6RE
!(), r
"$");
41 pub IP_REGEX
= concat
!(r
"^", IPRE
!(), r
"$");
42 pub CIDR_V4_REGEX
= concat
!(r
"^", CIDR_V4_REGEX_STR
!(), r
"$");
43 pub CIDR_V6_REGEX
= concat
!(r
"^", CIDR_V6_REGEX_STR
!(), r
"$");
44 pub CIDR_REGEX
= concat
!(r
"^(?:", CIDR_V4_REGEX_STR
!(), "|", CIDR_V6_REGEX_STR
!(), r
")$");
46 pub SHA256_HEX_REGEX
= r
"^[a-f0-9]{64}$"; // fixme: define in common_regex ?
47 pub SYSTEMD_DATETIME_REGEX
= r
"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ?
49 pub PASSWORD_REGEX
= r
"^[[:^cntrl:]]*$"; // everything but control characters
51 /// Regex for safe identifiers.
54 /// [article](https://dwheeler.com/essays/fixing-unix-linux-filenames.html)
55 /// contains further information why it is reasonable to restict
56 /// names this way. This is not only useful for filenames, but for
57 /// any identifier command line tools work with.
58 pub PROXMOX_SAFE_ID_REGEX
= concat
!(r
"^", PROXMOX_SAFE_ID_REGEX_STR
!(), r
"$");
60 pub SINGLE_LINE_COMMENT_REGEX
= r
"^[[:^cntrl:]]*$";
62 pub HOSTNAME_REGEX
= r
"^(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)$";
64 pub DNS_NAME_REGEX
= concat
!(r
"^", DNS_NAME
!(), r
"$");
66 pub DNS_NAME_OR_IP_REGEX
= concat
!(r
"^", DNS_NAME
!(), "|", IPRE
!(), r
"$");
68 pub BACKUP_REPO_URL_REGEX
= concat
!(r
"^^(?:(?:(", USER_ID_REGEX_STR
!(), ")@)?(", DNS_NAME
!(), "|", IPRE
!() ,"):)?(", PROXMOX_SAFE_ID_REGEX_STR
!(), r
")$");
70 pub CERT_FINGERPRINT_SHA256_REGEX
= r
"^(?:[0-9a-fA-F][0-9a-fA-F])(?::[0-9a-fA-F][0-9a-fA-F]){31}$";
72 pub ACL_PATH_REGEX
= concat
!(r
"^(?:/|", r
"(?:/", PROXMOX_SAFE_ID_REGEX_STR
!(), ")+", r
")$");
74 pub BLOCKDEVICE_NAME_REGEX
= r
"^(:?(:?h|s|x?v)d[a-z]+)|(:?nvme\d+n\d+)$";
76 pub ZPOOL_NAME_REGEX
= r
"^[a-zA-Z][a-z0-9A-Z\-_.:]+$";
79 pub const SYSTEMD_DATETIME_FORMAT
: ApiStringFormat
=
80 ApiStringFormat
::Pattern(&SYSTEMD_DATETIME_REGEX
);
82 pub const IP_V4_FORMAT
: ApiStringFormat
=
83 ApiStringFormat
::Pattern(&IP_V4_REGEX
);
85 pub const IP_V6_FORMAT
: ApiStringFormat
=
86 ApiStringFormat
::Pattern(&IP_V6_REGEX
);
88 pub const IP_FORMAT
: ApiStringFormat
=
89 ApiStringFormat
::Pattern(&IP_REGEX
);
91 pub const PVE_CONFIG_DIGEST_FORMAT
: ApiStringFormat
=
92 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
94 pub const CERT_FINGERPRINT_SHA256_FORMAT
: ApiStringFormat
=
95 ApiStringFormat
::Pattern(&CERT_FINGERPRINT_SHA256_REGEX
);
97 pub const PROXMOX_SAFE_ID_FORMAT
: ApiStringFormat
=
98 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
100 pub const SINGLE_LINE_COMMENT_FORMAT
: ApiStringFormat
=
101 ApiStringFormat
::Pattern(&SINGLE_LINE_COMMENT_REGEX
);
103 pub const HOSTNAME_FORMAT
: ApiStringFormat
=
104 ApiStringFormat
::Pattern(&HOSTNAME_REGEX
);
106 pub const DNS_NAME_FORMAT
: ApiStringFormat
=
107 ApiStringFormat
::Pattern(&DNS_NAME_REGEX
);
109 pub const DNS_NAME_OR_IP_FORMAT
: ApiStringFormat
=
110 ApiStringFormat
::Pattern(&DNS_NAME_OR_IP_REGEX
);
112 pub const PASSWORD_FORMAT
: ApiStringFormat
=
113 ApiStringFormat
::Pattern(&PASSWORD_REGEX
);
115 pub const ACL_PATH_FORMAT
: ApiStringFormat
=
116 ApiStringFormat
::Pattern(&ACL_PATH_REGEX
);
118 pub const NETWORK_INTERFACE_FORMAT
: ApiStringFormat
=
119 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
121 pub const CIDR_V4_FORMAT
: ApiStringFormat
=
122 ApiStringFormat
::Pattern(&CIDR_V4_REGEX
);
124 pub const CIDR_V6_FORMAT
: ApiStringFormat
=
125 ApiStringFormat
::Pattern(&CIDR_V6_REGEX
);
127 pub const CIDR_FORMAT
: ApiStringFormat
=
128 ApiStringFormat
::Pattern(&CIDR_REGEX
);
130 pub const BLOCKDEVICE_NAME_FORMAT
: ApiStringFormat
=
131 ApiStringFormat
::Pattern(&BLOCKDEVICE_NAME_REGEX
);
133 pub const PASSWORD_SCHEMA
: Schema
= StringSchema
::new("Password.")
134 .format(&PASSWORD_FORMAT
)
139 pub const PBS_PASSWORD_SCHEMA
: Schema
= StringSchema
::new("User Password.")
140 .format(&PASSWORD_FORMAT
)
145 pub const CERT_FINGERPRINT_SHA256_SCHEMA
: Schema
= StringSchema
::new(
146 "X509 certificate fingerprint (sha256)."
148 .format(&CERT_FINGERPRINT_SHA256_FORMAT
)
151 pub const PROXMOX_CONFIG_DIGEST_SCHEMA
: Schema
= StringSchema
::new(r
#"\
152 Prevent changes if current configuration file has different SHA256 digest.
153 This can be used to prevent concurrent modifications.
156 .format(&PVE_CONFIG_DIGEST_FORMAT
)
160 pub const CHUNK_DIGEST_FORMAT
: ApiStringFormat
=
161 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
163 pub const CHUNK_DIGEST_SCHEMA
: Schema
= StringSchema
::new("Chunk digest (SHA256).")
164 .format(&CHUNK_DIGEST_FORMAT
)
167 pub const NODE_SCHEMA
: Schema
= StringSchema
::new("Node name (or 'localhost')")
168 .format(&ApiStringFormat
::VerifyFn(|node
| {
169 if node
== "localhost" || node
== proxmox
::tools
::nodename() {
172 bail
!("no such node '{}'", node
);
177 pub const SEARCH_DOMAIN_SCHEMA
: Schema
=
178 StringSchema
::new("Search domain for host-name lookup.").schema();
180 pub const FIRST_DNS_SERVER_SCHEMA
: Schema
=
181 StringSchema
::new("First name server IP address.")
185 pub const SECOND_DNS_SERVER_SCHEMA
: Schema
=
186 StringSchema
::new("Second name server IP address.")
190 pub const THIRD_DNS_SERVER_SCHEMA
: Schema
=
191 StringSchema
::new("Third name server IP address.")
195 pub const IP_V4_SCHEMA
: Schema
=
196 StringSchema
::new("IPv4 address.")
197 .format(&IP_V4_FORMAT
)
201 pub const IP_V6_SCHEMA
: Schema
=
202 StringSchema
::new("IPv6 address.")
203 .format(&IP_V6_FORMAT
)
207 pub const IP_SCHEMA
: Schema
=
208 StringSchema
::new("IP (IPv4 or IPv6) address.")
213 pub const CIDR_V4_SCHEMA
: Schema
=
214 StringSchema
::new("IPv4 address with netmask (CIDR notation).")
215 .format(&CIDR_V4_FORMAT
)
219 pub const CIDR_V6_SCHEMA
: Schema
=
220 StringSchema
::new("IPv6 address with netmask (CIDR notation).")
221 .format(&CIDR_V6_FORMAT
)
225 pub const CIDR_SCHEMA
: Schema
=
226 StringSchema
::new("IP address (IPv4 or IPv6) with netmask (CIDR notation).")
227 .format(&CIDR_FORMAT
)
231 pub const TIME_ZONE_SCHEMA
: Schema
= StringSchema
::new(
232 "Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names.")
233 .format(&SINGLE_LINE_COMMENT_FORMAT
)
238 pub const ACL_PATH_SCHEMA
: Schema
= StringSchema
::new(
239 "Access control path.")
240 .format(&ACL_PATH_FORMAT
)
245 pub const ACL_PROPAGATE_SCHEMA
: Schema
= BooleanSchema
::new(
246 "Allow to propagate (inherit) permissions.")
250 pub const ACL_UGID_TYPE_SCHEMA
: Schema
= StringSchema
::new(
251 "Type of 'ugid' property.")
252 .format(&ApiStringFormat
::Enum(&[
253 EnumEntry
::new("user", "User"),
254 EnumEntry
::new("group", "Group")]))
257 pub const BACKUP_ARCHIVE_NAME_SCHEMA
: Schema
=
258 StringSchema
::new("Backup archive name.")
259 .format(&PROXMOX_SAFE_ID_FORMAT
)
262 pub const BACKUP_TYPE_SCHEMA
: Schema
=
263 StringSchema
::new("Backup type.")
264 .format(&ApiStringFormat
::Enum(&[
265 EnumEntry
::new("vm", "Virtual Machine Backup"),
266 EnumEntry
::new("ct", "Container Backup"),
267 EnumEntry
::new("host", "Host Backup")]))
270 pub const BACKUP_ID_SCHEMA
: Schema
=
271 StringSchema
::new("Backup ID.")
272 .format(&PROXMOX_SAFE_ID_FORMAT
)
275 pub const BACKUP_TIME_SCHEMA
: Schema
=
276 IntegerSchema
::new("Backup time (Unix epoch.)")
277 .minimum(1_547_797_308)
280 pub const UPID_SCHEMA
: Schema
= StringSchema
::new("Unique Process/Task ID.")
284 pub const DATASTORE_SCHEMA
: Schema
= StringSchema
::new("Datastore name.")
285 .format(&PROXMOX_SAFE_ID_FORMAT
)
290 pub const SYNC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
291 "Run sync job at specified schedule.")
292 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
295 pub const GC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
296 "Run garbage collection job at specified schedule.")
297 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
300 pub const PRUNE_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
301 "Run prune job at specified schedule.")
302 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
305 pub const REMOTE_ID_SCHEMA
: Schema
= StringSchema
::new("Remote ID.")
306 .format(&PROXMOX_SAFE_ID_FORMAT
)
311 pub const JOB_ID_SCHEMA
: Schema
= StringSchema
::new("Job ID.")
312 .format(&PROXMOX_SAFE_ID_FORMAT
)
317 pub const REMOVE_VANISHED_BACKUPS_SCHEMA
: Schema
= BooleanSchema
::new(
318 "Delete vanished backups. This remove the local copy if the remote backup was deleted.")
322 pub const SINGLE_LINE_COMMENT_SCHEMA
: Schema
= StringSchema
::new("Comment (single line).")
323 .format(&SINGLE_LINE_COMMENT_FORMAT
)
326 pub const HOSTNAME_SCHEMA
: Schema
= StringSchema
::new("Hostname (as defined in RFC1123).")
327 .format(&HOSTNAME_FORMAT
)
330 pub const DNS_NAME_OR_IP_SCHEMA
: Schema
= StringSchema
::new("DNS name or IP address.")
331 .format(&DNS_NAME_OR_IP_FORMAT
)
334 pub const BLOCKDEVICE_NAME_SCHEMA
: Schema
= StringSchema
::new("Block device name (/sys/block/<name>).")
335 .format(&BLOCKDEVICE_NAME_FORMAT
)
340 // Complex type definitions
345 schema
: BACKUP_TYPE_SCHEMA
,
348 schema
: BACKUP_ID_SCHEMA
,
351 schema
: BACKUP_TIME_SCHEMA
,
358 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
367 #[derive(Serialize, Deserialize)]
368 #[serde(rename_all="kebab-case")]
369 /// Basic information about a backup group.
370 pub struct GroupListItem
{
371 pub backup_type
: String
, // enum
372 pub backup_id
: String
,
373 pub last_backup
: i64,
374 /// Number of contained snapshots
375 pub backup_count
: u64,
376 /// List of contained archive files.
377 pub files
: Vec
<String
>,
378 /// The owner of group
379 #[serde(skip_serializing_if="Option::is_none")]
380 pub owner
: Option
<Userid
>,
384 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
385 #[serde(rename_all = "lowercase")]
386 /// Result of a verify operation.
387 pub enum VerifyState
{
388 /// Verification was successful
390 /// Verification reported one or more errors
404 #[derive(Serialize, Deserialize)]
406 pub struct SnapshotVerifyState
{
407 /// UPID of the verify task
409 /// State of the verification. Enum.
410 pub state
: VerifyState
,
416 schema
: BACKUP_TYPE_SCHEMA
,
419 schema
: BACKUP_ID_SCHEMA
,
422 schema
: BACKUP_TIME_SCHEMA
,
425 schema
: SINGLE_LINE_COMMENT_SCHEMA
,
429 type: SnapshotVerifyState
,
434 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
443 #[derive(Serialize, Deserialize)]
444 #[serde(rename_all="kebab-case")]
445 /// Basic information about backup snapshot.
446 pub struct SnapshotListItem
{
447 pub backup_type
: String
, // enum
448 pub backup_id
: String
,
449 pub backup_time
: i64,
450 /// The first line from manifest "notes"
451 #[serde(skip_serializing_if="Option::is_none")]
452 pub comment
: Option
<String
>,
453 /// The result of the last run verify task
454 #[serde(skip_serializing_if="Option::is_none")]
455 pub verification
: Option
<SnapshotVerifyState
>,
456 /// List of contained archive files.
457 pub files
: Vec
<BackupContent
>,
458 /// Overall snapshot size (sum of all archive sizes).
459 #[serde(skip_serializing_if="Option::is_none")]
460 pub size
: Option
<u64>,
461 /// The owner of the snapshots group
462 #[serde(skip_serializing_if="Option::is_none")]
463 pub owner
: Option
<Userid
>,
469 schema
: BACKUP_TYPE_SCHEMA
,
472 schema
: BACKUP_ID_SCHEMA
,
475 schema
: BACKUP_TIME_SCHEMA
,
479 #[derive(Serialize, Deserialize)]
480 #[serde(rename_all="kebab-case")]
482 pub struct PruneListItem
{
483 pub backup_type
: String
, // enum
484 pub backup_id
: String
,
485 pub backup_time
: i64,
490 pub const PRUNE_SCHEMA_KEEP_DAILY
: Schema
= IntegerSchema
::new(
491 "Number of daily backups to keep.")
495 pub const PRUNE_SCHEMA_KEEP_HOURLY
: Schema
= IntegerSchema
::new(
496 "Number of hourly backups to keep.")
500 pub const PRUNE_SCHEMA_KEEP_LAST
: Schema
= IntegerSchema
::new(
501 "Number of backups to keep.")
505 pub const PRUNE_SCHEMA_KEEP_MONTHLY
: Schema
= IntegerSchema
::new(
506 "Number of monthly backups to keep.")
510 pub const PRUNE_SCHEMA_KEEP_WEEKLY
: Schema
= IntegerSchema
::new(
511 "Number of weekly backups to keep.")
515 pub const PRUNE_SCHEMA_KEEP_YEARLY
: Schema
= IntegerSchema
::new(
516 "Number of yearly backups to keep.")
523 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
,
531 #[derive(Serialize, Deserialize)]
532 #[serde(rename_all="kebab-case")]
533 /// Basic information about archive files inside a backup snapshot.
534 pub struct BackupContent
{
535 pub filename
: String
,
536 /// Info if file is encrypted, signed, or neither.
537 #[serde(skip_serializing_if="Option::is_none")]
538 pub crypt_mode
: Option
<CryptMode
>,
539 /// Archive size (from backup manifest).
540 #[serde(skip_serializing_if="Option::is_none")]
541 pub size
: Option
<u64>,
552 #[derive(Clone, Serialize, Deserialize)]
553 #[serde(rename_all="kebab-case")]
554 /// Garbage collection status.
555 pub struct GarbageCollectionStatus
{
556 pub upid
: Option
<String
>,
557 /// Number of processed index files.
558 pub index_file_count
: usize,
559 /// Sum of bytes referred by index files.
560 pub index_data_bytes
: u64,
561 /// Bytes used on disk.
563 /// Chunks used on disk.
564 pub disk_chunks
: usize,
565 /// Sum of removed bytes.
566 pub removed_bytes
: u64,
567 /// Number of removed chunks.
568 pub removed_chunks
: usize,
569 /// Sum of pending bytes (pending removal - kept for safety).
570 pub pending_bytes
: u64,
571 /// Number of pending chunks (pending removal - kept for safety).
572 pub pending_chunks
: usize,
573 /// Number of chunks marked as .bad by verify that have been removed by GC.
574 pub removed_bad
: usize,
577 impl Default
for GarbageCollectionStatus
{
578 fn default() -> Self {
579 GarbageCollectionStatus
{
596 #[derive(Serialize, Deserialize)]
597 /// Storage space usage information.
598 pub struct StorageStatus
{
599 /// Total space (bytes).
601 /// Used space (bytes).
603 /// Available space (bytes).
609 upid
: { schema: UPID_SCHEMA }
,
610 user
: { type: Userid }
,
613 #[derive(Serialize, Deserialize)]
615 pub struct TaskListItem
{
617 /// The node name where the task is running on.
621 /// The task start time (Epoch)
623 /// The task start time (Epoch)
625 /// Worker type (arbitrary ASCII string)
626 pub worker_type
: String
,
627 /// Worker ID (arbitrary ASCII string)
628 pub worker_id
: Option
<String
>,
629 /// The user who started the task
631 /// The task end time (Epoch)
632 #[serde(skip_serializing_if="Option::is_none")]
633 pub endtime
: Option
<i64>,
635 #[serde(skip_serializing_if="Option::is_none")]
636 pub status
: Option
<String
>,
639 impl From
<crate::server
::TaskListInfo
> for TaskListItem
{
640 fn from(info
: crate::server
::TaskListInfo
) -> Self {
641 let (endtime
, status
) = info
643 .map_or_else(|| (None
, None
), |a
| (Some(a
.endtime()), Some(a
.to_string())));
647 node
: "localhost".to_string(),
648 pid
: info
.upid
.pid
as i64,
649 pstart
: info
.upid
.pstart
,
650 starttime
: info
.upid
.starttime
,
651 worker_type
: info
.upid
.worker_type
,
652 worker_id
: info
.upid
.worker_id
,
653 user
: info
.upid
.userid
,
661 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
662 #[serde(rename_all = "lowercase")]
663 /// Node Power command type.
664 pub enum NodePowerCommand
{
665 /// Restart the server
667 /// Shutdown the server
672 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
673 #[serde(rename_all = "lowercase")]
674 /// Interface configuration method
675 pub enum NetworkConfigMethod
{
676 /// Configuration is done manually using other tools
678 /// Define interfaces with statically allocated addresses.
680 /// Obtain an address via DHCP
682 /// Define the loopback interface.
687 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
688 #[serde(rename_all = "kebab-case")]
689 #[allow(non_camel_case_types)]
692 pub enum LinuxBondMode
{
693 /// Round-robin policy
695 /// Active-backup policy
701 /// IEEE 802.3ad Dynamic link aggregation
702 #[serde(rename = "802.3ad")]
704 /// Adaptive transmit load balancing
706 /// Adaptive load balancing
711 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
712 #[serde(rename_all = "kebab-case")]
713 #[allow(non_camel_case_types)]
715 /// Bond Transmit Hash Policy for LACP (802.3ad)
716 pub enum BondXmitHashPolicy
{
720 #[serde(rename = "layer2+3")]
723 #[serde(rename = "layer3+4")]
728 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
729 #[serde(rename_all = "lowercase")]
730 /// Network interface type
731 pub enum NetworkInterfaceType
{
734 /// Physical Ethernet device
740 /// Linux VLAN (eth.10)
742 /// Interface Alias (eth:1)
744 /// Unknown interface type
748 pub const NETWORK_INTERFACE_NAME_SCHEMA
: Schema
= StringSchema
::new("Network interface name.")
749 .format(&NETWORK_INTERFACE_FORMAT
)
751 .max_length(libc
::IFNAMSIZ
-1)
754 pub const NETWORK_INTERFACE_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
755 "Network interface list.", &NETWORK_INTERFACE_NAME_SCHEMA
)
758 pub const NETWORK_INTERFACE_LIST_SCHEMA
: Schema
= StringSchema
::new(
759 "A list of network devices, comma separated.")
760 .format(&ApiStringFormat
::PropertyString(&NETWORK_INTERFACE_ARRAY_SCHEMA
))
766 schema
: NETWORK_INTERFACE_NAME_SCHEMA
,
769 type: NetworkInterfaceType
,
772 type: NetworkConfigMethod
,
776 type: NetworkConfigMethod
,
780 schema
: CIDR_V4_SCHEMA
,
784 schema
: CIDR_V6_SCHEMA
,
788 schema
: IP_V4_SCHEMA
,
792 schema
: IP_V6_SCHEMA
,
796 description
: "Option list (inet)",
799 description
: "Optional attribute line.",
804 description
: "Option list (inet6)",
807 description
: "Optional attribute line.",
812 description
: "Comments (inet, may span multiple lines)",
817 description
: "Comments (inet6, may span multiple lines)",
822 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
826 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
834 schema
: NETWORK_INTERFACE_NAME_SCHEMA
,
837 bond_xmit_hash_policy
: {
838 type: BondXmitHashPolicy
,
843 #[derive(Debug, Serialize, Deserialize)]
844 /// Network Interface configuration
845 pub struct Interface
{
846 /// Autostart interface
847 #[serde(rename = "autostart")]
849 /// Interface is active (UP)
854 #[serde(rename = "type")]
855 pub interface_type
: NetworkInterfaceType
,
856 #[serde(skip_serializing_if="Option::is_none")]
857 pub method
: Option
<NetworkConfigMethod
>,
858 #[serde(skip_serializing_if="Option::is_none")]
859 pub method6
: Option
<NetworkConfigMethod
>,
860 #[serde(skip_serializing_if="Option::is_none")]
861 /// IPv4 address with netmask
862 pub cidr
: Option
<String
>,
863 #[serde(skip_serializing_if="Option::is_none")]
865 pub gateway
: Option
<String
>,
866 #[serde(skip_serializing_if="Option::is_none")]
867 /// IPv6 address with netmask
868 pub cidr6
: Option
<String
>,
869 #[serde(skip_serializing_if="Option::is_none")]
871 pub gateway6
: Option
<String
>,
873 #[serde(skip_serializing_if="Vec::is_empty")]
874 pub options
: Vec
<String
>,
875 #[serde(skip_serializing_if="Vec::is_empty")]
876 pub options6
: Vec
<String
>,
878 #[serde(skip_serializing_if="Option::is_none")]
879 pub comments
: Option
<String
>,
880 #[serde(skip_serializing_if="Option::is_none")]
881 pub comments6
: Option
<String
>,
883 #[serde(skip_serializing_if="Option::is_none")]
884 /// Maximum Transmission Unit
885 pub mtu
: Option
<u64>,
887 #[serde(skip_serializing_if="Option::is_none")]
888 pub bridge_ports
: Option
<Vec
<String
>>,
889 /// Enable bridge vlan support.
890 #[serde(skip_serializing_if="Option::is_none")]
891 pub bridge_vlan_aware
: Option
<bool
>,
893 #[serde(skip_serializing_if="Option::is_none")]
894 pub slaves
: Option
<Vec
<String
>>,
895 #[serde(skip_serializing_if="Option::is_none")]
896 pub bond_mode
: Option
<LinuxBondMode
>,
897 #[serde(skip_serializing_if="Option::is_none")]
898 #[serde(rename = "bond-primary")]
899 pub bond_primary
: Option
<String
>,
900 pub bond_xmit_hash_policy
: Option
<BondXmitHashPolicy
>,
906 fn test_cert_fingerprint_schema() -> Result
<(), anyhow
::Error
> {
908 let schema
= CERT_FINGERPRINT_SHA256_SCHEMA
;
910 let invalid_fingerprints
= [
911 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
912 "88:7C:BE:26:77:a5:62:67:D9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
913 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8:ff",
914 "XX:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
915 "86:88:Y4:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
916 "86:88:0:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
919 for fingerprint
in invalid_fingerprints
.iter() {
920 if let Ok(_
) = parse_simple_value(fingerprint
, &schema
) {
921 bail
!("test fingerprint '{}' failed - got Ok() while exception an error.", fingerprint
);
925 let valid_fingerprints
= [
926 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
927 "86:88:7C:BE:26:77:a5:62:67:D9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
930 for fingerprint
in valid_fingerprints
.iter() {
931 let v
= match parse_simple_value(fingerprint
, &schema
) {
934 bail
!("unable to parse fingerprint '{}' - {}", fingerprint
, err
);
938 if v
!= serde_json
::json
!(fingerprint
) {
939 bail
!("unable to parse fingerprint '{}' - got wrong value {:?}", fingerprint
, v
);
947 fn test_proxmox_user_id_schema() -> Result
<(), anyhow
::Error
> {
948 let invalid_user_ids
= [
953 "xx x@test", // contains space
954 "xx\nx@test", // contains control character
955 "x:xx@test", // contains collon
956 "xx/x@test", // contains slash
957 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@test", // too long
960 for name
in invalid_user_ids
.iter() {
961 if let Ok(_
) = parse_simple_value(name
, &Userid
::API_SCHEMA
) {
962 bail
!("test userid '{}' failed - got Ok() while exception an error.", name
);
966 let valid_user_ids
= [
970 "xxx@_T_E_S_T-it.com",
971 "x_x-x.x@test-it.com",
974 for name
in valid_user_ids
.iter() {
975 let v
= match parse_simple_value(name
, &Userid
::API_SCHEMA
) {
978 bail
!("unable to parse userid '{}' - {}", name
, err
);
982 if v
!= serde_json
::json
!(name
) {
983 bail
!("unable to parse userid '{}' - got wrong value {:?}", name
, v
);
991 #[derive(Copy, Clone, Serialize, Deserialize)]
992 #[serde(rename_all = "UPPERCASE")]
1003 #[derive(Copy, Clone, Serialize, Deserialize)]
1004 #[serde(rename_all = "lowercase")]
1005 pub enum RRDTimeFrameResolution
{
1006 /// 1 min => last 70 minutes
1008 /// 30 min => last 35 hours
1010 /// 3 hours => about 8 days
1012 /// 12 hours => last 35 days
1014 /// 1 week => last 490 days
1019 #[derive(Serialize, Deserialize)]
1020 #[serde(rename_all = "PascalCase")]
1021 /// Describes a package for which an update is available.
1022 pub struct APTUpdateInfo
{
1024 pub package
: String
,
1027 /// Package architecture
1029 /// Human readable package description
1030 pub description
: String
,
1031 /// New version to be updated to
1032 pub version
: String
,
1033 /// Old version currently installed
1034 pub old_version
: String
,
1037 /// Package priority in human-readable form
1038 pub priority
: String
,
1040 pub section
: String
,
1041 /// URL under which the package's changelog can be retrieved
1042 pub change_log_url
: String
,