]>
Commit | Line | Data |
---|---|---|
2fe60ff1 ZJS |
1 | <?xml version='1.0'?> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" > | |
4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> | |
5 | ||
6 | <refentry id="org.freedesktop.import1" conditional='ENABLE_IMPORTD' | |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
8 | <refentryinfo> | |
9 | <title>org.freedesktop.import1</title> | |
10 | <productname>systemd</productname> | |
11 | </refentryinfo> | |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>org.freedesktop.import1</refentrytitle> | |
15 | <manvolnum>5</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>org.freedesktop.import1</refname> | |
20 | <refpurpose>The D-Bus interface of systemd-importd</refpurpose> | |
21 | </refnamediv> | |
22 | ||
23 | <refsect1> | |
24 | <title>Introduction</title> | |
25 | ||
26 | <para> | |
27 | <citerefentry><refentrytitle>systemd-importd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
28 | is a system service which may be used to import, export and download additional system images, for | |
29 | running them as local containers using tools such as | |
30 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> The | |
31 | service is used as backend for <command>machinectl pull-raw</command> and <command>machinectl | |
32 | pull-tar</command> and related commands. | |
33 | This page describes the D-Bus interface.</para> | |
34 | ||
35 | <para>Note that | |
36 | <citerefentry><refentrytitle>systemd-importd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
37 | is mostly a small companion service for | |
38 | <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>. | |
39 | Many operations to manipulate local container and VM images are hence available via the <command>systemd-machined</command> bus API, c.f. | |
40 | <citerefentry><refentrytitle>org.freedesktop.machine1.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
41 | </para> | |
42 | </refsect1> | |
43 | ||
44 | <refsect1> | |
45 | <title>The Manager Object</title> | |
46 | ||
47 | <para>The service exposes the following interfaces on the Manager object on the bus:</para> | |
48 | ||
49 | <programlisting> | |
50 | $ gdbus introspect --system \ | |
51 | --dest org.freedesktop.import1 \ | |
52 | --object-path /org/freedesktop/import1 | |
53 | ||
54 | node /org/freedesktop/import1 { | |
55 | interface org.freedesktop.import1.Manager { | |
56 | methods: | |
57 | ImportTar(in h fd, | |
58 | in s local_name, | |
59 | in b force, | |
60 | in b read_only, | |
61 | out u transfer_id, | |
62 | out o transfer_path); | |
63 | ImportRaw(in h fd, | |
64 | in s local_name, | |
65 | in b force, | |
66 | in b read_only, | |
67 | out u transfer_id, | |
68 | out o transfer_path); | |
69 | ExportTar(in s local_name, | |
70 | in h fd, | |
71 | in s format, | |
72 | out u transfer_id, | |
73 | out o transfer_path); | |
74 | ExportRaw(in s local_name, | |
75 | in h fd, | |
76 | in s format, | |
77 | out u transfer_id, | |
78 | out o transfer_path); | |
79 | PullTar(in s url, | |
80 | in s local_name, | |
81 | in s verify_mode, | |
82 | in b force, | |
83 | out u transfer_id, | |
84 | out o transfer_path); | |
85 | PullRaw(in s url, | |
86 | in s local_name, | |
87 | in s verify_mode, | |
88 | in b force, | |
89 | out u transfer_id, | |
90 | out o transfer_path); | |
91 | ListTransfers(out a(usssdo) list); | |
92 | CancelTransfer(in u transfer_id); | |
93 | signals: | |
94 | TransferNew(u transfer_id, | |
95 | o transfer_path); | |
96 | TransferRemoved(u transfer_id, | |
97 | o transfer_path, | |
98 | s result); | |
99 | }; | |
100 | interface org.freedesktop.DBus.Peer { | |
101 | }; | |
102 | interface org.freedesktop.DBus.Introspectable { | |
103 | }; | |
104 | interface org.freedesktop.DBus.Properties { | |
105 | }; | |
106 | }; | |
107 | </programlisting> | |
108 | ||
109 | <refsect2> | |
110 | <title>Methods</title> | |
111 | ||
112 | <para><function>ImportTar()</function> and <function>ImportRaw()</function> import a system image and | |
113 | place it into <filename>/var/lib/machines/</filename>. The first argument should be a file descriptor | |
114 | (opened for reading) referring to the tar or raw file to import. It should reference either a file on | |
115 | disk or a pipe or socket. When <function>ImportTar()</function> is used the file descriptor should | |
116 | refer to a tar file, optionally compressed with | |
117 | <citerefentry project="die-net"><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
118 | <citerefentry project="die-net"><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
119 | or | |
120 | <citerefentry project="die-net"><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
121 | <command>systemd-importd</command> will detect the used compression scheme (if any) automatically. When | |
122 | <function>ImportRaw()</function> is used the file descriptor should refer to a raw or qcow2 disk image | |
123 | containing an MBR or GPT disk label, also optionally compressed with gzip, bzip2 or xz. In either case, | |
124 | if the file is specified as file descriptor on disk, progress information is generated for the import | |
125 | operation (since the size on disk is known then), if a socket or pipe is specified this is not | |
126 | available. The file descriptor argument is followed by a local name for the image. This should be a | |
127 | name suitable as a hostname and will be used to name the imported image below | |
128 | <filename>/var/lib/machines</filename>. A tar import is placed as directory tree or | |
129 | <citerefentry project="man-pages"><refentrytitle>btrfs</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
130 | subvolume below <filename>/var/lib/machines/</filename>, under the name specified with no suffix | |
131 | appended. A raw import is placed as file in <filename>/var/lib/machines/</filename> with the | |
132 | <filename>.raw</filename> suffix appended. The <option>force</option> argument controls whether any | |
133 | pre-existing image with the same name shall be removed for the operation. If true, it is removed, if | |
134 | false the operation fails on a name conflict. Finally, the <option>read_only</option> argument controls | |
135 | whether to create a writable or read-only image. The two calls return immediately after invocation, | |
136 | with the import transfer ongoing. They return a pair of transfer identifier and object path, which may | |
137 | be used to retrieve progress information about the transfer, or cancel it. The transfer identifier is a | |
138 | simple numeric identifier, the object path references an | |
139 | <interfacename>org.freedesktop.import1.Transfer</interfacename> object, see below. Listen for a | |
140 | <function>TransferRemoved</function> signal for the transfer ID it order to detect when a transfer is | |
141 | complete. The returned transfer object is useful to determine the current progress or log output of the | |
142 | ongoing import operation.</para> | |
143 | ||
144 | <para><function>ExportTar()</function> and <function>ExportRaw()</function> implement the reverse | |
145 | operation, and may be used to export a system image in order to place it in a tar or raw image. They | |
146 | take the machine name to export as first parameter, followed by a file descriptor (opened for writing) | |
147 | where the tar or raw file will be written. It may either reference a file on disk or a pipe/socket. The | |
148 | third argument specifies in which compression format to write the image. It takes one of | |
149 | <literal>uncompressed</literal>, <literal>xz</literal>, <literal>bzip2</literal> or | |
150 | <literal>gzip</literal>, depending on which compression scheme is required. The image written to the | |
151 | specified file descriptor will be a tar file in case of <function>ExportTar()</function> or a raw disk | |
152 | image in case of <function>ExportRaw()</function>. Note that currently raw disk images may not be | |
153 | exported as tar files, and vice versa, however this restriction might be lifted eventually. The call | |
154 | returns a transfer identifier and object path for canceling or tracking the export operation, similar | |
155 | to <function>ImportTar()</function> or <function>ImportRaw()</function> described above.</para> | |
156 | ||
157 | <para><function>PullTar()</function> and <function>PullRaw()</function> may be used to download, verify | |
158 | and import a system image from a web site. They take an URL argument, that should reference a tar or | |
159 | raw file on the <literal>http://</literal> or <literal>https://</literal> protocols, possibly | |
160 | compressed with xz, bzip2 or gzip. The second argument is a local name for the image. It should be | |
161 | suitable as hostname, similar to the matching argument of the <function>ImportTar()</function> and | |
162 | <function>ImportRaw()</function> calls above. The third argument indicates the verification mode for | |
163 | the image. It may be one of <literal>no</literal>, <literal>checksum</literal>, | |
164 | <literal>signature</literal>. <literal>no</literal> turns of any kind of verification of the image; | |
165 | <literal>checksum</literal> looks for a <filename>SHA256SUM</filename> file next to the downloaded | |
166 | image, and verifies any SHA256 hash value in that file again the image; <literal>signature</literal> | |
167 | does the same but also tries to authenticate the <filename>SHA256SUM</filename> file via | |
168 | <citerefentry project="man-pages"><refentrytitle>gpg</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
169 | first. The last argument indicates whether to replace a possibly pre-existing image with the same local | |
170 | name (if <literal>true</literal>), or whether to fail (if <literal>false</literal>). Like the import | |
171 | and export calls above these calls return a pair of transfer identifier and object path for the ongoing | |
172 | download.</para> | |
173 | ||
174 | <para><function>ListTransfers()</function> returns a list of ongoing import, export or download | |
175 | operations, as created with the six calls described above. It returns an array of structures, which | |
176 | consist of the numeric transfer identifier, a string indicating the operation (one of | |
177 | <literal>import-tar</literal>, <literal>import-raw</literal>, <literal>export-tar</literal>, | |
178 | <literal>export-raw</literal>, <literal>pull-tar</literal> or <literal>pull-raw</literal>), a string | |
179 | describing the remote file (in case of download operations this is the source URL, in case of | |
180 | import/export operations this is a short string describing the file descriptor passed in), a string | |
181 | with the local machine image name, a progress value between 0.0 (for 0%) and 1.0 (for 100%), as well as | |
182 | the transfer object path.</para> | |
183 | ||
184 | <para><function>CancelTransfer()</function> may be used to cancel an ongoing import, export or download | |
185 | operation. Simply specify the transfer identifier to cancel.</para> | |
186 | </refsect2> | |
187 | ||
188 | <refsect2> | |
189 | <title>Signals</title> | |
190 | ||
191 | <para>The <function>TransferNew</function> signal is generated each time a new transfer is added with | |
192 | the import, export or download calls described above. It carries the transfer ID and object path just | |
193 | created.</para> | |
194 | ||
195 | <para>The <function>TransferRemoved</function> signal is sent each time a transfer was completed, | |
196 | canceled or failed. It also carries the transfer ID and object path, followed by a string indicating | |
197 | the result of the operation, which is one of <literal>done</literal> (on success), | |
198 | <literal>canceled</literal> or <literal>failed</literal>.</para> | |
199 | </refsect2> | |
200 | </refsect1> | |
201 | ||
202 | <refsect1> | |
203 | <title>The Transfer Object</title> | |
204 | ||
205 | <programlisting> | |
206 | $ gdbus introspect --system \ | |
207 | --dest org.freedesktop.import1 \ | |
208 | --object-path /org/freedesktop/import1/transfer/_1 | |
209 | ||
210 | node /org/freedesktop/import1/transfer/_1 { | |
211 | interface org.freedesktop.import1.Transfer { | |
212 | methods: | |
213 | Cancel(); | |
214 | signals: | |
215 | LogMessage(u priority, | |
216 | s line); | |
217 | properties: | |
218 | readonly u Id = 1; | |
219 | readonly s Local = 'xenial-server-cloudimg-amd64-root'; | |
220 | readonly s Remote = 'https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-root.tar.gz'; | |
221 | readonly s Type = 'pull-tar'; | |
222 | readonly s Verify = 'signature'; | |
223 | readonly d Progress = 0.253; | |
224 | }; | |
225 | interface org.freedesktop.DBus.Peer { | |
226 | }; | |
227 | interface org.freedesktop.DBus.Introspectable { | |
228 | }; | |
229 | interface org.freedesktop.DBus.Properties { | |
230 | }; | |
231 | }; | |
232 | </programlisting> | |
233 | ||
234 | <refsect2> | |
235 | <title>Methods</title> | |
236 | ||
237 | <para>The <function>Cancel()</function> method may be used to cancel the transfer. It takes no | |
238 | parameters. This call is pretty much equivalent to the <function>CancelTransfer()</function> call on | |
239 | the <structname>Manager</structname> interface (see above), but is exposed on the | |
240 | <structname>Transfer</structname> object itself instead of taking a transfer ID.</para> | |
241 | </refsect2> | |
242 | ||
243 | <refsect2> | |
244 | <title>Properties</title> | |
245 | ||
246 | <para>The <varname>Id</varname> property exposes the numeric transfer ID of the transfer object.</para> | |
247 | ||
248 | <para>The <varname>Local</varname>, <varname>Remote</varname>, <varname>Type</varname> properties | |
249 | expose the local container name of this transfer, the remote source (in case of download: the URL, in | |
250 | case of import/export a string describing the file descriptor passed in), and the type of operation | |
251 | (see the Manager's <function>ListTransfer()</function> call above for an explanation of the possible | |
252 | values).</para> | |
253 | ||
254 | <para>The <varname>Verify</varname> property exposes the selected verification setting, and is only | |
255 | defined for download operations (see above).</para> | |
256 | ||
257 | <para>The <varname>Progress</varname> property exposes the current progress of the transfer, as a value | |
258 | between 0.0 and 1.0. To show a progress bar on screen it recommend to query this value in regular | |
259 | intervals, for example every 500 ms or so.</para> | |
260 | </refsect2> | |
261 | </refsect1> | |
262 | ||
263 | <refsect1> | |
264 | <title>Versioning</title> | |
265 | ||
266 | <para>These D-Bus interfaces follow <ulink url="http://0pointer.de/blog/projects/versioning-dbus.html"> | |
267 | the usual interface versioning guidelines</ulink>.</para> | |
268 | </refsect1> | |
269 | </refentry> |