monitord/dbus/
zbus_machines.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//! # D-Bus interface proxy for: `org.freedesktop.machine1.Manager`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data and approprietly adapted.
//! Source: `Interface '/org/freedesktop/machine1' from service 'org.freedesktop.machine1' on system bus`.
//!
//! More information can be found in the [Writing a client proxy] section of the zbus
//! documentation.
//!
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
//! following zbus API can be used:
//!
//! * [`zbus::fdo::PeerProxy`]
//! * [`zbus::fdo::IntrospectableProxy`]
//! * [`zbus::fdo::PropertiesProxy`]
//!
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
//!
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,

#![allow(warnings)]
use serde_tuple::Deserialize_tuple;
use zbus::proxy;
use zbus::zvariant::Type;

use crate::dbus::zbus_machine::MachineProxy;

#[derive(Deserialize_tuple, PartialEq, Eq, Debug, Type)]
pub struct ListedMachine {
    pub name: String,
    pub class: String,
    pub service: String,
    pub path: zbus::zvariant::OwnedObjectPath,
}

#[proxy(
    interface = "org.freedesktop.machine1.Manager",
    default_service = "org.freedesktop.machine1",
    default_path = "/org/freedesktop/machine1"
)]
pub trait Manager {
    /// BindMountMachine method
    fn bind_mount_machine(
        &self,
        name: &str,
        source: &str,
        destination: &str,
        read_only: bool,
        mkdir: bool,
    ) -> zbus::Result<()>;

    /// CleanPool method
    fn clean_pool(&self, mode: &str) -> zbus::Result<Vec<(String, u64)>>;

    /// CloneImage method
    fn clone_image(&self, name: &str, new_name: &str, read_only: bool) -> zbus::Result<()>;

    /// CopyFromMachine method
    fn copy_from_machine(&self, name: &str, source: &str, destination: &str) -> zbus::Result<()>;

    /// CopyFromMachineWithFlags method
    fn copy_from_machine_with_flags(
        &self,
        name: &str,
        source: &str,
        destination: &str,
        flags: u64,
    ) -> zbus::Result<()>;

    /// CopyToMachine method
    fn copy_to_machine(&self, name: &str, source: &str, destination: &str) -> zbus::Result<()>;

    /// CopyToMachineWithFlags method
    fn copy_to_machine_with_flags(
        &self,
        name: &str,
        source: &str,
        destination: &str,
        flags: u64,
    ) -> zbus::Result<()>;

