[node-patches] Change in ovirt-node[master]: installer: Improve storage loading time
rbarry at redhat.com
rbarry at redhat.com
Thu Dec 12 16:47:36 UTC 2013
Hello Fabian Deutsch,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/22355
to review the following change.
Change subject: installer: Improve storage loading time
......................................................................
installer: Improve storage loading time
Previously a time consuming function was called several times. This is
now still the case, but we cache the not-expected-to-change value.
Change-Id: Iee46ffac3586d1e5f998aabddf03f4afde19f4c9
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1041213
Signed-off-by: Fabian Deutsch <fabiand at redhat.com>
---
M src/ovirt/node/installer/core/boot_device_page.py
M src/ovirt/node/utils/storage.py
2 files changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/55/22355/1
diff --git a/src/ovirt/node/installer/core/boot_device_page.py b/src/ovirt/node/installer/core/boot_device_page.py
index 76cde7c..246207d 100644
--- a/src/ovirt/node/installer/core/boot_device_page.py
+++ b/src/ovirt/node/installer/core/boot_device_page.py
@@ -140,7 +140,7 @@
self.do_fake = do_fake
def run(self):
- devices = utils.storage.Devices(fake=self.do_fake)
+ self.devices = utils.storage.Devices(fake=self.do_fake)
self._all_devices = devices.get_all()
def all_devices(self):
diff --git a/src/ovirt/node/utils/storage.py b/src/ovirt/node/utils/storage.py
index 8958b70..51b98d3 100644
--- a/src/ovirt/node/utils/storage.py
+++ b/src/ovirt/node/utils/storage.py
@@ -80,6 +80,7 @@
"""A class to retrieve available storage devices
"""
_fake_devices = None
+ _cached_live_disk_name = None
def __init__(self, fake=False):
super(Devices, self).__init__()
@@ -95,12 +96,18 @@
def live_disk_name(self):
"""get the device name of the live-media we are booting from
+ BEWARE: Because querying this is so expensive we cache this result
+ Assumption: Live disk name does not change
"""
+ if self._cached_live_disk_name:
+ return self._cached_live_disk_name
+
from ovirtnode.ovirtfunctions import get_live_disk
name = get_live_disk()
if not "/dev/mapper" in name:
# FIXME explain ...
name = "/dev/%s" % name.rstrip('0123456789')
+ self._cached_live_disk_name = name
return name
def get_all(self):
--
To view, visit http://gerrit.ovirt.org/22355
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee46ffac3586d1e5f998aabddf03f4afde19f4c9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list