git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a little nicer
[nodemanager.git]
/
plugins
/
privatebridge.py
diff --git
a/plugins/privatebridge.py
b/plugins/privatebridge.py
index
8e77524
..
9489f69
100644
(file)
--- a/
plugins/privatebridge.py
+++ b/
plugins/privatebridge.py
@@
-1,35
+1,31
@@
-#!/usr/bin/env python3
+"""
+Private Bridge configurator.
+"""
-""" Private Bridge configurator. """
-
-import http.client
-import os
import select
import select
-import shutil
import subprocess
import time
import tools
import subprocess
import time
import tools
-from threading import Thread
import logger
import logger
-import tools
priority = 9
class OvsException (Exception) :
priority = 9
class OvsException (Exception) :
- def __init__ (self, message="no message"):
- self.message=message
- def __repr__ (self): return message
+ def __init__(self, message="no message"):
+ self.message = message
+ def __repr__(self):
+ return self.message
def start():
logger.log('private bridge plugin starting up...')
def log_call_read(command, timeout=logger.default_timeout_minutes*60, poll=1):
def start():
logger.log('private bridge plugin starting up...')
def log_call_read(command, timeout=logger.default_timeout_minutes*60, poll=1):
- message
=
" ".join(command)
+ message
=
" ".join(command)
logger.log("log_call: running command %s" % message)
logger.verbose("log_call: timeout=%r s" % timeout)
logger.verbose("log_call: poll=%r s" % poll)
logger.log("log_call: running command %s" % message)
logger.verbose("log_call: timeout=%r s" % timeout)
logger.verbose("log_call: poll=%r s" % poll)
- trigger
=
time.time()+timeout
+ trigger
=
time.time()+timeout
try:
child = subprocess.Popen(
command, bufsize=1,
try:
child = subprocess.Popen(
command, bufsize=1,
@@
-40,8
+36,9
@@
def log_call_read(command, timeout=logger.default_timeout_minutes*60, poll=1):
stdout = ""
while True:
# see if anything can be read within the poll interval
stdout = ""
while True:
# see if anything can be read within the poll interval
- (r, w, x)=select.select([child.stdout], [], [], poll)
- if r: stdout = stdout + child.stdout.read(1)
+ (r, w, x) = select.select([child.stdout], [], [], poll)
+ if r:
+ stdout = stdout + child.stdout.read(1)
# is process over ?
returncode=child.poll()
# yes
# is process over ?
returncode=child.poll()
# yes
@@
-55,12
+52,14
@@
def log_call_read(command, timeout=logger.default_timeout_minutes*60, poll=1):
return (returncode, stdout)
# child has failed
else:
return (returncode, stdout)
# child has failed
else:
- log("log_call:end command (%s) returned with code %d" %(message, returncode))
+ log("log_call:end command (%s) returned with code %d"
+ %(message, returncode))
return (returncode, stdout)
# no : still within timeout ?
if time.time() >= trigger:
child.terminate()
return (returncode, stdout)
# no : still within timeout ?
if time.time() >= trigger:
child.terminate()
- logger.log("log_call:end terminating command (%s) - exceeded timeout %d s"%(message, timeout))
+ logger.log("log_call:end terminating command (%s) - exceeded timeout %d s"
+ %(message, timeout))
return (-2, None)
break
except Exception as e:
return (-2, None)
break
except Exception as e:
@@
-109,8
+108,9
@@
def ovs_addport(name, portname, type, remoteip, key):
if key:
args = args + ["options:key=" + str(key)]
if key:
args = args + ["options:key=" + str(key)]
- (returncode, stdout) = ovs_vsctl(args)
- if (returncode != 0): raise OvsException("add-port")
+ returncode, stdout = ovs_vsctl(args)
+ if (returncode != 0):
+ raise OvsException("add-port")
def ovs_delport(name, portname):
(returncode, stdout) = ovs_vsctl(["del-port", name, portname])
def ovs_delport(name, portname):
(returncode, stdout) = ovs_vsctl(["del-port", name, portname])
@@
-182,7
+182,7
@@
def GetSlivers(data, conf = None, plc = None):
sliver_name = sliver['name']
# build a dict of attributes, because it's more convenient
sliver_name = sliver['name']
# build a dict of attributes, because it's more convenient
- attributes
=
{}
+ attributes
=
{}
for attribute in sliver['attributes']:
attributes[attribute['tagname']] = attribute['value']
for attribute in sliver['attributes']:
attributes[attribute['tagname']] = attribute['value']