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
;
15 pub use userid
::{Realm, RealmRef}
;
16 pub use userid
::{Username, UsernameRef}
;
17 pub use userid
::Userid
;
18 pub use userid
::PROXMOX_GROUP_ID_SCHEMA
;
20 // File names: may not contain slashes, may not start with "."
21 pub const FILENAME_FORMAT
: ApiStringFormat
= ApiStringFormat
::VerifyFn(|name
| {
22 if name
.starts_with('
.'
) {
23 bail
!("file names may not start with '.'");
25 if name
.contains('
/'
) {
26 bail
!("file names may not contain slashes");
31 macro_rules
! DNS_LABEL { () => (r"(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)") }
32 macro_rules
! DNS_NAME { () => (concat!(r"(?:", DNS_LABEL!() , r"\.)*", DNS_LABEL!())) }
34 macro_rules
! CIDR_V4_REGEX_STR { () => (concat!(r"(?:", IPV4RE!(), r"/\d{1,2}
)$
")) }
35 macro_rules! CIDR_V6_REGEX_STR { () => (concat!(r"(?:", IPV6RE!(), r"/\d{1,3})$")) }
38 pub IP_V4_REGEX
= concat
!(r
"^", IPV4RE
!(), r
"$");
39 pub IP_V6_REGEX
= concat
!(r
"^", IPV6RE
!(), r
"$");
40 pub IP_REGEX
= concat
!(r
"^", IPRE
!(), r
"$");
41 pub CIDR_V4_REGEX
= concat
!(r
"^", CIDR_V4_REGEX_STR
!(), r
"$");
42 pub CIDR_V6_REGEX
= concat
!(r
"^", CIDR_V6_REGEX_STR
!(), r
"$");
43 pub CIDR_REGEX
= concat
!(r
"^(?:", CIDR_V4_REGEX_STR
!(), "|", CIDR_V6_REGEX_STR
!(), r
")$");
45 pub SHA256_HEX_REGEX
= r
"^[a-f0-9]{64}$"; // fixme: define in common_regex ?
46 pub SYSTEMD_DATETIME_REGEX
= r
"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ?
48 pub PASSWORD_REGEX
= r
"^[[:^cntrl:]]*$"; // everything but control characters
50 /// Regex for safe identifiers.
53 /// [article](https://dwheeler.com/essays/fixing-unix-linux-filenames.html)
54 /// contains further information why it is reasonable to restict
55 /// names this way. This is not only useful for filenames, but for
56 /// any identifier command line tools work with.
57 pub PROXMOX_SAFE_ID_REGEX
= concat
!(r
"^", PROXMOX_SAFE_ID_REGEX_STR
!(), r
"$");
59 pub SINGLE_LINE_COMMENT_REGEX
= r
"^[[:^cntrl:]]*$";
61 pub HOSTNAME_REGEX
= r
"^(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)$";
63 pub DNS_NAME_REGEX
= concat
!(r
"^", DNS_NAME
!(), r
"$");
65 pub DNS_NAME_OR_IP_REGEX
= concat
!(r
"^", DNS_NAME
!(), "|", IPRE
!(), r
"$");
67 pub BACKUP_REPO_URL_REGEX
= concat
!(r
"^^(?:(?:(", USER_ID_REGEX_STR
!(), ")@)?(", DNS_NAME
!(), "|", IPRE
!() ,"):)?(", PROXMOX_SAFE_ID_REGEX_STR
!(), r
")$");
69 pub CERT_FINGERPRINT_SHA256_REGEX
= r
"^(?:[0-9a-fA-F][0-9a-fA-F])(?::[0-9a-fA-F][0-9a-fA-F]){31}$";
71 pub ACL_PATH_REGEX
= concat
!(r
"^(?:/|", r
"(?:/", PROXMOX_SAFE_ID_REGEX_STR
!(), ")+", r
")$");
73 pub BLOCKDEVICE_NAME_REGEX
= r
"^(:?(:?h|s|x?v)d[a-z]+)|(:?nvme\d+n\d+)$";
75 pub ZPOOL_NAME_REGEX
= r
"^[a-zA-Z][a-z0-9A-Z\-_.:]+$";
78 pub const SYSTEMD_DATETIME_FORMAT
: ApiStringFormat
=
79 ApiStringFormat
::Pattern(&SYSTEMD_DATETIME_REGEX
);
81 pub const IP_V4_FORMAT
: ApiStringFormat
=
82 ApiStringFormat
::Pattern(&IP_V4_REGEX
);
84 pub const IP_V6_FORMAT
: ApiStringFormat
=
85 ApiStringFormat
::Pattern(&IP_V6_REGEX
);
87 pub const IP_FORMAT
: ApiStringFormat
=
88 ApiStringFormat
::Pattern(&IP_REGEX
);
90 pub const PVE_CONFIG_DIGEST_FORMAT
: ApiStringFormat
=
91 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
93 pub const CERT_FINGERPRINT_SHA256_FORMAT
: ApiStringFormat
=
94 ApiStringFormat
::Pattern(&CERT_FINGERPRINT_SHA256_REGEX
);
96 pub const PROXMOX_SAFE_ID_FORMAT
: ApiStringFormat
=
97 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
99 pub const SINGLE_LINE_COMMENT_FORMAT
: ApiStringFormat
=
100 ApiStringFormat
::Pattern(&SINGLE_LINE_COMMENT_REGEX
);
102 pub const HOSTNAME_FORMAT
: ApiStringFormat
=
103 ApiStringFormat
::Pattern(&HOSTNAME_REGEX
);
105 pub const DNS_NAME_FORMAT
: ApiStringFormat
=
106 ApiStringFormat
::Pattern(&DNS_NAME_REGEX
);
108 pub const DNS_NAME_OR_IP_FORMAT
: ApiStringFormat
=
109 ApiStringFormat
::Pattern(&DNS_NAME_OR_IP_REGEX
);
111 pub const PASSWORD_FORMAT
: ApiStringFormat
=
112 ApiStringFormat
::Pattern(&PASSWORD_REGEX
);
114 pub const ACL_PATH_FORMAT
: ApiStringFormat
=
115 ApiStringFormat
::Pattern(&ACL_PATH_REGEX
);
117 pub const NETWORK_INTERFACE_FORMAT
: ApiStringFormat
=
118 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
120 pub const CIDR_V4_FORMAT
: ApiStringFormat
=
121 ApiStringFormat
::Pattern(&CIDR_V4_REGEX
);
123 pub const CIDR_V6_FORMAT
: ApiStringFormat
=
124 ApiStringFormat
::Pattern(&CIDR_V6_REGEX
);
126 pub const CIDR_FORMAT
: ApiStringFormat
=
127 ApiStringFormat
::Pattern(&CIDR_REGEX
);
129 pub const BLOCKDEVICE_NAME_FORMAT
: ApiStringFormat
=
130 ApiStringFormat
::Pattern(&BLOCKDEVICE_NAME_REGEX
);
132 pub const PASSWORD_SCHEMA
: Schema
= StringSchema
::new("Password.")
133 .format(&PASSWORD_FORMAT
)
138 pub const PBS_PASSWORD_SCHEMA
: Schema
= StringSchema
::new("User Password.")
139 .format(&PASSWORD_FORMAT
)
144 pub const CERT_FINGERPRINT_SHA256_SCHEMA
: Schema
= StringSchema
::new(
145 "X509 certificate fingerprint (sha256)."
147 .format(&CERT_FINGERPRINT_SHA256_FORMAT
)
150 pub const PROXMOX_CONFIG_DIGEST_SCHEMA
: Schema
= StringSchema
::new(r
#"\
151 Prevent changes if current configuration file has different SHA256 digest.
152 This can be used to prevent concurrent modifications.
155 .format(&PVE_CONFIG_DIGEST_FORMAT
)
159 pub const CHUNK_DIGEST_FORMAT
: ApiStringFormat
=
160 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
162 pub const CHUNK_DIGEST_SCHEMA
: Schema
= StringSchema
::new("Chunk digest (SHA256).")
163 .format(&CHUNK_DIGEST_FORMAT
)
166 pub const NODE_SCHEMA
: Schema
= StringSchema
::new("Node name (or 'localhost')")
167 .format(&ApiStringFormat
::VerifyFn(|node
| {
168 if node
== "localhost" || node
== proxmox
::tools
::nodename() {
171 bail
!("no such node '{}'", node
);
176 pub const SEARCH_DOMAIN_SCHEMA
: Schema
=
177 StringSchema
::new("Search domain for host-name lookup.").schema();
179 pub const FIRST_DNS_SERVER_SCHEMA
: Schema
=
180 StringSchema
::new("First name server IP address.")
184 pub const SECOND_DNS_SERVER_SCHEMA
: Schema
=
185 StringSchema
::new("Second name server IP address.")
189 pub const THIRD_DNS_SERVER_SCHEMA
: Schema
=
190 StringSchema
::new("Third name server IP address.")
194 pub const IP_V4_SCHEMA
: Schema
=
195 StringSchema
::new("IPv4 address.")
196 .format(&IP_V4_FORMAT
)
200 pub const IP_V6_SCHEMA
: Schema
=
201 StringSchema
::new("IPv6 address.")
202 .format(&IP_V6_FORMAT
)
206 pub const IP_SCHEMA
: Schema
=
207 StringSchema
::new("IP (IPv4 or IPv6) address.")
212 pub const CIDR_V4_SCHEMA
: Schema
=
213 StringSchema
::new("IPv4 address with netmask (CIDR notation).")
214 .format(&CIDR_V4_FORMAT
)
218 pub const CIDR_V6_SCHEMA
: Schema
=
219 StringSchema
::new("IPv6 address with netmask (CIDR notation).")
220 .format(&CIDR_V6_FORMAT
)
224 pub const CIDR_SCHEMA
: Schema
=
225 StringSchema
::new("IP address (IPv4 or IPv6) with netmask (CIDR notation).")
226 .format(&CIDR_FORMAT
)
230 pub const TIME_ZONE_SCHEMA
: Schema
= StringSchema
::new(
231 "Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names.")
232 .format(&SINGLE_LINE_COMMENT_FORMAT
)
237 pub const ACL_PATH_SCHEMA
: Schema
= StringSchema
::new(
238 "Access control path.")
239 .format(&ACL_PATH_FORMAT
)
244 pub const ACL_PROPAGATE_SCHEMA
: Schema
= BooleanSchema
::new(
245 "Allow to propagate (inherit) permissions.")
249 pub const ACL_UGID_TYPE_SCHEMA
: Schema
= StringSchema
::new(
250 "Type of 'ugid' property.")
251 .format(&ApiStringFormat
::Enum(&[
252 EnumEntry
::new("user", "User"),
253 EnumEntry
::new("group", "Group")]))
256 pub const BACKUP_ARCHIVE_NAME_SCHEMA
: Schema
=
257 StringSchema
::new("Backup archive name.")
258 .format(&PROXMOX_SAFE_ID_FORMAT
)
261 pub const BACKUP_TYPE_SCHEMA
: Schema
=
262 StringSchema
::new("Backup type.")
263 .format(&ApiStringFormat
::Enum(&[
264 EnumEntry
::new("vm", "Virtual Machine Backup"),
265 EnumEntry
::new("ct", "Container Backup"),
266 EnumEntry
::new("host", "Host Backup")]))
269 pub const BACKUP_ID_SCHEMA
: Schema
=
270 StringSchema
::new("Backup ID.")
271 .format(&PROXMOX_SAFE_ID_FORMAT
)
274 pub const BACKUP_TIME_SCHEMA
: Schema
=
275 IntegerSchema
::new("Backup time (Unix epoch.)")
276 .minimum(1_547_797_308)
279 pub const UPID_SCHEMA
: Schema
= StringSchema
::new("Unique Process/Task ID.")
283 pub const DATASTORE_SCHEMA
: Schema
= StringSchema
::new("Datastore name.")
284 .format(&PROXMOX_SAFE_ID_FORMAT
)
289 pub const SYNC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
290 "Run sync job at specified schedule.")
291 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
294 pub const GC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
295 "Run garbage collection job at specified schedule.")
296 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
299 pub const PRUNE_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
300 "Run prune job at specified schedule.")
301 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
304 pub const REMOTE_ID_SCHEMA
: Schema
= StringSchema
::new("Remote ID.")
305 .format(&PROXMOX_SAFE_ID_FORMAT
)
310 pub const JOB_ID_SCHEMA
: Schema
= StringSchema
::new("Job ID.")
311 .format(&PROXMOX_SAFE_ID_FORMAT
)
316 pub const REMOVE_VANISHED_BACKUPS_SCHEMA
: Schema
= BooleanSchema
::new(
317 "Delete vanished backups. This remove the local copy if the remote backup was deleted.")
321 pub const SINGLE_LINE_COMMENT_SCHEMA
: Schema
= StringSchema
::new("Comment (single line).")
322 .format(&SINGLE_LINE_COMMENT_FORMAT
)
325 pub const HOSTNAME_SCHEMA
: Schema
= StringSchema
::new("Hostname (as defined in RFC1123).")
326 .format(&HOSTNAME_FORMAT
)
329 pub const DNS_NAME_OR_IP_SCHEMA
: Schema
= StringSchema
::new("DNS name or IP address.")
330 .format(&DNS_NAME_OR_IP_FORMAT
)
333 pub const BLOCKDEVICE_NAME_SCHEMA
: Schema
= StringSchema
::new("Block device name (/sys/block/<name>).")
334 .format(&BLOCKDEVICE_NAME_FORMAT
)
339 // Complex type definitions
344 schema
: BACKUP_TYPE_SCHEMA
,
347 schema
: BACKUP_ID_SCHEMA
,
350 schema
: BACKUP_TIME_SCHEMA
,
357 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
366 #[derive(Serialize, Deserialize)]
367 #[serde(rename_all="kebab-case")]
368 /// Basic information about a backup group.
369 pub struct GroupListItem
{
370 pub backup_type
: String
, // enum
371 pub backup_id
: String
,
372 pub last_backup
: i64,
373 /// Number of contained snapshots
374 pub backup_count
: u64,
375 /// List of contained archive files.
376 pub files
: Vec
<String
>,
377 /// The owner of group
378 #[serde(skip_serializing_if="Option::is_none")]
379 pub owner
: Option
<Userid
>,
385 schema
: BACKUP_TYPE_SCHEMA
,
388 schema
: BACKUP_ID_SCHEMA
,
391 schema
: BACKUP_TIME_SCHEMA
,
395 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
404 #[derive(Serialize, Deserialize)]
405 #[serde(rename_all="kebab-case")]
406 /// Basic information about backup snapshot.
407 pub struct SnapshotListItem
{
408 pub backup_type
: String
, // enum
409 pub backup_id
: String
,
410 pub backup_time
: i64,
411 /// The first line from manifest "notes"
412 #[serde(skip_serializing_if="Option::is_none")]
413 pub comment
: Option
<String
>,
414 /// List of contained archive files.
415 pub files
: Vec
<BackupContent
>,
416 /// Overall snapshot size (sum of all archive sizes).
417 #[serde(skip_serializing_if="Option::is_none")]
418 pub size
: Option
<u64>,
419 /// The owner of the snapshots group
420 #[serde(skip_serializing_if="Option::is_none")]
421 pub owner
: Option
<Userid
>,
427 schema
: BACKUP_TYPE_SCHEMA
,
430 schema
: BACKUP_ID_SCHEMA
,
433 schema
: BACKUP_TIME_SCHEMA
,
437 #[derive(Serialize, Deserialize)]
438 #[serde(rename_all="kebab-case")]
440 pub struct PruneListItem
{
441 pub backup_type
: String
, // enum
442 pub backup_id
: String
,
443 pub backup_time
: i64,
448 pub const PRUNE_SCHEMA_KEEP_DAILY
: Schema
= IntegerSchema
::new(
449 "Number of daily backups to keep.")
453 pub const PRUNE_SCHEMA_KEEP_HOURLY
: Schema
= IntegerSchema
::new(
454 "Number of hourly backups to keep.")
458 pub const PRUNE_SCHEMA_KEEP_LAST
: Schema
= IntegerSchema
::new(
459 "Number of backups to keep.")
463 pub const PRUNE_SCHEMA_KEEP_MONTHLY
: Schema
= IntegerSchema
::new(
464 "Number of monthly backups to keep.")
468 pub const PRUNE_SCHEMA_KEEP_WEEKLY
: Schema
= IntegerSchema
::new(
469 "Number of weekly backups to keep.")
473 pub const PRUNE_SCHEMA_KEEP_YEARLY
: Schema
= IntegerSchema
::new(
474 "Number of yearly backups to keep.")
481 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
,
489 #[derive(Serialize, Deserialize)]
490 #[serde(rename_all="kebab-case")]
491 /// Basic information about archive files inside a backup snapshot.
492 pub struct BackupContent
{
493 pub filename
: String
,
494 /// Info if file is encrypted, signed, or neither.
495 #[serde(skip_serializing_if="Option::is_none")]
496 pub crypt_mode
: Option
<CryptMode
>,
497 /// Archive size (from backup manifest).
498 #[serde(skip_serializing_if="Option::is_none")]
499 pub size
: Option
<u64>,
510 #[derive(Clone, Serialize, Deserialize)]
511 #[serde(rename_all="kebab-case")]
512 /// Garbage collection status.
513 pub struct GarbageCollectionStatus
{
514 pub upid
: Option
<String
>,
515 /// Number of processed index files.
516 pub index_file_count
: usize,
517 /// Sum of bytes referred by index files.
518 pub index_data_bytes
: u64,
519 /// Bytes used on disk.
521 /// Chunks used on disk.
522 pub disk_chunks
: usize,
523 /// Sum of removed bytes.
524 pub removed_bytes
: u64,
525 /// Number of removed chunks.
526 pub removed_chunks
: usize,
527 /// Sum of pending bytes (pending removal - kept for safety).
528 pub pending_bytes
: u64,
529 /// Number of pending chunks (pending removal - kept for safety).
530 pub pending_chunks
: usize,
533 impl Default
for GarbageCollectionStatus
{
534 fn default() -> Self {
535 GarbageCollectionStatus
{
551 #[derive(Serialize, Deserialize)]
552 /// Storage space usage information.
553 pub struct StorageStatus
{
554 /// Total space (bytes).
556 /// Used space (bytes).
558 /// Available space (bytes).
564 upid
: { schema: UPID_SCHEMA }
,
565 user
: { type: Userid }
,
568 #[derive(Serialize, Deserialize)]
570 pub struct TaskListItem
{
572 /// The node name where the task is running on.
576 /// The task start time (Epoch)
578 /// The task start time (Epoch)
580 /// Worker type (arbitrary ASCII string)
581 pub worker_type
: String
,
582 /// Worker ID (arbitrary ASCII string)
583 pub worker_id
: Option
<String
>,
584 /// The user who started the task
586 /// The task end time (Epoch)
587 #[serde(skip_serializing_if="Option::is_none")]
588 pub endtime
: Option
<i64>,
590 #[serde(skip_serializing_if="Option::is_none")]
591 pub status
: Option
<String
>,
594 impl From
<crate::server
::TaskListInfo
> for TaskListItem
{
595 fn from(info
: crate::server
::TaskListInfo
) -> Self {
596 let (endtime
, status
) = info
598 .map_or_else(|| (None
, None
), |a
| (Some(a
.endtime()), Some(a
.to_string())));
602 node
: "localhost".to_string(),
603 pid
: info
.upid
.pid
as i64,
604 pstart
: info
.upid
.pstart
,
605 starttime
: info
.upid
.starttime
,
606 worker_type
: info
.upid
.worker_type
,
607 worker_id
: info
.upid
.worker_id
,
608 user
: info
.upid
.userid
,
616 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
617 #[serde(rename_all = "lowercase")]
618 /// Node Power command type.
619 pub enum NodePowerCommand
{
620 /// Restart the server
622 /// Shutdown the server
627 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
628 #[serde(rename_all = "lowercase")]
629 /// Interface configuration method
630 pub enum NetworkConfigMethod
{
631 /// Configuration is done manually using other tools
633 /// Define interfaces with statically allocated addresses.
635 /// Obtain an address via DHCP
637 /// Define the loopback interface.
642 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
643 #[serde(rename_all = "kebab-case")]
644 #[allow(non_camel_case_types)]
647 pub enum LinuxBondMode
{
648 /// Round-robin policy
650 /// Active-backup policy
656 /// IEEE 802.3ad Dynamic link aggregation
657 //#[serde(rename = "802.3ad")]
659 /// Adaptive transmit load balancing
661 /// Adaptive load balancing
666 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
667 #[serde(rename_all = "lowercase")]
668 /// Network interface type
669 pub enum NetworkInterfaceType
{
672 /// Physical Ethernet device
678 /// Linux VLAN (eth.10)
680 /// Interface Alias (eth:1)
682 /// Unknown interface type
686 pub const NETWORK_INTERFACE_NAME_SCHEMA
: Schema
= StringSchema
::new("Network interface name.")
687 .format(&NETWORK_INTERFACE_FORMAT
)
689 .max_length(libc
::IFNAMSIZ
-1)
692 pub const NETWORK_INTERFACE_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
693 "Network interface list.", &NETWORK_INTERFACE_NAME_SCHEMA
)
696 pub const NETWORK_INTERFACE_LIST_SCHEMA
: Schema
= StringSchema
::new(
697 "A list of network devices, comma separated.")
698 .format(&ApiStringFormat
::PropertyString(&NETWORK_INTERFACE_ARRAY_SCHEMA
))
704 schema
: NETWORK_INTERFACE_NAME_SCHEMA
,
707 type: NetworkInterfaceType
,
710 type: NetworkConfigMethod
,
714 type: NetworkConfigMethod
,
718 schema
: CIDR_V4_SCHEMA
,
722 schema
: CIDR_V6_SCHEMA
,
726 schema
: IP_V4_SCHEMA
,
730 schema
: IP_V6_SCHEMA
,
734 description
: "Option list (inet)",
737 description
: "Optional attribute line.",
742 description
: "Option list (inet6)",
745 description
: "Optional attribute line.",
750 description
: "Comments (inet, may span multiple lines)",
755 description
: "Comments (inet6, may span multiple lines)",
760 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
764 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
773 #[derive(Debug, Serialize, Deserialize)]
774 /// Network Interface configuration
775 pub struct Interface
{
776 /// Autostart interface
777 #[serde(rename = "autostart")]
779 /// Interface is active (UP)
784 #[serde(rename = "type")]
785 pub interface_type
: NetworkInterfaceType
,
786 #[serde(skip_serializing_if="Option::is_none")]
787 pub method
: Option
<NetworkConfigMethod
>,
788 #[serde(skip_serializing_if="Option::is_none")]
789 pub method6
: Option
<NetworkConfigMethod
>,
790 #[serde(skip_serializing_if="Option::is_none")]
791 /// IPv4 address with netmask
792 pub cidr
: Option
<String
>,
793 #[serde(skip_serializing_if="Option::is_none")]
795 pub gateway
: Option
<String
>,
796 #[serde(skip_serializing_if="Option::is_none")]
797 /// IPv6 address with netmask
798 pub cidr6
: Option
<String
>,
799 #[serde(skip_serializing_if="Option::is_none")]
801 pub gateway6
: Option
<String
>,
803 #[serde(skip_serializing_if="Vec::is_empty")]
804 pub options
: Vec
<String
>,
805 #[serde(skip_serializing_if="Vec::is_empty")]
806 pub options6
: Vec
<String
>,
808 #[serde(skip_serializing_if="Option::is_none")]
809 pub comments
: Option
<String
>,
810 #[serde(skip_serializing_if="Option::is_none")]
811 pub comments6
: Option
<String
>,
813 #[serde(skip_serializing_if="Option::is_none")]
814 /// Maximum Transmission Unit
815 pub mtu
: Option
<u64>,
817 #[serde(skip_serializing_if="Option::is_none")]
818 pub bridge_ports
: Option
<Vec
<String
>>,
819 /// Enable bridge vlan support.
820 #[serde(skip_serializing_if="Option::is_none")]
821 pub bridge_vlan_aware
: Option
<bool
>,
823 #[serde(skip_serializing_if="Option::is_none")]
824 pub slaves
: Option
<Vec
<String
>>,
825 #[serde(skip_serializing_if="Option::is_none")]
826 pub bond_mode
: Option
<LinuxBondMode
>,
832 fn test_cert_fingerprint_schema() -> Result
<(), anyhow
::Error
> {
834 let schema
= CERT_FINGERPRINT_SHA256_SCHEMA
;
836 let invalid_fingerprints
= [
837 "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",
838 "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",
839 "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",
840 "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",
841 "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",
842 "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",
845 for fingerprint
in invalid_fingerprints
.iter() {
846 if let Ok(_
) = parse_simple_value(fingerprint
, &schema
) {
847 bail
!("test fingerprint '{}' failed - got Ok() while exception an error.", fingerprint
);
851 let valid_fingerprints
= [
852 "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",
853 "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",
856 for fingerprint
in valid_fingerprints
.iter() {
857 let v
= match parse_simple_value(fingerprint
, &schema
) {
860 bail
!("unable to parse fingerprint '{}' - {}", fingerprint
, err
);
864 if v
!= serde_json
::json
!(fingerprint
) {
865 bail
!("unable to parse fingerprint '{}' - got wrong value {:?}", fingerprint
, v
);
873 fn test_proxmox_user_id_schema() -> Result
<(), anyhow
::Error
> {
874 let invalid_user_ids
= [
879 "xx x@test", // contains space
880 "xx\nx@test", // contains control character
881 "x:xx@test", // contains collon
882 "xx/x@test", // contains slash
883 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@test", // too long
886 for name
in invalid_user_ids
.iter() {
887 if let Ok(_
) = parse_simple_value(name
, &Userid
::API_SCHEMA
) {
888 bail
!("test userid '{}' failed - got Ok() while exception an error.", name
);
892 let valid_user_ids
= [
896 "xxx@_T_E_S_T-it.com",
897 "x_x-x.x@test-it.com",
900 for name
in valid_user_ids
.iter() {
901 let v
= match parse_simple_value(name
, &Userid
::API_SCHEMA
) {
904 bail
!("unable to parse userid '{}' - {}", name
, err
);
908 if v
!= serde_json
::json
!(name
) {
909 bail
!("unable to parse userid '{}' - got wrong value {:?}", name
, v
);
917 #[derive(Copy, Clone, Serialize, Deserialize)]
918 #[serde(rename_all = "UPPERCASE")]
929 #[derive(Copy, Clone, Serialize, Deserialize)]
930 #[serde(rename_all = "lowercase")]
931 pub enum RRDTimeFrameResolution
{
932 /// 1 min => last 70 minutes
934 /// 30 min => last 35 hours
936 /// 3 hours => about 8 days
938 /// 12 hours => last 35 days
940 /// 1 week => last 490 days
945 #[derive(Serialize, Deserialize)]
946 #[serde(rename_all = "PascalCase")]
947 /// Describes a package for which an update is available.
948 pub struct APTUpdateInfo
{
953 /// Package architecture
955 /// Human readable package description
956 pub description
: String
,
957 /// New version to be updated to
959 /// Old version currently installed
960 pub old_version
: String
,
963 /// Package priority in human-readable form
964 pub priority
: String
,
967 /// URL under which the package's changelog can be retrieved
968 pub change_log_url
: String
,