@@ -31,6 +31,17 @@ class is implemented by an extension.
31
31
:py:class:`str`.
32
32
"""
33
33
34
+ # TODO:
35
+ # Proposed device events:
36
+ # - device-list-changed: device-added
37
+ # - device-list-changed: device-remove
38
+ # - device-property-changed: property_name
39
+ # - device-assignment-changed: created
40
+ # - device-assignment-changed: removed
41
+ # - device-assignment-changed: attached
42
+ # - device-assignment-changed: detached
43
+ # - device-assignment-changed: property-set [? this is not great]
44
+
34
45
35
46
class DeviceAssignment (object ): # pylint: disable=too-few-public-methods
36
47
""" Maps a device to a frontend_domain. """
@@ -73,6 +84,54 @@ def device(self):
73
84
"""Get DeviceInfo object corresponding to this DeviceAssignment"""
74
85
return self .backend_domain .devices [self .devclass ][self .ident ]
75
86
87
+ #### NEW API
88
+ @property
89
+ def backend_domain (self ):
90
+ """
91
+ Which domain provides this device
92
+ :return: VM
93
+ """
94
+
95
+ @property
96
+ def frontend_domain (self ):
97
+ """
98
+ Which domain the device is attached to.
99
+ :return:
100
+ """
101
+
102
+ @property
103
+ def device_id (self ):
104
+ """
105
+ Per-backend-qube unique device identifier
106
+ :return: str
107
+ """
108
+
109
+ @property
110
+ def required (self ):
111
+ """
112
+ Is the presence of this device required for the domain to start? If yes,
113
+ it will be attached automatically.
114
+ TODO: this possibly should not be available for usb device? or always False?
115
+ TODO: this is a reworking of the previously existing "persistent" attachment, split in two option
116
+ :return: bool
117
+ """
118
+
119
+ @property
120
+ def attach_automatically (self ):
121
+ """
122
+ Should this device automatically connect to the frontend domain when
123
+ available and not connected to other qubes?
124
+ TODO: this possibly should not be available for usb device? or always False?
125
+ TODO: this is a reworking of the previously existing "persistent" attachment, split in two option
126
+ :return: bool
127
+ """
128
+
129
+ @property
130
+ def options (self ):
131
+ """
132
+ Device options (same as in the old API)5
133
+ :return: Dict[str, Any]
134
+ """
76
135
77
136
class DeviceInfo (object ):
78
137
""" Holds all information about a device """
@@ -106,6 +165,72 @@ def __eq__(self, other):
106
165
def __str__ (self ):
107
166
return '{!s}:{!s}' .format (self .backend_domain , self .ident )
108
167
168
+ ### NEW API
169
+ @property
170
+ def manufacturer (self ):
171
+ """
172
+ Device manufacturer
173
+ :return: str
174
+ """
175
+
176
+ @property
177
+ def name (self ):
178
+ """
179
+ Device name
180
+ :return: str
181
+ """
182
+
183
+ @property
184
+ def devtype (self ):
185
+ """
186
+ Type of device, such as "USB Camera", "USB Keyboard", "Microphone" etc.
187
+ :return: str
188
+ """
189
+ # TODO: perhaps this should be an Enum of possible types?
190
+
191
+ @property
192
+ def devclass (self ):
193
+ """
194
+ Device class, for compatibility with previous API:
195
+ :return: str, one of 'usb', 'pci', 'mic'
196
+ """
197
+
198
+ @property
199
+ def id (self ):
200
+ """
201
+ Device id (unique per backend qube)
202
+ :return: str
203
+ """
204
+
205
+ @property
206
+ def parent_device (self ):
207
+ """
208
+ If the device is part of another device (e.g. it's a single
209
+ partition of a usb stick), the parent device id should be here
210
+ :return: Optional[str]
211
+ """
212
+
213
+ @property
214
+ def backend_domain (self ):
215
+ """
216
+ Which domain provides this device.
217
+ :return: VM
218
+ """
219
+
220
+ @property
221
+ def port_id (self ):
222
+ """
223
+ Which port the device is connected to.
224
+ :return: str
225
+ """
226
+
227
+ @property
228
+ def attachments (self ):
229
+ """
230
+ Device attachments
231
+ :return: List[DeviceAssignment]
232
+ """
233
+
109
234
110
235
class UnknownDevice (DeviceInfo ):
111
236
# pylint: disable=too-few-public-methods
0 commit comments