From 3b594c7cd3c8054ca3b210198162d895aacee179 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jun 2010 18:39:07 +0100 Subject: [PATCH] whitespace fixes for nova/utils.py --- nova/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nova/utils.py b/nova/utils.py index 0cfa2cf6c7..6f0d848001 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -25,6 +25,11 @@ import inspect import subprocess import random +from nova import flags + +FLAGS = flags.FLAGS + + def fetchfile(url, target): logging.debug("Fetching %s" % url) # c = pycurl.Curl() @@ -36,6 +41,7 @@ def fetchfile(url, target): # fp.close() execute("curl %s -o %s" % (url, target)) + def execute(cmd, input=None): #logging.debug("Running %s" % (cmd)) obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, @@ -50,9 +56,11 @@ def execute(cmd, input=None): logging.debug("Result was %s" % (obj.returncode)) return result + def abspath(s): return os.path.join(os.path.dirname(__file__), s) + def default_flagfile(filename='nova.conf'): for arg in sys.argv: if arg.find('flagfile') != -1: @@ -65,10 +73,12 @@ def default_flagfile(filename='nova.conf'): if os.path.exists(filename): sys.argv = sys.argv[:1] + ['--flagfile=%s' % filename] + sys.argv[1:] + def debug(arg): logging.debug('debug in callback: %s', arg) return arg + def runthis(prompt, cmd): logging.debug("Running %s" % (cmd)) logging.debug(prompt % (subprocess.call(cmd.split(" ")))) @@ -77,15 +87,18 @@ def runthis(prompt, cmd): def generate_uid(topic, size=8): return '%s-%s' % (topic, ''.join([random.choice('01234567890abcdefghijklmnopqrstuvwxyz') for x in xrange(size)])) + def generate_mac(): mac = [0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) + def last_octet(address): return int(address.split(".")[-1]) + def get_my_ip(): ''' returns the actual ip of the local machine. '''