    /// CreateMachine method
    #[allow(clippy::too_many_arguments)]
    fn create_machine(
        &self,
        name: &str,
        id: &[u8],
        service: &str,
        class: &str,
        leader: u32,
        root_directory: &str,
        scope_properties: &[&(&str, &zbus::zvariant::Value<'_>)],
    ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// CreateMachineWithNetwork method
    #[allow(clippy::too_many_arguments)]
    fn create_machine_with_network(
        &self,
        name: &str,
        id: &[u8],
        service: &str,
        class: &str,
        leader: u32,
        root_directory: &str,
        ifindices: &[i32],
        scope_properties: &[&(&str, &zbus::zvariant::Value<'_>)],
    ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// GetImage method
    fn get_image(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// GetImageHostname method
    fn get_image_hostname(&self, name: &str) -> zbus::Result<String>;

    /// GetImageMachineID method
    #[zbus(name = "GetImageMachineID")]
    fn get_image_machine_id(&self, name: &str) -> zbus::Result<Vec<u8>>;

    /// GetImageMachineInfo method
    fn get_image_machine_info(
        &self,
        name: &str,
    ) -> zbus::Result<std::collections::HashMap<String, String>>;

    /// GetImageOSRelease method
    #[zbus(name = "GetImageOSRelease")]
    fn get_image_osrelease(
        &self,
        name: &str,
    ) -> zbus::Result<std::collections::HashMap<String, String>>;

    /// GetMachine method
    #[zbus(object = "Machine")]
    fn get_machine(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// GetMachineAddresses method
    fn get_machine_addresses(&self, name: &str) -> zbus::Result<Vec<(i32, Vec<u8>)>>;

    /// GetMachineByPID method
    #[zbus(name = "GetMachineByPID", object = "Machine")]
    fn get_machine_by_pid(&self, pid: u32) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// GetMachineOSRelease method
    #[zbus(name = "GetMachineOSRelease")]
    fn get_machine_osrelease(
        &self,
        name: &str,
    ) -> zbus::Result<std::collections::HashMap<String, String>>;

    /// GetMachineUIDShift method
    #[zbus(name = "GetMachineUIDShift")]
    fn get_machine_uidshift(&self, name: &str) -> zbus::Result<u32>;

    /// KillMachine method
    fn kill_machine(&self, name: &str, who: &str, signal: i32) -> zbus::Result<()>;

    /// ListImages method
    fn list_images(
        &self,
    ) -> zbus::Result<
        Vec<(
            String,
            String,
            bool,
            u64,
            u64,
            u64,
            zbus::zvariant::OwnedObjectPath,
        )>,
    >;

    /// ListMachines method
    fn list_machines(&self) -> zbus::Result<Vec<ListedMachine>>;

    /// MapFromMachineGroup method
    fn map_from_machine_group(&self, name: &str, gid_inner: u32) -> zbus::Result<u32>;

    /// MapFromMachineUser method
    fn map_from_machine_user(&self, name: &str, uid_inner: u32) -> zbus::Result<u32>;

    /// MapToMachineGroup method
    fn map_to_machine_group(
        &self,
        gid_outer: u32,
    ) -> zbus::Result<(String, zbus::zvariant::OwnedObjectPath, u32)>;

    /// MapToMachineUser method
    fn map_to_machine_user(
        &self,
        uid_outer: u32,
    ) -> zbus::Result<(String, zbus::zvariant::OwnedObjectPath, u32)>;

    /// MarkImageReadOnly method
    fn mark_image_read_only(&self, name: &str, read_only: bool) -> zbus::Result<()>;

    /// OpenMachineLogin method
    fn open_machine_login(&self, name: &str) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;

    /// OpenMachinePTY method
    #[zbus(name = "OpenMachinePTY")]
    fn open_machine_pty(&self, name: &str) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;

    /// OpenMachineRootDirectory method
    fn open_machine_root_directory(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedFd>;

    /// OpenMachineShell method
    #[allow(clippy::too_many_arguments)]
    fn open_machine_shell(
        &self,
        name: &str,
        user: &str,
        path: &str,
        args: &[&str],
        environment: &[&str],
    ) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;

    /// RegisterMachine method
    #[allow(clippy::too_many_arguments)]
    fn register_machine(
        &self,
        name: &str,
        id: &[u8],
        service: &str,
        class: &str,
        leader: u32,
        root_directory: &str,
    ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// RegisterMachineWithNetwork method
    #[allow(clippy::too_many_arguments)]
    fn register_machine_with_network(
        &self,
        name: &str,
        id: &[u8],
        service: &str,
        class: &str,
        leader: u32,
        root_directory: &str,
        ifindices: &[i32],
    ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

    /// RemoveImage method
    fn remove_image(&self, name: &str) -> zbus::Result<()>;

    /// RenameImage method
    fn rename_image(&self, name: &str, new_name: &str) -> zbus::Result<()>;

    /// SetImageLimit method
    fn set_image_limit(&self, name: &str, size: u64) -> zbus::Result<()>;

    /// SetPoolLimit method
    fn set_pool_limit(&self, size: u64) -> zbus::Result<()>;

    /// TerminateMachine method
    fn terminate_machine(&self, id: &str) -> zbus::Result<()>;

    /// UnregisterMachine method
    fn unregister_machine(&self, name: &str) -> zbus::Result<()>;

    /// MachineNew signal
    #[zbus(signal)]
    fn machine_new(&self, machine: &str, path: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;

    /// MachineRemoved signal
    #[zbus(signal)]
    fn machine_removed(
        &self,
        machine: &str,
        path: zbus::zvariant::ObjectPath<'_>,
    ) -> zbus::Result<()>;

    /// PoolLimit property
    #[zbus(property)]
    fn pool_limit(&self) -> zbus::Result<u64>;

    /// PoolPath property
    #[zbus(property)]
    fn pool_path(&self) -> zbus::Result<String>;

    /// PoolUsage property
    #[zbus(property)]
    fn pool_usage(&self) -> zbus::Result<u64>;
}