summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-14 12:00:23 +0000
committerGerrit Code Review <review@openstack.org>2013-05-14 12:00:23 +0000
commit75af47a596b47674deec3867d81fabbea243d2a0 (patch)
tree8cd4f3a627512e8feaeee4d30753340c82212d1c /nova/virt
parent874e8203fab39fee955a5a3cc468a77a02049a62 (diff)
parent3c36cbdbc83c1fe1e83fb0733101f84a7a61a0f7 (diff)
Merge "Hide lock_prefix argument using synchronized_with_prefix()"
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/firewall.py6
-rw-r--r--nova/virt/hyperv/imagecache.py9
-rwxr-xr-xnova/virt/libvirt/imagebackend.py13
-rw-r--r--nova/virt/libvirt/imagecache.py10
-rw-r--r--nova/virt/libvirt/volume.py9
-rw-r--r--nova/virt/storage_users.py6
6 files changed, 22 insertions, 31 deletions
diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py
index b61b57cfb..cf290dd10 100644
--- a/nova/virt/firewall.py
+++ b/nova/virt/firewall.py
@@ -24,8 +24,8 @@ from nova import context
from nova import network
from nova.network import linux_net
from nova.openstack.common import importutils
-from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
+from nova import utils
from nova.virt import netutils
LOG = logging.getLogger(__name__)
@@ -453,7 +453,7 @@ class IptablesFirewallDriver(FirewallDriver):
self.do_refresh_instance_rules(instance)
self.iptables.apply()
- @lockutils.synchronized('iptables', 'nova-', external=True)
+ @utils.synchronized('iptables', external=True)
def _inner_do_refresh_rules(self, instance, ipv4_rules,
ipv6_rules):
self.remove_filters_for_instance(instance)
@@ -476,7 +476,7 @@ class IptablesFirewallDriver(FirewallDriver):
self._do_refresh_provider_fw_rules()
self.iptables.apply()
- @lockutils.synchronized('iptables', 'nova-', external=True)
+ @utils.synchronized('iptables', external=True)
def _do_refresh_provider_fw_rules(self):
"""Internal, synchronized version of refresh_provider_fw_rules."""
self._purge_provider_fw_rules()
diff --git a/nova/virt/hyperv/imagecache.py b/nova/virt/hyperv/imagecache.py
index 2e28dc9db..85588a769 100644
--- a/nova/virt/hyperv/imagecache.py
+++ b/nova/virt/hyperv/imagecache.py
@@ -19,15 +19,16 @@ Image caching and management.
"""
import os
+from oslo.config import cfg
+
from nova.compute import flavors
from nova.openstack.common import excutils
-from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
+from nova import utils
from nova.virt.hyperv import pathutils
from nova.virt.hyperv import vhdutils
from nova.virt.hyperv import vmutils
from nova.virt import images
-from oslo.config import cfg
LOG = logging.getLogger(__name__)
@@ -76,7 +77,7 @@ class ImageCache(object):
root_vhd_size_gb,
path_parts[1])
- @lockutils.synchronized(resized_vhd_path, 'nova-')
+ @utils.synchronized(resized_vhd_path)
def copy_and_resize_vhd():
if not self._pathutils.exists(resized_vhd_path):
try:
@@ -101,7 +102,7 @@ class ImageCache(object):
base_vhd_dir = self._pathutils.get_base_vhd_dir()
vhd_path = os.path.join(base_vhd_dir, image_id + ".vhd")
- @lockutils.synchronized(vhd_path, 'nova-')
+ @utils.synchronized(vhd_path)
def fetch_image_if_not_existing():
if not self._pathutils.exists(vhd_path):
try:
diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
index 2ca71cc62..84686a82a 100755
--- a/nova/virt/libvirt/imagebackend.py
+++ b/nova/virt/libvirt/imagebackend.py
@@ -24,7 +24,6 @@ from oslo.config import cfg
from nova import exception
from nova.openstack.common import excutils
from nova.openstack.common import fileutils
-from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.disk import api as disk
@@ -139,8 +138,7 @@ class Image(object):
:filename: Name of the file in the image directory
:size: Size of created image in bytes (optional)
"""
- @lockutils.synchronized(filename, 'nova-', external=True,
- lock_path=self.lock_path)
+ @utils.synchronized(filename, external=True, lock_path=self.lock_path)
def call_if_not_exists(target, *args, **kwargs):
if not os.path.exists(target):
fetch_func(target=target, *args, **kwargs)
@@ -204,8 +202,7 @@ class Raw(Image):
self.driver_format = data.file_format or 'raw'
def create_image(self, prepare_template, base, size, *args, **kwargs):
- @lockutils.synchronized(base, 'nova-', external=True,
- lock_path=self.lock_path)
+ @utils.synchronized(base, external=True, lock_path=self.lock_path)
def copy_raw_image(base, target, size):
libvirt_utils.copy_image(base, target)
if size:
@@ -244,8 +241,7 @@ class Qcow2(Image):
self.preallocate = CONF.preallocate_images != 'none'
def create_image(self, prepare_template, base, size, *args, **kwargs):
- @lockutils.synchronized(base, 'nova-', external=True,
- lock_path=self.lock_path)
+ @utils.synchronized(base, external=True, lock_path=self.lock_path)
def copy_qcow2_image(base, target, size):
# TODO(pbrady): Consider copying the cow image here
# with preallocation=metadata set for performance reasons.
@@ -317,8 +313,7 @@ class Lvm(Image):
return False
def create_image(self, prepare_template, base, size, *args, **kwargs):
- @lockutils.synchronized(base, 'nova-', external=True,
- lock_path=self.lock_path)
+ @utils.synchronized(base, external=True, lock_path=self.lock_path)
def create_lvm_image(base, size):
base_size = disk.get_disk_size(base)
resize = size > base_size
diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py
index 8d1f71a96..0ef32a21d 100644
--- a/nova/virt/libvirt/imagecache.py
+++ b/nova/virt/libvirt/imagecache.py
@@ -34,7 +34,6 @@ from nova.compute import task_states
from nova.compute import vm_states
from nova.openstack.common import fileutils
from nova.openstack.common import jsonutils
-from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova import utils
from nova.virt.libvirt import utils as virtutils
@@ -174,8 +173,7 @@ def read_stored_info(target, field=None, timestamped=False):
lock_name = 'info-%s' % os.path.split(target)[-1]
lock_path = os.path.join(CONF.instances_path, 'locks')
- @lockutils.synchronized(lock_name, 'nova-', external=True,
- lock_path=lock_path)
+ @utils.synchronized(lock_name, external=True, lock_path=lock_path)
def read_file(info_file):
LOG.debug(_('Reading image info file: %s'), info_file)
with open(info_file, 'r') as f:
@@ -205,8 +203,7 @@ def write_stored_info(target, field=None, value=None):
lock_name = 'info-%s' % os.path.split(target)[-1]
lock_path = os.path.join(CONF.instances_path, 'locks')
- @lockutils.synchronized(lock_name, 'nova-', external=True,
- lock_path=lock_path)
+ @utils.synchronized(lock_name, external=True, lock_path=lock_path)
def write_file(info_file, field, value):
d = {}
@@ -399,8 +396,7 @@ class ImageCacheManager(object):
# Protect against other nova-computes performing checksums at the same
# time if we are using shared storage
- @lockutils.synchronized(lock_name, 'nova-', external=True,
- lock_path=self.lock_path)
+ @utils.synchronized(lock_name, external=True, lock_path=self.lock_path)
def inner_verify_checksum():
(stored_checksum, stored_timestamp) = read_stored_checksum(
base_file, timestamped=True)
diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py
index 5f8d4bd72..eee25a52b 100644
--- a/nova/virt/libvirt/volume.py
+++ b/nova/virt/libvirt/volume.py
@@ -27,7 +27,6 @@ import urlparse
from oslo.config import cfg
from nova import exception
-from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova.openstack.common import loopingcall
from nova.openstack.common import processutils
@@ -192,7 +191,7 @@ class LibvirtISCSIVolumeDriver(LibvirtBaseVolumeDriver):
def _get_target_portals_from_iscsiadm_output(self, output):
return [line.split()[0] for line in output.splitlines()]
- @lockutils.synchronized('connect_volume', 'nova-')
+ @utils.synchronized('connect_volume')
def connect_volume(self, connection_info, disk_info):
"""Attach the volume to instance_name."""
conf = super(LibvirtISCSIVolumeDriver,
@@ -266,7 +265,7 @@ class LibvirtISCSIVolumeDriver(LibvirtBaseVolumeDriver):
conf.source_path = host_device
return conf
- @lockutils.synchronized('connect_volume', 'nova-')
+ @utils.synchronized('connect_volume')
def disconnect_volume(self, connection_info, disk_dev):
"""Detach the volume from instance_name."""
super(LibvirtISCSIVolumeDriver,
@@ -654,7 +653,7 @@ class LibvirtFibreChannelVolumeDriver(LibvirtBaseVolumeDriver):
return pci_num
- @lockutils.synchronized('connect_volume', 'nova-')
+ @utils.synchronized('connect_volume')
def connect_volume(self, connection_info, disk_info):
"""Attach the volume to instance_name."""
fc_properties = connection_info['data']
@@ -750,7 +749,7 @@ class LibvirtFibreChannelVolumeDriver(LibvirtBaseVolumeDriver):
conf.source_path = device_path
return conf
- @lockutils.synchronized('connect_volume', 'nova-')
+ @utils.synchronized('connect_volume')
def disconnect_volume(self, connection_info, mount_device):
"""Detach the volume from instance_name."""
super(LibvirtFibreChannelVolumeDriver,
diff --git a/nova/virt/storage_users.py b/nova/virt/storage_users.py
index 6555609a4..8e56a1c6c 100644
--- a/nova/virt/storage_users.py
+++ b/nova/virt/storage_users.py
@@ -19,13 +19,13 @@ import json
import os
import time
-from nova.openstack.common import lockutils
+from nova import utils
TWENTY_FOUR_HOURS = 3600 * 24
-@lockutils.synchronized('storage-registry-lock', 'nova-', external=True)
+@utils.synchronized('storage-registry-lock', external=True)
def register_storage_use(storage_path, hostname):
"""Idenfity the id of this instance storage."""
@@ -45,7 +45,7 @@ def register_storage_use(storage_path, hostname):
f.write(json.dumps(d))
-@lockutils.synchronized('storage-registry-lock', 'nova-', external=True)
+@utils.synchronized('storage-registry-lock', external=True)
def get_storage_users(storage_path):
"""Get a list of all the users of this storage path."""