def subfunction_showopenstack_subnetneutron():
try:
openstackhypervisorlist = subprocess.check_output("neutron subnet-list -c id | awk '{print $2}' | grep -v ^$|grep -v id", shell=True).split("\n")
for item in openstackhypervisorlist:
if len(item ) > 0:
OPENSTACK_CMD_OUTPUT = "neutron subnet-show " + item
OPENSTACK_CMD_RESULT = subprocess.check_output( OPENSTACK_CMD_OUTPUT, shell=True )
print( "neutron subnet-show ", item)
print( OPENSTACK_CMD_RESULT )
except subprocess.CalledProcessError:
print("NO OPENSTACK CMD")
def subfunction_showopenstack_subnetneutron():
try:
openstackcmd = '/usr/bin/openstack'
if os.path.isfile(openstackcmd) == False:
print("NO OPENSTACK CMD")
sys.exit(0)
openstackhypervisorlist = subprocess.check_output("neutron subnet-list -c id | awk '{print $2}' | grep -v ^$|grep -v id", shell=True).split("\n")
print("type = ", type(openstackhypervisorlist), openstackhypervisorlist )
for item in openstackhypervisorlist:
if len(item ) > 0:
OPENSTACK_CMD_OUTPUT = "neutron subnet-show " + item
OPENSTACK_CMD_RESULT = subprocess.check_output( OPENSTACK_CMD_OUTPUT, shell=True )
print( OPENSTACK_CMD_RESULT )
except subprocess.CalledProcessError:
print("NO OPENSTACK CMD")
def subfunction_showopenstack_subnetfile():
try:
openstackhypervisorlistfile = subprocess.check_output("neutron subnet-list -c id | awk '{print $2}' | grep -v ^$ | grep -v id > /root/subnet-list.txt", shell=True)
fd = open("/root/subnet-list.txt",'r')
lines = fd.readlines()
FLINES = list(lines)
# print(FLINES)
fw = open("/root/subnet-list.sh",'w')
for line in FLINES:
# print(line)
dataname = "echo % neutron subnet-show " + line
data = "neutron subnet-show " + line
dataline = "echo \n"
fw.write(dataname)
fw.write(data)
fw.write(dataline)
fw.close()
fd.close()
os.system("sh /root/subnet-list.sh")
# sys.exit(0)
except subprocess.CalledProcessError:
print("NO OPENSTACK CMD")
'Virtualization Infrastructure' 카테고리의 다른 글
Docker ubuntu ssh 컨테이너 (0) | 2022.03.06 |
---|---|
OpenStack Service Info (0) | 2020.05.09 |