From 9268cd50edcedcd9adf9da19f7e39ec01d62d452 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 25 Jan 2018 22:33:52 +0000 Subject: [PATCH] trivial: Move __init__ function Tradition dictates this should come earlier than it does. Change-Id: I3158e82910ccab5bbed8e67d589d095feb82208e --- nova/pci/whitelist.py | 48 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/nova/pci/whitelist.py b/nova/pci/whitelist.py index 7133c4a38ca8..7266a57af8f0 100644 --- a/nova/pci/whitelist.py +++ b/nova/pci/whitelist.py @@ -25,15 +25,33 @@ CONF = nova.conf.CONF class Whitelist(object): - """White list class to represent assignable pci devices. - Not all devices on a compute node can be assigned to a guest. The - cloud administrator decides which devices can be assigned - based on vendor_id or product_id, etc. If no white list is specified, - no devices will be assignable. + Not all devices on a compute node can be assigned to a guest. The cloud + administrator decides which devices can be assigned based on ``vendor_id`` + or ``product_id``, etc. If no white list is specified, no devices will be + assignable. """ + def __init__(self, whitelist_spec=None): + """White list constructor + + For example, the following json string specifies that devices whose + vendor_id is '8086' and product_id is '1520' can be assigned + to guests. :: + + '[{"product_id":"1520", "vendor_id":"8086"}]' + + :param whitelist_spec: A JSON string for a dictionary or list thereof. + Each dictionary specifies the pci device properties requirement. + See the definition of ``passthrough_whitelist`` in + ``nova.conf.pci`` for details and examples. + """ + if whitelist_spec: + self.specs = self._parse_white_list_from_config(whitelist_spec) + else: + self.specs = [] + @staticmethod def _parse_white_list_from_config(whitelists): """Parse and validate the pci whitelist from the nova config.""" @@ -62,26 +80,6 @@ class Whitelist(object): return specs - def __init__(self, whitelist_spec=None): - """White list constructor - - For example, the following json string specifies that devices whose - vendor_id is '8086' and product_id is '1520' can be assigned - to guests. - '[{"product_id":"1520", "vendor_id":"8086"}]' - - :param whitelist_spec: A json string for a dictionary or list thereof. - Each dictionary specifies the pci device - properties requirement. See the definition of - passthrough_whitelist in nova.conf.pci for - details and examples. - """ - super(Whitelist, self).__init__() - if whitelist_spec: - self.specs = self._parse_white_list_from_config(whitelist_spec) - else: - self.specs = [] - def device_assignable(self, dev): """Check if a device can be assigned to a guest.