summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorCory Wright <cory.wright@rackspace.com>2011-04-01 20:26:59 +0000
committerCory Wright <cory.wright@rackspace.com>2011-04-01 20:26:59 +0000
commita4e1db03a2c61648588d9adb703a385f49d82fc0 (patch)
treed4a4309ef3628d1021dfcf39708b6282d3015ec0 /plugins
parent74b9f240c7e8c62e68011691488be9e63758e980 (diff)
downloadnova-a4e1db03a2c61648588d9adb703a385f49d82fc0.tar.gz
nova-a4e1db03a2c61648588d9adb703a385f49d82fc0.tar.xz
nova-a4e1db03a2c61648588d9adb703a385f49d82fc0.zip
use novalib for vif_rules.py, fix OvsFlow class
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py2
-rwxr-xr-xplugins/xenserver/networking/etc/xensource/scripts/vif_rules.py25
2 files changed, 9 insertions, 18 deletions
diff --git a/plugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py b/plugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py
index 82e79c2d8..23b6d85c9 100755
--- a/plugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py
+++ b/plugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py
@@ -36,7 +36,7 @@ XEN_BRIDGE = 'xenbr0'
OVS_OFCTL = '/usr/bin/ovs-ofctl'
-class OvsFlow():
+class OvsFlow(object):
def __init__(self, command, params, bridge=None):
self.command = command
self.params = params
diff --git a/plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py b/plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py
index 4e13bad9d..662def205 100755
--- a/plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py
+++ b/plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py
@@ -29,16 +29,18 @@ import sys
import simplejson as json
+from novalib import execute, execute_get_output
+
+
def main(dom_id, command, only_this_vif=None):
- xsls = execute('/usr/bin/xenstore-ls',
- '/local/domain/%s/vm-data/networking' % dom_id,
- return_stdout=True)
+ xsls = execute_get_output('/usr/bin/xenstore-ls',
+ '/local/domain/%s/vm-data/networking' % dom_id)
macs = [line.split("=")[0].strip() for line in xsls.splitlines()]
for mac in macs:
- xsread = execute('/usr/bin/xenstore-read',
- '/local/domain/%s/vm-data/networking/%s' %
- (dom_id, mac), True)
+ xsread = execute_get_output('/usr/bin/xenstore-read',
+ '/local/domain/%s/vm-data/networking/%s' %
+ (dom_id, mac))
data = json.loads(xsread)
for ip in data['ips']:
if data["label"] == "public":
@@ -53,17 +55,6 @@ def main(dom_id, command, only_this_vif=None):
apply_iptables_rules(command, params)
-def execute(*command, return_stdout=False):
- devnull = open(os.devnull, 'w')
- command = map(str, command)
- proc = subprocess.Popen(command, close_fds=True,
- stdout=subprocess.PIPE, stderr=devnull)
- devnull.close()
- if return_stdout:
- return proc.stdout.read()
- else:
- return None
-
# A note about adding rules:
# Whenever we add any rule to iptables, arptables or ebtables we first
# delete the same rule to ensure the rule only exists once.