whitespace fixes for nova/utils.py
This commit is contained in:
parent
94518726fb
commit
3b594c7cd3
|
@ -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.
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue