Add common popen support to the cisco plugin

Fixes bug 1055290

Change-Id: I5c90b3f23288101c34ac94470476676d5d9c141e
This commit is contained in:
Gary Kotton 2012-09-24 05:11:20 +00:00
parent 798341ee64
commit 1a2467ba6d
3 changed files with 18 additions and 10 deletions

View File

@ -35,6 +35,7 @@ import subprocess
import sys
from quantum.common import constants
from quantum.common import utils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.db import api as db
from quantum.plugins.cisco.db import l2network_db as l2db
@ -91,7 +92,8 @@ def insert_inpath_service(tenant_id, service_image_id,
create_vm_args.append(servconts.CREATE_VM_CMD)
create_vm_args.append(service_image_id)
print ("Creating VM with image: %s" % (service_image_id))
process = subprocess.Popen(create_vm_args, stdout=subprocess.PIPE)
process = utils.subprocess_popen(create_vm_args,
stdout=subprocess.PIPE)
result = process.stdout.readlines()
tokens = re.search("i-[a-f0-9]*", str(result[1]))
service_vm_name = tokens.group(0)
@ -208,7 +210,8 @@ def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
create_vm_args.append(servconts.CREATE_VM_CMD)
create_vm_args.append(vm_image_id)
print ("Creating VM with image: %s" % (vm_image_id))
process = subprocess.Popen(create_vm_args, stdout=subprocess.PIPE)
process = utils.subprocess_popen(create_vm_args,
stdout=subprocess.PIPE)
result = process.stdout.readlines()
tokens = re.search("i-[a-f0-9]*", str(result[1]))
vm_name = tokens.group(0)

View File

@ -24,6 +24,7 @@ import re
import subprocess
import time
from quantum.common import utils
from quantum.openstack.common import importutils
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.db import services_db as sdb
@ -54,8 +55,8 @@ class ServicesLogistics():
while not flag and counter <= 5:
counter = counter + 1
time.sleep(2.5)
process = subprocess.Popen(service_args,
stdout=subprocess.PIPE)
process = utils.subprocess_popen(service_args,
stdout=subprocess.PIPE)
result = process.stdout.readlines()
if not result:
flag = True
@ -75,8 +76,8 @@ class ServicesLogistics():
while not flag and counter <= 10:
counter = counter + 1
time.sleep(2.5)
process = subprocess.Popen(service_args,
stdout=subprocess.PIPE)
process = utils.subprocess_popen(service_args,
stdout=subprocess.PIPE)
result = process.stdout.readlines()
if result:
tokens = re.search("running", str(result[1]))

View File

@ -19,24 +19,27 @@
import subprocess
from quantum.common import utils
def get_next_dynic(argv=[]):
"""Get the next available dynamic nic on this host"""
cmd = ["ifconfig", "-a"]
f_cmd_output = (
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
utils.subprocess_popen(cmd, stdout=subprocess.PIPE).communicate()[0])
eths = [lines.split(' ')[0] for lines in f_cmd_output.splitlines()
if "eth" in lines]
#print eths
for eth in eths:
cmd = ["ethtool", "-i", eth]
f_cmd_output = (
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
utils.subprocess_popen(cmd,
stdout=subprocess.PIPE).communicate()[0])
bdf = [lines.split(' ')[1] for lines in f_cmd_output.splitlines()
if "bus-info" in lines]
#print bdf
cmd = ["lspci", "-n", "-s", bdf[0]]
f_cmd_output = (subprocess.Popen(cmd, stdout=subprocess.PIPE).
f_cmd_output = (utils.subprocess_popen(cmd, stdout=subprocess.PIPE).
communicate()[0])
deviceid = [(lines.split(':')[3]).split(' ')[0]
for lines in f_cmd_output.splitlines()]
@ -44,7 +47,8 @@ def get_next_dynic(argv=[]):
if deviceid[0] == "0044":
cmd = ["/sbin/ip", "link", "show", eth]
f_cmd_output = (
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
utils.subprocess_popen(cmd, stdout=subprocess.PIPE).
communicate()[0])
used = [lines for lines in f_cmd_output.splitlines()
if "UP" in lines]
if not used: