Add common popen support to the cisco plugin
Fixes bug 1055290 Change-Id: I5c90b3f23288101c34ac94470476676d5d9c141e
This commit is contained in:
parent
798341ee64
commit
1a2467ba6d
@ -35,6 +35,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from quantum.common import constants
|
from quantum.common import constants
|
||||||
|
from quantum.common import utils
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
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 api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as l2db
|
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(servconts.CREATE_VM_CMD)
|
||||||
create_vm_args.append(service_image_id)
|
create_vm_args.append(service_image_id)
|
||||||
print ("Creating VM with image: %s" % (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()
|
result = process.stdout.readlines()
|
||||||
tokens = re.search("i-[a-f0-9]*", str(result[1]))
|
tokens = re.search("i-[a-f0-9]*", str(result[1]))
|
||||||
service_vm_name = tokens.group(0)
|
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(servconts.CREATE_VM_CMD)
|
||||||
create_vm_args.append(vm_image_id)
|
create_vm_args.append(vm_image_id)
|
||||||
print ("Creating VM with image: %s" % (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()
|
result = process.stdout.readlines()
|
||||||
tokens = re.search("i-[a-f0-9]*", str(result[1]))
|
tokens = re.search("i-[a-f0-9]*", str(result[1]))
|
||||||
vm_name = tokens.group(0)
|
vm_name = tokens.group(0)
|
||||||
|
@ -24,6 +24,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from quantum.common import utils
|
||||||
from quantum.openstack.common import importutils
|
from quantum.openstack.common import importutils
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.db import services_db as sdb
|
from quantum.plugins.cisco.db import services_db as sdb
|
||||||
@ -54,8 +55,8 @@ class ServicesLogistics():
|
|||||||
while not flag and counter <= 5:
|
while not flag and counter <= 5:
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
process = subprocess.Popen(service_args,
|
process = utils.subprocess_popen(service_args,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
result = process.stdout.readlines()
|
result = process.stdout.readlines()
|
||||||
if not result:
|
if not result:
|
||||||
flag = True
|
flag = True
|
||||||
@ -75,8 +76,8 @@ class ServicesLogistics():
|
|||||||
while not flag and counter <= 10:
|
while not flag and counter <= 10:
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
process = subprocess.Popen(service_args,
|
process = utils.subprocess_popen(service_args,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
result = process.stdout.readlines()
|
result = process.stdout.readlines()
|
||||||
if result:
|
if result:
|
||||||
tokens = re.search("running", str(result[1]))
|
tokens = re.search("running", str(result[1]))
|
||||||
|
@ -19,24 +19,27 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from quantum.common import utils
|
||||||
|
|
||||||
|
|
||||||
def get_next_dynic(argv=[]):
|
def get_next_dynic(argv=[]):
|
||||||
"""Get the next available dynamic nic on this host"""
|
"""Get the next available dynamic nic on this host"""
|
||||||
cmd = ["ifconfig", "-a"]
|
cmd = ["ifconfig", "-a"]
|
||||||
f_cmd_output = (
|
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()
|
eths = [lines.split(' ')[0] for lines in f_cmd_output.splitlines()
|
||||||
if "eth" in lines]
|
if "eth" in lines]
|
||||||
#print eths
|
#print eths
|
||||||
for eth in eths:
|
for eth in eths:
|
||||||
cmd = ["ethtool", "-i", eth]
|
cmd = ["ethtool", "-i", eth]
|
||||||
f_cmd_output = (
|
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()
|
bdf = [lines.split(' ')[1] for lines in f_cmd_output.splitlines()
|
||||||
if "bus-info" in lines]
|
if "bus-info" in lines]
|
||||||
#print bdf
|
#print bdf
|
||||||
cmd = ["lspci", "-n", "-s", bdf[0]]
|
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])
|
communicate()[0])
|
||||||
deviceid = [(lines.split(':')[3]).split(' ')[0]
|
deviceid = [(lines.split(':')[3]).split(' ')[0]
|
||||||
for lines in f_cmd_output.splitlines()]
|
for lines in f_cmd_output.splitlines()]
|
||||||
@ -44,7 +47,8 @@ def get_next_dynic(argv=[]):
|
|||||||
if deviceid[0] == "0044":
|
if deviceid[0] == "0044":
|
||||||
cmd = ["/sbin/ip", "link", "show", eth]
|
cmd = ["/sbin/ip", "link", "show", eth]
|
||||||
f_cmd_output = (
|
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()
|
used = [lines for lines in f_cmd_output.splitlines()
|
||||||
if "UP" in lines]
|
if "UP" in lines]
|
||||||
if not used:
|
if not used:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user