diff options
author | Mark Washenberger <mark.washenberger@rackspace.com> | 2011-03-09 16:32:06 -0500 |
---|---|---|
committer | Mark Washenberger <mark.washenberger@rackspace.com> | 2011-03-09 16:32:06 -0500 |
commit | 95d25ba3f4cd3345355922018295f3789d5ddb7c (patch) | |
tree | 83c37b89d96150fd7d7bc04459b5e3b62986f1ad /nova/utils.py | |
parent | 82c4d6309909d6508df0944683ce4d3d7341de10 (diff) | |
parent | 5662a822a013bd0d159c15b990231c4d1f12797f (diff) | |
download | nova-95d25ba3f4cd3345355922018295f3789d5ddb7c.tar.gz nova-95d25ba3f4cd3345355922018295f3789d5ddb7c.tar.xz nova-95d25ba3f4cd3345355922018295f3789d5ddb7c.zip |
merge lp:nova and resolve conflicts
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/nova/utils.py b/nova/utils.py index 02b71900c..3007bf19d 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -23,10 +23,14 @@ System-level utilities and helper functions. import base64 import datetime +import functools import inspect import json +import lockfile +import netaddr import os import random +import re import socket import string import struct @@ -34,8 +38,6 @@ import sys import time import types from xml.sax import saxutils -import re -import netaddr from eventlet import event from eventlet import greenthread @@ -43,11 +45,13 @@ from eventlet.green import subprocess from nova import exception from nova.exception import ProcessExecutionError +from nova import flags from nova import log as logging LOG = logging.getLogger("nova.utils") TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" +FLAGS = flags.FLAGS def import_class(import_str): @@ -491,6 +495,18 @@ def loads(s): return json.loads(s) +def synchronized(name): + def wrap(f): + @functools.wraps(f) + def inner(*args, **kwargs): + lock = lockfile.FileLock(os.path.join(FLAGS.lock_path, + 'nova-%s.lock' % name)) + with lock: + return f(*args, **kwargs) + return inner + return wrap + + def get_from_path(items, path): """ Returns a list of items matching the specified path. Takes an XPath-like expression e.g. prop1/prop2/prop3, and for each item in items, |