__init__.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. #
  2. # The Qubes OS Project, https://www.qubes-os.org/
  3. #
  4. # Copyright (C) 2010-2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  5. # Copyright (C) 2011-2015 Marek Marczykowski-Górecki
  6. # <marmarek@invisiblethingslab.com>
  7. # Copyright (C) 2014-2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  8. #
  9. # This library is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU Lesser General Public
  11. # License as published by the Free Software Foundation; either
  12. # version 2.1 of the License, or (at your option) any later version.
  13. #
  14. # This library is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # Lesser General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Lesser General Public
  20. # License along with this library; if not, see <https://www.gnu.org/licenses/>.
  21. #
  22. '''
  23. Qubes OS
  24. :copyright: © 2010-2015 Invisible Things Lab
  25. '''
  26. import builtins
  27. import collections
  28. import os
  29. import os.path
  30. import string
  31. import lxml.etree
  32. import qubes.config
  33. import qubes.events
  34. import qubes.exc
  35. __author__ = 'Invisible Things Lab'
  36. __license__ = 'GPLv2 or later'
  37. __version__ = 'R3'
  38. class Label:
  39. '''Label definition for virtual machines
  40. Label specifies colour of the padlock displayed next to VM's name.
  41. When this is a :py:class:`qubes.vm.dispvm.DispVM`, padlock is overlayed
  42. with recycling pictogram.
  43. :param int index: numeric identificator of label
  44. :param str color: colour specification as in HTML (``#abcdef``)
  45. :param str name: label's name like "red" or "green"
  46. '''
  47. def __init__(self, index, color, name):
  48. #: numeric identificator of label
  49. self.index = index
  50. #: colour specification as in HTML (``#abcdef``)
  51. self.color = color
  52. #: label's name like "red" or "green"
  53. self.name = name
  54. #: freedesktop icon name, suitable for use in
  55. #: :py:meth:`PyQt4.QtGui.QIcon.fromTheme`
  56. self.icon = 'appvm-' + name
  57. #: freedesktop icon name, suitable for use in
  58. #: :py:meth:`PyQt4.QtGui.QIcon.fromTheme` on DispVMs
  59. self.icon_dispvm = 'dispvm-' + name
  60. @classmethod
  61. def fromxml(cls, xml):
  62. '''Create label definition from XML node
  63. :param lxml.etree._Element xml: XML node reference
  64. :rtype: :py:class:`qubes.Label`
  65. '''
  66. index = int(xml.get('id').split('-', 1)[1])
  67. color = xml.get('color')
  68. name = xml.text
  69. return cls(index, color, name)
  70. def __xml__(self):
  71. element = lxml.etree.Element(
  72. 'label', id='label-{}'.format(self.index), color=self.color)
  73. element.text = self.name
  74. return element
  75. def __str__(self):
  76. return self.name
  77. def __repr__(self):
  78. return '{}({!r}, {!r}, {!r})'.format(
  79. self.__class__.__name__,
  80. self.index,
  81. self.color,
  82. self.name)
  83. def __eq__(self, other):
  84. if isinstance(other, Label):
  85. return self.name == other.name
  86. return NotImplemented
  87. def __hash__(self):
  88. return hash(self.name)
  89. @builtins.property
  90. def icon_path(self):
  91. '''Icon path
  92. .. deprecated:: 2.0
  93. use :py:meth:`PyQt4.QtGui.QIcon.fromTheme` and :py:attr:`icon`
  94. '''
  95. return os.path.join(qubes.config.system_path['qubes_icon_dir'],
  96. self.icon) + ".png"
  97. @builtins.property
  98. def icon_path_dispvm(self):
  99. '''Icon path
  100. .. deprecated:: 2.0
  101. use :py:meth:`PyQt4.QtGui.QIcon.fromTheme` and :py:attr:`icon_dispvm`
  102. '''
  103. return os.path.join(qubes.config.system_path['qubes_icon_dir'],
  104. self.icon_dispvm) + ".png"
  105. class property: # pylint: disable=redefined-builtin,invalid-name
  106. '''Qubes property.
  107. This class holds one property that can be saved to and loaded from
  108. :file:`qubes.xml`. It is used for both global and per-VM properties.
  109. Property can be unset by ordinary ``del`` statement or assigning
  110. :py:attr:`DEFAULT` special value to it. After deletion (or before first
  111. assignment/load) attempting to read a property will get its default value
  112. or, when no default, py:class:`exceptions.AttributeError`.
  113. :param str name: name of the property
  114. :param collections.Callable setter: if not :py:obj:`None`, this is used to \
  115. initialise value; first parameter to the function is holder instance \
  116. and the second is value; this is called before ``type``
  117. :param collections.Callable saver: function to coerce value to something \
  118. readable by setter
  119. :param type type: if not :py:obj:`None`, value is coerced to this type
  120. :param object default: default value; if callable, will be called with \
  121. holder as first argument
  122. :param int load_stage: stage when property should be loaded (see \
  123. :py:class:`Qubes` for description of stages)
  124. :param int order: order of evaluation (bigger order values are later)
  125. :param bool clone: :py:meth:`PropertyHolder.clone_properties` will not \
  126. include this property by default if :py:obj:`False`
  127. :param str doc: docstring; this should be one paragraph of plain RST, no \
  128. sphinx-specific features
  129. Setters and savers have following signatures:
  130. .. :py:function:: setter(self, prop, value)
  131. :noindex:
  132. :param self: instance of object that is holding property
  133. :param prop: property object
  134. :param value: value being assigned
  135. .. :py:function:: saver(self, prop, value)
  136. :noindex:
  137. :param self: instance of object that is holding property
  138. :param prop: property object
  139. :param value: value being saved
  140. :rtype: str
  141. :raises property.DontSave: when property should not be saved at all
  142. '''
  143. #: Assigning this value to property means setting it to its default value.
  144. #: If property has no default value, this will unset it.
  145. DEFAULT = object()
  146. # internal use only
  147. _NO_DEFAULT = object()
  148. def __init__(self, name, setter=None, saver=None, type=None,
  149. default=_NO_DEFAULT, write_once=False, load_stage=2, order=0,
  150. save_via_ref=False, clone=True,
  151. doc=None):
  152. # pylint: disable=redefined-builtin
  153. self.__name__ = name
  154. self._setter = setter
  155. self._saver = saver if saver is not None else (
  156. lambda self, prop, value: str(value))
  157. self.type = type
  158. self._default = default
  159. self._default_function = None
  160. if isinstance(default, collections.Callable):
  161. self._default_function = default
  162. self._write_once = write_once
  163. self.order = order
  164. self.load_stage = load_stage
  165. self.save_via_ref = save_via_ref
  166. self.clone = clone
  167. self.__doc__ = doc
  168. self._attr_name = '_qubesprop_' + name
  169. def __get__(self, instance, owner):
  170. if instance is None:
  171. return self
  172. # XXX this violates duck typing, shall we keep it?
  173. if not isinstance(instance, PropertyHolder):
  174. raise AttributeError('qubes.property should be used on '
  175. 'qubes.PropertyHolder instances only')
  176. try:
  177. return getattr(instance, self._attr_name)
  178. except AttributeError:
  179. return self.get_default(instance)
  180. def get_default(self, instance):
  181. if self._default is self._NO_DEFAULT:
  182. raise AttributeError(
  183. 'property {!r} have no default'.format(self.__name__))
  184. elif self._default_function:
  185. return self._default_function(instance)
  186. else:
  187. return self._default
  188. def __set__(self, instance, value):
  189. self._enforce_write_once(instance)
  190. if value is self.__class__.DEFAULT:
  191. self.__delete__(instance)
  192. return
  193. try:
  194. oldvalue = getattr(instance, self.__name__)
  195. has_oldvalue = True
  196. except AttributeError:
  197. has_oldvalue = False
  198. if self._setter is not None:
  199. value = self._setter(instance, self, value)
  200. if self.type not in (None, type(value)):
  201. value = self.type(value)
  202. if has_oldvalue:
  203. instance.fire_event('property-pre-set:' + self.__name__,
  204. pre_event=True,
  205. name=self.__name__, newvalue=value, oldvalue=oldvalue)
  206. else:
  207. instance.fire_event('property-pre-set:' + self.__name__,
  208. pre_event=True,
  209. name=self.__name__, newvalue=value)
  210. instance._property_init(self, value) # pylint: disable=protected-access
  211. if has_oldvalue:
  212. instance.fire_event('property-set:' + self.__name__,
  213. name=self.__name__, newvalue=value, oldvalue=oldvalue)
  214. else:
  215. instance.fire_event('property-set:' + self.__name__,
  216. name=self.__name__, newvalue=value)
  217. def __delete__(self, instance):
  218. self._enforce_write_once(instance)
  219. try:
  220. oldvalue = getattr(instance, self.__name__)
  221. has_oldvalue = True
  222. except AttributeError:
  223. has_oldvalue = False
  224. if has_oldvalue:
  225. instance.fire_event('property-pre-del:' + self.__name__,
  226. pre_event=True,
  227. name=self.__name__, oldvalue=oldvalue)
  228. try:
  229. delattr(instance, self._attr_name)
  230. except AttributeError:
  231. pass
  232. instance.fire_event('property-del:' + self.__name__,
  233. name=self.__name__, oldvalue=oldvalue)
  234. else:
  235. instance.fire_event('property-pre-del:' + self.__name__,
  236. pre_event=True,
  237. name=self.__name__)
  238. instance.fire_event('property-del:' + self.__name__,
  239. name=self.__name__)
  240. def __repr__(self):
  241. default = ' default={!r}'.format(self._default) \
  242. if self._default is not self._NO_DEFAULT \
  243. else ''
  244. return '<{} object at {:#x} name={!r}{}>'.format(
  245. self.__class__.__name__, id(self), self.__name__, default)
  246. def __str__(self):
  247. return self.__name__
  248. def __hash__(self):
  249. return hash(self.__name__)
  250. def __lt__(self, other):
  251. if isinstance(other, property):
  252. return (self.load_stage, self.order, self.__name__) <\
  253. (other.load_stage, other.order, other.__name__)
  254. return NotImplemented
  255. def __eq__(self, other):
  256. if isinstance(other, str):
  257. return self.__name__ == other
  258. return isinstance(other, property) and self.__name__ == other.__name__
  259. def _enforce_write_once(self, instance):
  260. if self._write_once and not instance.property_is_default(self):
  261. raise AttributeError(
  262. 'property {!r} is write-once and already set'.format(
  263. self.__name__))
  264. def sanitize(self, *, untrusted_newvalue):
  265. '''Coarse sanitization of value to be set, before sending it to a
  266. setter. Can raise QubesValueError if the value is invalid.
  267. :param untrusted_newvalue: value to be validated
  268. :return: sanitized value
  269. :raises: qubes.exc.QubesValueError
  270. '''
  271. # do not treat type='str' as sufficient validation
  272. if self.type is not None and self.type is not str:
  273. # assume specific type will preform enough validation
  274. try:
  275. untrusted_newvalue = untrusted_newvalue.decode('ascii',
  276. errors='strict')
  277. except UnicodeDecodeError:
  278. raise qubes.exc.QubesValueError
  279. if self.type is bool:
  280. return self.bool(None, None, untrusted_newvalue)
  281. try:
  282. return self.type(untrusted_newvalue)
  283. except ValueError:
  284. raise qubes.exc.QubesValueError
  285. else:
  286. # 'str' or not specified type
  287. try:
  288. untrusted_newvalue = untrusted_newvalue.decode('ascii',
  289. errors='strict')
  290. except UnicodeDecodeError:
  291. raise qubes.exc.QubesValueError
  292. allowed_set = string.printable
  293. if not all(x in allowed_set for x in untrusted_newvalue):
  294. raise qubes.exc.QubesValueError(
  295. 'Invalid characters in property value')
  296. return untrusted_newvalue
  297. #
  298. # exceptions
  299. #
  300. class DontSave(Exception):
  301. '''This exception may be raised from saver to sign that property should
  302. not be saved.
  303. '''
  304. pass
  305. @staticmethod
  306. def dontsave(self, prop, value):
  307. '''Dummy saver that never saves anything.'''
  308. # pylint: disable=bad-staticmethod-argument,unused-argument
  309. raise property.DontSave()
  310. #
  311. # some setters provided
  312. #
  313. @staticmethod
  314. def forbidden(self, prop, value):
  315. '''Property setter that forbids loading a property.
  316. This is used to effectively disable property in classes which inherit
  317. unwanted property. When someone attempts to load such a property, it
  318. :throws AttributeError: always
  319. ''' # pylint: disable=bad-staticmethod-argument,unused-argument
  320. raise AttributeError(
  321. 'setting {} property on {} instance is forbidden'.format(
  322. prop.__name__, self.__class__.__name__))
  323. @staticmethod
  324. def bool(self, prop, value):
  325. '''Property setter for boolean properties.
  326. It accepts (case-insensitive) ``'0'``, ``'no'`` and ``false`` as
  327. :py:obj:`False` and ``'1'``, ``'yes'`` and ``'true'`` as
  328. :py:obj:`True`.
  329. ''' # pylint: disable=bad-staticmethod-argument,unused-argument
  330. if isinstance(value, str):
  331. lcvalue = value.lower()
  332. if lcvalue in ('0', 'no', 'false', 'off'):
  333. return False
  334. if lcvalue in ('1', 'yes', 'true', 'on'):
  335. return True
  336. raise qubes.exc.QubesValueError(
  337. 'Invalid literal for boolean property: {!r}'.format(value))
  338. return bool(value)
  339. def stateless_property(func):
  340. '''Decorator similar to :py:class:`builtins.property`, but for properties
  341. exposed through management API (including qvm-prefs etc)'''
  342. return property(func.__name__,
  343. setter=property.forbidden,
  344. saver=property.DontSave,
  345. default=func,
  346. doc=func.__doc__)
  347. class PropertyHolder(qubes.events.Emitter):
  348. '''Abstract class for holding :py:class:`qubes.property`
  349. Events fired by instances of this class:
  350. .. event:: property-load (subject, event)
  351. Fired once after all properties are loaded from XML. Individual
  352. ``property-set`` events are not fired.
  353. .. event:: property-set:<propname> \
  354. (subject, event, name, newvalue[, oldvalue])
  355. Fired when property changes state. Signature is variable,
  356. *oldvalue* is present only if there was an old value.
  357. :param name: Property name
  358. :param newvalue: New value of the property
  359. :param oldvalue: Old value of the property
  360. .. event:: property-pre-set:<propname> \
  361. (subject, event, name, newvalue[, oldvalue])
  362. Fired before property changes state. Signature is variable,
  363. *oldvalue* is present only if there was an old value.
  364. :param name: Property name
  365. :param newvalue: New value of the property
  366. :param oldvalue: Old value of the property
  367. .. event:: property-del:<propname> \
  368. (subject, event, name[, oldvalue])
  369. Fired when property gets deleted (is set to default). Signature is
  370. variable, *oldvalue* is present only if there was an old value.
  371. :param name: Property name
  372. :param oldvalue: Old value of the property
  373. .. event:: property-pre-del:<propname> \
  374. (subject, event, name[, oldvalue])
  375. Fired before property gets deleted (is set to default). Signature
  376. is variable, *oldvalue* is present only if there was an old value.
  377. :param name: Property name
  378. :param oldvalue: Old value of the property
  379. .. event:: clone-properties (subject, event, src, proplist)
  380. :param src: object, from which we are cloning
  381. :param proplist: list of properties
  382. Members:
  383. '''
  384. def __init__(self, xml, **kwargs):
  385. self.xml = xml
  386. propvalues = {}
  387. all_names = self.property_dict()
  388. for key in list(kwargs):
  389. if not key in all_names:
  390. continue
  391. propvalues[key] = kwargs.pop(key)
  392. super(PropertyHolder, self).__init__(**kwargs)
  393. for key, value in propvalues.items():
  394. setattr(self, key, value)
  395. if self.xml is not None:
  396. # check if properties are appropriate
  397. for node in self.xml.xpath('./properties/property'):
  398. name = node.get('name')
  399. if name not in all_names:
  400. raise TypeError(
  401. 'property {!r} not applicable to {!r}'.format(
  402. name, self.__class__.__name__))
  403. # pylint: disable=too-many-nested-blocks
  404. @classmethod
  405. def property_dict(cls, load_stage=None):
  406. '''List all properties attached to this VM's class
  407. :param load_stage: Filter by load stage
  408. :type load_stage: :py:func:`int` or :py:obj:`None`
  409. '''
  410. # use cls.__dict__ since we must not look at parent classes
  411. if "_property_dict" not in cls.__dict__:
  412. cls._property_dict = {}
  413. memo = cls._property_dict
  414. if load_stage not in memo:
  415. props = dict()
  416. if load_stage is None:
  417. for class_ in cls.__mro__:
  418. for name in class_.__dict__:
  419. # don't overwrite props with those from base classes
  420. if name not in props:
  421. prop = class_.__dict__[name]
  422. if isinstance(prop, property):
  423. assert name == prop.__name__
  424. props[name] = prop
  425. else:
  426. for prop in cls.property_dict().values():
  427. if prop.load_stage == load_stage:
  428. props[prop.__name__] = prop
  429. memo[load_stage] = props
  430. return memo[load_stage]
  431. @classmethod
  432. def property_list(cls, load_stage=None):
  433. '''List all properties attached to this VM's class
  434. :param load_stage: Filter by load stage
  435. :type load_stage: :py:func:`int` or :py:obj:`None`
  436. '''
  437. # use cls.__dict__ since we must not look at parent classes
  438. if "_property_list" not in cls.__dict__:
  439. cls._property_list = {}
  440. memo = cls._property_list
  441. if load_stage not in memo:
  442. memo[load_stage] = sorted(cls.property_dict(load_stage).values())
  443. return memo[load_stage]
  444. def _property_init(self, prop, value):
  445. '''Initialise property to a given value, without side effects.
  446. :param qubes.property prop: property object of particular interest
  447. :param value: value
  448. '''
  449. # pylint: disable=protected-access
  450. setattr(self, self.property_get_def(prop)._attr_name, value)
  451. def property_is_default(self, prop):
  452. '''Check whether property is in it's default value.
  453. Properties when unset may return some default value, so
  454. ``hasattr(vm, prop.__name__)`` is wrong in some circumstances. This
  455. method allows for checking if the value returned is in fact it's
  456. default value.
  457. :param qubes.property prop: property object of particular interest
  458. :rtype: bool
  459. ''' # pylint: disable=protected-access
  460. # both property_get_def() and ._attr_name may throw AttributeError,
  461. # which we don't want to catch
  462. attrname = self.property_get_def(prop)._attr_name
  463. return not hasattr(self, attrname)
  464. def property_get_default(self, prop):
  465. '''Get property default value.
  466. :param qubes.property or str prop: property object of particular
  467. interest
  468. '''
  469. return self.property_get_def(prop).get_default(self)
  470. @classmethod
  471. def property_get_def(cls, prop):
  472. '''Return property definition object.
  473. If prop is already :py:class:`qubes.property` instance, return the same
  474. object.
  475. :param prop: property object or name
  476. :type prop: qubes.property or str
  477. :rtype: qubes.property
  478. '''
  479. if isinstance(prop, qubes.property):
  480. return prop
  481. props = cls.property_dict()
  482. if prop in props:
  483. return props[prop]
  484. raise AttributeError('No property {!r} found in {!r}'.format(
  485. prop, cls))
  486. def load_properties(self, load_stage=None):
  487. '''Load properties from immediate children of XML node.
  488. ``property-set`` events are not fired for each individual property.
  489. :param int load_stage: Stage of loading.
  490. '''
  491. if self.xml is None:
  492. return
  493. all_names = set(
  494. prop.__name__ for prop in self.property_list(load_stage))
  495. for node in self.xml.xpath('./properties/property'):
  496. name = node.get('name')
  497. value = node.get('ref') or node.text
  498. if not name in all_names:
  499. continue
  500. setattr(self, name, value)
  501. def xml_properties(self, with_defaults=False):
  502. '''Iterator that yields XML nodes representing set properties.
  503. :param bool with_defaults: If :py:obj:`True`, then it also includes \
  504. properties which were not set explicite, but have default values \
  505. filled.
  506. '''
  507. properties = lxml.etree.Element('properties')
  508. for prop in self.property_list():
  509. # pylint: disable=protected-access
  510. try:
  511. value = getattr(
  512. self, (prop.__name__ if with_defaults else prop._attr_name))
  513. except AttributeError:
  514. continue
  515. try:
  516. value = prop._saver(self, prop, value)
  517. except property.DontSave:
  518. continue
  519. element = lxml.etree.Element('property', name=prop.__name__)
  520. if prop.save_via_ref:
  521. element.set('ref', value)
  522. else:
  523. element.text = value
  524. properties.append(element)
  525. return properties
  526. # this was clone_attrs
  527. def clone_properties(self, src, proplist=None):
  528. '''Clone properties from other object.
  529. :param PropertyHolder src: source object
  530. :param iterable proplist: list of properties \
  531. (:py:obj:`None` or omit for all properties except those with \
  532. :py:attr:`property.clone` set to :py:obj:`False`)
  533. '''
  534. if proplist is None:
  535. proplist = [prop for prop in self.property_list()
  536. if prop.clone]
  537. else:
  538. proplist = [prop for prop in self.property_list()
  539. if prop.__name__ in proplist or prop in proplist]
  540. for prop in proplist:
  541. try:
  542. # pylint: disable=protected-access
  543. self._property_init(prop, getattr(src, prop._attr_name))
  544. except AttributeError:
  545. continue
  546. self.fire_event('clone-properties', src=src, proplist=proplist)
  547. def property_require(self, prop, allow_none=False, hard=False):
  548. '''Complain badly when property is not set.
  549. :param prop: property name or object
  550. :type prop: qubes.property or str
  551. :param bool allow_none: if :py:obj:`True`, don't complain if \
  552. :py:obj:`None` is found
  553. :param bool hard: if :py:obj:`True`, raise :py:class:`AssertionError`; \
  554. if :py:obj:`False`, log warning instead
  555. '''
  556. if isinstance(prop, qubes.property):
  557. prop = prop.__name__
  558. try:
  559. value = getattr(self, prop)
  560. if value is None and not allow_none:
  561. raise ValueError('Property {!r} cannot be None'.format(prop))
  562. except AttributeError:
  563. # pylint: disable=no-member
  564. msg = 'Required property {!r} not set on {!r}'.format(prop, self)
  565. if hard:
  566. raise ValueError(msg)
  567. else:
  568. # pylint: disable=no-member
  569. self.log.fatal(msg)
  570. def close(self):
  571. super().close()
  572. # Remove all properties -- somewhere in them there are cyclic
  573. # references. This just removes all the properties, just in case.
  574. # They are removed directly, bypassing write_once.
  575. for prop in self.property_list():
  576. # pylint: disable=protected-access
  577. try:
  578. delattr(self, prop._attr_name)
  579. except AttributeError:
  580. pass
  581. # pylint: disable=wrong-import-position
  582. from qubes.vm import VMProperty
  583. from qubes.app import Qubes
  584. __all__ = [
  585. 'Label',
  586. 'PropertyHolder',
  587. 'Qubes',
  588. 'VMProperty',
  589. 'property',
  590. ]