diff options
| author | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-08-17 17:58:52 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-08-17 17:58:52 -0700 |
| commit | cdcbd516f62290697643eecc56550460bd48ff14 (patch) | |
| tree | 798d4da90b8025b041a3f2b5efe86f3e33e8ef53 /nova/utils.py | |
| parent | 1cd448f907e132c451d6b27c64d16c17b7530952 (diff) | |
| parent | 018ce9abbfb7047eff1e99379fba098a365e89eb (diff) | |
| download | nova-cdcbd516f62290697643eecc56550460bd48ff14.tar.gz nova-cdcbd516f62290697643eecc56550460bd48ff14.tar.xz nova-cdcbd516f62290697643eecc56550460bd48ff14.zip | |
merged trunk
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/nova/utils.py b/nova/utils.py index 63db080f1..e826f9b71 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -20,7 +20,7 @@ System-level utilities and helper functions. """ -from datetime import datetime, timedelta +import datetime import inspect import logging import os @@ -32,9 +32,11 @@ import sys from nova import exception from nova import flags + FLAGS = flags.FLAGS TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" + def import_class(import_str): """Returns a class from a string including module and class""" mod_str, _sep, class_str = import_str.rpartition('.') @@ -44,6 +46,7 @@ def import_class(import_str): except (ImportError, ValueError, AttributeError): raise exception.NotFound('Class %s cannot be found' % class_str) + def fetchfile(url, target): logging.debug("Fetching %s" % url) # c = pycurl.Curl() @@ -55,6 +58,7 @@ def fetchfile(url, target): # fp.close() execute("curl %s -o %s" % (url, target)) + def execute(cmd, input=None, addl_env=None): env = os.environ.copy() if addl_env: @@ -129,10 +133,12 @@ def get_my_ip(): logging.warn("Couldn't get IP, using 127.0.0.1 %s", ex) return "127.0.0.1" + def isotime(at=None): if not at: - at = datetime.utcnow() + at = datetime.datetime.utcnow() return at.strftime(TIME_FORMAT) + def parse_isotime(timestr): - return datetime.strptime(timestr, TIME_FORMAT) + return datetime.datetime.strptime(timestr, TIME_FORMAT) |
